Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. Krunek

    Format

    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.
  2. Krunek

    Populate SQL-table: resource(s) with shell scripts

    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...
  3. Krunek

    delete line if no data in all columns?

    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.
  4. Krunek

    need help with summarizing

    Hello, rufflocks! Try this awk command, please: awk 'NR == 1 { m = $1 } $1 !~ m { print prev } { prev = $0; m = $1 } END { print prev }' datafile God bless you. Bye! KP.
  5. Krunek

    How do i do this with awk....

    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.
  6. Krunek

    How do i do this with awk....

    prefix.txt: Jul 8 2004 6:03:00:000PM ~~123456789 ~~13571 suffix.txt: ~~10001A ~~N ~~123450.0 ~~0.0 ~~10002B ~~N ~~234560.0 ~~0.0 ~~10003A ~~N ~~345670.0 ~~0.0 ~~10004A ~~N ~~456780.0 ~~0.0 merging prefix.txt and suffix.txt: awk 'FILENAME ==...
  7. Krunek

    Change a value in a column

    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.
  8. Krunek

    Help with a couple of ??? using sed?

    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...
  9. Krunek

    Formatting a large dataset

    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...
  10. Krunek

    rounding problem

    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 &quot;BEGIN { printf \&quot;%015d\&quot;, 69.35 * 100 }&quot; 000000000006934 &quot;BEGIN { printf...
  11. Krunek

    awk to choose text

    Hi Beaster! You can try this awk command: awk '/CELL/ { swPrint = 1; next } swPrint = 1 { print substr($0, 22, 7 )}' file_in.txt > file_out.txt Bye! KP.
  12. Krunek

    To use AWK to find certain two fields from two files and create a thir

    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 == &quot;&quot;) fileName = FILENAME } # reads...
  13. Krunek

    if , then else I am confused

    Oops, mistake! Sorry, kd4pba! Thanks, vgersh99! Bye! KP.
  14. Krunek

    if , then else I am confused

    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.
  15. Krunek

    Need a script to output records by #of lines per recor

    Hi parser! You can put string &quot;<-SAR->&quot; as record separator: awk 'BEGIN { RS = &quot;<-SAR->&quot;; FS = &quot;\n&quot; } NF > 14 { print }' inputfile Bye! KP.
  16. Krunek

    Need Help ASAP With Nawk

    Oops! I use awk for DOS/Win. So, previous awk program must be enclosed between single quotes. Bye! KP.
  17. Krunek

    Need Help ASAP With Nawk

    Hi beaster! Please, try this awk query: awk &quot;NF == 1 { id = $0 } NF == 2 && /YES/ { print id }&quot; inputfile Bye! KP.
  18. Krunek

    Want to output a null character/byte

    Maybe is octal value acceptable: printf &quot;%s&quot;, &quot;\000&quot; Bye! KP.
  19. Krunek

    Want to output a null character/byte

    Hi dickiebird! You can try this: printf &quot;%s&quot;, &quot;\x00&quot; Warning: POSIX does not allow &quot;\x&quot; escapes. Bye! KP.
  20. Krunek

    sorta need help on sorting with awk

    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.

Part and Inventory Search

Back
Top