using awk for setting variable but change the output of this variable within awk
Hi all,
Hope someone can help me out here.
I have this BASH script (see below)
My problem lies with the variable path.
The output of the command find will give me several fields. The 9th field is the path. I want to captured that and the I want to filter this to a specific level.
The output of the path is somewhat like this: /Volume/Server/department/otherlevels/....
The part I want to capture in the variable is the department.
I can do this in a single line with awk -F/ '{print $5}' But I need it in an array.
Using it like it is now will give me an error.
Any idea how to resolve this ?
Many regards,
Ronald
Last edited by Scott; 08-10-2011 at 07:10 AM..
Reason: Please use code tags for code
hi there
I am trying to get a value from a remote machine into a local variable. To get this value i want to use awk but im having trouble getting it to run, am i escaping in the right places here and using the right quotes (i must have tried a million combinations :()
# VAR=`ssh server1... (5 Replies)
In awk script,
#!/bin/sh
awk 'BEGIN{i=0;}{i=i+5;}END{print i}' in.txt
vr=0;
vr=$i;
echo "$vr"
How can i assign that value of i in $vr(variable) of shell script? (7 Replies)
Hi,
I have a large flat file from host without delimiter. I'm transforming this file to a csv file using statements like
# Row 03: Customer / field position 3059 +20
WOFABNAM=substr( $0, 3059, 20 );
and deleting the trailing whitespaces before and after with that
sub( /^ +/, "",... (4 Replies)
Hi.
How to change string variable in awk?
for example, I parse with awk script text file named some_name_with_extension.txt
I want to print only some_name in my script
....
varCompName = FILENAME
print varCompName
How to put not all symbols from FILENAME to variable?
thank you
This... (4 Replies)
The following is part of a larger shell script
grep -v "Col1" my_test.log | grep -v "-" | awk '$5 == "Y" {print $1}'
instead of printing, can I set set $1 to a variable that the rest of the shell script can read?
if $5 == Y, I want to call another shell script and pass $1 as a... (2 Replies)
hi i want to find the size of a folder and assign it to a variable and then compare if it is greater than 1 gb.
i am doin this script, but it is throwing error....
#!/bin/ksh
cd . | du -s | size = awk '{print $1}'
if size >= 112000
then
echo size high
fi
ERROR : (4 Replies)
Hello All,
I have csv file, where one of fields is date (yyyy/mm/dd 00:00:00). Using awk I am trying to find all records with date newer/older than specific date. My idea was to compare unix timestamps of both dates:
start=`date +%s -d "$DateStart"`
awk -v start="$start" -v current=`date +%s... (34 Replies)
Hi Experts,
I am trying to get system output to capture inside awk , but not working:
Please advise if this is possible :
I am trying something like this but not working, the output is coming wrong:
echo "" | awk '{d=system ("date") ; print "Current date is:" , d }'
Thanks, (5 Replies)