delim might change to hold different values since it comes from the fourth char of another file. Can someone help me with my awk statement to use a the variable "delim"
You're setting the variable correctly but not doing anything with it. I don't know what you want to do with the variable, and you didn't say. And actually, I don't think you need awk at all here anyway...
That's a useless use of cat, too, several of them. UNIX commands are quite capable of reading files all by themselves, you don't need to spoon-feed them with cat. Even things like read, which don't take filenames, can have files simply redirected into them with <.
You've got the right idea by using 'while read', and can take that even further. The special IFS variable will cause read to split on whatever character you want.
Your syntax for while wasn't quite right.
Also, you can use ~/ as short-form for $HOME.
...But what are you actually trying to do here? There might be even more direct ways than this.
Hello All,
I am trying to run a script to extract data from the file. The format of the file is as below:
filename: sample.log
12345| ABCD
23456| GKHY
33454| ABCD
98765| TTRRI want to run a command in AWK as show below
extract.sh
#!/bin/bash
echo... (2 Replies)
I'm working on a script in which gives certain details in its output depending on user-specified options. So, what I'd like to do is something like:
if
then
awkcmd='some_awk_command'
else
awkcmd='some_other_awk_command'
fi
Then, later in the script, we'd do something like:
... (5 Replies)
Have a small doubt .
While using an iterator , i need to take the fields as seen as below .
But the Iterator is not been displayed . Can you please help with this .
Code:
ITERATOR=0COUNT=`cat test.txt`echo "$COUNT" while do echo $ITERATOR echo "$COUNT" awk... (3 Replies)
Hi Guys,
Can anyone of you please tell me how to use a variable inside a awk command.
For ex - if am printing the third column with respect to a pattern with delimiter ~
awk -F~ '$3=="pattern"' <file name> - This works,
Now here I have a set of patterns in a file and I want to put it in... (1 Reply)
Hi Gurus,
I need a suggestion, please help. I have a input file as below :
abc.txt :
*
xxxx: 00000
xxxxx: 00000
xxxx: RANDOM
xxx: RANDOM
**************************xxxxxxx***
* abc
******************************
abc:
abc: ... (3 Replies)
Trying to do something like this
ls -lrt | awk '$9=="test5"'
-rw-r--r-- 1 lrmq db2iadm1 381 Sep 20 21:56 test5
But now, I need to give a variable in place of test5. For example let's define x as test5
x=test5
ls -lrt | awk '$9=="$x"'
This doesn't seem to be working. It doesn't take the... (4 Replies)
Okay, so I am trying to use a count variable to reference the column of output sent from an echo statement. So I am trying to do this
#!/bin/bash
CURRENT=$PWD
VAR=3
CHANGE=`echo $CURRENT | awk -F "/" '{ print \$$VAR }'`
This instead of giving me the third instance after the "/" gives... (4 Replies)
Hi Jim,
The following script is in working state. But i m having one more problem with awk cmd. Could you tell me how to use any variable inside awk or how to take any variable value outside awk.
My problem is i want to maintain one property file in which i am declaring variable value into that... (12 Replies)
Hi All,
I have a awk command that is stored in a variable.
the value of the variable cmd is:
(mean output of echo $cmd is: )
awk -F";" '{print $1}'
Now I want to execute this command.
How can I do that????
Quick Reply will be appreciated.
Regards,
Amit (2 Replies)
Hi,
I have a situation where I have to specify a different value to an awk command, I beleive i have the gist of this done, however I am not able to get this correct. Here is what I have so far
echo $id
065859555
This value occurs in a "pipe" delimited file in postition 8. Hence I would... (1 Reply)