|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I would like to extract a line from every 3 lines from a file. the files looks like 1.1 1.2 1.3 1.4 1.5 1.6 I only want to extract 1.1 and 1.4 and put them in a different file, thanks for your ! Zhengquan |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
zhengquan scrisse:
> I would like to extract a line from every 3 lines from a file. With GNU sed: sed -n '1~3' infile > outfile |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 5/2/2008 4:40 PM, zhengquan wrote: > Hello, > I would like to extract a line from every 3 lines from a file. > the files looks like > > 1.1 > 1.2 > 1.3 > 1.4 > 1.5 > 1.6 > > I only want to extract 1.1 and 1.4 and put them in a different file, > thanks for > your ! > > Zhengquan awk '!((NR-1)%3)' file > newfile Ed. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 5/2/2008 4:59 PM, mallin.shetland wrote: > zhengquan scrisse: > > >>I would like to extract a line from every 3 lines from a file. > > > > With GNU sed: > > > sed -n '1~3' infile > outfile ITYM: sed -n '1~3p' infile > outfile Ed. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On May 2, 5:08 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
> On 5/2/2008 4:59 PM, mallin.shetland wrote: > > > zhengquan scrisse: > > >>I would like to extract a line from every 3 lines from a file. > > > With GNU sed: > > > sed -n '1~3' infile > outfile > > ITYM: > > sed -n '1~3p' infile > outfile > > Ed. Thank you guys! Zhengquan |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Friday 2 May 2008 23:59, mallin.shetland wrote:
> zhengquan scrisse: > >> I would like to extract a line from every 3 lines from a file. > > > With GNU sed: > > > sed -n '1~3' infile > outfile You need to print the line: sed -n '1~3p' infile > outfile and, you can do the same just as easily with standard sed: sed -n '1,${p;n;n}' infile > outfile -- D. |
|
![]() |
| Outils de la discussion | |
|
|