![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names | nikosey | Shell Programming and Scripting | 6 | 07-30-2008 10:46 PM |
| search for the contents in many file and print that file using shell script | cdfd123 | Shell Programming and Scripting | 3 | 10-07-2007 11:17 PM |
| Have a shell script check for a file to exist before processing another file | heprox | Shell Programming and Scripting | 3 | 11-14-2006 03:26 AM |
| Shell Script to Load data into the database using a .csv file and .ctl file | Csmani | Shell Programming and Scripting | 3 | 05-24-2006 09:09 AM |
| Reading file names from a file and executing the relative file from shell script | anushilrai | Shell Programming and Scripting | 4 | 03-10-2006 05:25 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
Quote:
You have to use mv $i /where/to/move Thanks... |
|
||||
|
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.. |
![]() |
| Bookmarks |
| Tags |
| scriptin |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|