LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 09:08 AM   #16
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,790

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201

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, 10: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



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

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

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