LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help me (https://www.linuxquestions.org/questions/linux-newbie-8/help-me-4175443074/)

eyadgh 12-27-2012 12:56 AM

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}}'

eyadgh 12-27-2012 01:04 AM

oh my god how

AnanthaP 12-27-2012 01:58 AM

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

eyadgh 12-27-2012 02:01 AM

thaaanks
i want to print the word btween { }
"staffline " was just as example
any word

eyadgh 12-27-2012 02:24 AM

how ?

sycamorex 12-27-2012 04:19 AM

@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/

eyadgh 12-27-2012 04:25 AM

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

colucix 12-27-2012 06:31 AM

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.


All times are GMT -5. The time now is 04:29 AM.