Find the answer to your Linux question:
Results 1 to 4 of 4
hi can anyone please help me to write a sed script with following requirements. delete all the lines in a file that ends with either alpha, beta or gamma. i ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2

    Sed script.

    hi

    can anyone please help me to write a sed script with following requirements.


    delete all the lines in a file that ends with either alpha, beta or gamma.

    i can write 3 different statements for it but i wnt to combine it in one statement. help me plz


    sed 's|[/a-z A-Z_0-9.-]*alpha$| |' File.txt
    sed 's|[/a-z A-Z_0-9.-]*beta$| |' File.txt
    sed 's|[/a-z A-Z_0-9.-]*gamma$| |' File.txt


    thanks in advance.

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    Use extended regexs. You'll have to use the -r option:

    -r, --regexp-extended

    use extended regular expressions in the script.


    Code:
    sed -r 's|[/a-z A-Z_0-9.-]*(alpha|beta|gamma)$| |' File.txt

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2
    Thanks, its working now. Thanks again.

  4. #4
    Just Joined!
    Join Date
    Apr 2009
    Posts
    2
    i dont create new topic, so i will write there.
    i have a problem with my script using sed.
    bash script must prints out the number of usernames that begin with each letter of the alphabet from some file.
    But: sed -e 's/\.//g' -e 's/ /\
    /g' "$1" | tr 'A-Z' 'a-z' | sort | uniq -c | sort -nr print and count the lines,but not first letters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...