Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

BASH with AWK

Shell Programming and Scripting


Tags
bash with awk

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-25-2008   -   Original Discussion by narasimhulu
narasimhulu's Unix or Linux Image
narasimhulu narasimhulu is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 1 July 2010, 7:45 AM EDT
Location: Bangalore
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
BASH with AWK

Hello,

I have a file.txt with 20000 lines and 2 columns each which consists of current_filename and new_filename . I want to create a script to find files in a directory with current_filename and move it to new folder with new_filename.

Could you please help me how to do that??

Thanks in advance,
Sponsored Links
    #2  
Old Unix and Linux 08-25-2008   -   Original Discussion by narasimhulu
aigles's Unix or Linux Image
aigles aigles is offline Forum Advisor  
Registered User
 
Join Date: Apr 2004
Last Activity: 1 December 2014, 9:03 AM EST
Location: Bordeaux, France
Posts: 1,711
Thanks: 2
Thanked 62 Times in 58 Posts
You can try something like that :
Code:
current_folder=.
new_folder=./archive

while read current_filename new_filename
do
   current="${current_folder}/${current_filename}"
   new="${new_folder}/${new_filename}"
   [ -f "${current}" ] && mv "${current}" "${new}"
done <file.txt

Jean-Pierre.
Sponsored Links
    #3  
Old Unix and Linux 08-26-2008   -   Original Discussion by narasimhulu
narasimhulu's Unix or Linux Image
narasimhulu narasimhulu is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 1 July 2010, 7:45 AM EDT
Location: Bangalore
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Jean.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using arrays in bash using strings to bash built-in true kristinu Shell Programming and Scripting 41 03-30-2012 09:07 PM
Bash Script: modify bash LibRid Shell Programming and Scripting 9 10-25-2010 07:17 PM
how to make your bash script run on a machine with csh and bash npatwardhan Shell Programming and Scripting 3 11-19-2008 04:17 AM
bash and ksh: variable lost in loop in bash? estienne Shell Programming and Scripting 2 08-25-2008 03:09 PM
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 01:25 PM



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