Sponsored Content
Full Discussion: Help with awk cmd
Top Forums Shell Programming and Scripting Help with awk cmd Post 302136034 by New2Scripting on Friday 14th of September 2007 08:02:14 AM
Old 09-14-2007
Help with awk cmd

Hi All,

I am trying to read a file as input and pull out some information from the file and put it into another file in column format and then take that file and make it an excel file. My problem is that I'm trying to put the date in one of the columns using a variable in an awk cmd, but when I do this I get some decimal number not the date. Can anyone help here is my code:

#!/bin/sh -x
# Script to pull out the tape number and expiration date from the Vault report file.

##########################################
FILEDIR=/usr/openv/netbackup/vault/reports

MONTH=`date +%b`
CURYEAR=`date +%Y`
NEXTYEAR=`expr $CURYEAR + 1`
TENYEAR=`expr $CURYEAR + 10`
IDATE=`date +%m/%d/%Y`

#This will find the latest summary file.#
FILE1=`ls -ltr $FILEDIR/summary_distlist_vault_??????????.rpt| awk '{ print $9 }' | sed -n '$p'`
OFFSITE=/tmp/offsite_tapes.xls
################################################################################################
# Remove the last offsite files before creating a new one.#
if [ -s $OFFSITE ];then
rm $OFFSITE
fi

cd $FILEDIR

# This should pars the latest file and pull out "MEDIA ID" and "EXPIRATION" and create the "$OFFSITE" file.#
cat $FILE1 | grep -Ev "$MONTH|full" | egrep "$CURYEAR|$NEXTYEAR|$TENYEAR" | awk '{ print "\t""\t"$2"\t""\t"$IDATE"\t"$3 }' > $OFFSITE
chmod 777 $OFFSITE

#Email the Excel file#
uuencode $OFFSITE offsite_tapes.xls | mailx -s "Offsite Tape Spreadsheet" email@something.com
##################################################

The red part is what's giving me the trouble. $IDATE is suppose to be the system date and I get a decimal number in the excel file. Thanks in advance for any help you can give me.Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

man <cmd> >> cmd.txt

I've noticed most of my postings here are because of syntax errors. So I want to begin compiling a large txt file that contains all the "man <cmd>" of the commands I most have problems with. I ran a "man nawk >> nawk.txt" but it included a header/footer on each "page". Anyone know how I'd be... (6 Replies)
Discussion started by: yongho
6 Replies

2. HP-UX

awk to output cmd result

I was wondering if it was possible to tell awk to print the output of a command in the print. .... | awk '{print $0}' I would like it to print the date right before $0, so something like (this doesn't work though) .... | awk '{print date $0}' (4 Replies)
Discussion started by: IMTheNachoMan
4 Replies

3. Shell Programming and Scripting

Combining many lines to one using awk or any unix cmd

Combining many lines to one using awk or any unix cmd Inputfile: Output : Appreciate help on this. (14 Replies)
Discussion started by: pinnacle
14 Replies

4. Shell Programming and Scripting

Capturing awk's system(cmd) output

Hi everybody, I am working on a bigger awk script in which one part is comparing the size of two files. I want to evaluate which file is bigger and then just save the bigger one. I got it all working except for the part where I want to figure out which file is bigger; the one awk is currently... (2 Replies)
Discussion started by: iMeal
2 Replies

5. Shell Programming and Scripting

Unix cmd prompt how to get old cmd run?

Hi, I am using SunOS I want to serch my previous command from unix prompt (like on AIX we can search by ESC -k) how to get in SunOs urgent help require. (10 Replies)
Discussion started by: RahulJoshi
10 Replies

6. Shell Programming and Scripting

Perl open(CMD, "cmd |"); buffering problem..

Hello, There's a third-party application's command that shows the application's status like "tail -f verybusy.log". When use the command, the output comes every 1-sec. but when it goes in a script below the output comes every 8-sec...What is the problem and how can I fix it? open(CMD,... (2 Replies)
Discussion started by: Shawn, Lee
2 Replies

7. Shell Programming and Scripting

Awk: cmd. line:1: fatal: division by zero attempted

when i try the snippet in the console its working fine: ps awwwux | grep php-fpm | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' output: but when i try the bash script: #!/bin/sh # -*- sh -*- #... (3 Replies)
Discussion started by: danieloooo
3 Replies

8. Shell Programming and Scripting

Invoking system(cmd) inside awk command

Hi, I was searching for a way to grep 2 lines before and after a certain keyword, and I came across the following code.. awk "\$0 ~ /ORA-/ { cmd=\"awk 'NR>=\" NR-2 \" && NR<=\" NR+2 \"' init.ora\" system(cmd) }" input_file I could not understand how this works. What is system() ? what... (2 Replies)
Discussion started by: Kulasekar
2 Replies

9. Shell Programming and Scripting

Get the awk cmd for two condition

Hi All, i have following cmd to get a “n/a” value from one particular column, but if i need to take one column n/a value with based on other column this cmd will help? ex: col1 col2 col3 234 RR Yes n/a RR1 No 236 RR2 No 237 RR3 Yes 238 RR4 No n/a ... (1 Reply)
Discussion started by: Shenbaga.d
1 Replies

10. Shell Programming and Scripting

awk cmd for vlookup in Mysql

Hi, Is there possible to do vlookup in Mysql one table from another table based on one column values and placed the data in same table? if it is possible in mysql itself pls share links for reference. Here is the ex: i need to vlookup the cus.id in table to and place the cus.name in 4th... (3 Replies)
Discussion started by: Shenbaga.d
3 Replies
CONJUNCT(1)						      General Commands Manual						       CONJUNCT(1)

NAME
conjunct - find dates of equinox or new or full moon SYNOPSIS
conjunct [options] DESCRIPTION
conjunct searches for one of these events: spring equinox (default), summer solstice, autumn equinox, winter solstice, new moon, or full moon. OPTIONS
-s, --start date Set starting date (default is current date). The date may be either a Julian day number (e.g. 2454180.0 for noon, 2007 March 20) or an ISO 8601 date (e.g. 2007-03-20). -e, --end date Set ending date (default is one year from now). -V, --vernal, --spring Search for spring equinox (default). -S, --summer Search for summer solstice. -A, --autumn, --fall Search for autumn equinox. -W, --winter Search for winter solstice. -N, --newmoon Search for new moon. -F, --fullmoon Search for full moon. -h, --help Show summary of options. SEE ALSO
aa(1). AUTHOR
conjunct was written by Stephen L. Moshier <steve@moshier.net>. This manual page was written by James R. Van Zandt <jrv@debian.org>, for the Debian project (but may be used by others). August 24, 2006 CONJUNCT(1)
All times are GMT -4. The time now is 08:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy