Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have a lots of mailq in postfix. I want to create a script but the return of mailq is below: 83BE81A1872* 8797A1A1998* 8C45A1A1A72* 865D71A1A45* 845CC1A1A46* 86B7E1A1C09* Is there ...
  1. #1
    Linux Newbie
    Join Date
    Mar 2006
    Posts
    101

    How could I exempt char to grep?

    Hi,

    I have a lots of mailq in postfix. I want to create a script but the return of mailq is below:

    83BE81A1872*
    8797A1A1998*
    8C45A1A1A72*
    865D71A1A45*
    845CC1A1A46*
    86B7E1A1C09*

    Is there a way in grep where I can remove the (*) so that I can delete the file manually?

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    grep is simply a matcher. You want an editor. Fortunately, in your particular case, Bash has this built in:
    Code:
    line="test*"
    echo "${line%\*}"
    ${var%substring} notation means "Take the variable $var, and remove the shortest substring that matches my substring from the end".

    In your particular case, just be careful with the '*', because this is a special character in Bash. Make sure you quote it.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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