Home » Infrastructure » Unix » how to delete lines through shell command
how to delete lines through shell command [message #378920] Fri, 02 January 2009 11:48 Go to next message
mrpranab
Messages: 32
Registered: March 2005
Member
Hi All,
I have a file called test.flg.fl and the data contains in the file as below
mmddyy_list25.prn
mmddyy_list26.prn
mmddyy_list27.prn
mmddyy_list28.prn
mmddyy_list29.prn
mmddyy_list3.prn
mmddyy_list30.prn
mmddyy_list31.prn
mmddyy_list32.prn

I need to delete lines which contain list26, list27, list28, list29, list 30, list 31. So my new file test.flg.fl will be now looks like below after I delete the lines.

mmddyy_list25.prn
mmddyy_list3.prn
mmddyy_list32.prn

Can you please tell me the command how to do this to delete those lines? Please let me know if you need more informations.

Thank you...

Re: how to delete lines in unix [message #378921 is a reply to message #378920] Fri, 02 January 2009 11:53 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
This is hardly a question related to Oracle. Post it in *nix forums.

[Updated on: Fri, 02 January 2009 11:57]

Report message to a moderator

Re: how to delete lines in unix [message #378922 is a reply to message #378920] Fri, 02 January 2009 12:00 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
the easy way...
my_dev>cat t.txt
mmddyy_list25.prn
mmddyy_list26.prn
mmddyy_list27.prn
mmddyy_list28.prn
mmddyy_list29.prn
mmddyy_list3.prn
mmddyy_list30.prn
mmddyy_list31.prn
mmddyy_list32.prn

# exclude the strings you don't want. Take extra care not to zap
# strings you still want (be careful else "string2" will zap "string2", "string21" etc...)
my_dev>egrep -v "_list26.|_list27.|_list28.|_list29.|_list30.|_list31." t.txt
mmddyy_list25.prn
mmddyy_list3.prn
mmddyy_list32.prn

# redirect to temp file & rename
my_dev>egrep -v "_list26.|_list27.|_list28.|_list29.|_list30.|_list31." t.txt > t1.txt

my_dev>mv t1.txt t.txt


my_dev>cat t.txt
mmddyy_list25.prn
mmddyy_list3.prn
mmddyy_list32.prn
how to delete lines through shell command [message #378931 is a reply to message #378920] Fri, 02 January 2009 14:04 Go to previous message
mrpranab
Messages: 32
Registered: March 2005
Member
Hi All,

I have a file called test.flg.fl and the data contains in the file as below

mmddyy_list20.prn
mmddyy_list21.prn
mmddyy_list22.prn
mmddyy_list23.prn
mmddyy_list24.prn
mmddyy_list25.prn
mmddyy_list26.prn
mmddyy_list27.prn
mmddyy_list28.prn
mmddyy_list29.prn
mmddyy_list3.prn
mmddyy_list30.prn
mmddyy_list31.prn
mmddyy_list32.prn
mmddyy_list33.prn
mmddyy_list34.prn
mmddyy_list35.prn
mmddyy_list36.prn
mmddyy_list37.prn
mmddyy_list38.prn
mmddyy_list42.prn

I need to delete lines which contain list21 to list 37 (i.e. list21, list22, list23 etc etc..). So my new file test.flg.fl will be now looks like below after I delete the lines.

mmddyy_list20.prn
mmddyy_list3.prn
mmddyy_list38.prn
mmddyy_list42.prn

Can you please tell me the command how to do this to delete those lines using Unix shell scripts? Please let me know if you need more informations.

Thank you!

Previous Topic: asm
Next Topic: Allign output
Goto Forum:
  


Current Time: Fri Mar 29 00:47:44 CDT 2024