How to remove all blank lines from file – grep command

How to remove all blank lines from file – grep command

1] cat the file arun.txt which has several blank lines

root@indianGNU.org:/home# cat arun.txt
This is first line of file

this is second line

ok this script will help you to delete all blank links from file
How to start shell scripting

make sure that you will win

arun bagul

end of file

root@indianGNU.org:/home#

2] Run command for removing lines

root@indianGNU.org:/home# grep -v “^$” arun.txt > no_blank_lines.txt

3] Chcek new file –

root@indianGNU.org:/home# cat no_blank_lines.txt
This is first line of file
this is second line
ok this script will help you to delete all blank links from file
How to start shell scripting
make sure that you will win
arun bagul
end of file
root@indianGNU.org:/home#

Similar Posts:

Be Sociable, Share!

1 Reply to “How to remove all blank lines from file – grep command”

Leave a Reply

Your email address will not be published. Required fields are marked *