Name: arnettme Date: May 15, 2007 at 12:10:28 Pacific Subject: Help with awk OS: Solaris 9 CPU/Ram: 1024 Model/Manufacturer: Sun Blade 150
Comment:
I'm dumping a string of numbers anywhere between 1-6 figures into a file.
Example 1: cat filea 23754
What I'd like to do is awk the last number of the sting; in this case it would be the "4". There will be only one string of numbers in this file at any given time and I will need only the last number.
i guess the first step is to read the docs? anyway, i assume you are using unix on windows? this command: cd /apps/bss/BatchProg/bss; ls -l *.sh can be shortened to ls -l /apps/bss/BatchProg/bss/*sh.
anyway, describe what you want to get out from your ls -l output. do you want to get file size? time ??
actually ls -l iss giving me 5 column output which is permissions, user, file size, date, time, filename. I only want to have file size, date and filename as the output.
I m actually new to this programming... thanks for your help again.
my ls -l output is different [code] ls -l | awk 'NR>1{printf "%s,%s,%s-%s-%s\n",$9,$5,$6,$7,$8}' [/code] my col 9 is filename, column 5 is size, column 6-8 is date/time field....substitute for yours as necessary
are you using a combination of batch + shell scripting? can you describe your environment? i guess if you can use ls, cd, and those normal shell commands , you can also use the unix date utitlity. without further info, i can only show you the how i do it in Unix. [code] thedate=$(date "+%Y%m%d") mv "$filename" "$filename$thedate" [/code]
m using a batch script in command prompt. And m diaplaying the output from a remote server. Finally m storing the output in a txt file with the date on it. So that later on I can compare the files and get to know the daily changes in the server.
the actual and complete script is :
plink -ssh -pw XXXXXXXXX sr54221@nus730pn cd /apps/bss/BatchProg/bss; ls -l *.sh >> nus730pn%(date "+%Y%m%d");