![]() |
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 |
| get characters from output of a command in a variable | muaz | Shell Programming and Scripting | 3 | 06-02-2008 09:13 AM |
| ls command output to variable in script | dsrookie | UNIX for Dummies Questions & Answers | 1 | 03-10-2008 04:14 PM |
| assigning command output to a shell variable | kprattip | Shell Programming and Scripting | 2 | 07-09-2007 04:01 AM |
| Assigning output of command to a variable | oma04 | Shell Programming and Scripting | 5 | 06-27-2006 12:11 PM |
| redirect command output to variable | hugow | UNIX for Dummies Questions & Answers | 1 | 06-22-2005 06:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
With cut -c 8-13 myfile,
I am getting some numeric value. In my shell script I am trying to assign something like this, var=cut -c 8-13 myfile But at the time of execution I am getting -c is not found. If I dont assign, then script executes well. Can we not simply use the value from one command output into the variable in shell script? |
|
||||
|
Meanwhile I started with awk. So on the similar lines I am trying to evaluate
awk o/p to var. start=2 len=10 var=`awk <"$1""myfile" '{print substr($0,$start,$len)}'` echo $var After executing, I am getting awk error. If at the place of $start & $len, I put 2 & 10 resp, it works. Where am I making a mistake? |
|
||||
|
Zazzybob
Yes, that works. But let me explain what was my thought process behind prev command. awk < filename - I understand as, file 'filename' is an input to awk. $1 param consists dir loc where the file is residing. In my fixed width file, I have these numeric values. Those I am retrieving with substring. |
|
||||
|
Also I would like to get rid of leading zeros, after I read a number from fixed width
file. Say, 00000015 should be read as 15. How would I achieve that? |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|