/kb

personal knowledgebase

Archive for the ‘bash’ tag

Bash shell prompt colors

without comments

Here are the colors available for use in the bash shell prompt:

Black 01;30
Blue 01;34
Brown 01;33
Cyan 01;36
Green 01;32
Red 01;31
Pink 01;35
Yellow 01;33

This is my shell prompt:

PS1='\[\033[01;32m\]\u@\h \[\033[01;35m\]\W \$ \[\033[00m\]'

Which produces output on the form user@computer DIRECTORY $. I use different colors for different computers/users.

Written by hgrimelid

August 8th, 2008 at 12:25 am

Posted in Shell

Tagged with , ,

Root partition free space

without comments

du -xh --max-depth=1  /

Written by hgrimelid

May 17th, 2008 at 7:21 pm

Posted in Shell

Tagged with ,

grep through several files

without comments

By adding option -H to the grep command, the filename will be output together with the matching line:

grep -i -H TEXT_TO_SEARCH_FOR

-i turns on ignore case.

Written by hgrimelid

April 10th, 2008 at 10:13 am

Posted in Shell

Tagged with , , ,

Simple scp script for copying to SSH enabled accounts

without comments

I frequently use scp to copy files to shell accounts. It’s quite annoying to type the full account info each time, so by writing a very small and very simple shell script some typing can be saved:

#!/bin/bash
scp -r "$1" login@server.domain.com:$2

The script copies file $1 to the destination $2 on the server. With -r option directories are copied as well. The “” are for taking care of file/directory names with spaces in.

Written by hgrimelid

April 10th, 2008 at 9:37 am

Posted in Scripts

Tagged with , , , ,