Search Results

Search: Posts Made By: kato
13,586
Posted By kato
Merry Christmas! With a few improvements after...
Merry Christmas! With a few improvements after @Franklin52:
awk 'BEGIN{RS=">"}NR>1{sub("\n","\t"); gsub("\n",""); print RS$0}' file
13,586
Posted By kato
You could try using a tab, instead of replacing...
You could try using a tab, instead of replacing the new line with nothing:
awk 'BEGIN{RS=">"}{gsub("\n","\t",$0); print ">"$0}' file
13,586
Posted By kato
try this: awk 'BEGIN{RS=">"}{gsub("\n","",$0);...
try this:
awk 'BEGIN{RS=">"}{gsub("\n","",$0); print ">"$0}' file
1,673
Posted By kato
I don't believe you can overwrite the original...
I don't believe you can overwrite the original file without causing a problem. Although this did work for me:

{print > FILENAME}But to be safe, you can move the new file to the old file after awk...
1,673
Posted By kato
If I understand you correctly, you want to...
If I understand you correctly, you want to specify the value to insert after DRIVES. Try this:

z="TEST"
grep -l '0007862454' ./* | xargs awk -v newDrive=$z '/DRIVES/{a=NR+1}...
1,673
Posted By kato
Try this from within the directory your files are...
Try this from within the directory your files are in:
grep -l '0007862454' ./* | xargs awk '/DRIVES/{a=NR+1} a==NR{$0=FILENAME}{print > FILENAME".new"}'
5,744
Posted By kato
Perhaps an over simplified solution: ls | awk...
Perhaps an over simplified solution:
ls | awk '{printf "%s.%05d\n", $0, i++}'
3,832
Posted By kato
If vbe is correct you should be able to clean the...
If vbe is correct you should be able to clean the file using the dos2unix utility:

dos2unix hello.ksh

Then try running your script.
10,499
Posted By kato
Alternatively, as you initially thought, sed...
Alternatively, as you initially thought, sed proves more concise:
sed '/^PC/{N;/\nPC/!{s/\n//};P;D}' file
10,499
Posted By kato
try this: awk...
try this:
awk '/^PC/{a[NR]=$0}!/^PC/{a[NR-1]=a[NR-1]$0}END{for(i=0;i<NR;i++){print a[i]}}' file
1,186
Posted By kato
awk '/0/' file
awk '/0/' file
2,937
Posted By kato
If you use awk instead of grep then you can set...
If you use awk instead of grep then you can set $1 into a local variable:

new_var=$(awk '!/Col1/ && !/-/ && $5=="Y"{print $1}' my_test.log)
1,526
Posted By kato
Unless I misunderstand you, there is no problem...
Unless I misunderstand you, there is no problem with committing directory trees into source control systems. If you want a structure of /mod1/files then you should just create it on your local file...
2,135
Posted By kato
I read the other day, a better way to do this: ...
I read the other day, a better way to do this:
ps -ax | grep [f]tpd
1,107
Posted By kato
If you want to test your amount and then print...
If you want to test your amount and then print the formatted line if it passes the test, try:


awk '{a=substr($0,33,11); line=substr($0,1,1) "," substr($0,2,19); if(a>712.40) print line}' file
...
1,540
Posted By kato
This is perhaps overkill, but this will handle...
This is perhaps overkill, but this will handle files of different dates...

In the directory with your files:
ls *csv | awk -f matcher.awk
where matcher.awk contains:


BEGIN{FS="_"}
{
...
1,151
Posted By kato
how about just piping the grep output into the...
how about just piping the grep output into the awk command?
grep -A1000000 "Acceptance" Brown_DL | awk '
NR==1
NR>1{ for (i=1; i<=NF; i++) { a[i]+=$i; }}
END { if (NR > 1) { for...
17,116
Posted By kato
awk -F"\x01" '{for(i=1;i<NF;i++)...
awk -F"\x01" '{for(i=1;i<NF;i++) if($i=="TAG001")print $(i+1)}' file
4,472
Posted By kato
try this from within your folder with the links: ...
try this from within your folder with the links:
find . -type l | xargs ls -l | awk '{system("ln -sf " $11" "$9)}'

Although, you may want to test this first or it will mess up your links:
find ....
3,534
Posted By kato
I'm not familiar with nawk, but shouldn't the...
I'm not familiar with nawk, but shouldn't the toupper be done before the print?
if(/^cn:/) x=toupper($0); print NF?$0:a[x]"\n"Also, I just noticed this:
but in your example:
id_list
cn: abc, id:...
7,767
Posted By kato
I think your file must have some control...
I think your file must have some control characters in it that are not visible and also not copied into your example text.
That would explain why the code works when I use it on the examples given....
4,373
Posted By kato
No problem. It is better to make the code more...
No problem. It is better to make the code more readable:

awk '
/UDP flood/{ --> match lines with UDP flood
flood=$0; --> copy it for later
if(line){ ...
4,373
Posted By kato
try this: awk '/UDP flood/{flood=$0;...
try this:

awk '/UDP flood/{flood=$0; if(line){print line ORS $0;line=""}} !/UDP flood/{line=$0; if(flood){print flood ORS $0;flood=""}}' file
7,767
Posted By kato
awk -F=...
awk -F= '/MSISDN/{s=(s=="")?$2:s"+"$2}/SMSMSG/{s=s"="$2;print s;s=""}' file
2,579
Posted By kato
grep -E '/\*.*\*/|\-\-' file or if you have...
grep -E '/\*.*\*/|\-\-' file
or if you have multi-line /* */ comments:
awk '/\/\*.*\*\// || /\/\*/,/\*\//{print}/--/' file
Showing results 1 to 25 of 64

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