Sponsored Content
Top Forums Shell Programming and Scripting Variable assignment inside awk Post 302792829 by ahamed101 on Thursday 11th of April 2013 05:08:08 AM
Old 04-11-2013
They are shell string substitutions. The output from the pntadm statement results into IP address and Expiry date separated by space.

ip=${val% *} will remove everything from behind till it encounters a space i.e. it will remove the expiry date
time=${val#* } will remove everything from front till it encounters a space i.e. it will remove the IP address

--ahamed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk variable assignment in a file

Hi All, I have a little awk script which uses a variable (x): awk -v x=0 'NF != 6 { ++x } END { print "This batch had " x " errors out of ", NR" records"}' But when I've tried to put the command in a file I can't seem to declare the variable. I've managed to simplify the code so that I... (4 Replies)
Discussion started by: pondlife
4 Replies

2. Shell Programming and Scripting

getting variable inside awk

Hi All, I have awk script for replacing the nth ocurance of a string in an xml file... My code is like this FILETYPE=xml TAGNAME=type OCCURANCE=$1 TAGVALUE=valueur echo OCCURANCE:$OCCURANCE echo TAGNAME:$TAGNAME echo TAGVALUE:$TAGVALUE awk -v n=$OCCURANCE -v... (1 Reply)
Discussion started by: subin_bala
1 Replies

3. Shell Programming and Scripting

variable assignment using awk

Guys, Could you please help me out. I need two values in two variables using awk from the o/p of grep. example:- grep sdosanjh <filename> sdosanjh myhostname myfilename NOW WHAT I WANT IS :- sdosanjh should be in variable (say NAME) myhostname should be in variable (say... (8 Replies)
Discussion started by: sdosanjh
8 Replies

4. Shell Programming and Scripting

Automatic variable assignment inside a for loop

cs1=`echo "scale=8;($css1/$css0)*100"|bc` cs2=`echo "scale=8;($css2/$css0)*100"|bc` cs3=`echo "scale=8;($css3/$css0)*100"|bc` cs4=`echo "scale=8;($css4/$css0)*100"|bc` cs5=`echo "scale=8;($css5/$css0)*100"|bc` cs6=`echo "scale=8;($css6/$css0)*100"|bc` cs7=`echo "scale=8;($css7/$css0)*100"|bc`... (3 Replies)
Discussion started by: thulasidharan2k
3 Replies

5. Shell Programming and Scripting

AWK Variable assignment issue Ksh script

Hi There, I am writing a ksh script which assigns variable values from file "A" and passes that variables to file "B". While passing the parameters an additional "$" sign is being assigned to awk -v option. Could any one help me with this please. #!/bin/ksh head -1... (3 Replies)
Discussion started by: Jeevanm
3 Replies

6. Shell Programming and Scripting

awk variable assignment-- inside braces or not?

So, in awk, I've always put my variable assignments inside of the curly braces, just like dad, and grandpa, and the 26 generations before them. But today I came upon an awk statement that had them outside the braces-- blasphemy! Seriously, though, is there any practical difference? I was... (3 Replies)
Discussion started by: treesloth
3 Replies

7. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

8. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies

9. Shell Programming and Scripting

[awk] printing value of a variable assignment from a file

Heyas Me try to print only the value of a (specific) variable assignment from a file. What i get (1): :) tui $ bin/tui-conf-get ~/.tui_rc TUI_THEME dot-blue "" "$TUI_DIR_INSTALL_ROOT/usr" "$TUI_DIR_INSTALL_ROOT/etc/tui" "$TUI_PREFIX/share/doc/tui" "$TUI_PREFIX/share/tui"... (2 Replies)
Discussion started by: sea
2 Replies

10. Shell Programming and Scripting

Optimize multiple awk variable assignment

how can i optimize the following: TOTALRESULT="total1=4 total2=9 total3=89 TMEMORY=1999" TOTAL1=$(echo "${TOTALRESULT}" | egrep "total1=" | awk -F"=" '{print $NF}') TOTAL2=$(echo "${TOTALRESULT}" | egrep "total2=" | awk -F"=" '{print $NF}') TOTAL3=$(echo... (4 Replies)
Discussion started by: SkySmart
4 Replies
FETCH(9)						   BSD Kernel Developer's Manual						  FETCH(9)

NAME
fetch, fubyte, fuswintr, fuword, fuword16, fuword32, fuword64, fueword, fueword32, fueword64 -- fetch data from user-space SYNOPSIS
#include <sys/types.h> #include <sys/systm.h> int fubyte(volatile const void *base); long fuword(volatile const void *base); int fuword16(volatile const void *base); int32_t fuword32(volatile const void *base); int64_t fuword64(volatile const void *base); long fueword(volatile const void *base, long *val); int32_t fueword32(volatile const void *base, int32_t *val); int64_t fueword64(volatile const void *base, int64_t *val); #include <sys/resourcevar.h> int fuswintr(void *base); DESCRIPTION
The fetch functions are designed to copy small amounts of data from user-space of the current process. If read is successful, it is per- formed atomically. The data read must be naturally aligned. The fetch routines provide the following functionality: fubyte() Fetches a byte of data from the user-space address base. The byte read is zero-extended into the results variable. fuword() Fetches a word of data (long) from the user-space address base. fuword16() Fetches 16 bits of data from the user-space address base. The half-word read is zero-extended into the results variable. fuword32() Fetches 32 bits of data from the user-space address base. fuword64() Fetches 64 bits of data from the user-space address base. fuswintr() Fetches a short word of data from the user-space address base. This function is safe to call during an interrupt context. fueword() Fetches a word of data (long) from the user-space address base and stores the result in the variable pointed by val. fueword32() Fetches 32 bits of data from the user-space address base and stores the result in the variable pointed by val. fueword64() Fetches 64 bits of data from the user-space address base and stores the result in the variable pointed by val. The callers of fuword(), fuword32() and fuword64() functions cannot distinguish between -1 read from userspace and function failure. RETURN VALUES
The fubyte(), fuword(), fuword16(), fuword32(), fuword64(), and fuswintr() functions return the data fetched or -1 on failure. The fueword(), fueword32() and fueword64() functions return 0 on success and -1 on failure. SEE ALSO
copy(9), store(9) BSD
October 29, 2014 BSD
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy