# Tag Info

0

For those who want to see only a list of filenames, here is the relevant part of Peter.O's answer: find "${1:-.}" -type f -name '*' | awk -F/ '{ if( name[$NF] ) { dname[$NF]++ } name[$NF]=name[$NF]$0 "\n" } END { for( d in dname ) { printf name[d] "\n" } }' I don't need md5sums because I use fslint-gui before the script to clear all ...

1

Here's one way. This assumes that questions are separated by consecutive newlines (\n\n). $perl -000pne 's/\n/\n\\begin{enumerate}\n/; s/\n\d./\n\\item /g; s/$/\\end{enumerate}\n/' file l. Lorem ipsun la la la? \begin{enumerate} \item Sopor \item Stupor \item Torpor \end{enumerate} 2. A patient has Lorem? \begin{enumerate} \item ...

2

If you mean a shell variable: t=7,51,10,22,3,2014 perl -MTime::Local -le 'print timelocal split ",", shift' -- "$t" t=1398163867 perl -le 'print scalar localtime shift' -- "$t"

0

A perl solution: $perl -MTime::Local -nle 'push @day,$1 if /.*\<td\>(.*)\<\/td\>/; END { for (@day) { if (/^\d/) { ($y,$m,$d,$h,$mi,$s,@tail) = split("-|\\.",$_); print timelocal($s,$mi,$h,$d,$m-1,$y); } } }' file 1400822580 1401098400 To change the file ... 0 I recommend always storing GMT dates, or if this is really inconvenient dates with timezone information. Leaving unspecified dates around isn't a good idea. If you're stuck with this data format, Perl is a good tool for transforming the local dates into GMT dates and back. Parsing HTML with regular expressions is a bad idea in general, but it's ok if the ... 0 If you don't mind using gawk >= 4.0, this (which is pretty much the same as terdon's) will produce the desired output, with optional name and key ordering: NF { Names[$3][$1] = 1; Names[$3][$2] = 1; } END { PROCINFO["sorted_in"] = "@ind_str_asc"; # if you want Name ordered for (Name in Names) { PROCINFO["sorted_in"] = ... 1 Personally, I would just do the whole thing in Awk from the original file rather than half in PHP and half in Awk or Perl. Given file1.txt above, the following will produce the desired output: { Vals[$1]++; Vals[$2]++; Third_col[$1, $2] = Third_col[$2, $1] =$3; } END{ for (i in Vals) { for (j in Vals) { if (i == j || (i ...

1

Here's another Perl approach: $perl -ane 'foreach(@F[0..1]){$k{$F[2]}{$_}++} END{ foreach $v (sort keys(%k)){ print "$_ " foreach(keys(%{$k{$v}})); print "$v\n" }; } ' file This produces: 47723284 47196436 name1 42672249 430695 52856963 name2 380983 55094959 ... 1 Another awk solution:$ awk 'FNR==NR{a[$1,$2]=$3;next} {print$0,a[$1,$2]?a[$1,$2]:a[$2,$1]?a[$2,$1]:0} ' file1 file2 3377090 8145216 1.5 1405541 8145216 0 1405541 3377090 0 53595498 8145216 0 53595498 3377090 0 53595498 1405541 1.53637

2

A perl solution: $perl -ane '$h{$F[2]} .= " ".$F[0]." ".$F[1]; END { for$k (sort keys %h) { print $_," " for grep {!$seen{$_}++} split(" ",$h{$k}); print "$k\n"; } }' file 47196436 47723284 name1 42672249 52856963 430695 name2 55094959 380983 name3 17926380 55584836 3213456 34211 54321 name4

1

awk 'NR==FNR{a[$1>=$2?$1SUBSEP$2:$2SUBSEP$1]=$3;next}; {k=$1>=$2?$1SUBSEP$2:$2SUBSEP$1; print$0, k in a?a[k]:0}' file1.txt file2.txt 3377090 8145216 1.5 1405541 8145216 0 1405541 3377090 0 53595498 8145216 0 53595498 3377090 0 53595498 1405541 1.53637

2

Ungainly, but seems to do the job awk '$3 != prev {if (NR != 1) print prev; prev=$3; delete a}; !($1 in a){a[$1]++; printf "%s ", $1}; !($2 in a){a[$2]++; printf "%s ",$2}; END {print prev}' ccc.txt 47196436 47723284 name1 42672249 52856963 430695 name2 55094959 380983 name3 17926380 55584836 3213456 34211 54321 name4

0

"but I lose the formatting information, which I'd like to preserve." It isn't that it thinks you aren't on a tty, it's that it thinks you are on a really old tty which does overstrike tricks through grotty, the back-end processor of groff. From the man page: Use the -c switch to revert to the old behaviour, printing a bold character c with the ...

1

You are right, your issue is the rendering of the beautification done by nroff/groff. To avoid this beautification, bypass nroff/groff and output your pod documentation into text with pod2text (this is a part of Perl distrib, so you should have it): watch "pod2text <your_perl_withpod_file>"

1

Another awk solution: $awk 'FNR==NR{if(!NF){a[FNR]=1}next}a[FNR]{print"\n"$0;next}{print}' file1.txt file2.txt 1234|oneflewovercuckoosnest^asgoodasitgets 5678|theshining 4321|batmanbegins^darkknight When reading file1.txt, we mark the line number in array a if line is blank. When reading file2.txt, we get line number which is blank in array a and print ...

3

To introduce a blank line in a file at the same position as changes in actors in file1.txt, try: $awk -F '|' '{save=$0; getline<"file1.txt"} NR>1 && $2!=prev {print ""} {prev=$2; print save}' file2.txt 1234|oneflewovercuckoosnest^asgoodasitgets 5678|theshining 4321|batmanbegins^darkknight The above works quite a bit like your code except ...

2

ls | grep -oP "(?<=$study.)[A-Z]$" will return any uppercase letter that is preceded by the contents of $study plus one arbitrary character (the T in your example) and followed by the end of the line. The -P option (Perl regular expressions) is needed to be able to use the positive lookbehind expression (?<=...), but might not be available on every ... 0 A perl solution:$ perl -nle 'print chop if length == 11' file A X Or if you can use bash: while read var do [ ${#var} -eq 11 ] && echo${var:(-1)} done < file

0

ls | grep $study | grep -o "[AX]$" returns only the result of 'A' or 'X' as the last character

Top 50 recent answers are included