Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'one-liner for bash prompt' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
one-liner for bash prompt
Authored by: dfe on Dec 05, '03 11:42:48PM

I guess what they say about PERL programmers is true after all. :-) You can do this with a shell command that can be typed at the bash prompt. If you prefer tcsh then it will be slightly different.

for i in *.txt; do /Developer/Tools/SetFile -t 'TEXT' -c 'ALFA' "$i"; done

You can of course use -t or -c by itself, or you can use any of the 3 other options. There's also an even more handy method for finding files other than by basic shell globbing:

find . -type f -name '*.xml' -exec /Developer/Tools/SetFile -t 'TEXT' -c 'CWIE' {} \;

That will find all entries in the current directory (.) and its subdirectories that are regular files (i.e. not directories, symlinks, or device special) that match the shell glob '*.xml'. For each flie found it will execute the command replacing {} with the name of the file. A semicolon terminates the parameters to the -exec option and must be backslash escaped (or surrounded in quotes like ';') because otherwise the shell interprets it (as it does in the for command above).

One feature I can see with this PERL script is that it does both GetFileInfo and SetFile in one command. For that you'd want to check if the user specified any options then run SetFlie and if the user didn't then run GetFileInfo

Also, /Developer/Tools is not by default on the PATH so the PERL script won't even work out of the box.



[ Reply to This | # ]
one-liner for bash prompt
Authored by: hamarkus on Dec 06, '03 02:05:28PM

Another stupid question, how do I add /Developer/Tools to the path? I have found some instructions
<a href="http://www.informit.com/isapi/product_id~%7B73676503-9D68-4791-A8CA-0DAAFDEECD8D%7D/element_id~%7B56177C72-E3B1-4082-B017-C55F663E14B1%7D/st~%7BFC01C6FA-A166-40A9-BEFF-FA0234A128E9%7D/content/articlex.asp"> here </a>

but there seems to be no .tcshrc nor .profile file on my computer?

(And what am I doing wrong with my link formatting?)



[ Reply to This | # ]