Orginal files directory Suppose the directory ~/IFT383/Bash/archive contains the
ID: 3879421 • Letter: O
Question
Orginal files directory
Suppose the directory ~/IFT383/Bash/archive contains the following files:
DeductionRequest_To_IA_07142017_040109.csv.PGP
LifeSpace_To_IA_CAD20170710.csv.pgp
Herr Foods Inc_To_IA_CAD_20170705.csv.pgp
new directory files
Write a script called changename.sh to change the filenames to the below and place them in ~/IFT383/Bash/inbound:
DeductionRequest_To_IA_07142017_040109.csv.pgp
LifeSpace_To_IA_CAD_20170710.csv.pgp
HerrFoodsInc_To_IA_CAD_20170705.csv.pgp
Include a rst line that calls the Bourne shell as the interpreter Add a comment to state the purpose of the script and other comments to make the script easier to read
Writing a unix script moving from one directory to another directory.
Explanation / Answer
Hi,
We can use "mv" command to rename the file in the linux.
Syntax-
mv <old_file_name> <new_file_name>
Below are the contents of the changename.sh file-
#!/bin/bash
#########Below code renames the files in the ~/IFT383/Bash/archive path###############
cd ~/IFT383/Bash/archive
mv DeductionRequest_To_IA_07142017_040109.csv.PGP DeductionRequest_To_IA_07142017_040109.csv.pgp
mv LifeSpace_To_IA_CAD20170710.csv.pgp LifeSpace_To_IA_CAD_20170710.csv.pgp
mv Herr Foods Inc_To_IA_CAD_20170705.csv.pgp HerrFoodsInc_To_IA_CAD_20170705.csv.pgp
#########Below code is to transfer the files to ~/IFT383/Bash/inbound/ path##############
cp DeductionRequest_To_IA_07142017_040109.csv.pgp ~/IFT383/Bash/inbound/DeductionRequest_To_IA_07142017_040109.csv.pgp
cp LifeSpace_To_IA_CAD_20170710.csv.pgp ~/IFT383/Bash/inbound/LifeSpace_To_IA_CAD_20170710.csv.pgp
cp HerrFoodsInc_To_IA_CAD_20170705.csv.pgp ~/IFT383/Bash/inbound/HerrFoodsInc_To_IA_CAD_20170705.csv.pgp
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.