1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Linux question

  1. Jan 28, 2012 #1
    1. The problem statement, all variables and given/known data

    I have a really basic task in which I have to make a shell script, pipe ls to grep and
    only output files that has capitals in it, meaning no lower case, no symbols, no numbers, etc.

    I've been searching all over google and my notes but I've been doing this over an hour and still cant figure it out

    2. Relevant equations


    3. The attempt at a solution

    I tried ls | grep [A-Z][^a-z0-9]
    but it prints words with symbol such as "_" eg: "DAFA_FDSA".
  2. jcsd
  3. Jan 28, 2012 #2

    I like Serena

    User Avatar
    Homework Helper

    Welcome to PF, Bimpo! :smile:

    Apparently you need to learn a little more about regular expressions.
    Right now you're matching files that have at least one capital in it, followed by 1 symbol that is not a lowercase letter of digit.

    You will need to match the beginning and end of the filename with ^ resp. $, and you will have to specify that they all have to be uppercase letters, using * to indicate zero or more repetitions.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook