![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Checking the Empty line in csv file | sollins | Shell Programming and Scripting | 4 | 05-15-2008 04:48 AM |
| Error checking a file from previous file size | stuck1 | Shell Programming and Scripting | 2 | 12-06-2007 05:39 AM |
| Checking file size of zip file | skwyer | UNIX for Dummies Questions & Answers | 2 | 10-11-2007 08:51 AM |
| Help with checking file size | ssmith001 | Shell Programming and Scripting | 15 | 09-08-2005 06:48 PM |
| Checking file size | jkuchar747 | UNIX for Dummies Questions & Answers | 2 | 03-02-2005 11:34 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
checking size of the first line ina file
Hi My test.log file looks like this:
Code:
0 190_GSTV_HUX_003QISCGSK026_error070322_115331917.log 34 190_GSTV_HUX_003QISCGSK026_error070117_151311385.log 12 190_GSTV_HUX_003QISCGSK026_error070117_151230001.log 2 190_GSTV_HUX_003QISCGSK026_error070117_101010001.log 0 190_GSTV_HUX_003QISCGSK026_error070117_0832001254.log 0 190_GSTV_HUX_003QISCGSK026_error070115_122813125.log 3 190_GSTV_HUX_003QISCGSK026_error070115_115331917.log 0 190_GSTV_HUX_003QISCGSK026_error070115_114442254.log 0 190_GSTV_HUX_003QISCGSK026_error070112_1156001509.log ie.,in this case the size of "190_GSTV_HUX_003QISCGSK026_error070322_115331917.log" please note that the test.log will be updated everytime i run a script and only the part remains constant is '190_GSTV_HUX_003QISCGSK026_errorXXXXXX_XXXXXXXXX.log' is there any cmd which checks for the size of the first line in the test.log file and give the result?using which i need to write a condition... Presently i tried this: Code:
check=`cat /home/user/test.log | awk '{print $1}'`
0 34 12 2 0 0 3 0 0 if i use the condition Code:
if [ $check = 0 ] beacause check contains 0 32 12 2 ....... Please can some one help me in this regard??? Thanks in advance Last edited by kiran1112; 03-23-2007 at 01:48 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Give a try on this..
Quote:
|
|
#3
|
|||
|
|||
|
Quote:
Code:
awk -F " " '{ print length($2) }' filename
Last edited by matrixmadhan; 03-22-2007 at 01:45 AM. Reason: should be $2 |
|
#4
|
|||
|
|||
|
Quote:
Seems like this thread is a continuation of the below thread...I think he is not looking for the size of the second field.....rather, the first field which is the size of the file.. script to check for a condition inside a file |
|
#5
|
|||
|
|||
|
how about this,
Code:
ls -l `awk -F" " 'NR == 1 { print $2; exit }' file` | awk '{ print 5 }'
|
|
#6
|
||||
|
||||
|
Code:
sed -n -e "s/^ *\([^ ]*\) *.*_error.*/\1/p;q" /home/user/temp.log |
|
#7
|
|||
|
|||
|
Hi all
many thanks for all your suggestions but none of the commands is able to give the size of only the first line. the following cmds Code:
awk -F" " 'NR=1{print $1}' test.log
and
sed -n -e "s/^ *\([^ ]*\) *.*_error.*/\1/p;" test.log
and
ls -l `awk -F" " 'NR == 1 { print $2; exit }' test.log` | awk '{ print 1 }'
any help is appreciated Thanks Kiran |
|||
| Google The UNIX and Linux Forums |