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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by aigles

  1. aigles

    tricky sqlplus

    Remove the -s option. You can play with the SET ECHO {ON|OFF} in you sql script. Jean-Pierre. Jean-Pierre.
  2. aigles

    Substitution query

    sed 's/\./:/;s/\./:/;s/-/:/;s/-/:/' inputfile Jean-Pierre.
  3. aigles

    Conversion to csv file

    A more cryptic solution using sed : sed -n 'H;${x;s/\n//g;s/,$//;p;}'dftmp2 For a production script, prefer the PHV'solution that is more simple to understand and to maintain. Jean-Pierre.
  4. aigles

    delete specific line

    GNU sed The following address types are supported: number Match only the specified line number. first~step Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5...
  5. aigles

    ksh integer variable assignment

    Another syntax : integer CurrentBackup PreviousBackup CurrentNumber if ((CurrentBackup==0)); then (( PreviousBackup=10-(CurrentNumber-1) )) else (( PreviousBackup=CurrentNumber-1 )) fi Jean-Pierre.
  6. aigles

    egrep "| N1" and "| N2" and "| N3" from file

    Try : fgrep -f strings.txt pipe_delim.txt Jean-Pierre.
  7. aigles

    getline 2 fields then print match + content of field 2 in first file

    gawk -F"|" 'NR==FNR {a[$1]=$2;next} { if ($1 in a) { print $0 a[$1]"|" > "good" } else { print $0 > "bad" } }' rangefile myfile Jean-Pierre.
  8. aigles

    Printing a certain string from multiple locations

    A small variation : - Use any non alpha-numeric character as field separator. - Strings are displayed only once. awk -F '[^[:alnum:]]' ' { for (f=1; f<=NF; f++) { if ($f ~ /GN0[0-9][0-9][0-9][0-9]/) ++strings[substr($f, 1, 7)]; } } END { for (s in...
  9. aigles

    Search for words in 1 file that match a list in another file.

    Another solution with awk #/usr/bin/awk -f #Awk Program : city.awk NR == FNR { city[++cities_count] = $0; pattern[cities_count] = "(^|[^a-z-])" tolower($0) "([^a-z-]|$)"; count[cities_count] = 0; next; } { $0 = tolower($0); for (c=1; c<=cities_count; c++) if ($0 ~...
  10. aigles

    Join 2 lines

    An awk solution : #!/usr/bin/awk -f # Awk program : join.awk /^[0-9][0-9]\// { if (line) print line; line=""} { gsub(/[[:space:]]+/, " "); line = line $0 } END { if (line) print line } Output: $ join.awk table1.txt 06/15/2007 02:28:47 TABLE "nmmp_" - 18,015,000...
  11. aigles

    Join lines in a file

    Another way with awk awk ' /^TAG/ {if (tag) print tag; tag = "" } { tag = tag $0 } END {if (tag) print tag } ' inputfile Jean-Pierre.
  12. aigles

    How to read and manipulate file?

    You can include the awk program in a ksh script in the following ways : 1) Create the awk program file fmt.awk and include the following statement in your KSH script file : awk -f fmt.awk tmp.txt 2) If you don't want to use an external file, you can include all the awk program in your KSH...
  13. aigles

    How to read and manipulate file?

    You can do something like that : #!/usr/bin/awk -f # Awk program : fmt.awk /ARCHIVING DATABASE/ { db_prefix = "ARCHIVING DATABASE " $5; print db_prefix; next; } $3 ~ /TABLE/ { out = db_prefix; for (f=3; f<= NF && f<=9; f++) out = out " " $f; print out; } $3 ~...
  14. aigles

    hwo to use awk to collect information in mutiple records

    You can try something like that: # # Proceed all records # { records[NR] = $0; # Memorize record keys[NR] = $1; # Memorize record key ++counts[$1]; # Count records with this key sums[$1] += $2; # Summurize values for this key } # # End of datas # END { # #...
  15. aigles

    Add Commas to Number Output

    \B Matches everywhere but on a word boundary; that is it matches if the character to the left and the character to the right are either both "word" characters or both "non-word" characters. \> Constrains a RE to match the end of a string or to precede a character that is not a digit...

Part and Inventory Search

Back
Top