LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-03-2014, 11:24 AM   #1
mierdatuti
Member
 
Registered: Aug 2008
Posts: 53

Rep: Reputation: 15
how to split in three lines these sentence...


Hi,
I have these code
Code:
, (select * from sales group by id_call
and I would like to split in 3 lineas like these:

Code:
,(select *
from sales
group by ...
How could I do these (with awk)?
Thanks and sorry for my English!
 
Old 12-03-2014, 01:28 PM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
If you look in this awk tutorial it should give you the solution to your problem.
 
Old 12-04-2014, 03:42 AM   #3
mierdatuti
Member
 
Registered: Aug 2008
Posts: 53

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jdkaye View Post
If you look in this awk tutorial it should give you the solution to your problem.
Thanks. I detect the sentence with awk like these:
Code:
{

   i=match($0,"SELECT");
   if ( i ){
            From=match($0,"FROM");
            if ( From ){
                Group=match($0,"GROUP");
                  if ( Group ){
                       print "GROUP ...." Group;
                  }
             }

   }

}
But how could I insert carriage return in positions "From" and "Group".

Thanks!
 
Old 12-04-2014, 03:46 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,505

Rep: Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434
just add a \n , for example:
print "\nGROUP"
 
  


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
split a line into multiple lines santhosh_cv Programming 7 08-17-2012 12:54 PM
[SOLVED] Split a file into two - the first being the first two lines and the second the rest jasonws Linux - General 2 11-02-2010 05:32 AM
why does AWK split my lines into two? keenboy Linux - General 1 08-05-2010 12:34 PM
[SOLVED] how to split string into an array/list of lines in C++? rohedin Programming 11 06-06-2010 11:54 AM
Scripting: split file into 12 lines array zklone Programming 12 12-07-2009 11:02 PM


All times are GMT -5. The time now is 03:07 PM.

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