English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

OK. this is the final question i have (hopefully). this is my problem.

What im trying to do is
1) take all the full pathnames of directories and print them to a text file. I've already got an answer on how to do this...

2) i need to loop through them one at a time and print single rows to another text file. it prints row one, then runs another of my shell scripts. when the shellscript is done, i need to do the same while printing row two to the text file...

i dont know how to do step two. I thought origionally awk would be the answer, but awk deals with columns, not rows.

Any insight? thanks.

2007-08-14 06:53:52 · 3 answers · asked by toodles_1399 1 in Computers & Internet Programming & Design

3 answers

#!/bin/sh

find [directory] -type d -mindepth 1 > dirList.txt

while read line; do
echo $line >> output.txt
mySubScript.sh $line >> output.txt
done < dirList.txt

===========================
I think you could do the entire thing as one big find command, if you don't need the intermediate (directory list) file for anything else:

find [directory] -type f -mindepth 1 -print -exec mySubScript.sh {} \; >> output.txt


===========================
And you can count the line number, if you care to, easily:


find [directory] -type d -mindepth 1 > dirList.txt

lineNo=0
while read line; do
lineNo=$(($lineNo+1))
echo $lineNo ':' $line >> output.txt
mySubScript.sh $line >> output.txt
done < dirList.txt

2007-08-14 09:58:11 · answer #1 · answered by McFate 7 · 0 0

#!/bin/bash
start=1
end=`cat oldfile.txt | wc -l`
for (( a = $start; a <= $end; a++ ))
do
row=`cat oldfile.txt | sed -n "${a},${a}p"`
echo $row >> newfile.txt
#run your another script here
done

2007-08-14 14:41:18 · answer #2 · answered by Anonymous · 0 0

by using echo u will see that in one line
next time that will be appear in next line

2007-08-14 14:03:26 · answer #3 · answered by satya e 2 · 0 0

fedest.com, questions and answers