Search Results

Search: Posts Made By: futurelet
20,680
Posted By futurelet
BEGIN { RS = "" ; FS = "\n" split(...
BEGIN {
RS = "" ; FS = "\n"
split( "%s|%7s| : %-9s| : %9s| : %s" \
"| : %s| : %s| : %s", format, "|" )
}

{ if ( $1 !~ /\(CONT\)/ )
print ""
for (i=4; i<=NF; i+=2 )
...
7,301
Posted By futurelet
Ruby: ARGF.map {|line| line[/: (.*?) /,...
Ruby:
ARGF.map {|line|
line[/: (.*?) /, 1].scan(/\S\S/).map{|s| s.to_i(16) }.
map{|n| ((n < 32 or n>126) ? 10 : n).chr}.join
}.join.gsub(/^.?\n/,"").split("\n").zip(
[ [/^.../, ""],
...
12,921
Posted By futurelet
Ruby: "xxx".center(9) ==>" xxx " ...
Ruby:
"xxx".center(9)
==>" xxx "

Awk:
BEGIN {
print ">" center( "xxx", 9 ) "<"
}

function center( str, n ,left,right )
{ right = int((n - length(str)) / 2)
left = n -...
1,525
Posted By futurelet
BEGIN { FS=OFS=":" } { count = 0 for...
BEGIN { FS=OFS=":" }

{ count = 0
for (i=3; i<=5; i++)
count += "y"==$i
print $1, $2, count
}
4,071
Posted By futurelet
Ruby: h = Hash.new{[]} while line = gets ...
Ruby:
h = Hash.new{[]}
while line = gets
k,v = line.split
h[k] <<= v
end
puts h.sort.map{|a| a.join " "}
4,461
Posted By futurelet
Using newLisp: (set 'str (read-file (last...
Using newLisp:
(set 'str (read-file (last (main-args))))
(xml-type-tags nil nil nil nil)
(set 'xml-list (first (xml-parse str (+ 1 2 4))))
(dolist (stuff xml-list)
(and (= "item" (first...
9,865
Posted By futurelet
Perhaps $1 ~ /flag1/. After this assignment,...
Perhaps $1 ~ /flag1/.

After this assignment, is $2 or $0 ever used?
3,030
Posted By futurelet
awk 'BEGIN{RS=""} {print $NF; exit}'
awk 'BEGIN{RS=""} {print $NF; exit}'
3,012
Posted By futurelet
Don't use Perl. Use awk, sed, or Ruby. %...
Don't use Perl. Use awk, sed, or Ruby.

% foo.app | append_semicolon.awk >outfile
where the awk file contains
#!/usr/bin/nawk -f
{ printf "%s;\n", $0 }
or simply do
% foo.app | nawk '{ printf...
2,349
Posted By futurelet
Try something like this: ifconfig rl0 | gawk...
Try something like this:
ifconfig rl0 | gawk --re-interval '/^[0-9]{1,3} .*inet/ {print $2}'
If you're using awk, you seldom need to use grep. :rolleyes:
2,284
Posted By futurelet
ruby -e 'p gets.split.index("bar").succ' myfile ...
ruby -e 'p gets.split.index("bar").succ' myfile

newlisp -e '(+ 1(find "foo" (parse (read-line))))' <myfile
2,131
Posted By futurelet
BEGIN { RS=""; q="\""; OFS= q "," q } { $1=$1 ;...
BEGIN { RS=""; q="\""; OFS= q "," q }
{ $1=$1 ; print q $0 q }
19,546
Posted By futurelet
newlisp -e '(silent) (while(setq s(read-line)) ...
newlisp -e '(silent)
(while(setq s(read-line))
(println(title-case(first(parse s)))))' <file
5,440
Posted By futurelet
awk 'BEGIN{RS=""; ORS="\n\n"} !/CONNECT|alter...
awk 'BEGIN{RS=""; ORS="\n\n"}
!/CONNECT|alter system switch logfile/'

The lines separating the paragraphs must be empty.

If the in-between lines may contain spaces or tabs:

gawk...
3,338
Posted By futurelet
ruby -e 'puts (ARGV.last.split - ...
ruby -e 'puts (ARGV.last.split -
ARGV[-2].split).join(" ")' "foo bar" "zed foo bar zab"
zed zab

newlisp -e '(silent)(println (join (difference
(parse (last (main-args))) (parse (nth -2...
1,740
Posted By futurelet
ruby -e 'p gets(nil)==gets(nil) if File.file?...
ruby -e 'p gets(nil)==gets(nil) if File.file? $*[0]'
4,550
Posted By futurelet
awk '{sub(/~ */,x);printf $0(/\|$/?ORS:x)}' ...
awk '{sub(/~ */,x);printf $0(/\|$/?ORS:x)}'

awk '{sub(/~ */,x);sub(/\|$/, "|\n")}8' ORS="" file1 >file2
46,602
Posted By futurelet
ruby -e 'p %w(apple orange apple...
ruby -e 'p %w(apple orange apple banana).uniq.sort'
Output:
["apple", "banana", "orange"]
47,761
Posted By futurelet
awk 'FNR>1' myfile or awk 'FNR>1' myfile1...
awk 'FNR>1' myfile
or
awk 'FNR>1' myfile1 myfile2
2,105
Posted By futurelet
awk 'BEGIN{FS=OFS=","}{print...
awk 'BEGIN{FS=OFS=","}{print substr($1,1,6),$3-$2}' datafile
1,875
Posted By futurelet
Even better perhaps, /usr/xpg4/bin/awk
Even better perhaps, /usr/xpg4/bin/awk
1,875
Posted By futurelet
awk ' ARGV[1]==FILENAME && /VAL1/ { value = $2...
awk '
ARGV[1]==FILENAME && /VAL1/ { value = $2 }
ARGV[2]==FILENAME { sub( /\$\$VAL1\$\$/, value ); print }
' file1 file2
11,124
Posted By futurelet
ruby -rdate -e '(Date.today -...
ruby -rdate -e '(Date.today - ARGV.first.to_i).display' 31
2006-03-22
13,634
Posted By futurelet
ruby -e 'puts $<.sort_by{|x| x.split( /["()]/...
ruby -e 'puts $<.sort_by{|x| x.split( /["()]/ ).values_at(3,1) }'
2
awk
2,121
Posted By futurelet
awk '{print substr($1,1,3)}' file
awk '{print substr($1,1,3)}' file
Showing results 1 to 25 of 135

 
All times are GMT -4. The time now is 05:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy