Solved

Shell help1

Posted on 2015-02-10
6
95 Views
Last Modified: 2015-02-16
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
Comment
Question by:magento
  • 3
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40600523
mv FolderB/file FolderC
rm FolderC/file
0
 
LVL 5

Author Comment

by:magento
ID: 40600961
Hi Ozo,

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

Thanks
0
 
LVL 84

Expert Comment

by:ozo
ID: 40600973
#!/bin/bash
mv FolderB/file FolderC
rm FolderC/file
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 5

Author Comment

by:magento
ID: 40601036
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
 
LVL 84

Assisted Solution

by:ozo
ozo earned 150 total points
ID: 40601070
f() {
 mv FolderB/file FolderC/
 rm FolderA/file
}
0
 
LVL 48

Accepted Solution

by:
Tintin earned 350 total points
ID: 40602050
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now