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 Mike Lewis 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. FedoEx

    Array help.

    Got it. $1!=0&&$2==0{ b[$3]-=$4;} $1==0&&$2==0{ b[$3]+=$4;} $1==0&&$2!=0{ b[$3]-=$4;print $3, b[$3] } It works for this particular case. I am still looking for alternative solutions.
  2. FedoEx

    Array help.

    Thanks. I could use that approach. The blocks are not necessarily 9 lines. It could change from one block to another. My bad I did not specify that. Still I believe I can use your approach . Will post back as soon as I get some solution.
  3. FedoEx

    Array help.

    I have four columns input data.x,y,z b,c,d are some numbers not necessarily the same. x 0 z1 bl x 0 z2 cl x 0 z3 dl 0 0 z1 bc 0 0 z2 cc 0 0 z3 dc 0 y z1 br 0 y z2 br 0 y z3 br The data could be separated in blocks of triplets for which the third column is the same. The sequence z1,z2,z3 would...
  4. FedoEx

    Convert to *.js file

    Yes. That is exactly what I need. Thanks a lot.
  5. FedoEx

    Convert to *.js file

    I need only the last line to end with ; All the rest should end with +.
  6. FedoEx

    scp and avoiding the password prompt

    Hope I am not deviating much from the thread promp Recently I had to setup a cronjob where periodically would copy the file over scp.The command portion of my cronttab looked something like that. /usr/bin/scp -i /home/user/.ssh/id_dsa /tmp/file.dat server.net:~/ If I were to execute the same...
  7. FedoEx

    Convert to *.js file

    Input file 1300483198 -4.60508 1300483199 -4.60825 1300483200 -4.60691 1300483201 -4.60581 1300483202 -4.60806 1300483203 -4.60747 1300483205 -4.60788 1300483206 -4.60704 1300483207 -4.60843 1300483208 -4.60675 1300483209 -4.60827 1300483210 -4.60721 1300483211 -4.60807 1300483212 -4.60778...
  8. FedoEx

    print string that is on the next line below the regex

    Thanks again feherke. The deisired output for regex1 regex2 would be 1 11 12 2 21 22 3 31 32 To explain. First value of each row is the block number. Values two three are the values of the fields right under the regex1 and regex2.
  9. FedoEx

    print string that is on the next line below the regex

    Thanks. My initial try was this. awk '{for(i=1;i<=NF;++i)if(match($i,/regex1/)); getline; print $i }' What I don't understand is why the /regex1/ outside the {...} block is needed. If you remove it awk should process that for loop inside the {...} for each line of the input file and yet if I...
  10. FedoEx

    print string that is on the next line below the regex

    simple example inputfile regex1 regex2 regex3 1 2 3 4 5 6 regex1 regex3 regex2 aa bb cc 7 8 9 If I want to print the next line after the regex2. In my inptut file awk '/regex1/{getline;print $0}' inputfile How can I print only the...
  11. FedoEx

    Anyone have bash script to delete all be x number of files?

    Find has an option to search for files older/newer than X days,hours,... find ABC* -mtime +3 -exec rm {} \; Removes the ABC* files older than 3 days.
  12. FedoEx

    Block IPs of brute force attackers?

    try denyhosts http://denyhosts.sourceforge.net/ Adds ip's to //etc/hosts.deny after X number of unsuccessful login attempts for the period of the last Y days. Highly configurable with many options. or sshutout Blocks ip's on the iptables level...
  13. FedoEx

    learning unix

    www.linuxfromscratch.org/
  14. FedoEx

    Extract ranges of lines based on values in the lines

    Consider the input file where the last $2==y entries are consecutive. 1 y 10 2 y 11 3 y 10 4 n 12 5 n 22 6 y 12 7 y 12 8 n 33 9 y 12 10 y 10 11 y 10 12 y 10 13 y 10 14 n 12 Now the output of the the second code will give 1 2 3 6 - 7 9 10 The last line is missing...
  15. FedoEx

    Extract ranges of lines based on values in the lines

    Thanks feherke. $1 values are ascending integers from 1 to 1000.
  16. FedoEx

    Extract ranges of lines based on values in the lines

    Sample input 1 y 10 2 y 11 3 y 10 4 n 12 5 n 22 6 y 12 7 y 12 8 n 33 9 y 12 10 y 10 11 y 10 12 y 10 13 y 10 14 y 11 If I want to extract list of lines for which $2==y I can do. awk '$2=="y"{print $1}' list 1 2 3 6 7 9 10 11 12 13 14 What I really need is to print...
  17. FedoEx

    Moving Files based on Content

    Thank you. I was not aware of the FILENAME variable. Need to do some more awk RTFM. Just for completeness of my initial try. awk '/cat=b/{system("cp " FILENAME " dir_b/") }' file* Which is still inefficient. Based on Annihilannic solution, but using system(...) instead awk -F=...
  18. FedoEx

    Moving Files based on Content

    Here is incomplete awk solution awk 'NR==1 && /"cat=a"/{} END{print system("cp " ARGV[2] " dir_a/") }' file* In that case will move file_b Just need a way to get the right filenames that are matching the cat=a regex and call them instead the ARGV[2] at the END{...}
  19. FedoEx

    Moving Files based on Content

    I have non awk solution. Let say you have file_a file_b file_c file_a looks like this cat=a text in file a file_b looks like this cat=b text in file b file_c looks like this cat=c text in file c and you want to move the file containing cat=a into directory called dir_a. This should do the...
  20. FedoEx

    Variable number of input arguments and why did I need {/strt/,/end/}

    Can you explain this line /#S [0-9]+ / && ($2 in wanted) { section=$2 } I know that it turns on the section switch and assigns value to section to be used in the name of the output file later. What that plus after the regex list means? Is it possible to use something like this instead...

Part and Inventory Search

Back
Top