Sponsored Content
Top Forums Shell Programming and Scripting Pass awk field to a command line executed within awk Post 302863785 by ctsgnb on Tuesday 15th of October 2013 06:11:12 AM
Old 10-15-2013
Code:
$echo "1381653229 something" | while read a b;do echo $(date -d@$a +'%D %T')"|$b" ;done
10/13/13 10:33:49|something
$

 

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
DATETIME.SETTIMESTAMP(3)						 1						  DATETIME.SETTIMESTAMP(3)

DateTime::setTimestamp - Sets the date and time based on an Unix timestamp

       Object oriented style

SYNOPSIS
public DateTime DateTime::setTimestamp (int $unixtimestamp) DESCRIPTION
Procedural style DateTime date_timestamp_set (DateTime $object, int $unixtimestamp) Sets the date and time based on an Unix timestamp. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $unixtimestamp - Unix timestamp representing the date. RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure. EXAMPLES
Example #1 DateTime.setTimestamp(3) example Object oriented style <?php $date = new DateTime(); echo $date->format('U = Y-m-d H:i:s') . " "; $date->setTimestamp(1171502725); echo $date->format('U = Y-m-d H:i:s') . " "; ?> Procedural style <?php $date = date_create(); echo date_format($date, 'U = Y-m-d H:i:s') . " "; date_timestamp_set($date, 1171502725); echo date_format($date, 'U = Y-m-d H:i:s') . " "; ?> The above examples will output something similar to: 1272508903 = 2010-04-28 22:41:43 1171502725 = 2007-02-14 20:25:25 NOTES
Using the Unix timestamp format to construct a new DateTime object is an alternative when using PHP 5.2, as shown in the example below. Example #2 DateTime.setTimestamp(3) alternative in PHP 5.2 <?php $ts = 1171502725; $date = new DateTime("@$ts"); echo $date->format('U = Y-m-d H:i:s') . " "; ?> The above example will output something similar to: 1171502725 = 2007-02-14 20:25:25 SEE ALSO
DateTime.getTimestamp(3). PHP Documentation Group DATETIME.SETTIMESTAMP(3)
All times are GMT -4. The time now is 08:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy