Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

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

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

add comment

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}
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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