The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. Shell Script Page.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Awking!! Printing decimal output is struck divzz Shell Programming and Scripting 4 05-28-2008 05:02 AM
how to make a line BLINKING in output and also how to increase font size in output mail2sant Shell Programming and Scripting 3 04-14-2008 04:30 AM
Printing to a Savin - Size of output wrong h1timmboy AIX 2 02-28-2006 05:19 AM
Printing output to the monitor jyotipg Shell Programming and Scripting 2 06-22-2004 02:41 AM
Printing Problems in unix ... ( Bar-cdoe - Ip Printing) QuickSilver UNIX for Advanced & Expert Users 3 06-04-2002 07:48 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-22-2007
Registered User
 

Join Date: Dec 2006
Location: CA,United States
Posts: 168
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
printing output more than 13

i want to print the idle time of the users more than 10 days.

for eg:
my "w" command output is like below.

-sh-3.00$ w
03:47:41 up 13 days, 16:59, 3 users, load average: 10.00, 10.00, 10.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root :0 - 08Jan07 ?xdm? 2days 0.18s /usr/bin/gnome-
root pts/1 :0.0 08Jan07 13days 0.00s 0.00s bash
krrishv pts/2 221-135-33-1.sif 02:55 1.00s 0.05s 0.00s w

i am printing $1 & $5 alone using awk. Now how do i loop it and check each line and if $5 is gt 13 than i want to echo it with the user name $1
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-22-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Code:
w | awk ' NR > 2 && $0 ~ "day" {sub("[^0-9]*$","",$5);if( $5 > 10 ) print $5 } '
Reply With Quote
  #3 (permalink)  
Old 01-22-2007
Registered User
 

Join Date: Dec 2006
Location: CA,United States
Posts: 168
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
thanks anbu
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
"inappropriate ioctl for device" 421 service not available, remote server has closed connection ^m autosys awk trim bash eval bash exec bash for loop boot: cannot open kernel/sparcv9/unix close_wait command copy/move folder in unix curses.h cut command in unix dead.letter find grep find null character in a unix file grep multiple lines grep or grep recursive grep unique inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime perl array length ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp batch sftp script snoop unix stale nfs file handle syn_sent tar exclude unix unix .profile unix com unix forum unix forums unix interview questions unix mtime unix simulator unix.com vi tab size vi+substitute+end+of+line+character while loop within while loop shell script


All times are GMT -7. The time now is 12:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101