Archive for the 'UNIX' Category

Vim Scripts

For those of you that have already progressed beyond the basics in Vim, Linux.com has some great tips on using scripts within Vim. I particularly like the Multiple Search script, which allows you to do multiple searches and have them stay highlighted:

Vim Multiple Search Screenshot

For you emacs folks, there is even a script to enable Emacs Emulation.

Five scripts that make life easier with Vim [Linux.com]

Editors & Vim & Tips & Tricks & Command Line & UNIX & Linux & Scripts Jed Daniels 05 Jul 2007 No Comments

Learn to use Vi

gVim Editing an HTML Document
Lifehacker has a link this week to the UC San Diego’s Beginner’s Guide to the Vi Editor. I highly recommend that if you read it, the first thing you do is mentally replace all occurrences of Vi with Vim. Vim is Vi iMproved, and it is an awesome editor once you get comfortable with it. Spending a little time to learn Vim can have a significant gain on productivity and performance when you are doing any sort of text editing. I use Vim for just about everything, from note taking to web design (in my opinion there is no better IDE for HTML and CSS).

Once you get started, I also suggest you go here and print out the Vim cheat Sheet, which will help you remember things until you build the required muscle memory to really fly. They also have an excellent 7-step tutorial based on cheat sheets of slowly increasing complexity.

Vim Cheat Sheet

And another great beginner resource is the Vi Survival Guide. This is a good crash course in getting started with Vi, and it includes some advanced usage too.

Howto & Training & Editors & Vim & Tips & Tricks & Productivity & UNIX & Linux & Command Line & Mac Jed Daniels 03 Jul 2007 No Comments

More Shell Tips and Commands

471556 ammonietThese site is pretty new, but I hope it sticks around for a while, cause they’ve already got at least one great entry: 10 Linux Shell Tricks You Don’t Already Know. Really, we swear. And for the most part, they were right (I knew about backgrounding commands in a loop, using tar with -x, and the handy sed one-liners site). But this is an excellent resource and certainly has some useful tips. Technically these should probably be called “shell commands you don’t already know”, but I guess they seem like tricks until you learn the commands behind them. Great stuff, I look forward to more from VentureCake.

10 Linux Shell Tricks You Don’t Already Know. Really, we swear. [VentureCake]

Command Line & Tips & Tricks & BSD & Linux & UNIX & Scripts Jed Daniels 22 Jun 2007 No Comments

Excellent Shell Scripting Guide

471556 ammonietDo you want to brush up your shell scripting skills, but can never really find a decent resource that gives you good examples? Or maybe you’ve just never had the opportunity to learn any scripting at all. Well, I just found a fantastic site that so far seems to be a really awesome review/intro/guide to Bash Shell scripting (warning: I’ve only perused the first couple of sections so far–there is a ton of information here). I don’t know how I haven’t run across this page before, because it appears to have been around for a while. The Bash shell is a standard component of just about all Linux and UNIX systems these days, and Windows users can get it with a tool such as Cygwin to get the functionality available too (I’ll be writing a guide to using Cygwin on Windows soon, but until I do, take a look at Lifehacker’s excellent Introduction To Cygwin series).

Here is a snippet from the Intro of the Advanced Bash-Scripting Guide:

This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction . . . all the while sneaking in little snippets of UNIX® wisdom and lore. It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell scripting techniques. The exercises and heavily-commented examples invite active reader participation, under the premise that the only way to really learn scripting is to write scripts.

The doc reads easily, and progresses fast, but doesn’t assume you are already an expert (something many books and tutorials are guilty of). It covers many topics in detail that most other documents simply gloss over. This is a good one folks, I highly recommend it.

Advanced Bash-Scripting Guide [The Linux Documentation Project]

Tips & Tricks & FreeBSD & Howto & Training & Books & Command Line & UNIX & Linux & BSD & Scripts Jed Daniels 21 Jun 2007 No Comments

Run Linux/UNIX programs in OSX

Ok folks, sorry for the lack of new posts over the last week, it has been a bit crazy for me and keeping up with everything has been a bit difficult. I promise over the next couple of weeks you are going to be amazed with the plethora of stuff I’ve got for you. To get started, here is a useful little tool for running Linux or UNIX programs in Mac OS. Yes, I know we’ve been a bit Apple centric around here lately, but don’t worry, I’m getting my Windows on too and for there will be plenty of tips and useful stuff for those of you that just gotta have some of that Microsoft lovin’.

This one comes via that amazingly useful site, Lifehacker, and gives you step-by-step instructions for installing Fink and Fink Commander. Fink is basically a ports collection based on Debian’s dpkg and APT, and a package management system to handle installation and uninstallation, etc.. Fink Commander is a nice GUI to help out. I’ve known about Fink for along time, and even tried to install and use it when I first got my MacBook Pro, but it was a royal pain and I quickly gave up. These instructions make it easy and clear, and really make the process simple.

How to Install Linux Applications in OSX [Simplehelp.net via Lifehacker]

Tips & Tricks & Linux & UNIX & Applications & Mac Jed Daniels 29 May 2007 No Comments

Useful Unix/Linux/BSD Commands

This submission came from a colleague who knows his stuff, just hadn’t had much exposure to UNIX/Linux/BSD prior to starting at his current job. It has a pretty good mix of helpful things to remember, and can be a valuable addition to your notes or cheat sheet (I’ve been using some *NIX for over 15 years and some of these are either things I’ve forgotten or things I can never quite remember and have to look up every time I want to use them).

  • How to find specific files in a tree and delete them

    find . -name ‘lib*.so*’ -exec rm {} \;

  • Route all output from this script to /dev/null

    exec > /dev/null 2>&1

  • To search for directories in the current dir

    ls -F | grep /$

  • How to Strip out Control M’s from a file without using dos2unix or unix2dos
    You can use tr to remove all carriage returns and Ctrl-z ( ^Z ) characters from a Windows file by entering:

    tr -d ‘\15\32′ < winfile.txt > unixfile.txt

    You cannot use tr to convert a document from Unix format to Windows.
    To use awk to convert a Windows file to Unix, at the Unix prompt, enter:

    awk ‘{ sub(”\r$”, “”); print }’ winfile.txt > unixfile.txt

    To convert a Unix file to Windows using awk, at the command line, enter:

    awk ’sub(”$”, “\r”)’ unixfile.txt > winfile.txt

    On some systems, the version of awk may be old and not include the function sub. If so, try the same command, but with gawk or nawk replacing awk.
    To convert a Windows text file to a Unix text file using Perl, at the Unix shell prompt, enter:

    perl -p -e ’s/\r$//’ < winfile.txt > unixfile.txt

    To convert from a Unix text file to a Windows text file with Perl, at the Unix shell prompt, enter:

    perl -p -e ’s/\n/\r\n/’ < unixfile.txt > winfile.txt

    You must use single quotation marks in either command line. This prevents your shell from trying to evaluate anything inside.

    In vi, you can remove the carriage return ( ^M ) characters with the following command:

    :1,$s/^M//g

    Note: To input the ^M character, press Ctrl-v , then press Ctrl-m (or Enter or return on most systems).

  • Steps to Make an ISO image from a tar file and burn a cdrom…..
    1. Extract the files from the tar file.
    2. Create the iso image using mkisofs
    3. mkisofs -L -I -R -J -V ESEC -A ESEC -sysid ESEC -o disk1.iso disk1

      *disk1 is the extracted folder

    4. Copy the .iso to a location on your Windows PC.
    5. If you have Roxio installed or another CD burning program installed, double clicking the disk1.iso file will bring up the Roxio GUI. [Note from editor: we will do an article on CD/DVD burning software soon.]
    6. Choose the minimum write speed and click on the ‘Record/Write’ button.

Command Line & BSD & Linux & UNIX Jed Daniels 10 May 2007 No Comments