How to wite shell script to moves files?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to wite shell script to moves files?
# 1  
Old 04-13-2013
How to wite shell script to moves files?

Greetings to all,

i am new to shell scripting. i need to wite a script that moves files after renaming them to .txt . The exact scenario is this.
i have a directory /stsarie/btms/v5.0/report/wps where files will be imported from Host system periodically. Along with a file say named 130402-QASOUMI-5000000669 a 0 byte STMP file is also imported (STMP.130402-QASOUMI-5000000669) to esnsure complete file is copied.

i need to move the original file to another directory /stsarie/btms/v5.0/report/DS/App/inputFiles renaming the file to 130402-QASOUMI-5000000669.txt
Kindly help me.

Regards,
# 2  
Old 04-13-2013
Try:
Code:
#!/bin/ksh
OD=/stsarie/btms/v5.0/report/DS/App/inputFiles
cd /stsarie/btms/v5.0/report/wps
for i in STMP.*
do      base="${i#STMP.}"
        mv "$base" "$OD/$base" && mv "$i" "moved.$i"
done

This was tested using the Korn shell, but will work with bash, ksh, or any other standards conforming shell.
# 3  
Old 04-13-2013
Thanks.

Thanks a lot. its working perfectly...
Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for field wise record count for different Files .csv files

Hi, Very good wishes to all! Please help to provide the shell script for generating the record counts in filed wise from the .csv file My question: Source file: Field1 Field2 Field3 abc 12f sLm 1234 hjd 12d Hyd 34 Chn My target file should generate the .csv file with the... (14 Replies)
Discussion started by: Kirands
14 Replies

2. Shell Programming and Scripting

Read files in shell script code and run a C program on those files

HI, I am trying to implement a simple shell script program that does not make use of ls or find commands as they are quite expensive on very large sets of files. So, I am trying to generate the file list myself. What I am trying to do is this: 1. Generate a file name using shell script, for... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

3. Shell Programming and Scripting

Script to check one command and if it fails moves to other command

Input is list of Server's, script is basically to remove old_rootvg, So it should check first command "alt_rootvg_op -X old_rootvg" if it passes move to next server and starts check and if it fails moves to other command "exportvg old_rootvg" for only that particular server. I came up with below,... (6 Replies)
Discussion started by: aix_admin_007
6 Replies

4. Windows & DOS: Issues & Discussions

Script that, if file exists in Samba share, moves file to Unix server

I'm looking to do pretty much what the title says. I want a script that runs, it can run on Unix or Windows, doesn't matter, and searches a Samba shares for a .txt file. If the file exists, the script will move (or possibly copy) the file from the Samba share into a directory on our Unix... (3 Replies)
Discussion started by: twcostello
3 Replies

5. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

6. Shell Programming and Scripting

moves checkout files to local system

I am using my script which generally checkout the repository.Is there any coomand which can help me to checkout the repository not on that svn server while it moves it to your local system at the desired location. (0 Replies)
Discussion started by: rohit22hamirpur
0 Replies

7. Shell Programming and Scripting

moves files remotely using ftp

Hi All, How can i move files from one directory to another in remote server using ftp? Thanks in Advance, (4 Replies)
Discussion started by: HemaV
4 Replies

8. Shell Programming and Scripting

Script that moves itself

Hello all, I'm new here, so if this is in the wrong place please feel free to move it. :) As a challenge to myself, I've decided I want to make a "alive" script. Well not really, but almost. I want to make a script that will rove around my hard drive in the background (actually "moving"... (2 Replies)
Discussion started by: chmod
2 Replies
Login or Register to Ask a Question