![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| assign a value to a variable | Shivdatta | Shell Programming and Scripting | 10 | 01-17-2007 07:40 AM |
| assign value to variable using AWK | HAA | Shell Programming and Scripting | 4 | 12-06-2006 11:43 AM |
| assign a value to variable | markjason | Shell Programming and Scripting | 3 | 10-10-2006 02:05 PM |
| hot to assign output to a variable | walnut | Shell Programming and Scripting | 1 | 02-22-2006 09:19 PM |
| assign to variable | AkumaTay | UNIX for Dummies Questions & Answers | 1 | 05-18-2002 02:11 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Assign o/p of awk to a variable
Hi UNIX gurus,I am facing a typical problem while assigining while assigining output of awk to a variable. I have a fixed length file say myinputfile.txt When I allow the value/output of an awk to be redirected to a file, it works fine. i.e. awk "/^.{232}$acctNum/ { printf(\"%s;Y;Account#\n\",substr(\$0,241,1)) ; exit} " myinputfile.txt >> mylogfile.txt However, when I try to assign the the value of same to a variable, and then echo the variable, it displays blank.i.e. myvariable=`awk "/^.{232}$acctNum/ { printf(\"%s;Y;Account#\n\",substr(\$0,241,1)) ; exit} " myinputfile.txt` Can somebody please help. ![]() |
|
||||
|
Only awk is working fine. However, while assigning the same to variable, it is not working.
My Sample Inputfile is as shown below: MyAdd1 MyAdd2 MyAdd3 MyAdd4 MyAdd5 Sachin Tendulkar 222 222-2222 11111111111111A0000111122223333XYX YourAdd1 YourAdd2 YourAdd3 YourAdd4 YourAdd5 Rahul Dravid 111 121-5555 22222222222222B0123456789123456XYX (In above example, spaces are getting truncated in this forum) Basically, position 233-240 denotes account number. Also, by substring, I am trying to extract 241 character. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|