Archives

All posts for the month June, 2012

Lately been struggling with quotes and getting my variables working correctly inside the quotes.  With more precisely variables followed directly by text without spaces.  Like updating sudoers files the end result I want, to take whatever groups are in sudoers now and append _ldap to them using only bash echo.

%testgroup1 ALL=(ALL) ALL

%testgroup1_ldap ALL=(ALL) ALL

 

use strong quotes around everything except the variable

echo ‘%’$GROUP’_ldap ALL=(ALL) ALL’ >> /some/file

 

 

 

More of a helpful reminder for myself, seems I get this confused sometimes.

Example (I know there are faster ways to write this)

Need to move certain kind of files from multiple directories..

for i in 27 28 29 30; do cd $i; for j in *.gz; do mv -v $j /some/where/; done ;cd ..; done