Solved

Shell help1

Posted on 2015-02-10
6
103 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

630 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