- In awk, variable references are without $-signs... for example:
- When assigning shell variables to awk variable, it is good practice to quote the shell variables, since it is not a shell assignment:
Does anybody have an explanation for the following:
The following scripts runs fine on IRIX64 6.5 but has bugs on Solaris 8.
#! /bin/sh
echo run only on an SGI machine
echo type in linenumber
read j
echo value
read value
awk -f rmspass2 level=$value $j'step1.mlf'
When the script is... (5 Replies)
Hi
I have a unix shell script with an awk statement. I would like to print some of the fields of an input file. However, I would like to print them dynamically, ie by passing the literal $1 $3 into the script to define the output.
I have tried the following:
variable1='$1'
awk... (2 Replies)
I am trying to pass the results from a variable gathered from awk, however when I echo the 'PARSE' and 'SUB', the response is blank. This is my command.
awk -F= '/Unit/''{ PARSE=substr($2,1,5) ; SUB=substr($2,1,1) }' inputfile.lst
Is this a kind of valid attempt or am I obligated to declare... (3 Replies)
I'm trying to write a ksh script that uses awk, but I want to pass variables to awk. For example (not working):
if ];then
searchstr=$1
lsof -i | awk '{if($9~/SEARCHSTR/) print $2} SEARCHSTR=$searchstr'
else
echo "usage: $0 <search string>"
fi
I tried several options. Is it... (3 Replies)
Hi all,
I'm using awk in a .ksh script to split one file by line prefix into different files (up to 4). The files are named after the prefix in the line, and a sequence no.
Is there any way to get the filenames in to variables too? I need _ftpfile1, _ftpfile2, _ftpfile3 and _ftpfile4 which are... (2 Replies)
Hi.
I need to parse file and assign some values to variables, right now i do like below
MYHOMEDIR=`awk '/Home/ {print $NF}' output.txt`
MYSHELL=`awk '/Shell/ {print $NF}' output.txt`
PRGRP=`awk '/Primary/ {print $NF}' output.txt`
SECGRP=`awk '/Second/ {print $NF}' output.txt`
In this... (10 Replies)
I'm trying to use awk to write new entries to a hosts file if they don't exist. I need to do so depending on the type of system I have. Below is what I have, but it isn't working.
awk -v myip1=$IP1 myip2=$IP2 myhost1=$HOST1 myhost2=$HOST2' BEGIN { mqhost1=0; mqhost2=0; stap1=0; stap2=0; }
... (4 Replies)
Hi guys,
I need to fetch data from logfile between two given dates,i got the below code from our forum.It works perfect,but i need to enter the value dynamically to awk while running.
awk '/2012 Jun/{p=1}!/2012 Jul/ && prev~/2012 Jul/ && p{p=0}{prev=$0}p' file
i tried the below code,but... (4 Replies)
Am looking to pass some Linux environment variables into AWK , can I simply use the -v option ?
awk -F: -v AHOME=$HOME '{ if
{rm AHOME/file.txt
a=2 } }'
config.txt
... (4 Replies)