Sponsored Content
Top Forums Shell Programming and Scripting Pass awk field to a command line executed within awk Post 302863775 by balajesuri on Tuesday 15th of October 2013 05:55:09 AM
Old 10-15-2013
You could do this, without troubling awk:

Code:
[user@host ~]$ set 1381653229 something
[user@host ~]$ echo "$(date -d @$1 +"%m/%e/%y %H:%M")|$2"
10/13/13 14:03|something
[user@host ~]$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can I pass awk variable to system command?

I wanna use a system function to deal with several data. So I use awk variable FILENAME to transfer the file directory to system command, but it does not work. I use a shell function "out_function" to deal with data and save the result in another directory with the same file name. How can I... (2 Replies)
Discussion started by: zhynxn
2 Replies

2. Shell Programming and Scripting

how to pass variable in NR function used in awk command?

Hi I want to pass variables with the NR function in awk command. test_file1 is input file having 500 records. var1=100. var2=200 awk -F" " 'NR >= $var1 && NR <= $var2' test_file1 > test_file2. My end result should be that test_file2 should have records from line number between... (2 Replies)
Discussion started by: Nishithinfy
2 Replies

3. Shell Programming and Scripting

Pass command line arguments to awk

I am trying to pass max as a sommand line argument when I call awk. Made the modification in the BEGIN but it is not working I'm getting an error as below: awk: txsrx.awk:82: (FILENAME=jcd.tx FNR=4161) fatal: cannot open file `40' for reading (No such file or directory) Somehow it... (2 Replies)
Discussion started by: kristinu
2 Replies

4. Shell Programming and Scripting

How to pass a field from awk in a pipe?

Thanks in advance : ) I try for a long time searching for a way to split a large gzip csv file into many gzip files (except for the last sub-file which is to joint the next big file's children.) All the subfiles are to be named by the field. But I only managed to split them into the... (9 Replies)
Discussion started by: Kingsley
9 Replies

5. Shell Programming and Scripting

Pass Parameters to awk command

I need to pass values at runtime for the below awk command where l is the length and partial.txt is the file name. awk -v l=285 '{s="%-"l"s\n";printf(s,$0);}' partial.txt > temp1.txt; (5 Replies)
Discussion started by: Amrutha24
5 Replies

6. Shell Programming and Scripting

Cannot pass rsh and awk command into a variable

Hello, I'm having some issues getting a home dir from a remote server passed to a variable. Here is what I have so far: rsh server "(ls -ld /home*/user | awk '{print \$9}')" /home3/userThat works fine and brings back what I need. But when I try to add it to a variable it goes all... (3 Replies)
Discussion started by: elcounto
3 Replies

7. Shell Programming and Scripting

How to pass filename as arguement to awk command?

Hi, I am facing one issue. The awk command works fine if i hardcode the file name but if is pass it as an arguement it doesn't work. For e.g:Below commands works fine awk -v A="$type" '{F=substr($0,23,8) "_LTD_" A ".txt"; print $0 >> F; close(F) }' RL004.txt But the below command does not... (2 Replies)
Discussion started by: Neelkanth
2 Replies

8. Shell Programming and Scripting

How to pass command line arguments to awk program?

#!/bin/awk -f BEGIN { FS=":"; } { if ( $7 == "" ) { print $1 ": no password!"; } } I want to execute this program for a particular user to check for his password from the file /etc/passwd (as the input file) and the user details to be given... (1 Reply)
Discussion started by: sri.phani
1 Replies

9. Shell Programming and Scripting

awk command not getting executed in shell script

I am able to execute awk command from shell prompt. but the same command is not getting executed when written and run in a bash script the command from bash cmd prompt. awk '/world/{for (i=2; i<NF; i++) printf $i " "; print $NF}1' myfile >tmp$$ ; mv tmp$$ myfile file: # hello world my... (4 Replies)
Discussion started by: ashima jain
4 Replies

10. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
innetgr(1)							   NSS utilities							innetgr(1)

NAME
innetgr - Check netgroup membership SYNTAX
innetgr [-d domain] [-h host] [-u user] [-v] <netgroup> DESCRIPTION
innetgr checks if the specified user, host or domain is a member of the given netgroup. The program does not produce any output unless the verbose ( -v ) flag is given. The exit status is 0 if the user/host/doman combination is a member of the given netgroup. Exit status is 1 if the combination is not found in the group, and 2 if one of the arguments are invalid. OPTIONS
--domain <domain> | -d <domain> Search in the given domain. --host <host name> | -h <host name> Search for the given host name. --user <user name> | -u <user name> Search for the given user name. --verbose | -v Enable verbose mode --version | -V Show version information. EXAMPLES
To check if the current host is listed in the netgroup allhosts, use this command line: if innetgr -h `uname -n` allhosts ; then echo "Found"; fi CONFORMING TO
A innetgr program first appeared in NetBSD 1.4. AUTHORS
Petter Reinholdtsen <pere@hungry.com> SEE ALSO
getent(1) netgroup(1) innetgr(3) netgroup(5) nsswitch.conf(5) Petter Reinholdtsen 0.7 innetgr(1)
All times are GMT -4. The time now is 02:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy