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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
text manipulation injeti Shell Programming and Scripting 11 06-05-2008 10:42 AM
file manipulation tungaw2004 Shell Programming and Scripting 2 04-04-2008 10:26 PM
Text file manipulation Ezy UNIX for Dummies Questions & Answers 4 02-25-2008 01:15 PM
Text Manipulation. Icepick Shell Programming and Scripting 4 02-25-2008 04:18 AM
shell script : text manipulation (easy quesiton) champion Shell Programming and Scripting 3 07-01-2002 03:10 AM

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 Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 01-18-2006
svannala svannala is offline
Registered User
  
 

Join Date: Sep 2003
Location: Irving, TX
Posts: 3
Lightbulb Text file manipulation

Hi,
I need to remove lines from a text file that are less than certain length in UNIX. For example, test.txt file contains the following lines:

abcdefghijklmnopqrstuvwxyz.
123456789009876543211234567
This line to be removed.
zyxwvutsrqponmlkjihgfedcba.


The length of each line is supposed to be 27 characters. I need to remove 3rd line which is less than 27 characters.
Pls. help.

Thanks,
Suresh
  #2 (permalink)  
Old 01-18-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
awk ' { if ( length($0) >= 27 ) print $0; }' test.txt
  #3 (permalink)  
Old 01-18-2006
svannala svannala is offline
Registered User
  
 

Join Date: Sep 2003
Location: Irving, TX
Posts: 3
This worked perfect. Thanks a Lot.
  #4 (permalink)  
Old 01-20-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,416
Just another syntax for the awk command :

awk 'length >= 27' text.txt
  #5 (permalink)  
Old 01-20-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
Cool... gud one
  #6 (permalink)  
Old 01-20-2006
linuxpenguin's Avatar
linuxpenguin linuxpenguin is offline Forum Advisor  
Registered User
  
 

Join Date: May 2002
Location: India
Posts: 295
grep ".\{27\}" test.txt

huh!!! I had used this long long ago, when I didnt know awk. Took a long research to get to this
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 07:35 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