Sponsored Content
Top Forums Shell Programming and Scripting trying to cope with awk difficulties Post 302193412 by amatuer_lee_3 on Friday 9th of May 2008 08:05:07 AM
Old 05-09-2008
trying to cope with awk difficulties

Quote:
echo "Enter month: "

read MONTH

awk '$3=="$MONTH" {print $1, $2, $3, $4, $5, $6}' *.hits

The data we are searching is populated in this way:

----IP---------DAY----MONTH----DATE--------TIME---------YEAR
12.3234.34-----Fri------Nov-------15-------18:05:14 GMT---2008

I want the user to be able to search for the data according to month and year.
However, I cannot quite figure out how to do this. Above is the code i have and i can't understand what is wrong?

If we try and put in the variable e.g Nov, it wont give us any results.

It works only if instead of "$MONTH" we enter the month itself e.g Nov or Sep.

Last edited by amatuer_lee_3; 05-09-2008 at 09:11 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

Simple Network Program Difficulties

I'm trying to write 2 programs, client & server, that communicate with integers, however, all resources I have found on the net assume that you want to send and recieve information as a character array. I don't want to send my integers as characters, I want to send them as ints (casting them to... (2 Replies)
Discussion started by: Mistwolf
2 Replies

2. IP Networking

Proxy ARP Difficulties

edited ... (7 Replies)
Discussion started by: TheMaskedMan
7 Replies

3. UNIX for Dummies Questions & Answers

Sorting Difficulties

Hey guys, I am sort of new to unix and I am having difficulty sorting. What I am trying to do is sort a particular field in reversed order and another field in alphabetic order to create a new file that looks like this: MILLER,EDWARD AL 14 101293 9341 MOORE,HENRY 15 ... (6 Replies)
Discussion started by: nthamma
6 Replies

4. Shell Programming and Scripting

cope exist file prioritie

Hello I want to make new file which have the same priorities of specified exist file, by super user, and the file is no contents. To explain it with example: exist file: ls -l old.sql -rw-r--r-- 1 oracle oinstall 33 Feb 24 16:09 old.sql if I copy and clean it. cp -p old.sql new.sql... (0 Replies)
Discussion started by: qyxiell
0 Replies

5. Filesystems, Disks and Memory

iSCSI client setup difficulties

I am trying to set up iscsi linux clients and am having some problems. iscsid is running, I can do discovery fine, but adding the iscsi lun I get the following error: iscsiadm -m node -T iqn.xxxxxxxxxxxxxx -p y.y.y.y:3260 -l Logging in to iscsid: session already running. iscsiadm: Could not... (0 Replies)
Discussion started by: humbletech99
0 Replies

6. Red Hat

Difficulties with pam_tally2! :-(

Dear All I have having some trouble with pam_tally2 on RHEL 6.0 which I am getting quite frustrated with and I am sure it is a simple problem. I have the following lines in system-auth and password-auth: - auth required pam_tally2.so onerr=fail file=/var/log/faillog... (1 Reply)
Discussion started by: gz3xzf
1 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. UNIX for Dummies Questions & Answers

Facing difficulties to untar a tra.gz file

Hi , I trying to cp a files to one location and trying to untar there,the tar.gz files get copied to the specified location but wont untar. Here is what i did if cp /path/of/the/file.tar.gz /path/to/the/file/file.tar.gz then tar -zxvf /path/to/the/file/file.tar.gz echo "FILE... (2 Replies)
Discussion started by: vikatakavi
2 Replies

10. Shell Programming and Scripting

Difficulties in matching left bracket as literal in awk

I need to work with records having #AX in the EXP1 , please see my data sample and my attempt below: $ cat xx 08:30:33 KEY1 (1255) EXP1 VAL:20AX0030006 08:30:33 KEY1 (1255) EXP1 VAL:20AX0030006 08:30:33 KEY1 (1255) EXP1 VAL:20AW0030006 08:30:33 KEY1 (1255) EXP1 VAL:20AW0030006 $ gawk '{... (1 Reply)
Discussion started by: migurus
1 Replies
Widgets::Calendar(3pm)					User Contributed Perl Documentation				    Widgets::Calendar(3pm)

NAME
Curses::Widgets::Calendar - Calendar Widgets MODULE VERSION
$Id: Calendar.pm,v 1.103 2002/11/03 23:33:05 corliss Exp corliss $ SYNOPSIS
use Curses::Widgets::Calendar; $cal = Curses::Widgets::Calendar->({ CAPTION => 'Appointments', CAPTIONCOL => 'yellow', INPUTFUNC => &scankey, FOREGROUND => undef, BACKGROUND => 'black', BORDER => 1, BORDERCOL => 'red', FOCUSSWITCH => " ", X => 1, Y => 1, HIGHLIGHT => [12, 17, 25], HIGHLIGHTCOL=> 'green', MONTH => '11/2001', ONYEAR => &yearly, ONMONTH => &monthly, ONDAY => &daily, }); $cal->draw($mwh, 1); See the Curses::Widgets pod for other methods. REQUIREMENTS
Curses Curses::Widgets DESCRIPTION
Curses::Widgets::Calendar provides simplified OO access to Curses-based calendars. Each object maintains it's own state information. METHODS
new (inherited from Curses::Widgets) $cal = Curses::Widgets::Calendar->({ CAPTION => 'Appointments', CAPTIONCOL => 'yellow', INPUTFUNC => &scankey, FOREGROUND => undef, BACKGROUND => 'black', BORDER => 1, BORDERCOL => 'red', FOCUSSWITCH => " ", X => 1, Y => 1, HIGHLIGHT => [12, 17, 25], HIGHLIGHTCOL=> 'green', MONTH => '11/2001', ONYEAR => &yearly, ONMONTH => &monthly, ONDAY => &daily, }); The new method instantiates a new Calendar object. The only mandatory key/value pairs in the configuration hash are X and Y. All others have the following defaults: Key Default Description ============================================================ CAPTION undef Caption superimposed on border CAPTIONCOL undef Foreground colour for caption text INPUTFUNC &scankey Function to use to scan for keystrokes FOREGROUND undef Default foreground colour BACKGROUND undef Default background colour BORDER 1 Display a border around the field BORDERCOL undef Foreground colour for border FOCUSSWITCH " " Characters which signify end of input HIGHLIGHT [] Days to highlight HIGHLIGHTCOL undef Default highlighted data colour HEADERCOL undef Default calendar header colour MONTH (current) Month to display VALUE 1 Day of the month where the cursor is ONYEAR undef Callback function triggered by year ONMONTH undef Callback function triggered by month ONDAY undef Callback function triggered by day Each of the ON* callback functions expect a subroutine reference that excepts one argument: a handle to the calendar object itself. If more than one trigger is called, it will be called in the order of day, month, and then year. draw $cal->draw($mwh, 1); The draw method renders the calendar in its current state. This requires a valid handle to a curses window in which it will render itself. The optional second argument, if true, will cause the calendar's selected day to be rendered in standout mode (inverse video). HISTORY
1999/12/29 -- Original calendar widget in functional model 2001/07/05 -- First incarnation in OO architecture AUTHOR
/COPYRIGHT (c) 2001 Arthur Corliss (corliss@digitalmages.com) perl v5.8.8 2006-09-14 Widgets::Calendar(3pm)
All times are GMT -4. The time now is 09:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy