Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    command to get certain line

    Hi guys.

    I want to do a scripting..

    # ls -l /tmp/MC* | wc -l
    ls: cannot access /tmp/MC*: No such file or directory

    How do I get the line with 0? I need it for a condition.

    I tried to google around for sed or cut command but unfortunately I did not find any hint.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Use find instead of ls, as it wont throw an error in case nothing is found and you also can set much more accurate filters (e.g. -type f)
    find /tmp -type f -name "MC*" | wc -l
    You must always face the curtain with a bow.

  3. #3
    find /tmp -type f -name "MC*" | wc -l
    Great! thanks a lot.

  4. $spacer_open

Posting Permissions

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