Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513
Rep:
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?
sasha@reactor: echo "EXTRA=5768" | sed "s/5768/-$(date)/g"
EXTRA=-Sat Feb 20 14:34:17 AST 2010
sasha@reactor:
@ Awesome -- not sure why it won't work for you -- it works for me; and, as you suggest you have tried, using double quotes has always worked for me when the replacement contains a variable I want to insert, rather than a literal string.
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"
EXTRA=-02/20/10
sasha@reactor
Last edited by GrapefruiTgirl; 02-20-2010 at 01:29 PM.
@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.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513
Original Poster
Rep:
Truth
Quote:
Originally Posted by XavierP
@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.
What was Truth IS Truth NOW, and it always will be Truth. There is One Truth. Everything else is wrong. I don't make Truth. I don't even enforce it. I only report it. If no one is willing to speak Truth, everybody dies. I don't expect appreciation, only tolerance. Am I not entitled to my opinion? Is my opinion wrong? Do certain people, like me, have 'wrong thinking'? I'm a masculine male, which is more than I can say for most men nowadays.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.