i have to modify a line in a file using shell scripts,i dont know how to go about it
the content of the file is more like this
101 bruno alex 29383 2009 102 mary smith 2829 2892 103 junu adama 282 828298 104 wendy will 29373 122 assuming i want to modify the first line with 101 what could possibly be the solution. the name of the file is details. |
what have you tried so far?
|
Code:
$ sed -i /101/s/bruno/not-bruno/ filename |
First post - does this look like homework or not ?.
|
Quote:
First you have to select something with which to make the change. sed/AWK/python/perl all sound like the kind of thing that you could use, so, having a short list you select a possible candidate (say sed, that seems like a good choice) and read the man page. So you issue the command 'man sed' and you get information. (If you didn't have a list of possibles, you try 'man -k string' and see if that helps; as an example 'man -k change' shows you a lot of unintresting stuff, but 'man -k edit' gets lists stuff you might actually use). Having read the man page, you try something. If after that you can't understand what is going on, or there is a definable area that you didn't understand, you could try posting on Linuxquestions to see if someone can help you on to the next stage, telling people what you have tried or what you think. then, whether it is homework or not, someone will probably actually help, rather than giving you a fragment of code that does the job without helping you much |
thanks
Quote:
as in sed '101d' filename but its not deleting the line with 101 i am new to shell scripting and linux. "newbie" |
thanks for ur idea
i have done that;
i am trying to do it using shell scripts |
yes
more like it
|
thanks
i ll try it now
|
Quote:
Be careful which regular expression you use to find a match. To simple a pattern, and you might delete other lines as well. Use ^, $ and literals (as anchors) to prevent false matches. Test what you have on a larger set. For example, if you wanted to match the line "104 wendy will 29373 122" and a later line had 104 in the 5th column, it would be deleted as well. |
All times are GMT -5. The time now is 08:36 AM. |