![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I have many of this similar lines in a file and it is always start with number 7. How can replace this Whole-Line with something that I want.
7 ;0;12 ;3;0; ; ; ;ABCD ;n;n; ; ; ; ; ; I tried: sed 's/^7/tom/g' file I get: tom ;0;12 ;3;0; ; ; ;ABCD ;n;n; ; ; ; ; ; Also, there are lines that may start with 70, 71,.....79. How can I make it works for just "7" For example: 79 ;0;12 ;3;0; ; ; ;ABCD ;n;n; ; ; ; ; ; I will get: tom9 ;0;12 ;3;0; ; ; ;ABCD ;n;n; ; ; ; ; ; Many Thanks! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
sed 's/^7 ;.*$/tom/' < infile > outfile
|
|
#3
|
|||
|
|||
|
Thank you for the reply! but it is not working!
|
|
#4
|
|||
|
|||
|
replace whole line?
Code:
sed 's/^7.*/tom/g' |
|
#5
|
|||
|
|||
|
Thanks! It works!
|
|
#6
|
||||
|
||||
|
Quote:
You said Quote:
Code:
$ echo "79 ;sadjsajdds" | sed 's/^7.*/tom/g' tom |
||||
| Google The UNIX and Linux Forums |