Solved

Shell help1

Posted on 2015-02-10
6
101 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
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 …
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

752 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