Results 1 to 5 of 5
Hi all
i want to create a script in which it will read a file and if in that file there would be any word DEV at he end of ...
- 04-30-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 20
search from a file
Hi all
i want to create a script in which it will read a file and if in that file there would be any word DEV at he end of the line it will appand iii01at the end otherwise it will append aa01 at the end of the file.
cat dd.txt
jhdhjdfh5453_DEV
apple_DEV
linewithout123456
hello
hello_DEV
Please help.
Thanks,
Inder
- 05-01-2008 #2Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Hey There,
You can probably do it taking up even less space than this, but this should do the trick for you
Hope that helpsCode:awk '{ if ( $NF ~ /DEV/ ) print $0 "iii01";else print $0 "aa01" }' dd.txt
, Mike
- 05-01-2008 #3Just Joined!
- Join Date
- Jan 2008
- Posts
- 20
Thanks Mike, it works for me..
Thanks you very much ..
- 05-01-2008 #4Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Your very welcome. Glad to help

, Mike
- 05-03-2008 #5Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
Another variant:
Code:awk '/DEV$/ {print $0 "iii01"; next} {print $0 "aa01"}' dd.txt


Reply With Quote