hi All,
I have a file like this;
aaaaaaaaaa
bbbbbbbb
cccccc
ddddddddddd
........
xxxxxxxxxxxx
I want to delete hole lines and it must be like this
aaaaaaaaaa
bbbbbbbb
cccccc
ddddddddddd
how can I do this ??
R.
Alice
hi All,
I have a file like this;
aaaaaaaaaa
bbbbbbbb
cccccc
ddddddddddd
........
xxxxxxxxxxxx
I want to delete hole lines and it must be like this
aaaaaaaaaa
bbbbbbbb
cccccc
ddddddddddd
how can I do this ??
R.
Alice
Edit the file using vi editor then type in
dd on the empty space this will delete the line
the procedure is
vi filename
dd
then :wq to save
I have more than 1500 line and 30 files. if I use vi and "dd" I can complete until end of my life.
In order to automate this we will need a more clear definition of the problem. Your example seems to imply that you want to keep only the first four non-blank lines. Is this correct?
yes thats right.
this file is contaings 1530 lines and it has blank lines between each lines. I want to delete blank lines in this files.
You can use awk
awk '{if ( $1 != "") print $1}' < file.in > file.out
file.in is your input file name &
file.out is your output file name
cat file.in | grep -v ^$ > file.out
This will use the descriptors ^ for beginning of line and $ for end of line to match a blank line and remove from output with the -v option of grep.
Cool...
It may be less efficient than awk but still valid. And less syntax problems.
Nice, didn't think of using ^$ like that, had to stick it in double quotes to get it work on sco by the way.
Just complementing ...
In the awk command, you may subtitute the $1 for $0 if yoy have space between words, because $0 references the entire line and $1 only the first column.
awk '{if ( $0 != "") print $0}' < arq.in > arq.out
arq.in:
aaa aaa aaa aaa
bbb bbb bbb bbb
ccc ccc ccc ccc
arq.out:
aaa aaa aaa
bbb bbb bbb
ccc ccc ccc