0

Hi I have a long file like this:

information_1 this is my file....@s...asdadada 
information_2 this is my file....s...asdadada sdsfsd
information_3 this is my file@sasdadada 
information_4 this is my filesasdadada 
information_5 this is my filesasdadada@

And I want a file like this, whitout the lines that contains "@" charachter:

information_2 this is my file....s...asdadada sdsfsd
information_4 this is my filesasdadada 

How can I do it with bash commands like sed, awk...?

Joan Triay
  • 1,518
  • 6
  • 20
  • 35

3 Answers3

4

With sed :

 sed '/@/d' file

Deletes all lines that contain a @.

With grep :

grep -v @ file

Output lines that does not contain a @.

SLePort
  • 15,211
  • 3
  • 34
  • 44
0

With awk:

$ awk '!/@/' file
information_2 this is my file....s...asdadada sdsfsd
information_4 this is my filesasdadada
user000001
  • 32,226
  • 12
  • 81
  • 108
0

With perl:

$ perl -ne 'print unless /@/' file

To replace in file (also create a backup .BAK for example, more precisely rename file to file.BAK and create new file with the same name)

$ perl -i.BAK -ne 'print unless /@/' file
Nahuel Fouilleul
  • 18,726
  • 2
  • 31
  • 36