LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-08-2007, 05:18 PM   #1
rsmccain
Member
 
Registered: Apr 2004
Location: Louisiana
Distribution: SUSE
Posts: 154

Rep: Reputation: 30
need assistance with this script


im trying to remove the first 4 lines of every text file then copy the file over to another directory..

i can do this fine if its going from 1 directory to the next. however, there are 3 directories i need to do this on. rather than write a for loop could i script this in somehow? check the script below, it will make more sense.

#!/bin/bash

for i in /home/dssics1/reverse/extended/ACESSPRD/*[^clean]; do
if [ -f $i ]; then
tail -n +4 $i > $i.clean
cp -R $i.clean /media/dss-sqltest/external/dssics1/
rm *clean*
fi
done

for i in /home/dssics2/reverse/extended/ACESSPRD/*[^clean]; do
if [ -f $i ]; then
tail -n +4 $i > $i.clean
cp -R $i.clean /media/dss-sqltest/external/dssics2/
rm *clean*
fi
done

for i in /home/dssics3/reverse/extended/ACESSPRD/*[^clean]; do
if [ -f $i ]; then
tail -n +4 $i > $i.clean
cp -R $i.clean /media/dss-sqltest/external/dssics3/
rm *clean*
fi
done
 
Old 02-08-2007, 06:32 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,470
Blog Entries: 54

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Code:
#!/bin/bash
for i in /home/dssics{1,2,3}/reverse/extended/ACESSPRD/*[^clean]; do
 if [ -f $i ]; then tail -n +4 $i > $i.clean;  t=${i//\/home\//}; t=${t//\/reverse*/}
  cp -R $i.clean /media/dss-sqltest/external/$t/; rm *clean*
 fi
done
exit 0
 
Old 02-08-2007, 10:41 PM   #3
rsmccain
Member
 
Registered: Apr 2004
Location: Louisiana
Distribution: SUSE
Posts: 154

Original Poster
Rep: Reputation: 30
thanks!

Quote:
Originally Posted by unSpawn
Code:
#!/bin/bash
for i in /home/dssics{1,2,3}/reverse/extended/ACESSPRD/*[^clean]; do
 if [ -f $i ]; then tail -n +4 $i > $i.clean;  t=${i//\/home\//}; t=${t//\/reverse*/}
  cp -R $i.clean /media/dss-sqltest/external/$t/; rm *clean*
 fi
done
exit 0

thanks.. i'll try it tommorow at work..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script assistance required.. TheEngineer Linux - Newbie 4 10-26-2006 06:42 AM
Assistance with 'find -exec cp' shell script dick.swift Linux - Software 6 01-23-2006 10:00 AM
Need assistance please wennie Linux - Software 5 03-16-2005 07:24 AM
Need assistance spotslayer Linux - Software 1 11-18-2004 06:49 AM
Need Assistance Bizar Slackware 11 06-25-2003 09:10 PM


All times are GMT -5. The time now is 01:35 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration