![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing variables to sed | jfisch | Shell Programming and Scripting | 3 | 03-07-2005 07:25 AM |
| Passing awk Variables | gozer13 | Shell Programming and Scripting | 3 | 01-04-2005 04:32 PM |
| Passing Variables to Awk | Bab00shka | Shell Programming and Scripting | 2 | 10-05-2004 08:18 AM |
| passing variables | sounder123 | Shell Programming and Scripting | 1 | 06-10-2004 10:19 AM |
| Passing Variables to AWK | AreaMan | Shell Programming and Scripting | 5 | 01-28-2002 06:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Passing specific fields from files as variables
Hi all,
I have a question regarding passing specific fields from files to shell scripts as variables. I have 2 files, I want to compare the record counts of these files in a shell script. Thus far I have done: wc -l file1 > file1test yields: 73 filename wc -l file2 > file2test yields: 73 filename What I want to do is take the 73 field from each file and store them in separate variables, then use those variables in a conditional statement. Any help would be greatly appreciated. Last edited by keladar; 04-14-2005 at 01:04 AM.. |
|
||||
|
Quote:
Code:
VARIABLE_1=`wc -l file1 | awk -F\ '{print $1}'`
VARIABLE_2=`wc -l file2 | awk -F\ '{print $1}'`
|
|
||||
|
Quote:
Code:
$ time awk 'END {print NR}' bigfile
1314268
real 1m50.36s
user 1m42.52s
sys 0m5.35s
$ time wc -l bigfile | awk -F\ '{print $1}'
1314268
real 0m18.67s
user 0m13.19s
sys 0m4.33s
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|