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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

piping "find" output to a script. how to do this

Status
Not open for further replies.

OieL

MIS
Sep 6, 2002
17
0
0
US

find . *.bak | d_script.sh

in my script d_script.sh , i want to manipulate each line of output of find ... how will I capture each to a variable ? any ideas to do this ?

I know that in "d_script.sh FILE"
FILE is $1, what about in pipes.
 

in 'd_script.sh'

#!/bin/sh
for myinput
do
echo $myinput
# your work
done

then type: d_script.sh 'find . -name \*\.bat'
ALTERNATIVE
find . -name \*\.bat |xargs d_script.sh


-----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
alternative
in 'd_script.sh'

for i in `find . -name $1`
do
echo $i
#ur work
done

pass what u want to find as a command line argument
e.g.
d_script.sh *.bak
 
Yet another way
Code:
while read line;
do
#$line contains this file
done
//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top