Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Linux. Write a shell script filesreneam.sh that takes a list of input file names

ID: 3810719 • Letter: L

Question

Linux. Write a shell script filesreneam.sh that takes a list of input file names (e.g. generated using a wildcard character) and makes copies of those files to new filenames with predefined prefex and suffix strings. Use variables to hard code the prefex "new " and suffix "dat" to replace "pdb". Use a conditional to detect if there are one or more input filenames and take the appropriate action as shown below. Use a for loop to iterate through the file names where each iteration extracts the file name root ,, copies the file to the new file name, and echoes the result.

Explanation / Answer

i=1
for file in $*
do
if [ $i -eq 1 ]
then
src="$file"
else
cp "$src" "$file"
echo "$file"
cat "$file"
fi
i=` expr $i + 1`
done

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote