The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-07-2008
manojkarthi manojkarthi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 10
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 (permalink)  
Old 08-07-2008
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Quote:
Originally Posted by manojkarthi View Post

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 (permalink)  
Old 08-07-2008
manojkarthi manojkarthi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 10
Quote:
Originally Posted by namishtiwari View Post
You have to use

mv $i /where/to/move

Thanks...




i have to move ....the files from Source dir to Target Dir.....
  #4 (permalink)  
Old 08-07-2008
manojkarthi manojkarthi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 10
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 (permalink)  
Old 08-07-2008
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Quote:
use a semi colon at the end of for loop or put the do on the next line..
Thanks..
  #6 (permalink)  
Old 08-07-2008
manojkarthi manojkarthi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 10
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 (permalink)  
Old 08-07-2008
manojkarthi manojkarthi is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 10
sir... why its showing like this....
kindly help me..

I need the script by today sir
Closed Thread

Bookmarks

Tags
scriptin

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0