i have a problem with inline editing via scripts and i was hoping one of you smarter gents could help me out. i'm just doing my baby steps so bare with me if you can.
so i have an input file which goes something like this:
6
5
6
3
i'd like to be able to change a number, like say the first 6 to 2. i played around with sed lie so
sed '1!d' file | sed "s/.*/2/"
but how can i put this to the same line i want to edit?
also i searched the forum for solutions, and saw things in perl, i don't want to go that far just for a solution (since i don't know the first thing about perl). basic bash or awk would be the best.
Hi,
i didn't get your question, i would like to give a sugestion, it would be always nice you can show the expected output as the part of question.
so that things becomes more clear.i suppose that you like to see the changes made by sed in the s=input file.
the syntax for that is
sed 's/pattern1/pattern2/g' -i file
or
sed 's/pattern1/pattern2/g' -i.back file
the later one would create a back up of the old file
the command above replaces pattern1 to pattern2 all over the file
the 's' used in sed represent the operation substitute you can use 1s , 6s to substitute only that line
It means to click the "New Thread" button on the forum's overview page, as opposed to "Post Reply" to somebody else's thread with an unrelated question.