Tag Archives: unix

Elinks User Agent Override

To manually set the useragent for the e-links web browser, edit this file: ~/.elinks/elinks.conf The syntax for setting or overriding the user agent is something like this: set protocol.http.user_agent = “Firefox/2.0.0.4″ Or possibly this for a more realistic agent string: set protocol.http.user_agent = “Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060426 Firefox/1.5.0.4″

Posted in Web Development | Tagged , , , , , , , | Leave a comment

Unix: Change To Last Directory

If you’re wondering, can I: in unix, change to last directory in unix, cd to last used directory in unix change to most recent directory Well, cd – will switch you to the previous directory. For example, if you are in /usr/bin/tmp, and go to /etc, you can type cd – to go back to /usr/bin/tmp. You can use this to toggle back and forth between two directories. cd dir (without a /) will put you in a subdirectory. for example, if you are in /usr, typing cd bin will put you in /usr/bin, while cd /bin puts you in /bin. cd .. will move you up one directory. So, if you are /usr/bin/tmp, cd .. moves you to /usr/bin, while cd ../.. moves you to /usr (i.e. up two levels). You can use this indirection to access subdirectories too. So, from /usr/bin/tmp, you can use cd ../../local to go to /usr/local. cd by itself or cd ~ will always put you in your home directory. cd ~username will put you in username’s home directory.

Posted in Tech Tips | Tagged , | Leave a comment

Where Linux Mail files are stored on OS X

“1 new message” – a common notification when you start the terminal, especially if you have cron jobs set up and an error occurs. You can use the built-in “mail” function to check and erase messages, or you can manually edit / delete the files located in the directory: /var/mail

Posted in Tech Tips | Tagged , , , , | Leave a comment

Replacing Variables with Bash

$(var:pos[:len]) # extract substr from pos (0-based) for len $(var/substr/repl) # replace first match $(var//substr/repl) # replace all matches $(var/#substr/repl) # replace if matches at beginning (non-greedy) $(var/##substr/repl) # replace if matches at beginning (greedy) $(var/%substr/repl) # replace if matches at end (non-greedy) $(var/%%substr/repl) # replace if matches at end (greedy) ${#var} # returns length of $var ${!var} # indirect expansion

Posted in Web Development | Tagged , | Leave a comment

unix commands

find / grep find . -iname “*.php” -exec grep -textString {} \;

Posted in Tech Tips | Tagged , , | Leave a comment

ibm aix

Maybe this still has a place in today’s tech world, but I think IBM should just give up and move over to working with true *NIX clipped from en.wikipedia.org IBM AIX AIX (Advanced Interactive eXecutive) is the name given to a series of proprietary operating systems sold by IBM for several of its computer system platforms, based on UNIX System V with 4.3BSD-compatible command and programming interface extensions. Latest stable release 6.1 / November, 2007 Source model Closed source License Proprietary  

Posted in Tech Opinion | Tagged | Leave a comment

Useful Unix Commands

To backup everything in the current directory, exclude anything ending with jpg: tar cvf mybackup.tar –exclude “*.jpg” . To exclude more than one type, just add another –exclude statement: tar cvf mybackup.tar –exclude “*.jpg” –exclude “*.gif” . Search current directory and sub directories for mp3 files: find . -name \*mp3 Need to Learn: how to get the total size of the files returned by the above search command AIX Those were on RHEL, not aix – they will work for a lamp instance.  With AIX we have to consult the man tar page. This should work: find . \! -name “*.mp3″ > inputfilelist tar -cvf mybackup.tar -L inputfilelist This should also work (in the opposite direction): find . -name “*.mp3″ > excludefilelist tar -cvf mybackup.tar -X excludefilelist . In either case, you can use this to see if there are any mp3 files in the archive: tar -tvf mybackup.tar | grep mp3

Posted in Tech Opinion, Tech Tips, Web Development | Tagged | Leave a comment