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 Chris Miller 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: *

  • Users: olded
  • Order by date
  1. olded

    AWK or something else?

    In file2, assuming field2 is unique, read file2 into an array. Then, read file1 checking if each array element is between file1 and field2: awk ' BEGIN { while( getline < "file2" ) arr[$2]=$1 } { for(ind in arr) if(arr[ind] > $1 && arr[ind] < $2) print arr[ind]" "ind } ' file1
  2. olded

    line break every two fields

    Save the call to awk: xargs -n 2 < U1414_velocity_function.txt
  3. olded

    Remove files

    I recommend using something like this: # UNTESTED! find . -name "RECPT-ZONE*" |xargs rm -f -exec rm ... generates a Unix process for each file removed where xargs generates only one and xargs guarantees not to overflow the command line.
  4. olded

    Serach for txt files in a direcory and all subdirectories

    Travis: I assumed he meant to copy the directory structure, but you might be right; maybe he wanted all files copied to a seperate directory. Anyway, back in the day before Linux I used cpio a lot because of portability issues with tar. You can copy a directory structure using tar: cd...
  5. olded

    Serach for txt files in a direcory and all subdirectories

    It is not a perl solution, but this command copies everything in the /usr/my directory to the /usr/mynew directory: cd /usr/my; find . -depth -print|cpio -pd /usr/mynew What constitutes a text file - a file with a text extension? You can search just for files with a text extension something...
  6. olded

    Hello How to calculate the diffe

    A way .... #!/bin/ksh # This function takes a date time string of the format: # YYYY MM DD HH MM SS # perl autosplits the string and uses timelocal to return # the number of seconds from the Epoch. # No error checking! function seconds_from_epoch { echo $*| perl -MTime::Local -ane ' my...
  7. olded

    Need Secure File and ETL for AIX

    Since your data is on Windows and database is on Unix, why don't you look at a client-server solution like Ab Initio. A.I. programming is done with a Graphical Development Environment. There is a learning curve, but it's window's programming - not Unix scripting. Ab Initio has a website you...
  8. olded

    Insert duplicate field - repeat in long string

    One way to create a shell script which dynamically creates the awk script based on a string - "8 21 34 47" in this case. Obviously there are enhancements that can be done to this: #!/bin/ksh file_name="theawk.ss" echo "nawk ' BEGIN { FS=\",\" } { for(i=1; i <=NF; i++) { " > $file_name...
  9. olded

    Insert duplicate field - repeat in long string

    Let me try it again: #!/bin/ksh nawk ' BEGIN { FS="," } { for(i=1; i <=NF; i++) { if(i < 8 || (i > 8 && i < 21) || (i > 21 && i < NF ) ) printf("%s,", $i) if(i == NF) printf("\n") if( (i == 8) || (i == 21) ) printf("%s,%s,", $i,$i) } } ' mydata55.txt
  10. olded

    Insert duplicate field - repeat in long string

    I find it easier to print out each field and then duplicate fields 8 and 21. Older awks have a limitation on the number of fields that awk supports, but this works for nawk on Solaris: #!/bin/ksh nawk ' BEGIN { FS="," } { for(i=1; i <=NF; i++) { if(i < 8 || (i > 8 && i < 21) || (i >...
  11. olded

    Need if/then statement in /etc/profile

    'whoami' should work, but this parses the id command to get the real user: # get the real user id realuser=$(id|sed -e 's,^[^(]*(,,' -e 's,).*$,,' -e 1q) case $realuser in root | olded ) echo "root or olded" ;; *) echo "blah" exit 0 ;; esac
  12. olded

    Multiple sed commands..........

    jdespres: I prefer the awk solution, but sed is possible: sed -e '6,$!d' -e 'N;$!P;$!D;$d' mydata.txt|sed '1!G;h;$!d'
  13. olded

    Command line joining multiple lines.

    Or ... lsvg|xargs
  14. olded

    Solaris 10 Cron *frustration*

    I take it you have redirected to a file to see if you have an error? This link offers two alternate commands that might work: http://www.linuxquestions.org/questions/aix-43/how-do-i-get-a-cronjob-to-run-every-two-hours-in-aix-00-*-2-*-*-*-command-no-work-763034/
  15. olded

    sed replacement between characters

    I don't have time to help you right now, but this link should help: http://main.rtfiber.com.tw/~changyj/sed/html/p.20080725a.html
  16. olded

    Deleting lines with the perl match operator

    feherke: Thank you. That was helpful. Ed
  17. olded

    Deleting lines with the perl match operator

    Using perl's matching operator, I can extract lines 3, 6, and 9 from a file: perl -wnl -e 'print if $. !~ m/^(3|6|9)$/' datafile.txt Is there syntax for the matching operator that allows deleting a range of lines, say from 3 to 9? Thanks! Ed
  18. olded

    Customize prompt

    This works assuming you are using ksh (or maybe bash): export PS1=${USER}@`uname -n`':${PWD} % ' I think you need to NOT escape ${PWD}
  19. olded

    Character replace

    crasho: While on Solaris, try using nawk instead of awk.
  20. olded

    keyboard buffer

    This link describes checking for Y or N in a script: http://www.tek-tips.com/viewthread.cfm?qid=749422&page=158

Part and Inventory Search

Back
Top