LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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-11-2013, 11:45 PM   #16
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783

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-11-2013 at 11:46 PM.
 
  


Reply



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] Replace 2nd occurrence of a string in a file - sed or awk? kushalkoolwal Programming 26 09-26-2021 04:10 PM
[SOLVED] awk split file into variable number of files captainentropy Linux - Newbie 12 07-10-2012 09:54 PM
How to split a file into multiple files using AWK? keenboy Linux - General 1 08-05-2010 01:18 PM
split very large 200mb text file by every N lines (sed/awk fails) doug23 Programming 8 08-10-2009 06:08 PM
Split large file in several files using scripting (awk etc.) chipix Programming 14 10-29-2007 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:19 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
Open Source Consulting | Domain Registration