Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 106
  • Last Modified:

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
0
magento
Asked:
magento
  • 3
  • 2
2 Solutions
 
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
 
ozoCommented:
#!/bin/bash
mv FolderB/file FolderC
rm FolderC/file
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
ozoCommented:
f() {
 mv FolderB/file FolderC/
 rm FolderA/file
}
0
 
TintinCommented:
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

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now