LinuxQuestions.org
Review your favorite Linux distribution.
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


Closed Thread
  Search this Thread
Old 12-27-2012, 01:56 AM   #1
eyadgh
Member
 
Registered: Dec 2012
Posts: 40

Rep: Reputation: Disabled
help me


awk cat file.txt :

1|34|2012.12.01 00:08:35|12|4|921-*203-0000000000-962797807950|mar0101|0|00000106829DAE7F3FAB187550B920530C00|0|0|4000018001000002||962797807950|||||-1|||||-1||-1|0||||0||||||-1|-1|||-1|0|-1|-1|-1|2012.12.01 00:08:35|1|0||-1|1|||||||||||||0|0|||472|0|12|-2147483648|-2147483648|-2147483648|-2147483648|||||||||||||||||||||||||0|||0||1|6|252|tid{111211344662580792}pfid{10}gob{1}rid{globitel} afid{}uid1{962797807950}aid1{1}ar1{100}uid2{globitel}aid2{-1}pid{1234}pur{!GDRC RESERVE AMOUNT 10000}ratinf{}rec{0}rots{0}tda{}mid{}exd{0}reqa{100}ctr{StaffLine}ftksn{JMT}ftksr{0001}ftktp{PayCall Ticket}||



hi alla i have this this file and i want to print the word "staffline" or any word in this brace "ctr{word}"
always ctr and brace and any word im want to print this word bye use substr function in awk

i try:
awk '{comp[substr["ctr",0]{print}}'
 
Old 12-27-2012, 02:04 AM   #2
eyadgh
Member
 
Registered: Dec 2012
Posts: 40

Original Poster
Rep: Reputation: Disabled
oh my god how
 
Old 12-27-2012, 02:58 AM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 804

Rep: Reputation: 186Reputation: 186
Search for the pattern /ctr{StaffLine}/. If the line contains this, then print it (not the line but the pattern).

If this is what you want, in the selected line, find out where the string sarts and THEN use substr.

OK

---------- Post added 12-27-12 at 01:28 PM ----------

Search for the pattern /ctr{StaffLine}/. If the line contains this, then print it (not the line but the pattern).

If this is what you want, in the selected line, find out where the string sarts and THEN use substr.

OK
 
Old 12-27-2012, 03:01 AM   #4
eyadgh
Member
 
Registered: Dec 2012
Posts: 40

Original Poster
Rep: Reputation: Disabled
thaaanks
i want to print the word btween { }
"staffline " was just as example
any word
 
Old 12-27-2012, 03:24 AM   #5
eyadgh
Member
 
Registered: Dec 2012
Posts: 40

Original Poster
Rep: Reputation: Disabled
how ?
 
Old 12-27-2012, 05:19 AM   #6
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,811
Blog Entries: 1

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
@eyagh

1. Don't double-post. Post your question only in one place.
2. Why are you insisting on the substr() function? A usually approach is find the best tool for the job, not do everything with one tool. As I posted in your other thread, sed might work better in this particular case.
http://www.linuxquestions.org/questi...lp-4175443087/
 
1 members found this post helpful.
Old 12-27-2012, 05:25 AM   #7
eyadgh
Member
 
Registered: Dec 2012
Posts: 40

Original Poster
Rep: Reputation: Disabled
ok i'm so sorry
ok forget substr but your dont work if we have many "ctr{word} " two or three
hint: we have many "ctr{word} " and i want to count the same word and print the count for each
 
Old 12-27-2012, 07:31 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread


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




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