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
Using $0 and 'Function' Keyword novice1324 UNIX for Dummies Questions & Answers 3 08-26-2008 05:52 PM
display (ehco) 5 lines before and after find keyword wangzosen Shell Programming and Scripting 5 08-17-2008 10:58 PM
keyword searching of documents Miles OS X (Apple) 1 02-25-2008 06:38 PM
Far Keyword svh High Level Programming 2 02-08-2006 12:16 AM
Keyword in perl sarwan Shell Programming and Scripting 1 01-17-2006 04:35 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 03-18-2009
Trump Trump is offline
Registered User
  
 

Join Date: Mar 2009
Location: Russia
Posts: 23
Cut lines before keyword

Hi,
How to cut all lines in file before keyword?

from
1 2333214 word ...... some text
2 234343 234234 word ...... some text
3 234324 324 3234 word ...... some text

to
1 2333214
2 234343 234234
3 234324 324 3234
  #2 (permalink)  
Old 03-18-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
echo '3 234324 324 3234 word ...... some text' | sed 's#word.*##'

  #3 (permalink)  
Old 03-18-2009
Trump Trump is offline
Registered User
  
 

Join Date: Mar 2009
Location: Russia
Posts: 23
thnx
  #4 (permalink)  
Old 03-18-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092

Code:
echo "1 2333214 word ...... some text" | sed 's/word.*$//'

  #5 (permalink)  
Old 03-18-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,556

Code:
# while read line;do echo ${line%%word*};done < file
1 2333214
2 234343 234234
3 234324 324 3234

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