Bash script, unix
Script that receives multiple arguments arg1, arg2, arg3… And renames according to swap even and odd. For example, script.sh fooA fooB food fooD fooE would rename fooA to fooB, fooC to fooD, fooE to fooF, and so on. Assume all files exist, up to 50 arguments.
Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Bash script, unix…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Check the number of arguments first to ensure an even amount of arguments.
Expert Answer
Have rename.txt in the same directory as your files exist.
where rename.txt contain only pairs of
oldname newname
on each line.
Run this command
eval “$(sed ‘s/^/mv /g’ rename.txt )”
sed is used to convert your rename_rules into mv oldname newname
eval is then used to execute it, thus the file gets renamed