Search:

Type: Posts; User: ghostdog74; Keyword(s):

Page 1 of 10 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    18
    Views
    790

    Re: Want to learn..but what first?

    like what?
  2. Replies
    14
    Views
    8,242

    Re: Bash, Sed & Awk tutorials

    Have you read the link "Effective awk" in my sig? awk is little language that provides you with the basics for programming, arrays, variables, functions, if/else, switch etc. What can it program ?...
  3. [SOLVED] Re: Remove all empty lines in file using grep?

    Use awk. It has the advantage of getting rid of empty lines for you AND if you need other processing on other lines, it will do that for you too.



    #remove empty lines
    awk 'NF' file


    for...
  4. Replies
    14
    Views
    8,242

    Re: Bash, Sed & Awk tutorials

    that was just a poor example.. You can see geirha's example. (@geirha's thanks,been dormant for a while and forgot about FILENAME). Sorry what point are you proving again?



    when it comes to...
  5. Replies
    14
    Views
    8,242

    Re: Bash, Sed & Awk tutorials

    don't forget, -exec is an option for the find command


    find . -type f -name "file" -exec awk '{gsub(/replace/,"new")}1' "{}" > temp \; -exec mv temp "{}" \;


    true, awk doesn't have in place...
  6. Replies
    14
    Views
    8,242

    Re: Bash, Sed & Awk tutorials

    You only need to learn awk out of sed/awk. Forget about sed. With awk, you can do what sed does , and much more, because Awk is a programming language itself. If you want to get more in depth on awk,...
  7. Replies
    9
    Views
    1,469

    [SOLVED] Re: Remove certain lines of text from a file

    no, that will not.
  8. Re: Iterate from input number to end of range (Ruby)

    also
  9. Replies
    9
    Views
    1,469

    [SOLVED] Re: Remove certain lines of text from a file

    there are 2 notions to "removing lines". One is actual removal from the file itself. Another is just not printing them out (and redirecting those printed to another file)

    awk (not printing them...
  10. Replies
    7
    Views
    652

    [SOLVED] Re: Keep only certain parts of a text file

    there are many other ways to do it

    awk


    awk '/^\/var\/mobile\/Application.*\.app$/' file


    sed
  11. Re: Iterate from input number to end of range (Ruby)

    this a more rubyish


    n = ARGV[0].to_i
    n.upto(1000) do|x|
    puts x
    end
  12. Replies
    9
    Views
    587

    Re: Manipulate text files

    provided there's no floating point numbers.
  13. Replies
    3
    Views
    3,458

    [SOLVED] Re: Detect CAPS LOCK with a bash script?

    is your caps lock ALWAYS going to be ON? type a character on your terminal, if its CAPs, then turn it off. Why do you need a script for that?
  14. Replies
    9
    Views
    587

    Re: Manipulate text files

    next time, show your expected output as well


    awk 'NR>1{$1=($1>20)?$1-5:$1+5;print}' file
  15. Replies
    2
    Views
    536

    Re: first awk script

    awk '/success/&&!f{v=$0;f=1}/success/{last=$0}END{print v;print last}' file
  16. Re: Bash newbie help, swapping stuff around.

    use awk, as shown, or you can just the shell without calling external commands.


    var="1 2 3 4 5"
    set -- $var
    echo "$5 $3"
  17. Replies
    8
    Views
    3,957

    Re: python and os.system("grep from *")

    Its a Python question. Why the Perl stuff?
  18. Replies
    8
    Views
    3,957

    Re: python and os.system("grep from *")

    if you want to use Python, then use Python. Why mix shell and Python together? Unless you really have no choice, then do it this way. It makes your code non portable.


    for file in...
  19. Replies
    6
    Views
    517

    [SOLVED] Re: for loop giving me fits

    It could have been written this way, without the need for calling external expr.


    x=0
    finish=100
    while [ $x -le $finish ]
    do
    echo $x
    ((x++))
    done
  20. Replies
    6
    Views
    517

    [SOLVED] Re: for loop giving me fits

    wrong

    and wrong.


    @OP
    your problem is , brace expansion is performed before any other expansions.


    ....
  21. Replies
    4
    Views
    354

    Re: basic bash question

    Bash is useless when it comes to floating points, if your number of lines is odd, that is.

    you should really learn how to use awk instead



    awk 'END{print NR/2}' file


    that's it.
  22. Replies
    8
    Views
    3,487

    Re: Sed select between two patterns

    and what if the pattern is like


    # echo "AAAABBCBBCCCCAAAADDDD" | sed -e :a -e '/AAAA.*CCCC/{s/CCCC//;s/AAAA//;ta}'
    BBCBBAAAADDDD <<----wrong


    # echo "AAAABBBBCCCCAAAADDDD" | awk...
  23. Replies
    8
    Views
    3,487

    Re: Sed select between two patterns

    yes, i do mean it in general. And yes, i still stand by my point of view. There is no need to learn sed at all. awk does what sed does, and a lot more. See http://awk.info for some projects done with...
  24. Replies
    8
    Views
    3,487

    Re: Sed select between two patterns

    what if the pattern is
    AAAABBCBBCCCCAAAADDDDCCCC ?
    the output should be
    BBCBB



    # echo "AAAABBCBBCCCCAAAADDDDCCCC" | awk 'BEGIN{RS="CCCC";FS="AAAA"}RT{print $2 }'
    BBCBB
    DDDD
  25. Replies
    8
    Views
    3,487

    Re: Sed select between two patterns

    Forget about sed, use awk. They both have the same capabilities, BUT awk is more powerful since its also a programming language.



    $ echo "AAAABBBBCCCCAAAADDDDCCCC" | awk...
Results 1 to 25 of 250
Page 1 of 10 1 2 3 4