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
4 GB delimited-textfile on ONE LINE magedfawzy Shell Programming and Scripting 5 05-13-2009 04:12 AM
Reading a file line by line and processing for each line sagarparadkar Shell Programming and Scripting 6 03-02-2009 11:59 AM
To substitute a string in a line to another string Niroj Shell Programming and Scripting 4 10-31-2008 04:23 AM
search for a string ,replace the whole line with new line kkraja Shell Programming and Scripting 4 08-07-2008 03:26 AM
How I Can get String From the Line habuzahra UNIX for Dummies Questions & Answers 2 10-29-2006 07:55 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-05-2009
izuma izuma is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 10
cut a string in a textfile line per line

i need to cut the string in a textfile but each line has a specific way of cutting it (different lengths)

i have a for loop that gets the string line per line, then each line has to be compared:


Code:
for x in `cat tmp2.txt`; do
       if[ "BAC" == _____  ]; then
               echo 'BAC'
       elif[ "sdf_ada" == _____]
         etcetc
       fi
done

sample tmp2.txt file that needs to be trim to specific length :
BAC0904102604 -> BAC
AFR0904102604 -> AFR
HHF0904102604 -> HHF
UI100904102907 ->UI10
sdf_ada_9541-9543.1 -> sdf_ada
_fsf13145533 ->fsf

note: the file is in random order.

Last edited by bakunin; 05-05-2009 at 07:07 AM.. Reason: added code-tags. Please do that yourself from now on. Thanks
 

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 09:28 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