background preloader

Bash

Facebook Twitter

Bash Prompts. This web page is a child of the Bash Prompt HOWTO that I'm maintaining for the Linux Documentation Project. The HOWTO explains a lot more than I'm going to here. My interest in Bash Prompts developed when I found "The BashPrompt Themes Project (now long deceased). Some of their prompts show up here, and a lot of what I've done shows the influence of their work.

I started these pages because so many people have been mailing me cool prompts that I couldn't see putting them all in the HOWTO as examples, but I thought they ought to be available to give other people ideas. And it gives me an opportunity to show off some of mine. So here they are. They are presented approximately in increasing order of complexity. Stock RedHat 5.1 Prompt A point of reference.

Stock Suse Prompt Another reference. Dan's Prompt A long-time tcsh user, Dan's prompt includes the history number, the tty number, and the return value of the last run process. Jobs Prompt Keeping track of suspended jobs. A Light-weight Prompt. How To Use awk In Bash Scripting. How do I use awk pattern scanning and processing language under bash scripts? Can you provide a few examples? Awk is an excellent tool for building UNIX/Linux shell scripts. AWK is a programming language that is designed for processing text-based data, either in files or data streams, or using shell pipes.

In other words you can combine awk with shell scripts or directly use at a shell prompt. This pages shows how to use awk in your bash shell scripts. Print a Text File awk '{ print }' /etc/passwd OR awk '{ print $0 }' /etc/passwd Print Specific Field Pattern Matching You can only print line of the file if pattern matched. If no pattern is given, then the action applies to all lines. Print Lines Containing tom, jerry AND vivek Print pattern possibly on separate lines: awk '/tom|jerry|vivek/' /etc/passwd Print 1st Line From File awk "NR==1{print;exit}" /etc/resolv.conf awk "NR==$line{print;exit}" /etc/resolv.conf Simply Arithmetic Call AWK From Shell Script AWK and Shell Functions Awk Program File.

ShellEd | Download ShellEd software for free. Heiner&#039;s SHELLdorado. Stupid cat Tricks: Mike Chirico. Stupid "cat" tricks that work. The "cat" command is very powerful and fast. These may be some tips the contents of multiple files from one list. These tips are simple, fast and worth a quick look. shortened. $ cat -v mout|tail test M-v test M-w test M-x test M-y test M-z test M-{ test M-| test M-} test M-~ test M-^? In nearly all cases $ cat file | some_command and its args ...can be rewritten as: $ <file some_command and its args ... Linux System Admin Tips: There are over 200 Linux tips and tricks in this article. Linux Quota Tutorial: This tutorial walks you through implementing disk quotas for both users and groups on Linux, using a virtual filesystem, which is a filesystem created from a disk file. Breaking Firewalls with OpenSSH and PuTTY: If the system administrator deliberately filters out all traffic except port 22 (ssh), to a single server, it is very likely that you can still gain access other computers behind the firewall.

Working With Time: What? Mmv MAN Page. Mass Move and rename - Move, copy, append or link Multiple files using wildcard patterns. Syntax mmv [Source_Option] [-h] [-d|p] [-g|t] [-v|n] [--] [from to] Options: -h help -d Delete -p Protect (don't delete or overwrite) -g Go -t Terminate -v verbose mode -n no-execute mode (display messages about what would have been done) Source_Options: -m Move source file to target name. Both must be on the same device. Will not move directories. If the source file is a symbolic link, moves the link without checking if the link's target from the new directory is different than the old. -x same as -m, except cross-device moves are done by copying, then deleting source. When copying, sets the permission bits and file modification time of the target file to that of the source file. -r Rename source file or directory to target name. Mmv moves (or copies, appends, or links, as specified) each source file matching a from pattern to the target name specified by the to pattern.

Multiple Pattern Pairs. Steve.org.uk: Free Software - GNU Bash for Windows. Sed - An Introduction and Tutorial. Quick Links - NEW Table of Contents Copyright 1994, 1995 Bruce Barnett and General Electric Company Copyright 2001,2005,2007,2011,2013 Bruce Barnett All rights reserved You are allowed to print copies of this tutorial for your personal use, and link to this page, but you are not allowed to make electronic copies, or redistribute this tutorial in any form without permission.

Original version written in 1994 and published in the Sun Observer How to use sed, a special editor for modifying files automatically. There are a few programs that are the real workhorse in the UNIX toolbox. Sed is the ultimate stream editor. Anyhow, sed is a marvelous utility. Do not fret! Sed has several commands, but most people only learn the substitute command: s. Sed s/day/night/ <old >new Or another way (for UNIX beginners), sed s/day/night/ old >new and for those who want to test this: echo day | sed s/day/night/ This will output "night".

I didn't put quotes around the argument because this example didn't need them. Or.