awk - append date to output of a command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk - append date to output of a command
# 1  
Old 01-18-2013
awk - append date to output of a command

Hi all;

I am running a script:
Code:
/var/tmp/gcsw -ne | grep "State:2" | wc

that gives me output like:
Code:
80 480 6529

but i need this output as:
Code:
2013-01-18 13:00 -> 80 480 6529

# 2  
Old 01-18-2013
You mean prepend Smilie
Code:
printf '%s -> %s\n' "$(date '+%Y-%m-%d %H:%M')" "$(/var/tmp/gcsw -ne | fgrep 'State:2' | wc)"

This User Gave Thanks to radoulov For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python script to run multiple command and append data in output csv file

Experts, I am writing a script and able to write only small piece of code and not able to collect logic to complete this task. In input file have to look for name like like this (BGL_HSR_901_1AG_A_CR9KTR10) before sh iss neors. Record this (BGL_HSR_901_1AG_A_CR9KTR10) in csv file Now have to... (0 Replies)
Discussion started by: as7951
0 Replies

2. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies

3. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

4. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

5. Shell Programming and Scripting

How to append a value to the output after using sed command?

Hi All, I have a file where I am converting newlines to comma separated values but I would like to append zero if the output is empty Here is the command I am using sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}' test1.txt test1.txt will have comma seperated values but sometimes this file can be... (6 Replies)
Discussion started by: rajeevm
6 Replies

6. Shell Programming and Scripting

Help with tar --append command output redirection

I am using tar command to append daily database backups on tape. "tar --append " command help me to do this. But tar --append command does not produce any output on stdout if it succeed. I want the output for that appended command to a log file. This log file should contain only the name of the... (0 Replies)
Discussion started by: pganguly46
0 Replies

7. Shell Programming and Scripting

Date command output conversion

hi all, i need to measure time difference between the time a process started, to the time it ended. i am assuming the following are the steps: 1. output 'date' command at start time 2. output 'date' command at end time 3. subtract the two question is, how do i subtract the two time... (4 Replies)
Discussion started by: rathajs
4 Replies

8. UNIX for Advanced & Expert Users

Date Conversion on output string from awk

Hi, I would like to convert the output from awk function to date and print on the screen. Example : echo "Start Date: May 24 2010" | gawk -F": " '{print $2}' Output : May 04 2010 I want this to be converted to 2010/05/24 Can i use date function here and how? Thanks, Deepika (2 Replies)
Discussion started by: deepikad
2 Replies

9. Shell Programming and Scripting

Help changing date output with AWK

Hello all, I have an issue where I'm trying to change a date in a csv text file. The file contains lines that have several fields. For example "John", "Smith","some_address","some_city","555-555-5555","11/11/1972" "Joan","User","some_address","some_city","444-444-4444","12/02/1963" The date... (6 Replies)
Discussion started by: commobox
6 Replies

10. Shell Programming and Scripting

Getting a specific date from cal output with AWK

Hi guys! I'll make this short... Is there any good way to get the day number that first matches the Monday column from the cal command output with awk (or any other text manipulator commands) ? I'm sorry if my question wasn't clear at all. For example... One cal output would be $... (6 Replies)
Discussion started by: Casey
6 Replies
Login or Register to Ask a Question