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 IamaSherpa 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. bondtrails

    How to delete files older than X generations...

    Hello all! I am new to unix scripting and I am trying to learn a few things by writing in unix scripts utility programs I wrote in other languages. Here is where I am currently stumped: I would like to delete files older than "X" generations. By that I mean if in a given directory there are 10...
  2. bondtrails

    Replacing non-printable characters...

    Hi all, This newbie needs some help. I've been playing with AWK and SED and am trying to figure out how to replace all non-printable characters with a "." Actually, can someone tell me how in AWK or SED, I can replace any ASCII characters in the range of 0 - 31 (x0 - x1F), but not the line feed...
  3. bondtrails

    Splitting a file...

    Hi all, I am a bit stuck here with a seemingly simple process: How do I split a file of say X records into n files each file having X/n records? So if I have a 30,000 record file, how can I split the file into 3 files with each file containing 10,000 records? Thanks for helping out the newbie...
  4. bondtrails

    Oversize packet error...

    Hello everyone, When i try to download a file from a server to my laptop via AFP (Apple File Protocol over TCP/IP), the file transfer is unbearably SLOW. Transferring a 1 meg file takes about 2 mins (that's way too slow). However, uploading the same file to the server takes about the time to...
  5. bondtrails

    Write to multiple files in awk via another file...

    ahh!! CaKiwi, you are a ray of light!! --Bondster!!
  6. bondtrails

    Write to multiple files in awk via another file...

    Hi CaKiwi, here's my program. Don't know why it prints to STDOUT awk -f Program.awk dataFile.txt # ========= program1.awk ========== outfile = substr($0,9,18) gsub(/ /,"",outfile) {print >>outfile ; close(outfile)} The only way to not get printout on my screen is to redirect STNDOUT...
  7. bondtrails

    Write to multiple files in awk via another file...

    CaKiwi, {print >>$1) works fine, it writes to the appropriate file, but it also prints to STDOUT (screen). How can I suppress screen printout? Thanks! --Bondster!!
  8. bondtrails

    Searching in fixed locations with AWK...

    Okay, thanks CaKiwi and Baraka, I got it to work :-) However, in the general sense, my question still lingers. If I wanted to search records of a file, but limiting my search within specific column locations, how would I do it. I am thinking perhaps the function "substr" might do it...
  9. bondtrails

    Searching in fixed locations with AWK...

    Hi all, how can I match using fixed locations. It seems like AWK allows pattern matching, but I need to match in a fixed position. Ex: FileA.txt contains: aaaaJobCode bbbbb aaaaJobControlbbbbb aaaaJobStatus ccccc eeeeJob dddddd If I want only those records that match "Job...
  10. bondtrails

    Write to multiple files in awk via another file...

    Hey everyone, newbie #1 still learning awk. I need some help: I have a file, each record contains data and a filename. I want my awk program to append each record to a file whose file name is on that records. For example, if file FILE_A.txt contains: filename_1.txt data data data filename_1.txt...
  11. bondtrails

    Grabbing output from grep and awk into a variable...

    Okay, after some experimenting I got it to work! It had to do with a subtle change: Instead of: A=`awk '/""$B""/{ print $3 } inFile.txt` I used: A=`awk '/'"$B"'/{ print $3 } inFile.txt` Can someone explain why this works? Thanks!! --Bondster!!
  12. bondtrails

    Grabbing output from grep and awk into a variable...

    Ed, thank you for your prompt response. I tried the double quotes but didn't have much luck. I also tried the link you posted but it just took me back to the tek-tips home page. Any other suggestions would be greatly appreciated!! --Bondster!! P.S. Here is what I am trying to do (with your...
  13. bondtrails

    Grabbing output from grep and awk into a variable...

    Hi everyone, after some time, I need to revisit this problem. The suggested solution: A=`awk'/HELLO/{ print $3 } inFile.txt` does a fine job of storing the text "b001.txt" in variable A However, suppose instead of hardcoding "HELLO", I wish to use a variable, say $B followed...
  14. bondtrails

    How to drop n chars from a record...

    Hi all, what's the best way to drop n characters from each record in a given file? The n characters are consecutive, but they could be at the beginning, middle, or end of the record. For example, given file A.txt which has a record length of 1000, how can I get make file B.txt which has a...
  15. bondtrails

    using awk in a script...

    Hey thanks Jamisar, I think your simple example clarified the rules behind quoting. Geez, I wish the book I was reading used similar examples. Anyway, I changed my script and it worked well. I'll probably wind up asking for help again in the near future, but I figure with all this practice, It...
  16. bondtrails

    using awk in a script...

    Oops! Forgot the "=" in after parm. It should read: PARM='-v fna='"$DIR/$FILE_1"' -f program.awk' It still doesn't work though :-( --Bondster
  17. bondtrails

    using awk in a script...

    Hi everyone, I can't seem to get shell quoting correct in a unix script. I tried this command in the command line, and it works great: awk -v file="input1.dat" -f program.awk input2.dat > output.dat but i can't seem to make it work in a script--I've tried a few quoting combination...
  18. bondtrails

    Comparing and extracting from 2 files...

    Hey CaWiki, thanks for the explanation. So does this mean that the expression in a[] have to evaluate to consecutive characters in the record? Suppose I wanted to do my file comparison based on not just column locations 32-49, but instead, locations 32-38, 41, 47, 49. How to do?? --Bondster...
  19. bondtrails

    Comparing and extracting from 2 files...

    By the way, can you walk me through your code? I get the jist of the whole thing, but not at a line-by-line level. In your dif.awk script, I see that you loop through the entire fna file (in my case, my A.txt file) and limit your comparison in the desired column locations (via substr($0,32,18))...
  20. bondtrails

    Comparing and extracting from 2 files...

    Ugh!!! Silly Silly foolish me!!! CaWiki, thanks for all your good help--I found out what was wrong. Your code was impeccable--I was at fault. Here's what I did wrong: I wrote the dif.awk program using Apple's TextEdit program (which of course, adds RTF control characters). When I examined the...

Part and Inventory Search

Back
Top