BASH: How to change a line in file?
Hello,
I need a simple script which changes one line in input file. Concretely, I want to replace the title of eps file. The file before: Code:
. Code:
. Thanks. |
sed 's/Original name of the eps file/My new name of the eps file/'
But somehow I suspect you're actually asking for more than that. |
Yes, actually for more. If you know how to put to the sed for replacement
value of variable, then it could be done e.g.: [code] NEW_TITLE="This is my new title" OLD_TITLE=$(grep "%%Title:" $FILE | cut -d: -f2) sed 's/$OLD_TITLE/$NEW_TITLE/' $FILE > output.eps [\code] But it doesn't work! :( |
Would double quotes and an address work?
OLD=foo NEW=bar sed "/%%Title/s/$OLD/$NEW/" $FILE > out -- I mean, I gather this file has other lines in it you *don't* want to change? Still kind of confused about the objective and restrictions here. But that may do what you want. |
I suspect the sed solution can't work, as it choke on binary contents or very long lines which are likely to appear on an eps file.
|
All times are GMT -5. The time now is 04:50 PM. |