UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 4th, 2004, 01:12 PM
bkpatterson bkpatterson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 bkpatterson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question SED Help

I am using an egrep to output all successful entries of a batch script I am running. The batch file runs, and if successful, it codes an entry in the file that begins with the identifier for that batch.

Ex: Batch for location id 20 = if batch is successful, I get

20xxxxxxxxxxxxxxx.out = file.

This part is hard-coded from an application, I can't change the filename.

What I am doing is using egrep to search the contents of all these files, looking for the successful batches... the output is:

Successful Batches $date
-------------------------
/path/20xxxxxxxxxxxx.out
/path/21xxxxxxxxxxxx.out
/path/22xxxxxxxxxxxx.out
/path/23xxxxxxxxxxxx.out

I already have:

sed 's/\/path\//Location /g' to get rid of the path, but now I need to get rid of the xxxxxxxxxxxxxx.out portion, which always begins with the 9th character of the line (I can't truncate all lines due to the headers, etc.)

End all goal is

Successful Batches $date
-------------------------
Location 20
Location 21
Location 22
Location 23


All help appreciated, apologize if the explanation is confusing.

Reply With Quote
  #2  
Old August 4th, 2004, 05:43 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 49 m 57 sec
Reputation Power: 9
yes, confusing
assumed, you are looking for digits after '/path/' try

sed -ne 's/\/path\/\([0-9]*[0-9]\).*/location \1/p'

post the batch, i am sure you do not NEED grep

Reply With Quote
  #3  
Old August 5th, 2004, 08:03 AM
bkpatterson bkpatterson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 bkpatterson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by guggach
yes, confusing
assumed, you are looking for digits after '/path/' try

sed -ne 's/\/path\/\([0-9]*[0-9]\).*/location \1/p'

post the batch, i am sure you do not NEED grep


Apologize for the confusion... perhaps let's forget all about the egrep, and look at only the output I'm trying to get.

Your statement does do me some good (although I'm having trouble interpreting it step by step). It does replace the path, which I have been able to do thus far - and in addition, it removes the .out file extension from the list. The only thing left I need to get rid of is the xxxxxxxxxx string that is the filename after the first 2 characters which identify the location.

Thus, my output would be "Location 20" where 20 WAS the first two characters of the filename.

I'm sure there is an easier way to go about this, but my lack of experience and the sensitivity of the data in the batch file prevent me from disclosing much more.

Appreciate your help!

Reply With Quote
  #4  
Old August 5th, 2004, 08:50 AM
bkpatterson bkpatterson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 bkpatterson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
EDITfor Stupidity, leaving so someone else can learn at my expense: Remove the -ne!

Follow-up... A slight modification to your line, and it is giving me the output I want:

sed -ne 's/\/credit_auth\/\([0-9][0-9]\).*/Location \1/p'

Output is:

Location 20

without the remaining filename or the .out extension.

Now all I need to do is make it only process on lines which actually HAVE that path, because right now it is deleting my header.

Many thanks!

Reply With Quote
  #5  
Old August 5th, 2004, 11:02 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 49 m 57 sec
Reputation Power: 9
bkpatterson

grep is a wonderfull tool
sed is (a lot of times) better
a little read of manuals && experience && you see it

Reply With Quote
  #6  
Old August 5th, 2004, 02:15 PM
bkpatterson bkpatterson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 bkpatterson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
guggach - Thanks again for your assistance, it has been most helpful. I have obtained an older copy of a book: "Unix Text Processing" - I am well on my way.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > SED Help


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway