Shell help1

Hi ,

I need a function in shell scripting to move the files as below.

 -Move file from FolderB to FolderC
 -Delete file from FolderA

Thanks
LVL 5
magentoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TintinConnect With a Mentor Commented:
Assuming you are passing in a filename, then do something like

#!/bin/bash
function mvdelete {
  file=$1
  
  mv FolderB/$file FolderC
  rm -f FolderA/$file
}

mvdelete filename

Open in new window

0
 
ozoCommented:
mv FolderB/file FolderC
rm FolderC/file
0
 
magentoAuthor Commented:
Hi Ozo,

Can you please let me know how to do this in a function in shell script ?

Thanks
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ozoCommented:
#!/bin/bash
mv FolderB/file FolderC
rm FolderC/file
0
 
magentoAuthor Commented:
Hi Ozo,

I am sorry for the confusion.

I thought of using this in many places in the code so if its a function , i can call it whenever necessary.
If u advice only command to be called in if needed, then i can use commands only.

Thanks
0
 
ozoConnect With a Mentor Commented:
f() {
 mv FolderB/file FolderC/
 rm FolderA/file
}
0
All Courses

From novice to tech pro — start learning today.