The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Trying to remove '^M' characters from a file. Krispy Shell Programming and Scripting 13 05-12-2009 06:46 PM
sed remove last 10 characters of a line start from 3rd line minifish Shell Programming and Scripting 7 03-26-2008 04:42 PM
How to remove Characters before '~' Amey Joshi UNIX for Dummies Questions & Answers 4 01-07-2008 06:43 AM
Find lines greater than 80 characters in a file mrgubbala Shell Programming and Scripting 8 03-11-2007 12:51 AM
Remove control characters aravind_mg UNIX for Dummies Questions & Answers 5 10-02-2002 02:07 PM

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 06-14-2005
naren_14 naren_14 is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 4
how to remove line greater then 3000 characters.

I am using awk and it stops when it encounter line greater then 3000 character. Is there any command which will help me remove line greater then 3000 characters.
  #2 (permalink)  
Old 06-15-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
You can write those lines which are less than or equal to 3000 characters.


Code:
awk ' length($0) <= 3000 ' inputfile

Vino
  #3 (permalink)  
Old 06-15-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Here is a sed solution for the same


Code:
sed '/^.\{3000\}/d' inputfile

Vino
  #4 (permalink)  
Old 06-15-2005
naren_14 naren_14 is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 4
still getting error.

Here is what i am trying to do.

awk ' length($0) < 3000 ' access.050531.log |wc -l
awk: record `64.43.232.10 - - [31...' too long
record number 58134
58134

Still it gets to that line and stops parsing log file.

Thanks,
Naren
  #5 (permalink)  
Old 06-15-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
if you're on Solaris, try using either /usr/bin/nawk OR /usr/xpg4/bin/awk
  #6 (permalink)  
Old 06-15-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
Quote:
Originally Posted by naren_14
Here is what i am trying to do.

awk ' length($0) < 3000 ' access.050531.log |wc -l
awk: record `64.43.232.10 - - [31...' too long
record number 58134
58134

Still it gets to that line and stops parsing log file.

Thanks,
Naren
for awk to be able to count and know that there are less than 3000 characters in the line --- it has to count the characters in the line ... problem is that awk will not stop counting at below 3000 characters if the line actually has more than that ...

maybe you don't want awk in this case ... perl or c might be better ...
  #7 (permalink)  
Old 06-15-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Quote:
Originally Posted by Just Ice

maybe you don't want awk in this case ... perl or c might be better ...

How the about the sed solution ? Will that fail ?


Code:
sed '/^.\{3000\}/d' inputfile

naren_14, could you try that ?


Vino
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 10:48 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