LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-12-2013, 12:45 AM   #16
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444

Quote:
Originally Posted by David the H. View Post
@Firerat, Nicely done. Just a couple of quick suggestions. "print" on its own is the same as "print $0",
Ahh yes, an old habit of mine always using $0
I think it is because I'm usually including some extra strings to the output.
Quote:
Originally Posted by David the H. View Post
and an "else" would probably be a better choice to connect the two commands, rather than "next".
Very true, I think it is the first time I have ever used next in an awk, not that I have really done that many.
Quote:
Originally Posted by David the H. View Post
I believe you could also reduce it down to just this (untested, 'cause I'm lazy):

Code:
awk '$1 == "SRIG_NAME:" { FileName = $NF } { print >> FileName".txt" }' DataDictionary.txt
It works fine.. with one slight downside.
As it appends the output, without proper housekeeping multiple runs will result in duplicate data.
Which is no show stopper really.

Last edited by Firerat; 06-12-2013 at 12:46 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] awk split file into variable number of files captainentropy Linux - Newbie 12 07-10-2012 10:54 PM
[SOLVED] Replace 2nd occurrence of a string in a file - sed or awk? kushalkoolwal Programming 10 05-02-2011 03:30 PM
How to split a file into multiple files using AWK? keenboy Linux - General 1 08-05-2010 02:18 PM
split very large 200mb text file by every N lines (sed/awk fails) doug23 Programming 8 08-10-2009 07:08 PM
Split large file in several files using scripting (awk etc.) chipix Programming 14 10-29-2007 12:16 PM


All times are GMT -5. The time now is 06:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration