Search Results

Search: Posts Made By: aydj
14,439
Posted By bakunin
You are falling into the same trap as mohtasims...
You are falling into the same trap as mohtasims (in whose thread you have answered): you confuse the CONTENT of a file and its REPRESENTATION.

You construct a stream of characters forming your...
2,028
Posted By Don Cragun
For your sample input, where you want to perform...
For your sample input, where you want to perform an alphabetic sort on the 1st two characters of the 2nd field as the primary key, a numeric sort on the remaining characters in the 2nd field as the...
2,864
Posted By Scrutinizer
An adaptation of the GNU awk script in post #2: ...
An adaptation of the GNU awk script in post #2:
awk '
/ FTR *$/ {
s=$0
f=""
while(match(s,/[^ ]+ */)) { # use greedy match with field width and trailing spaces to find maximum...
2,864
Posted By Scrutinizer
Hi, try (using GNU awk): awk ' FNR==1 { ...
Hi, try (using GNU awk):
awk '
FNR==1 {
s=$0
while(match(s,/[^ ]+ */)) { # use greedy match with field width and trailing spaces to find maximum width
f=(f?f OFS:x) RLENGTH ...
2,521
Posted By Don Cragun
Assuming that none of your headings are...
Assuming that none of your headings are substrings of any earlier (from left to right) headings, you could try something like:
awk -F' +' -v LM="$(getconf LINE_MAX)" '
t == 0 && NF > 1 {
# 1st...
3,790
Posted By Scrutinizer
Yes, the sort wasn't right. Try: nawk...
Yes, the sort wasn't right. Try:
nawk '{p=$0;$1=$2 FS $1; gsub(/[0-9]+/," &",$1)}{print $1,p}' file | sort -k1,1 -k2,2n -k3,3 -k4,4n | nawk '{print $5,$6,$7}'



---

On Solaris one needs to...
2,104
Posted By Scrutinizer
After some reformatting and outlining (it helps!)...
After some reformatting and outlining (it helps!) I came up with the following quick fix:
#!/usr/bin/ksh
awk '
{
D[$2]++
A[$4]++
C[$3]
B[$4,$3,$2] = B[$4,$3,$2] ?...
3,361
Posted By Don Cragun
Assuming TERM is set in your environment to...
Assuming TERM is set in your environment to correctly indicate your terminal or terminal emulator type, the following should work:
#!/usr/bin/ksh
addword() {
tput clear
if [ "$input" != "" ]...
2,455
Posted By SriniShoo
awk 'NR == FNR {a[$0]; next} {if(! (FNR in...
awk 'NR == FNR {a[$0]; next}
{if(! (FNR in a)) {print}}' list.txt main.txt
2,053
Posted By Akshay Hegde
Single awk can do your job, if order doesn't...
Single awk can do your job, if order doesn't matter then you can process in END block also, current script reads same input twice and take care of output order.


Input
akshay@nio:/tmp$ cat...
2,053
Posted By RudiC
Try awk ' {I[$1] ...
Try awk ' {I[$1]
for (i=1; i<=Ccnt && $3 != C[i]; i++);
if (i > Ccnt) C[++Ccnt]=$3
T[$1, $3]=T[$1,$3]...
9,690
Posted By cjcox
Consider the following: PID=$$ # The...
Consider the following:


PID=$$
# The self killer
(sleep 30;kill $PID)&

# The program
while [ T ]; do
date
sleep 2
done
9,690
Posted By bakunin
First: it is highly unlikely that the PID is...
First: it is highly unlikely that the PID is recycled so fastly. PIDs are - for a reason - supposed to be almost random.

Second: even this small chance is further reduced to absolute zero because...
2,227
Posted By SriniShoo
awk '{for(i = 5; i <= NF; i++) {split($i, a,...
awk '{for(i = 5; i <= NF; i++) {split($i, a, ":"); $i = ""; split(a[2], b, "");
for(j = 1; j <= length(b); j++) {if(b[j] == 1)
{$i = ($i == "") ? (a[1] ":" length(b) - j) : ($i FS a[1] ":"...
5,434
Posted By Scott
Not getting output using /usr/sfw/bin/ggrep -E...
Not getting output using /usr/sfw/bin/ggrep -E -A1 ...?

Can you please show what you have done, including some sample from the file you are searching on?
5,434
Posted By MadeInGermany
With awk awk '/(HI|FR|GO|TAT)/ {c=2} (c!=0 &&...
With awk
awk '/(HI|FR|GO|TAT)/ {c=2} (c!=0 && c--!=0)'
15,930
Posted By Akshay Hegde
See this might help you awk ' ...
See this might help you

awk '

function bits2str(bits, data, mask)
{
if (bits == 0)
return "0"

mask = 1
for (; bits != 0; bits...
15,930
Posted By jim mcnamara
This works in the bash shell. It is a one-off...
This works in the bash shell. It is a one-off hack, IMO. perl or some other interpreted language would be more efficient.

#!/bin/bash
#obase.shl - convert to binary from hex
while read rec
do...
1,380
Posted By anbu23
$ sed "s/TRS-[^ ]* //g" file 23 345 235 45...
$ sed "s/TRS-[^ ]* //g" file
23 345 235
45 423 000
76 300 234
3,319
Posted By RudiC
Way more clumsy than I intended when I started,...
Way more clumsy than I intended when I started, but it will keep the order of occurrences of $2. Try awk '!A[$2]++ {IX[++MAX]=$2}
{B[$2 FS $3]=B[$2 FS $3]","$1}
...
3,319
Posted By Akshay Hegde
@RudiC : in first tag he wantsCC=OA0,ON0 to come...
@RudiC : in first tag he wantsCC=OA0,ON0 to come first



Here is a code which takes care about order

awk ' {
A[$2]++
B[$2 FS $3] = B[$2 FS $3] ? B[$2 FS $3] "," $1 : $1...
3,780
Posted By radoulov
awk '{ for (i = 3; ++i <= NF;) print...
awk '{
for (i = 3; ++i <= NF;)
print $1, $2, $3, $i
}' infile
2,046
Posted By Franklin52
Or try: awk 'cat!=$1{if(cat){print "ok" RS}...
Or try:
awk 'cat!=$1{if(cat){print "ok" RS} cat=$1; print "category ", $1} {print "item", $2}END{print "ok"}' file
2,046
Posted By Akshay Hegde
If field1 is sorted then this would work $ ...
If field1 is sorted then this would work

$ cat <<test | awk '$1!=p{print NR == 1 ? "category" OFS $1 : "ok" RS RS "category" OFS $1}{print "item",$2;p=$1}END{print "ok"}'
CAT1 FRY-01
CAT1...
7,119
Posted By ctsgnb
# cat f2 DT:3 foo_err DT:34 bar_frr DT:47...
# cat f2
DT:3 foo_err
DT:34 bar_frr
DT:47 foo_bar
TK:22 gree
# cat f1
he will come to DT:34 and stay there. I will meet her in DT:3
gree will see me there
he will come to DT:34 and stay...
Showing results 1 to 25 of 38

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