New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Copy multiply files with rename
Hi am trying to copy multiply file's but i want to rename the copied file to the name of the directory it was copy form.
The path to file are /home/{wildcard}/etc/{wildcard}/info
E.g /home/ryan/etc/test.tld/info would get copy as test.tld.
I had to type {wildcard} as * was not showing
Comments
And * is not showing correctly because your forum post is parsed as Markdown, where *foo* makes foo appear in italics.
Escape it with a backslash to disable that behaviour:
\*
i have a question for you would help me save time
we can rename a file this way
mv /some/path/mfile{,.old}
the mfile will be renamed mfile.old
now what what about rename it back to mfile ? in a geeky way
mv /some/path/mfile{.old,}
?The string manipulation features don't really make your life easier here, since you would first need to assign the filename to a variable, e.g.:
The
${variable#substring}
/${variable##substring}
/${variable%substring}
/${variable%%substring}
notation (for removing matching substrings) andbash
's other string manipulation features are explained here: http://tldp.org/LDP/abs/html/string-manipulation.htmlucxo you are my hero
@Flazo, i think we should get to know ucxo better hahah