@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> hi all
<0> is it possiple to use awk F without taking care of new lines in result ?
<0> i want that $1 contains multiline text
<1> no
<0> :(
<2> You could do it in Perl though: perl -we 'local $/; my $str = <>; print $str' /etc/hosts
<2> what's your source?
<0> my source is a yum.repos file
<0> this look like a .Ini file
<0> [core]
<0> name=Fedora Core $releasever - $basearch
<0> #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/
<0> mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=core-$releasever&arch=$basearch
<2> then substitute /etc/hosts with the path to the yum.repos file and everything is fine.
<0> and they are more [section] in the file



<0> i dont think i have perl on the hosts where i want to deploy the script
<0> awk have a record-separator
<0> i was thinking that if i set it to "" it will have multiline variables
<2> what kind of hosts? perl is available on *nearly all*
<2> *nix-alike operating systems
<0> minimal web servers
<0> and ohters home computers
<0> can i p*** the RS="" variable on a wak -f comand line ?
<0> awk -F "[" 'BEGIN { RS = "" } ; { print $3 }' don' do the trick :(
<3> perl is definitely included in fedora core..
<0> ok ok :)
<0> i dont know perl very well so i was thinking doing it with bash and awk
<0> i dont know it in facts
<0> :)
<4> :: yawn ::
<4> Nico_Bdav: awk -v RS=""
<3> Nico_Bdav: well shigetsu told you how to do it in perl so...
<2> hello
<3> meh
<4> Greetings.
<4> miah: :*
<5> wow lots of ppl here woot ;)
<5> I have a file that looks like this (each is on its own line) 1/tcp 2/tcp 3/tcp
<5> with awk, how do I print tcp(1,2,3) from that?
<5> do I need to use substr()?
<6> war: echo -e "tcp\ntcp\ntcp" |awk '{printf "%s,",$O}' #tcp,tcp,tcp,
<5> ok ,, next step is
<5> $ cat line | awk '{printf "%s ",$0}'
<5> 1/tcp 2/tcp 3/tcp
<5> I see--
<5> but trying to make it print 1,2,3
<5> (each port)
<6> post an example line to text
<5> k sec
<5> http://rafb.net/p/XCNtgl81.html
<6> ok
<5> basically Id like the output to look like this
<5> tcp(4000,1200,34)
<5> udp(2,3,4)
<5> icmp(other)
<5> in order if possible as well (the ports)
<5> I can handle that , I can ensure the ports are in order line by line
<5> but Im nnot sure how to get awk to only print the ports for tcp/udp (nand just print other for icmp)
<6> how did you derive the needed output from the raw input?
<5> like this
<5> sed -r -n "/$IP/"'{s/.*PROTO=ICMP.*/other\/icmp/p; t; s/.*PROTO=([^ ]*).*DPT=([^ ]*).*/\L\2\/\1/p}' "$DATA.raw" | sort | uniq | sort -n > "$DATA.tmp"
<6> no, what math or other logic gets the output: udp(2,3,4) from your pastebin post
<5> ohh
<5> that is what I am trying to accomplish, sorry
<5> with awk( if possible)
<6> what does udp(2,3,4) mean?
<5> I need something like awk { /^.*tcp/ { FS='/' {print $1}' }
<5> 2,3,4 are the ports
<5> in the example:
<5> 2/udp
<5> 3/tcp
<5> erm,
<5> 2/udp
<5> 3/udp



<5> I want it to show: udp(2,3)
<5> make sense?
<6> all i see in your pastebin is 5/udp 10/udp
<5> oops
<5> then in that case
<5> udp(5,10)
<6> ok
<4> Bonjour.
<6> bon apetite ;)
<5> awk '{ /^.*tcp/ { FS='/' {print $1}' } }' <- need something like this yea?
<5> something like that :\
<6> pr3d4t0r: how to >echo -e "5/udp\n10/udp" |awk to get output udp(5,10)?
<4> gnubien: What does -e do?
<7> pr3d4t0r: interpret \n
<4> gnubien: Ah, got it.
<4> gnubien: -v FS="\n"
<4> gnubien: Wait... let me think for a bit.
<4> gnubien: Are there more than one udp(x, y) in the input?
<5> there can be a number of ports
<4> gnubien: In the real input.
<4> war: Ah... so you could have udp(5, 10, 15, 20)?
<5> yes
<4> war: Are you likely to have TCP as well, or other stuff?
<5> tcp,udp and icmp
<4> war: OKi... and the sequence is always number/protocol\n?
<5> yes
<4> war: Any cute things like 5/udp\n10/udp/12/udp, or are the records always separated by \n ?
<5> always by \n
<4> war: Ah. Easy then.
<4> war: I'm going to use the pastebin because the one liner will be longish and fuglish. It's easy.
<5> k
<5> pr3d4t0r: your previous awk statement helped me a lot
<5> this basically gives me what I want
<5> grep tcp line | cut -f1 -d'/' | awk '{printf "%s ",$0}' | sed 's/\ $//g'
<5> grep udp line | cut -f1 -d'/' | awk '{printf "%s ",$0}' | sed 's/\ $//g'
<5> grep icmp line | cut -f1 -d'/' | awk '{printf "%s ",$0}' | sed 's/\ $//g'
<4> war: Getting there. I forgot that awk lacks a switch statement. Revising.
<5> k
<4> war: http://eugeneciurana.com/pastebin/pastebin.php?show=1413
<4> war: Your with grep + cut + awk + sed calls will run about 5 times or more slower than just calling awk.
<4> war: awk can do everything you wanted, and more.
<4> war: And everything runs in a single process :)
<4> war: We can optimize the code I gave you even more, but right now it's that way so that you can see what it's doing at each step.
<4> war: I gotta go -- my g/f's airplane lands in 30 minutes and I gotta be there on-time.
<4> I'll be around for another 7 minutes or so, if you have questions.
<5> k
<5> I will check it out
<5> awesome stuff man, Ive always wanted to know how to do such things with awk
<5> thx!!
<4> war: Line 28: It should be printf(")\n"); -- I have a bug in that pastebin.
<5> k
<5> did you pickup awk by examples & reading the awk books or practice /both? I learn best by example--thx again,--brb
<4> war: HeH.
<4> war: I picked it up over 20 years ago :)
<5> nice
<4> war: Mostly from reading "The UNIX Programming Environment" by Kernighan.
<4> war: Get a copy of that book. It may even be free for download somewhere.
<4> war: It was written 20+ years ago and it's every bit as relevant today as back then.
<4> war: It'll teach you how to use shell, awk, sed, etc. programming better than almost any tutorial.
<5> will look for that
<5> thx.
<5> Last problem. (34185,34239,34240,34241,34242,34243,34244,34245,36348,36350,36351,36353,50749,5<line break> 0800,50801,50802,50803,50804,50806,50807,51484,52905,53020,5302<line break> 1)
<5> I have $tcp_ports which is equal to (1,2,3,4..60) but in the e-mail when I get it, it shows up as (1..2.3.<line break> (return).. next line->5,6,7) how can I make it format nicely?
<5> will take a picture
<5> bash/string formatting problem, how do you format text (long lines) so it looks nice? see my problem here (look at the output) http:///209.136.127.142~war/help.jpg
<5> http:///209.136.127.142/~war/help.jpg
<5> I want it to continue on the next line after the previous line's tcp
<5> so its like a mini-paragraph (indented port listing), make sense?
<1> war: grep | cut | awk | sed -- can all be replaced by awk
<5> awk /blah/ ~ $1 yea, awk is nice
<1> cool


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #awk
or
Go to some related logs:

#gimp
freepbx echo monitor
gimp inner glow
postfix/postqueue fatal: usage: postqueue -f
kopete gentoo error reemerge
#linux
gentoo safe mode -php -f8 single user
puppylinux vlc
svnpipe
ubuntu video4linux



Home  |  disclaimer  |  contact  |  submit quotes