Hi
I’m having a bit of trouble writing my first Unix script.
I’ve written a script which includes some awk coding to extract certain information from a file. The filename is hard-coded into the awk routine. The script is working okay, but what I’d like to do is to have all the files in a directory passed to the script, and if the names match particular criteria then have my awk lines process them. It sounds simple, but I can’t get my head around it!
I’d like everything to happen in the script (ie don’t pass the directory listing as arguments to the script). However, I’ve also tried command line permutations such ‘ls | awk ‘{print $9;}’ | myscript which I thought might pass the filenames into my script, but I’m not sure how to read them from within the script, or even if it’s possible.
Thanks very much.
I’m having a bit of trouble writing my first Unix script.
I’ve written a script which includes some awk coding to extract certain information from a file. The filename is hard-coded into the awk routine. The script is working okay, but what I’d like to do is to have all the files in a directory passed to the script, and if the names match particular criteria then have my awk lines process them. It sounds simple, but I can’t get my head around it!
I’d like everything to happen in the script (ie don’t pass the directory listing as arguments to the script). However, I’ve also tried command line permutations such ‘ls | awk ‘{print $9;}’ | myscript which I thought might pass the filenames into my script, but I’m not sure how to read them from within the script, or even if it’s possible.
Thanks very much.