Hello, sabetik!
As I know, you must convert integer 123455 to floating-point number 1234.55 and then you can use printf function.
God bless you. Bye!
KP.
Hello, Ladyluck!
Suppose that you have table tbl1:
create table tbl1 (
id integer primary key,
dsc varchar,
dte date
);
You also have data in a csv text file (semicolon is a field separator):
1;1st row;20060415
2;2nd row;20060416
2;3rd row;20060417
Suppose that you must...
Hello, rhnaeco!
You can try this
awk 'NF > 3' file[s]
or (if you wish to see filename)
awk 'NF > 3 { print FILENAME, $0 }' file[s]
Jesus loves you. Bye!
KP.
Thank you for greetings, CaKiwi! God bless you.
I've tried your solution and it works perfect:
awk 'NR == 1 { a = $0; next } { print a, $0 }' prefix.txt suffix.txt
Bye!
KP.
This awk command changes every line with zero at the end of line and prints every line:
awk '/0$/ { $0 = substr($0, 1, length - 1) } { print }' inputfile
KP.
If you don't mind awk, try these solutions:
# strips off the first field
BEGIN { FS = "\t" }
{
for (i = 2; i <= NF; i ++)
printf "%s\t", $i
printf "\n"
}
# swaps the first two fields
BEGIN { FS = "\t" }
{
printf "%s\t", $2
printf "%s\t", $1
for (i = 3; i...
This is solution with comma as field separator:
BEGIN { FS = "," }
{
for (i = 1; i <= NF; i++) {
l = length($i)
oStr = substr($i, 2, l - 2)
if ($i ~ /""/)
oStr = " "
printf "%s ", oStr
}
printf "\n"
}
It's a variation of Ygor's...
Hello daddymack!
This is because awk's arithmetic is done internally in floating point. Instead %d picture you can use %f picture. See this awk examples (I use awk for DOS and Win):
awk "BEGIN { printf \"%015d\", 69.35 * 100 }"
000000000006934
"BEGIN { printf...
Hi awktonished!
This is an example.
1st input file:
a 1
b 2
c 2
2nd input file:
a 22
c 2
c 11
awk program compares 1st column of files:
BEGIN {
fileNr = 1
cnt = 0
}
# saves the filename of the 1st file
{
if (fileName == "")
fileName = FILENAME
}
# reads...
Hi kd4pba!
Yo can omit grep step in your command line statement and use directly awk to filter output of ps command and print 2. and 9. column:
ps -ef | awk '/in.telnetd/ { next } {print $2, $9 }'
Bye!
KP.
Hi parser!
You can put string "<-SAR->" as record separator:
awk 'BEGIN { RS = "<-SAR->"; FS = "\n" } NF > 14 { print }' inputfile
Bye!
KP.
This awk command prints only unique lines even input data isn't sorted, but output is unsorted:
awk '{ a[$0] = $0 } END { for (i in a) print i }' inputfile
I use array (awk's arrays are associative); this is a powerful awk-tool.
Bye!
KP.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.