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
Passing the values to the secondary script when it invoked by primary script venu_eie UNIX for Advanced & Expert Users 2 07-03-2008 08:10 AM
Passing the values to the secondary script when it invoked by primary script venu_eie Shell Programming and Scripting 1 07-03-2008 07:16 AM
create a shell script that calls another script and and an awk script magikminox Shell Programming and Scripting 0 06-26-2008 03:50 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 04:06 AM

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 10-06-2008
karansachdeva karansachdeva is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 39
Looking for a Script

Hi All,

I have a small requirement in which i need to search for specific folders and bring out the file names in those folder and also the line 1 characters 49 to 17.

It is possible to do this in UNIX. I am a beginner.

Any help would be highly appreciated.

Thanks

Karan
  #2 (permalink)  
Old 10-06-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
Giving some examples here would help everyone...
  #3 (permalink)  
Old 10-06-2008
karansachdeva karansachdeva is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 39
For example

I have a folder "archive" in it i have a folder 0808 and 0809.

Then I have a folder arc_transferred in both of them.

Then multiple folders are there in arc_transferred.

I am looking to search in these folders ...find out the file names and print the first line which is starting with XRI01 the characters 49 to 17.

Hope this information helps.

Thanks

Karan
  #4 (permalink)  
Old 10-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
What do you mean by "49 to 17"? The characters 17 to 49 in reverse order? Or the 17 characters starting at position 49?
  #5 (permalink)  
Old 10-06-2008
karansachdeva karansachdeva is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 39
17 characters starting at position 49.
  #6 (permalink)  
Old 10-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652

Code:
for file in archive/080[89]/arc_transferred/*; do
    egrep '^.{48,61}XRI01' | head -1
done

You could do the same with a sed script, and avoid the for loop, but this is probably easier to extend and adapt if it doesn't work exactly the way you like. (Check if the egrep offsets are correct; your idea of "first" and "17 positions" might differ from mine.)
  #7 (permalink)  
Old 10-06-2008
karansachdeva karansachdeva is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 39
it didnt give me any output...can i redirect the output to a file??? on the Unix box
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 05:02 AM.


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