ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
In my scenario the name of the iso keeps on changing like test1234-abcd.iso, test12346789-abcd.iso, test1234-abcdefg.iso, test123xyz.iso bla bla bla. But in all cases "test" will remain as it is and only the contents between "test" & ".iso" will change
So I want to write a generalized sed script to replace the previous iso name with the new iso name. For example to change
sed doesn't modify the contents of original file.
it needs to be redirected to another file.
say,
u can achieve modifying the contents of ur test.vmx file thro' 2 steps
(i) sed -e 's/test*iso/test-abc-xyz.iso/' test.vmx > test.vmx.swp
(ii) mv test.vmx.swp test.vmx
for ur second question,
The regular expression is not used properly.
sed 's/test[0-9]*\-[a-z]*\.iso/linux/g' < filename >filename1
would now replace ur filename[eg:test1234-abc.iso] with "linux" everywhere.
U can try with ur filename instead.
1) Actually, newer sed can edit-in-place. See the -i[SUFFIX] option.
2) * in regular expressions means 0 or more of the preceeding character. So you need to indicate what character you want to quantify. In your case, you want any character, and this is dot (.). So, you could use:
Distribution: Debian, Ubuntu, Redhat, Fedora, SLES, OpenSUSE, FreeBSD, Mac OS X
Posts: 221
Original Poster
Rep:
Guys....Stop fighting.....All it maters is that it resolved my problem within seconds....Special thanks to "Disillusionist"...for making the command more easy & generalized ........All cheers to LQ...LQ rocks man...
Yeah, I was ribbing too... I know ghostdog for a long time, Mr.C. for a while, I felt I could do a little joke. ghostdog himself once told me to not be too serious... this is the good spirit at LQ. Enjoy it
I have known colucix and Mr.C (from another forum) for a long time too and we are not fighting, so no worries. by the way, i sure hope that your path do not coincidentally have "test" and "iso" together like in
ide1:0.fileName = "D:\isos\test12blahiso\test1234-abcd.iso".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.