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.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to read the data from an excel sheet and use those data as variable in the unix c Anne Grace UNIX for Advanced & Expert Users 1 03-03-2008 03:21 AM
how to verify that copied data to remote system is identical with local data. ynilesh Shell Programming and Scripting 3 01-31-2008 04:55 AM
Howto capture data from rs232port andpull data into oracle database-9i automatically boss UNIX for Dummies Questions & Answers 1 09-22-2007 11:35 PM
Using loop reading a file,retrieving data from data base. Sonu4lov Shell Programming and Scripting 1 01-18-2007 11:38 PM
How to change Raw data to Coloumn data fields Nayanajith Shell Programming and Scripting 1 08-28-2006 10:23 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-02-2006
Registered User
 

Join Date: Oct 2001
Posts: 6
Extrating Data

I'm new to unix scripting

I have a file with thousands of rows, each row starts with a transaction code such as H1012, H1013, T7890, M678N. Each Transaction code is always 5 letter long. I need to extract all the rows starting from U1012 and write the output to another file.

How do I do that?

Thanks in Advance
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-02-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,643
Quote:
Originally Posted by irehman
I'm new to unix scripting

I have a file with thousands of rows, each row starts with a transaction code such as H1012, H1013, T7890, M678N. Each Transaction code is always 5 letter long. I need to extract all the rows starting from U1012 and write the output to another file.

How do I do that?

Thanks in Advance
Two interpretations for the above questions.

Extract all rows starting from txn code U1012 till end of file.

Code:
sed -n -e '/^U1012/,$p' input.txt > output.txt
Or, get all txn rows like U1012, U1013 et al. i.e. all U txn rows.

Code:
sed -n -e '/^U.*/p' input.txt > output.txt
Reply With Quote
  #3 (permalink)  
Old 03-02-2006
Registered User
 

Join Date: Dec 2005
Location: India
Posts: 218
or if you are looking for all the rows with transaction code U1012, which is very unlikely to be the case
Quote:
grep '^U1012' input.txt > output.txt
Gaurav
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:18 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