The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
How to grab the value of field before the line reached ahjiefreak Shell Programming and Scripting 3 03-28-2008 05:59 AM
Grab a smaller and larger value Raynon Shell Programming and Scripting 3 10-11-2007 06:23 AM
grab next consecutive line or lines wisher115 Shell Programming and Scripting 1 12-07-2006 08:01 AM
find 2 line numbers, grab text in between Da_Duck Shell Programming and Scripting 11 09-26-2006 12:51 PM
How to Grab the latest file n9ninchd UNIX for Dummies Questions & Answers 1 05-10-2001 04:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2007
cdfd123 cdfd123 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 112
grab the line using awk

suppose u have a file
AAAAAKKSKSKMSKMSKBNNSHNKSNJNMSYNMSBH
This is exactly wht the input is like
Question is i want to list wht is on the line 5 tht will be A
but Remember u want to extract in between say from 100 to 300
i tried using
awk 'BEGIN {FS=""} {print$100,$300}' file
but it will print only wht is the line on 100 and 300 so the question is how to grep or extract the line between 100 and 300??
thanks
  #2 (permalink)  
Old 10-10-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Er, when you say lines, does that mean that it is actually seperated by '\n'? Or is this all on one line? If it is all on one line, use this:
Code:
awk '{print substr($0,100,200)}' file
For seperate lines, use sed:
Code:
sed -n '100,300p' file
Closed Thread

Bookmarks

Tags
grep or

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 03:03 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