pictures

Copy to Clipboard in the Command Line Interface (CLI)

hr
hr Heading 2 Icon Copy to Clipboard in the Command Line Interface (CLI)

Ever wonder how to copy something from the command line into the Mac OS clipboard? If you want to copy/paste a files content (perhaps a log file or a conf file, etc) into the clipboard to use outside of the CLI, you can use the commands pbcopy and pbpaste. Example: I want to copy the contents of my public key to the clipboard (so I can send it to a server admin who will use it in allowing me to access their subversion repository).

All I would need to do is:
cat id_dsa.pub | pbcopy

(cat writes out the content and then it is piped (|) into the clipboard) This comes in handy!

Nano Tip.

hr
hr Heading 2 Icon Nano Tip.

I have been doing a lot of work recently on a remote server and have needed to use a text editor - so I decided to use the ever-so-easy nano. Problem is - the files I am working on are very long and editing them is not fun. I finally decided to look through the man pages (I am an emacs person myself) and found something that ended up saving me tons of time..."go to line number". If you are editing a file and know you need to edit something on line 1245, you would type in:

CODE:
nano +1245 master.css

and it would open the file to line 1245 so you do not need to scroll down. Thank you man pages!

whereis and locate.

hr
hr Heading 2 Icon whereis and locate.

A few simple commands to help make your life working with UNIX a little easier:

If you are looking for a certain programs, use:whereis. Example. You want to find out where ipfw is located. In the command line type whereis ipfw and whereis will spit out the location (/sbin/ipfw).
If you need to find a program or a file and you know what it is called, use:locate. Example. I know I want to uninstall MySQL, and I want to see every file that has mysql in the file path. In the command line, type locate MySQL and locate will spit out every file with MySQL in the file path. (Note, locate is case sensitive).

print file size command.

hr
hr Heading 2 Icon print file size command.

Earlier today I was asked for the command to show a file size in UNIX and so I thought I would share. There are, of course, a few ways to do this. One great little command to keep handy is:du -h. The du (display utility) will print out the size of a file or directory. The -h will make it "human readable" (put the sizes in Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte). So, next time you need file or directory sizes, use du -h and be done with it!

command line to the rescue…again.

hr
hr Heading 2 Icon command line to the rescue…again.

While upgrading a client's web site to XOOPS 2.0.14 I ran into some issues with the XOOPS 2.0.14 package file (a tar.gz file). Stuffit Expander would only extract a few folders, then report an error and quit. After a few attempts, and all failures, I had to chose to turn to the command line and bingo, no problems! So, if you ever have any issues with Stuffit Expander and need to uncompress a .tar.gz file, the following commands will come in handy:

To uncompress a gz file: gunzip file.gz
To uncompress a tar file:
tar [tar options (usually xvf)] file.tar
To uncompress a .tar.gz file: tar xzvf file.tar.gz

Questions? Check out the man pages for tar and gunzip.
[tags]XOOPS, gunzip, tar[/tags]

ubuntu 5.10 for PPC.

hr
hr Heading 2 Icon ubuntu 5.10 for PPC.

Well, after some problems downloading the 3.3GB image of Fedora Core 5 and then my PowerBook not recognizing the DVD media (no, I was not about to re-download all five install CD images and burn them to CD...this is not 1993 again with installer floppies everywhere...and I did not have any other DVD media on hand), I decided to try a different flavor of Linux: Ubuntu. A few people that I I have been talking to recently either prefer Ubuntu, or have recently tried it, like Tim. Since the install image is only 644.5MB, I decided it might be the time to try it out.

From the very beginning, I was impressed. I first had problems with my install because of a CD error, but to my delight, the Ubuntu installer gav eme an option to set up a web server with a click of a button which served all the installation log files so I could look at them and find the problem. When I got home, I burned another copy and while my Comcast connection was out (TV and internet!) I installed and configured Ubuntu with ease.

What ... [more]

print out certain line numbers with sed.

hr
hr Heading 2 Icon print out certain line numbers with sed.

It has been a year now since I completed my UNIX/Linux certification training and every once and awhile I think about my friend Perl, but I really enjoy helping others with some simple needs. Ben (yeah, I got him using WordPress too ;)) aked me a great recently:

Question: If i have a huge log text fie and i want to pull a range of lines out of the middle, how can I easily do this?

Answer: sed -n '3,6 p' /var/log/httpd/error_log

Answer broken down:

sed is the UNIX tool I chose for this. -n is used so that sed does not print out more than what I need.
'3,6 p'indicates that I want lines 3-6 of the log file to print out (in the command line) and the p is used for: "If the substitution was made, then print the new pattern space."
/var/log/httpd/error_log specifies the log file that I need to extract data from

Hope this comes in handy!
[tags] sed [/tags]


search

subscription information

Blog RSS

Comments RSS



Powered by FeedBlitz

blog categories

blog tags

most popular posts


blog archive

standards

Get Firefox!
XHTML
CSS