How may i merge these two lines into one line?

chown abc:abc *.sh

chown abc:abc *.txt

Change ownership of two file extensions into one liner.

link|improve this question
feedback

migrated from stackoverflow.com Sep 13 '11 at 9:38

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 6 down vote accepted

Like this:

chown abc:abc *.txt *.sh

Or if you really want to get fancy:

chown abc:abc *.{txt,sh}
link|improve this answer
2  
+1, although "fancy" would be something like find . \( -name '*.txt' -or -name '*.sh' \) -maxdepth 0 -print0 | xargs -0 chown abc:abc {} ';' :-) – paxdiablo Sep 13 '11 at 3:35
1  
@paxdiablo: no, you're confusing fancy with demented (ok, yes I'm guilty of using abominations like that, but I'm demented so it's ok). – Chris Sep 13 '11 at 3:36
Note that the brace syntax is not portable to basic Bourne shell. – tripleee Sep 13 '11 at 5:55
I realize it might be on purpose, but the find + xargs version is over-complicated. In particular, xargs -r0 chown abc:abc at the end is quite sufficient. – tripleee Sep 13 '11 at 5:57
@triplee: what does -r do on xargs? Darwin's xargs doesn't have that option... – w00t Sep 13 '11 at 12:05
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.