LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-31-2016, 10:08 AM   #16
MadeInGermany
Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 545

Rep: Reputation: 252Reputation: 252Reputation: 252

Note
\+ is not defined in BRE.
Strict BRE needs [0-9][0-9]* or [0-9]\{1,\} instead of [0-9]\+
 
Old 02-05-2016, 11:40 AM   #17
Adamgl
LQ Newbie
 
Registered: Oct 2012
Location: Seattle, WA
Distribution: RHEL
Posts: 1

Rep: Reputation: Disabled
Taking the assumption that you want the first field and the last 3 fields with some static text in between, you can use awk to slice in from the end and then strip off the double quotes. $NF is the number of fields, which in awk is equivalent to the last field.

Code:
awk '{print $1" example "$(NF - 2)" "$(NF - 1)" "$(NF)}' example.txt | sed 's/\"//g'
example.txt:
Code:
10 "Stop abcdee fghi jk lmnz toejamz.com SS -c -i567 -i8a9b"
20 "Stop pqrstu vwxyz toejamz2.com SS -c -g123 -g456"
Output:
Code:
10 example -c -i567 -i8a9b
20 example -c -g123 -g456
 
  


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
cat|grep|awk pudhiyavan Programming 6 07-14-2008 02:56 AM
cat and grep dipuasks Linux - General 11 04-21-2008 04:39 AM
cat to grep to textfile? jabfinger Linux - General 3 09-05-2006 04:25 PM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 12:36 PM
Question About Cat And Grep George2 Linux - Software 10 03-09-2006 04:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:49 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