hi guys...
i have 15-20 directories having 15-20 txt files in each.
these files are being passed one by one as an argument in a script.
i need a script whch shud pass all the files of each directory to be passed in my script one by one and give output in a single file, output in different file will also b ok...
thanx.
find /directory-to-scan/ -type f -name "*.txt" | while read file
do
echo $file #Do your operation here.
done
thanx dear... it worked...
I want to do One more thing... i have many text files with different names.. i want to copy the content of all the files in a single text file... thanx
find /directory-to-scan/ -type f -name "*.txt" | while read file
do
cat $file >> singlefile.txt
done
pludi
September 14, 2011, 5:06am
5
You don't have to copy them, only to conman cat (POSIX) inate them and redirect into a new file.
thanx bro...
---------- Post updated at 01:53 AM ---------- Previous update was at 01:51 AM ----------
hi frnds... one more prob is dere....
i have a text file containing following data:
2011/09/14 23:55
KRSN 142355Z AUTO 00000KT 10SM CLR 30/22 A2990 RMK AO2
2011/09/14 23:55
KRSN 142355Z AUTO 00000KT 10SM CLR 30/22 A2990 RMK AO2
2011/09/14 23:45
KHAI 142345Z AUTO 30006KT 10SM SCT036 SCT042 BKN100 11/08 A3010 RMK AO2
2011/09/14 23:55
KOBE 142355Z AUTO 06005KT 10SM CLR 26/20 A2991 RMK AO2
2011/09/14 23:45
KHAI 142345Z AUTO 30006KT 10SM SCT036 SCT042 BKN100 11/08 A3010 RMK AO2
2011/09/14 23:55
KOBE 142355Z AUTO 06005KT 10SM CLR 26/20 A2991 RMK AO2
2011/09/14 23:50
ENBR 142350Z 34007KT 9999 VCSH FEW020 SCT035 BKN060 10/09 Q1004 RMK WIND 1200FT 31016KT
2011/09/14 23:50
ENRY 142350Z 00000KT CAVOK 13/08 Q0998
2011/09/14 23:50
ENTC 142350Z 14007KT 8000 -DZ FEW006 BKN008 09/07 Q0990 RMK WIND 2600FT35007KT
2011/09/14 23:50
ENVA 142350Z 29012KT 9999 FEW029 SCT053 OVC100 10/07 Q1000 RMK WIND 670FT 30017KT
2011/09/14 23:50
ENZV 142350Z 33012KT 9999 -SHRA FEW017 SCT023 BKN045 12/09 Q1005
2011/09/14 23:55
KRQO 142355Z AUTO 04016G19KT 10SM CLR 25/07 A3008 RMK AO2
I need that this should look like in a new file..:
2011/09/14 23:55
METAR KRQO 142355Z AUTO 04016G19KT 10SM CLR 25/07 A3008 RMK AO2=
means adding METAR in starting and = in last of each line except the date and timing line...
thnx.
sed '/^[^0-9$]/ s/\(.*\)/METAR \1=/g' inputFile
---------- Post updated 09-15-11 at 12:02 AM ---------- Previous update was 09-14-11 at 11:59 PM ----------
or
awk '{x=$0}/^[^0-9]/{x="METAR " $0 "="}{print x}' inputFile
sed ' /^[A-Z]/ s/.*/METAR&=/' file