Embed command output in sed expression.
One would suspect:
sed -i 's/EXTRAVERSION =/EXTRAVERSION = -$(date +%D)/g' file would search in the file, file for the string: 'EXTRAVERSION =', and change every instance it finds to 'EXTRAVERSION = -02/20/2010'. BUT IT DOESN'T. It changes it to 'EXTRAVERSION = $(date +%D)', literally. I've tried single and double quotes in almost every possible configuration. Is there any way to tell sed that one desires the command output, not the literal text? |
Code:
sasha@reactor: echo "EXTRA=5768" | sed "s/5768/-$(date)/g" NOTE that in my example, I just used `echo` but I have done the same during sed-inplace on files, and that too has worked. Try again with double quotes? :) Sasha OH -- wait! Your date string will contain SLASHES, which may be borking the RHS -- use something else as a separator, like a % or a pipe. EDIT: Yes, this seems to be the problem. Like so: Code:
sasha@reactor: echo "EXTRA=5768" | sed "s%5768%-$(date +%D)%g" |
You need to use double quotes instead of single quotes. Then the variables and command substitution is performed before sed gets the command.
You can use `set' to see how arguments were expanded before the command runs: Code:
set sed -i 's/EXTRAVERSION =/EXTRAVERSION = -$(date +%D)/g' file |
Here's eventually what I did:
Code:
sed -i "s%EXTRAVERSION =%EXTRAVERSION = \-$(date +%D | sed 's%\/%%g')%g" ./Makefile Code:
EXTRAVERSION = -022010 |
@AwesomeMachine - what on earth are you talking about? You "must voice an opinion"? Not sure if you have noticed, but we're no longer in the Bronze Age. Your weird spouting would appear to be something a caricature of a Middle Eastern person would say. While it's cool that your time machine took you back 6000 years and you're in the perfect world, you still have to post in ours. Edit your thread to take out the offensive statements and I'll get this removed.
And if it was supposed to be a joke, well, no one is laughing. |
Truth
Quote:
|
Nobody asked you to report "your version of truth", nor did anyone ask for your opinion about a woman's "role" in society. Whether or not your opinion is wrong, is not at issue, though opinions, by their very nature, are neither right nor wrong-- they are simply opinions.
Around here, you will not be appreciated, nor shown tolerance, for expressing your opinion on this subject matter, especially in a thread that is both unrelated to said opinion, and not in the General forum. You have two more lines of text to remove from your post. In case you are unsure which ones they are, they are the ones following the second code block. Sasha |
And with Sasha's words I'm taking this thread to the grave.
With no respect or tolerance for Awesome's outburst of primeval tribal law I removed the remaining offending lines. Cheers, Tink |
All times are GMT -5. The time now is 03:40 AM. |