The Cornerstone for Creative Christians
AlteredEgg.com
Home arrow Multimediacs arrow Terminal Commands for the Creative Christian Geek
Links you might like:
Beautiful Church Websites 
Best Church Websites 
Christian Gamers Guild 
Christian-Web-Masters.com 
ChristianCoders.com 
Clubbers Temple 
Creation in Digital 
EasyWorship 
ID Arts 
MediaShout 
MinistryTech.net 
Sermonvideos.com 
SundayPlus 
Worship Arts Network 
Your Destiny, Your Choice 
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 directory

ls 

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
>> means append to file

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' {} \;
find . -type f -name '*.html' -exec /Developer/Tools/SetFile -t 'TEXT' -c 'CWIE' {} \;
find . -type f -name '*.php' -exec /Developer/Tools/SetFile -t 'TEXT' -c 'GoMk' {} \;

Change File Type and Creator of single files:

cd /Developer/Tools/
./SetFile  -t 'TEXT' -c 'GoMk' /path/to/thefile.txt
./SetFile  -t 'XDOC' -c 'XPR3' /path/to/thefile.txt

View file Type and Creator:

/Developer/Tools/GetFileInfo thefile.html

Change all files to red label

find . -type f -name '*.*' -exec setlabel red {} \;

Remove all .ds_store files

find /top/dir -name '.DS_Store' -print0 | xargs -t0 rm
find . -name '.DS_Store' -print0 | xargs -t0 rm

Open all URLs on the clipboard in your browser:

open `pbpaste`

Add default options to a shell command:

alias ps="ps -ax"
alias ls="ls -al"

Big thanks to macosxhints.com for many of these! 





Digg!Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
Comments
Add New Search
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
< Prev   Next >
[ Back ]

We want your stuff!
Follow us on Twitter:

@confidant_ca (business)
@alteredegg (fun)

Main Menu
Home
What is This Website?
Bookmarks
Send Us Your Stuff!
Why is Jesus So Important?
News, Commentary & Weird
Famous Christian Creatives
Contact Us
Site Map
Interesting Stuff For:
Actors
Animators & Filmmakers
Architects
Artists
Cartoonists
Clothing Designers
Dancers
Graphic Designers
Illustrators
Multimediacs
Musicians
Photographers
Poets
Preachers
Writers