LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-25-2013, 07:28 AM   #16
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751

Nice; can you make it work for the 1st field per line?
 
Old 04-25-2013, 04:41 PM   #17
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
As far as I know, sed does not support non-greedy matching, so not using the same approach, but if you have two seds chained together, it can usually* be converted to a single sed:
Code:
sed -ne 's/\([A-Z]*-TP_[A-Z]*\).*/ \1/' -e 's/.*[^A-Z]\([A-Z]-TP_\)/\1/p'
* Theoretically it can always be converted, but sometimes the resulting sed script may be quite complicated and not worth it.
 
Old 04-25-2013, 11:42 PM   #18
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Yeah, I got a 2 pass soln already (see my 1st post).
I was just wondering if a sed expert could come up with a single pass, just for my own edification.
 
Old 04-30-2013, 09:32 AM   #19
sumit.inform
LQ Newbie
 
Registered: Mar 2013
Posts: 19

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
Hi All,

ABCD-TP_XYZ CrossConnect RTQ TL5 STC NONE
Tpcx LMPI-TP_UIP CrossConnect RTQ TL0 STC NONE (LMPO-TP_UIP)
Tpc MPLO-TP_KP CrossConnect RTQ TL0 STC NONE (MPLO-TP_KP)

With all suggested methods I tried the code in Cygwin terminal and I found that is working fine but when I tried with TELNET due to Special Character it is showing error.

------------------------------------------------------------------------------
e.g following command give me error due to "~".
awk '{for (j=1;j<=NF;j++) if ($j~"-TP_") {print $j;break}}' $InFile >$OutFile
------------------------------------------------------------------------------
Has any one give me simple method in which there is no use of special character, That would be work for me on TELNET.
 
Old 05-01-2013, 08:00 AM   #20
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Well, the best way is to put (edit) whichever method you want to use into a file on the remote system, then run it.
That way you don't have to keep typing it in.
Alternately, put it into a file locally and scp it across.
You really shouldn't use telnet anyway, its all plaintext, so insecure; try ssh instead.
See also rsh & related http://www.informit.com/articles/art...p=169465&rll=1
 
  


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
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
how can I "cat" or "grep" a file to ignore lines starting with "#" ??? callagga Linux - Newbie 7 08-16-2013 06:58 AM
Are the words " Word,Excel,PowerPoint" are proprietary sailajabhandaru General 12 12-06-2005 08:51 PM
How can I catch some "KEY WORDS" from a text file without opening it? yuzuohong Linux - General 1 06-14-2002 09:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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