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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sequence number generation on a key column sbasetty Shell Programming and Scripting 6 03-27-2008 12:09 PM
column number, awk, help jkl_jkl Shell Programming and Scripting 2 03-15-2008 10:16 PM
Identifying the column number pondlife Shell Programming and Scripting 2 09-28-2007 11:43 AM
awk to select a column from particular line number mab_arif16 Shell Programming and Scripting 4 05-08-2006 06:26 AM
printf returning unknown number m0nk3y Shell Programming and Scripting 1 08-08-2005 12:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-06-2007
scriptingmani scriptingmani is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 17
returning a column number

Hi all,

i was doing a small program where if i was to be given the first 3 letters of any month i.e. in the form of Jan or Apr then it would return the column number where it finds a match. To do this i created a 12 element array of months with first 3 letters and if i echo'ed the contents of the array, piped it into another command that would return me a column number where it matched. i thought awk could do this by replacing 'print' with 'find' but it doesn't work although it doesn't give an error message. Is there a command already out there that does this?

thanks

Mani
  #2 (permalink)  
Old 07-06-2007
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
Mani,

Can you post your problem ?

that would help us to give currect solution.
  #3 (permalink)  
Old 07-06-2007
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092
Hi,maybe this can help you

I suppose you want to scan a file, and then find the file's line which contain Abbrevision for MONTH, and then print the line's line number.

Follow maybe can help u, just for you reference:

The file content(a.txt):

Code:
this is Mar
now come a Feb
then another Mar
he a Jun comes

The script:


Code:
read mon
echo "The line number which contain ${mon} is as follow:"
sed "/$mon/=" a.txt

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0