Search Results

Search: Posts Made By: Franklin52
7,131
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.
7,131
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
27,206
Posted By Franklin52
Another approach with awk :): awk -F"\""...
Another approach with awk :):
awk -F"\"" '!$NF{print;next}{printf("%s ", $0)}' file
1,026
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
29,079
Posted By Franklin52
Try this: awk '/ENDMDL/{i++}{print >...
Try this:

awk '/ENDMDL/{i++}{print > "file.pdb."i}' file
2,327
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,110
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...
2,170
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
789
Posted By Franklin52
Please show what you have tried so far.
Please show what you have tried so far.
882
Posted By Franklin52
Thread closed, continue here: ...
Thread closed, continue here:

https://www.unix.com/linux/255080-small-problem.html
726
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) }'
910
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.
910
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
4,484
Posted By Franklin52
With awk: awk '!p{p=sub("2Z694-00609",x)}1'...
With awk:
awk '!p{p=sub("2Z694-00609",x)}1' file
2,348
Posted By Franklin52
I'm sorry, the first command should be: ...
I'm sorry, the first command should be:
newvar=$($var1 | awk '{print $1}')
19,687
Posted By Franklin52
Indeed :D
Indeed :D
14,379
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
6,509
Posted By Franklin52
printf "HELLO"|od -An -t x1
printf "HELLO"|od -An -t x1
3,034
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...
1,734
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
4,719
Posted By Franklin52
Something like this? ls -l 1*
Something like this?
ls -l 1*
2,252
Posted By Franklin52
Something like this? awk '/RC...
Something like this?
awk '/RC No/{close(f);f=$4}{print >> f}' test.txt
2,252
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,252
Posted By Franklin52
Or maybe something like: awk...
Or maybe something like:
awk '/^TD/{close(f);f=$2}{print >> f}' file
3,192
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

 

Featured Tech Videos

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