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
Convert a tab delimited/variable length file to fixed length file Everton_Silveir UNIX for Dummies Questions & Answers 2 12-19-2008 06:21 PM
separate a line having particular field Satyak Shell Programming and Scripting 2 10-13-2008 07:20 AM
how to show it on separate line userking UNIX for Dummies Questions & Answers 2 07-23-2008 01:01 AM
Fixing line length in a file dbessell UNIX for Advanced & Expert Users 2 08-04-2003 06:40 PM
Listing words from a file on a Separate Line Astudent UNIX for Dummies Questions & Answers 2 03-14-2001 06:44 PM

Reply
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 05-27-2009
venven venven is offline
Registered User
  
 

Join Date: May 2009
Posts: 4
separate file by line length

hi all,

i'm new in unix....

i have question, sorry if it's missplace or too silly

let say i have a file name testfile.log that contains data

000001
000002
000003
aaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbb
cccccccccccccc
dddddddddddddddddd
000004

i want to make new file (newfile.log) that only consist

aaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbb
cccccccccccccc
dddddddddddddddddd

ps: what i want is, i split by line length which is > 6

regards,

steven
  #2 (permalink)  
Old 05-27-2009
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 517
Quote:
Originally Posted by venven View Post
...
i want to make new file (newfile.log) that only consist

aaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbb
cccccccccccccc
dddddddddddddddddd

ps: what i want is, i split by line length which is > 6

...
Something like this:

Code:
$
$ # display contents of testfile.log
$ cat testfile.log
000001
000002
000003
aaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbb
cccccccccccccc
dddddddddddddddddd
000004
$
$ # pick up only those lines that are more than 6 chars long
$ awk 'length > 6' testfile.log
aaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbb
cccccccccccccc
dddddddddddddddddd
$
$ # pick up only those lines that are more than 6 chars long AND put them in a new file
$ awk 'length > 6' testfile.log > newfile.log
$
$ # verify that the new file has the stuff you want
$ cat newfile.log
aaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbb
cccccccccccccc
dddddddddddddddddd
$
$
tyler_durden
  #3 (permalink)  
Old 05-27-2009
venven venven is offline
Registered User
  
 

Join Date: May 2009
Posts: 4
thx

thx help alot

-----Post Update-----

another question

i want to make new file that dont consist particular string for example "bbbb"

i have

aaaaaaa
vbbbbq
abbbbx
cccccc
ddddd


i want to make new file that consist
aaaaaaa
cccccc
ddddd



thx before
  #4 (permalink)  
Old 05-27-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
you questions are very simple to do. what have you got ? someone has already shown you how to use awk. Look up the awk documentation and see how you can do the second task.
Reply

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