Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script output

Status
Not open for further replies.

Ramu66

Programmer
Jun 2, 2004
7
US
I've the following script

Code:
integer ctr=0

cat files.txt | while read line

do
(( ctr+=1 ))
if [[ ctr -ne 1 ]]
then

cp $(print $line | cut -f2 -d' ')  /home/csis/rajus/test 


fi
done
[code]

which is supposed to copy filename red from another file
to a directory specified. It is doing it, but still
it gives me a n output mentoning the usage of cp command.
if i send that output to /dev/null it fine. But
how to avoid it in the first place

thanks
 
Can you please post the contents of files.txt ?
Anyway, you may try something like this:
head +2l files.txt | while read a file
do cp "$file" /home/csis/rajus/test
done


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
here is the content of the file

filenumber filename
1 test.txt
2 test1.txt
 
I think this should suit your needs:

Code:
#!/usr/bin/ksh

cp $(awk 'NR>1 {print $2}' files.txt) /home/csis/rajus/test

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top