Search Results

Search: Posts Made By: Franklin52
9,838
Posted By Franklin52
The print command appends a newline after a...
The print command appends a newline after a string and the printf doesn't.
9,838
Posted By Franklin52
Another approach: awk -F\" 'BEGIN{print...
Another approach:
awk -F\" 'BEGIN{print "Cust-Number,Cust-Name,Cust-Town,Cust-Purchase"}
/hobby/ || !NF{next}
/purchase/{print $2; next}
{printf $2 ","}
' file
31,512
Posted By Franklin52
Another approach with awk :): awk -F"\""...
Another approach with awk :):
awk -F"\"" '!$NF{print;next}{printf("%s ", $0)}' file
1,353
Posted By Franklin52
If your grep doesn't support the -A and the -B...
If your grep doesn't support the -A and the -B options you can try:
awk 'NR==FNR{if($0 ~ /error/){n=NR}next}FNR > n-4 && FNR < n+4' /home/file.txt /home/file.txt
30,153
Posted By Franklin52
Try this: awk '/ENDMDL/{i++}{print >...
Try this:

awk '/ENDMDL/{i++}{print > "file.pdb."i}' file
3,553
Posted By Franklin52
Try this: awk 'NR % 6 {printf $0 FS; next}1' ...
Try this:
awk 'NR % 6 {printf $0 FS; next}1' file
7,955
Posted By Franklin52
Another approach to print the monday of the...
Another approach to print the monday of the current week:
cal |
awk -v d="$(date +"%m %d %y")" 'BEGIN{split(d,a)} $0 ~ int(a[2]) {print a[1] $2 a[3]}'

For the tuesday you can replace $2 with $3...
3,044
Posted By Franklin52
Use double quotes instead of single quotes to...
Use double quotes instead of single quotes to expand the shell variables:
sed -n "/$FromTime/,/$ToTime/p" $logFile > new_log.log
1,110
Posted By Franklin52
Please show what you have tried so far.
Please show what you have tried so far.
1,279
Posted By Franklin52
Thread closed, continue here: ...
Thread closed, continue here:

https://www.unix.com/linux/255080-small-problem.html
1,032
Posted By Franklin52
With printf you can use the width trick,...
With printf you can use the width trick, something like:
date | awk '{ printf("%s %*s\n", $2, 2, $3) }'
1,281
Posted By Franklin52
The sub function replaces only the field and...
The sub function replaces only the field and preserves the field separators, $1="" or $1=x doesn't.
1,281
Posted By Franklin52
Try this: awk -F\| 'NR==FNR{i=$1;sub($1,x);...
Try this:
awk -F\| 'NR==FNR{i=$1;sub($1,x); a[i]=$0; next} $1 in a{print $0 a[$1]}' input2.txt input1.txt
6,346
Posted By Franklin52
With awk: awk '!p{p=sub("2Z694-00609",x)}1'...
With awk:
awk '!p{p=sub("2Z694-00609",x)}1' file
3,027
Posted By Franklin52
I'm sorry, the first command should be: ...
I'm sorry, the first command should be:
newvar=$($var1 | awk '{print $1}')
22,922
Posted By Franklin52
Indeed :D
Indeed :D
16,451
Posted By Franklin52
Something like this? awk '{ ...
Something like this?
awk '{
for(i=1;i<=NF;i++){
if($i ~ /apply_server/ || $i ~ /apply_schema/){
if(s){
s=s FS $i
} else {
s=$i
}
}
}
print...
Forum: AIX 12-08-2010
8,482
Posted By Franklin52
printf "HELLO"|od -An -t x1
printf "HELLO"|od -An -t x1
4,943
Posted By Franklin52
Sure. df -h | awk 'NF==1{f=$1;getline;$0=f FS...
Sure.
df -h | awk 'NF==1{f=$1;getline;$0=f FS $0} int($5) >=80 {print "CRITICAL\n" $1 " has reach " $5}' file

Explanation:

NF==1{f=$1;getline;$0=f FS $0} -> if the line has 1 field add the...
3,759
Posted By Franklin52
This should be more efficient: awk -F"[# ]"...
This should be more efficient:
awk -F"[# ]" 'NR==FNR{a[$1]=$1;next}$NF in a {print $1, $2, a[$NF]}' list.txt testfile.txt
5,361
Posted By Franklin52
Something like this? ls -l 1*
Something like this?
ls -l 1*
2,984
Posted By Franklin52
Something like this? awk '/RC...
Something like this?
awk '/RC No/{close(f);f=$4}{print >> f}' test.txt
2,984
Posted By Franklin52
/^RC No/ - Matches the pattern at the beginning...
/^RC No/ - Matches the pattern at the beginning of the line
NF means the number of fields and $NF means the last field
2,984
Posted By Franklin52
Or maybe something like: awk...
Or maybe something like:
awk '/^TD/{close(f);f=$2}{print >> f}' file
4,419
Posted By Franklin52
Everyone at the UNIX and Linux Forums gives their...
Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and...
Showing results 1 to 25 of 493

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