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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.