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 SkipVought 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. 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...
  16. aigles

    Add Commas to Number Output

    # add commas to numeric strings, changing "1234567" to "1,234,567" sed ':a;s/\B[0-9]\{3\}\>/,&/;ta' # GNU sed sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' # other seds Jean-Pierre.
  17. aigles

    eval

    #usage: matchBool "less_filx22dat.txt" "dat" b matchBool(){ x=$3; eval $x=\\$(awk -v name=$1 -v patern=$2 'BEGIN{print match(name,patern)}'); if eval [ \$$x -eq 0 ] then eval $x=0 else eval $x=1 fi }Can be simplified: #usage: matchBool "less_filx22dat.txt"...
  18. aigles

    eval

    You don't need to use eval ; for fl in `find -name "*.jpg"`;do x=$(awk -v name=$fl 'BEGIN{print match(name,/less/)}') if [ $x -eq 0 ] then echo "No match for file $fl" else echo "Match at position $x for file $fl" fi doneExample: $ ls *.jpg file_less.jpg file_more.jpg $ krava.sh...
  19. aigles

    header

    With awk : putHeader(){ for fl in `find -name "$1"`; do echo $fl tmpNm=$(basename $fl).tmp awk -v hd="$2" 'BEGIN{print hd}' $fl > $fl.tmp mv $fl.tmp $fl done } putHeader "tau*" "energy errors" Jean-Pierre.
  20. aigles

    nawk print to file in the same line

    The usage of printf without format may be dangerous $ cat infile xyz %s %s%s%s ccc $ awk '{printf $1 " "}' infile xyz awk: There are not enough parameters in printf statement %s . The input line number is 2. The file is infile. The source line number is 1. $The better way is : $ awk...

Part and Inventory Search

Back
Top