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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
e.g p3( 19 - 23 ) should rename to p3( 18.50 - 22.50 )
i wrote a simple code but i dont know how to expand that for this work
for example to change all 18 to 17.50
Code:
find . -type d | while read FILE
do
echo "$FILE" | grep 18 | sed 's/18/17.50/g'
done
and so on but my code does not make sense because 18 should be a counter from 1 to 23 and every time change in grep and sed to rename all directories .
or find numbers in directories' name with awk and wrote a case to check $2 and $4 and change all of them
find . -type d | while read FILE
do
echo "$FILE" |awk '/-/ { print $2 $4 }
done
any one have any idea to rename all that directories like output ???
any idea ????
I am not finding your explanation to be clear. Are the directory names the string of this formula like "p8( 18.30 - 19 )" with the spaces and parenthesis characters? And you want to change "19" to "18.50" in all directory names that have "19"? By rename do you mean the "mv" command? or are you just wanting a string substitution for output purposes (no change to the filesystem)?
On a side note, whilst I know anyone create whatever they want, this has to be some of the more bizaar directory naming conventions. One could easily see issues occurring
at a later date
On a side note, whilst I know anyone create whatever they want, this has to be some of the more bizaar directory naming conventions. One could easily see issues occurring
at a later date
going back to your 'randomness'
what are your rules for reassigning 'the numbers'
In the long run it is probably easier if we see the whole of your script
Would also be nice to know why you need to do this in the first place.
is it a 'one off' or is this something you need to do routinely.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.