need shell script for moving file one by one


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need shell script for moving file one by one
# 1  
Old 08-07-2008
need shell script for moving file one by one

#SD=source dir TD= target dir

SD="$/amddev/app01/manoj/new/scripts/old"
TD="$/amddev/app01/manoj/new/scripts/new"
EXT="$*.txt"
for i in `ls -F "$SD"/*"$EXT"|grep -v /$` do
mv "$SD" "$TD"
if [ "$?" -eq '0' ]
then
echo "$i" successfully moved
echo Manoj successfully..1 ( here i have to add a process)
else
echo error moving "$i" - no processing for this file
# .... echo break command if you desire ...
fi
done


The above script i tried but not working...
acctually i want to move the files one by one from sou-dir to target-dir
if one file moved ..it have process my call...the next file like that

any one help me...today i need this script
# 2  
Old 08-07-2008
Quote:
Originally Posted by manojkarthi
Code:
#SD=source dir TD= target dir

SD="$/amddev/app01/manoj/new/scripts/old"
TD="$/amddev/app01/manoj/new/scripts/new"
EXT="$*.txt"
for i in `ls -F "$SD"/*"$EXT"|grep -v /$` do
   mv "$SD" "$TD"
    if [ "$?" -eq '0' ]
    then
        echo "$i" successfully moved
       echo Manoj successfully..1  ( here i have to add a process)
    else
        echo error moving "$i" - no processing for this file
#        .... echo break command if you desire ...
    fi
done

The above script i tried but not working...
acctually i want to move the files one by one from sou-dir to target-dir
if one file moved ..it have process my call...the next file like that

any one help me...today i need this script

You have to use

mv $i /where/to/move

Thanks...
# 3  
Old 08-07-2008
Quote:
Originally Posted by namishtiwari
You have to use

mv $i /where/to/move

Thanks...




i have to move ....the files from Source dir to Target Dir.....
# 4  
Old 08-07-2008
i have to move ....the files from Source dir to Target Dir.....

i have tried but it showing


mds@ttl03ap:/amddev/app01/manoj/new/scripts>sh manoj.sh
manoj.sh[4]: Syntax error at line 5 : `mv' is not expected.
# 5  
Old 08-07-2008
Quote:
use a semi colon at the end of for loop or put the do on the next line..
Thanks..
# 6  
Old 08-07-2008
i have tried but it showing *.txt not found why its showing ..like this ...
In the directory ...five txt files are there

In "manoj.sh" 16 lines, 432 characters
SD="$/amddev/app01/manoj/new/scripts/old"
TD="$/amddev/app01/manoj/new/scripts/new"
EXT="$*.txt"
for i in `ls -F "$SD"/*"$EXT"|grep -v /$`;
do
mv $i /amddev/app01/manoj/new/scripts/new/
if [ "$?" -eq '0' ]
then
echo "$i" successfully moved
echo Manoj successfully..1
else
echo error moving "$i" - no processing for this file
# .... echo break command if you desire ...
fi
done

~
~
"manoj.sh" 16 lines, 432 characters
[5] + Stopped vi manoj.sh
mds@ttl03ap:/amddev/app01/manoj/new/scripts>sh manoj.sh
$/amddev/app01/manoj/new/scripts/old/*.txt not found
mds@ttl03ap:/amddev/app01/manoj/new/scripts>cd ../old
mds@ttl03ap:/amddev/app01/manoj/new/old>cd /amddev/app01/manoj/new/scripts/old/
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>ls
TTLNotes.txt a man.txt
TTLNoteslast.txt b srnoteska.txt
UPDATEFILEPRECHECKFMSUPE060808.txt c
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>


"manoj.sh" 16 lines, 432 characters
SD="$/amddev/app01/manoj/new/scripts/old"
TD="$/amddev/app01/manoj/new/scripts/new"
EXT="$*.txt"
for i in `ls -F "$SD"/*"$EXT"|grep -v /$`;
do
mv $i /amddev/app01/manoj/new/scripts/new/
if [ "$?" -eq '0' ]
then
echo "$i" successfully moved
echo Manoj successfully..1
else
echo error moving "$i" - no processing for this file
# .... echo break command if you desire ...
fi
done

~
~

"manoj.sh" 16 lines, 432 characters
[5] + Stopped vi manoj.sh
mds@ttl03ap:/amddev/app01/manoj/new/scripts>sh manoj.sh
$/amddev/app01/manoj/new/scripts/old/*.txt not found

mds@ttl03ap:/amddev/app01/manoj/new/old>cd /amddev/app01/manoj/new/scripts/old/
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>ls
TTLNotes.txt a man.txt
TTLNoteslast.txt b srnoteska.txt
UPDATEFILEPRECHECKFMSUPE060808.txt c
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>

Last edited by manojkarthi; 08-07-2008 at 03:47 AM..
# 7  
Old 08-07-2008
sir... why its showing like this....
kindly help me..

I need the script by today sir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Beginner need help how file moving script could look like

Hi there, I am an absolut beginner in scripting. I am using Ubuntu Linux 18.04 LTS: I just need some hints/suggestions how a script could look like doing the following stuff: assuming I am in directory "base_directory" like xyz@mypc:~/base_directory$ within the "base_directory there... (1 Reply)
Discussion started by: dut42
1 Replies

2. Shell Programming and Scripting

Shell Script for renaming and moving Files - Easy?

Hey guys, ive been working on this for about 2hrs now - without any solution. At first I need to say I dont have skills in linux bash scripting, but I tried to use some codesnippets and manuals from google. What I want to do: I have different folders including 2 different filestypes with... (15 Replies)
Discussion started by: peter1337
15 Replies

3. Homework & Coursework Questions

Shell Scripting , Moving Old file to specific folder

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/log you need to find out all... (4 Replies)
Discussion started by: shajoftaj
4 Replies

4. Ubuntu

Shell Scripting , Moving Old file to specific folder

There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/logyou need to find out all the log files of last 1 month and move them into $HOME/logs/lastmonth/ this should be implemented with reference of file name. ---------- Post updated at 12:30 PM ----------... (3 Replies)
Discussion started by: shajoftaj
3 Replies

5. Shell Programming and Scripting

Moving log files based on month - help with ksh shell script

Hello, I'm trying to move the log files from the parent directory to respective monthly folder and I would be running this script on a weekly basis through cron. I'm new to this scripting and here is what i could come up and it runs without really doing anything. I even tried placing echo... (2 Replies)
Discussion started by: jusblues
2 Replies

6. UNIX for Dummies Questions & Answers

File Moving Script

I want to make a script that moves all files with a keyword on it to another folder. and lets me know how many files it moved with that keyword. Im a total newbie with scripting so a little help would be much appreciated. (3 Replies)
Discussion started by: marchina
3 Replies

7. Shell Programming and Scripting

Shell Script for moving 3 days old file to Archive Folder

Hi Experts, I have a "Source" folder which may contain some files. I need a shell script which should move all files which are older than 3 days to "Archive" folder. Thanks in Advance... (4 Replies)
Discussion started by: phani333
4 Replies

8. Shell Programming and Scripting

Need help with shell script for moving/deleting/renaming files

Hi. I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next. Here's an example: /var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Discussion started by: aflower
4 Replies

9. Shell Programming and Scripting

Help with shell script: moving end of line character

Hello. I have a file (old.txt) that I need to copy into another file (new.txt). Each line on old.txt ends with CR/LF but the position of CR/LF varies from one record to another. I need to copy each line of record to new.txt and move CR/LF in pos 165. Can I use awk to achieve this? How?... (8 Replies)
Discussion started by: udelalv
8 Replies

10. Shell Programming and Scripting

shell script for moving all the file from the same folder

Hi , I need a shell script which basicaly moves all the files from one folder say folder x to folder y and once they are moved to folder y a datetimestamp should be attached to there name for ex file a should be moved to y folder and renamed as a_20081015 (1 Reply)
Discussion started by: viv1
1 Replies
Login or Register to Ask a Question