Skip to main content

Thread: grep returns errors with [0-9] at end


i'm sorry if repeated question, tried search on forums , inundated unrelated posts.

messing around in terminal , decided try find hard drive devices. changed /dev , entered "ls -a | grep [hs]d[a-z][0-9]"

lo , behold, this:
grep: sda2: permission denied
grep: sda3: permission denied
grep: sda5: permission denied
grep: sda6: permission denied
grep: sda7: permission denied
using sudo on ls , grep did nothing change that. tried putting ampersand after pipe--no dice. did work eliminating sort of bracket @ end of command--if put in "grep [hs]d[a-z]." period @ end instead of "[0-9]", grep returns perfectly. couldn't find explanation anywhere on internet or in man pages. know why it's acting way?

edit: clear, when errors occur, there no stdout being displayed. piping 2> /dev/null returns nothing

i tried here home folder (not cd-ing /dev), found drives, needed sudo on grep, listing /dev without raising privileges seems work fine.

code:
$ ls -a /dev | sudo grep [hs]d[a-z][0-9] [sudo] password *<my-local-username>*:  sda1 sda10 sda11 sda12 sda13 sda14 sda2 sda3 sda5 sda6 sda7 sda8 sda9 sdb1 sdb2 sdb3 sdb4 sdc1 sdd1


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] grep returns errors with [0-9] at end


Ubuntu

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account