Multimediacs
Terminal Commands for the Creative Christian Geek
| Terminal Commands for the Creative Christian Geek |
|
Those of you who have a Mac may find this collection of commands useful. Many of them may even run in a BASH shell on Linux/Unix. Non-geeks, please look away! Note: For some commands, Mac users may need to have the Developer Tools installed (usually comes on your system software cds). I'll start off with the basics. First step: Open up your Terminal program (Mac) which is found in the Utilities folder within the Applications folder. Remember to hit Return at the end of each of these commands. To change directories:cd /Users/Shared/Documents Tip: You can quickly enter a file path such as the one above by dragging an icon from the Finder into the Terminal window. To switch to your home directory:cd ~/ To view a file listing of your current directoryls Okay, that's the basics. Now on to the good stuff... Total the file size of everything in your current directory in kilobytes:du -cks Hey cool, I like ducks! To decode email file attachments from Base64:openssl base64 -d -in <infile> -out <outfile>
Where infile refers to the input filename (source) and outfile refers
to the output filename (destination). Type 'man enc' for more
detailed information on using OpenSSL commands. Conversely, to encode to Base64:openssl base64 -in <infile> -out <outfile> Find all pdfs in a directory and add up their file size:
find /Users/allan/Desktop/siast -name "*.pdf" -exec du -sk {} \; | awk '{total += $1} END {print total}'
Search for a string in a selection of files:
find . -exec grep "www.athabasca" '{}' \; -print
This command will search in the current directory and all sub directories. All files that contain the string will have their path printed to standard output. If you want to just find each file then pass it on for processing use the -q grep option. This finds the first occurrence of the search string. It then signals success to find and find continues searching for more files:
find . -exec grep -q "www.athabasca" '{}' \; -print
This command is very important for process a series of files that contain a specific string. You can then process each file appropriately. An example is find all html files with the string "www.athabascau.ca". You can then process the files with a sed script to change those occurrances of "www.athabascau.ca" with "intra.athabascau.ca". Start a program that only runs in X window environment
If you are aware of such a program then you probably already know this. In Terminal type: startx This starts XTerm. Then in XTerm type the name of your program, such as: fontforge Mount a DMG disk image:sudo hdituil attach file name.dmg Create a symlink:A symlink is like an alias but is more likely to be treated as an actual file by the system. ln -s [the link target] [where to put the symlink] ln -s /Library/Application\ Support/AppleWorks/AppleWorks.app/ /Applications/ Process a text file line by line:You would replace the command between the semicolons with whatever command you want. The one below encodes a list of passwords. for i in `less allan.txt`; do md5 -s $i>>convertedallan.txt;done
-s means treat as string Change File Type and Creator of Multiple Files:
Sometimes files won't open in the correct program, especially text-based files. In the examples below, the code 'GoMk' causes the system to think the file is a GoLive text file. Notice I'm targeting all .txt files in the first and all .php files in the second. for i in *.txt; do /Developer/Tools/SetFile -t 'TEXT' -c 'GoMk' "$i"; done for i in *.php; do /Developer/Tools/SetFile -t 'TEXT' -c 'GoMk' "$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:
find . -type f -name '*.xml' -exec /Developer/Tools/SetFile -t 'TEXT' -c 'CWIE' {} \;
Change File Type and Creator of single files:
|
|||||||
| Comments |
|
| < Prev | Next > |
|---|
|
| Follow us on Twitter: |
|---|
@confidant_ca (business)
|
| Main Menu | |||||||||
|---|---|---|---|---|---|---|---|---|---|
|
| Interesting Stuff For: | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|