Reading in all files from parent directory (GAWK)

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading in all files from parent directory (GAWK)
# 8  
Old 07-18-2011
Glad you figured it out.
To overwrite the file, just use the '>' redirection instead of '>>':
$GAWK $IN_all > $OUT_all

# 9  
Old 07-18-2011
Hey Mirni,

I tried that but it still adds to the original file. Any other ideas?

# 10  
Old 07-18-2011
mmm.... no. Please check that you are looking at the correct file.
You can try
echo 'Boom!' > $OUT_all

to see that your whole file $OUT_all contains nothing but one line with "Boom!" in it.
Tha is the definition of '>' operator: it truncates the file to zero length and then appends the output of previous command.
This User Gave Thanks to mirni For This Post:
# 11  
Old 07-18-2011
haha thanks for the boom! tip, it worked a treat.

Also I figured out where I was going wrong, my original code was

find /u/Picarro/DataLog/2011/june -type f -name "*dat" -exec cat {} >> june.dat \;

so I just removed one '>' and it worked. My fault, sorry!

Thanks for the help though, you've been great!
# 12  
Old 07-18-2011
Glad you worked it out. BTW, find(1) is one very useful tool, that many of us use every day. Apart from the powerful -exec switch, that can be used to execute any command on the files, you can process the files one-by-one with the following construct:
find /path -type f -name "*.dat" | while read file ; do
   echo "Processing file $file "
   #do something with $file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find/searching files in subdirectories excluding the fiels in Parent Directory

Hi All, requirement is to find and remove the files from sub directories but it should exclude the files from parent directory. At present i am using the below one but it finds and remove files from both parent and sub directories. find ${PATH} -type f \( -name securitas\* -o -name \*gz... (1 Reply)
Discussion started by: Naveenkk
1 Replies

2. Shell Programming and Scripting

Copying files from parent directory only

Hello, Please can someone assist on a issue I am having. I want to find specific files in the parent directory only that have been modified over the last 2 days and copy them to another location. NOTE: The version of AIX I am using does not have MAXDEPTH. I have currently written the... (3 Replies)
Discussion started by: Dolph
3 Replies

3. Shell Programming and Scripting

Help on Backing up all the files in the subdirectories under a parent directory

Hi, I am not too familiar with Unix scripting but I have to write code to find all the files under all the sub directories under a parent directory of unix location and move them to the corresponding Windows location. For eg: I have \home\sreenu\Files\ Under neath this I have multiple sub... (3 Replies)
Discussion started by: raj.sreenu
3 Replies

4. Shell Programming and Scripting

How to list all Subdirectories and files with its full path in a parent directory?

How to list all Subdirectories and files with its full path in a parent directory? (1 Reply)
Discussion started by: johnveslin
1 Replies

5. UNIX for Dummies Questions & Answers

Need Help in reading N days files from a Directory & combining the files

Hi All, Request your expertise in tackling one requirement in my project,(i dont have much expertise in Shell Scripting). The requirement is as below, 1) We store the last run date of a process in a file. When the batch run the next time, it should read this file, get the last run date from... (1 Reply)
Discussion started by: dsfreddie
1 Replies

6. Shell Programming and Scripting

reading files from a directory.

Can some body help me to code this? go to a specific directory.(/home/abcd/test) file1.txt, file2.txt, ... .. filen.txt read the files in side the folder 'test' and print the content of each file into other folder in the same directory lets say(testresult) with the same file name... (4 Replies)
Discussion started by: rocking77
4 Replies

7. Shell Programming and Scripting

Find files inside the parent directory only

Hi All, The following find command lists the files which are 45 minutes older. But it searches for the sub directories also. $ find . -type f -mmin +45 -print ./hello.txt ./test/hi.txt ./temp/now.txt ls hello.txt test temp How can i modify the find command in such way that it finds... (4 Replies)
Discussion started by: Tuxidow
4 Replies

8. UNIX for Dummies Questions & Answers

Listing files in a non-parent directory

Hi, Edit: The title should really read listing files in a non-parent directory, sorry! Im trying to get one of my Bash scripting assignments done for uni and now I'm stuck. This is probably going to be one of those kick yourself moments but, in my script I have a variable usrDir which... (2 Replies)
Discussion started by: Adzi
2 Replies

9. Shell Programming and Scripting

gawk - reading two files & re arrange the columns

Hi, I am trying to read 2 files and writing to the 3rd file if I find the same elements in 2 files. my first file is 1 0 kb12124819 766409 1.586e-01 1 0 kb17160939 773886 8.674e-01 1 0 kb4475691 836671 8.142e-01 1 0 ... (2 Replies)
Discussion started by: ezhil01
2 Replies

10. Shell Programming and Scripting

Reading files in directory

Hi Everyone , have a nice day i need a help on this thing algo is something like in certain path like /root/user1 i have many files , i need a code which could open every file one by one and then each file has contents like this <moid>CcnCounters=CAPv3-Received-Total-Requests, Source =... (3 Replies)
Discussion started by: Dastard
3 Replies
Login or Register to Ask a Question