Might try it on my laptop and see how it suffers.steveb wrote:this one starts manny bash prcesses and you can watch the cpu going crazy:cheersCode: Select all
:(){ :|:&};:
SteveB
btw: don't do it if you are not fast enought to do an killall bash!

Might try it on my laptop and see how it suffers.steveb wrote:this one starts manny bash prcesses and you can watch the cpu going crazy:cheersCode: Select all
:(){ :|:&};:
SteveB
btw: don't do it if you are not fast enought to do an killall bash!
I often forget how to do things, so I started writing down reminders for all sorts of things and kept them in a textfile. When it became too large to cat, I wrote this handy script, it works just like grep except that it prints the entire matching paragraph, not just a line.allucid wrote:I was wondering what everyone's favorite (and relatively unknown...) bash tricks were.
Code: Select all
#!/bin/bash
# Variables:
file_to_search=/home/user/reminders/reminders
ignore_case=1 # Non-zero value ignores case.
awk -v "RS=\n\n" -v "IGNORECASE=$ignore_case" '/'$1'/{print $0"\n"}' $file_to_searchCode: Select all
Format a floppy (NOT mounted, and as root)
fdformat /dev/fd0
To start another x server:
startx -- :1
creating symlinks:
ln -s /path/to/dir /path/to/symlink
Create an iso image (the r is for rockridge, filenames other than 8+3):
mkisofs -r directory/ > image.iso
Burn a cd from an iso (speed will be set to 4 for cdrw):
cdrecord -v speed=8 dev=/dev/hdc image.iso
Code: Select all
for i in `cat <some file>`;do rm $i;done
Code: Select all
ls /usr/local/portage/sys-kernel/love-sources >> <some file>
ls /usr/local/portage/sys-kernel/love-sources/files >> <some file>
Fortune? The thing that displays a funny quote when you log in? Do you mean like a "bash tip of the day", or are there other ways to use it? I've never used fortune so I'm not sure what you're thinking of...axxackall wrote:Andersson, you may want to consider fortune to host all your reminders (or cookies in term of forutne).
BTW, fortune is in portage.
YABTW, you may want to originate bash-related cookies as an ebuild and many of us would be happy to contribute to it.

I found fortune (or fortune-like tips) usefull in several places:Andersson wrote:Fortune? The thing that displays a funny quote when you log in? Do you mean like a "bash tip of the day", or are there other ways to use it? I've never used fortune so I'm not sure what you're thinking of...

Backticks are nice, but it's good to get into a habit of using the more nesting-friendly $() construct.sonic_ wrote:Also, a bit mainstream, but backticks (`) are so bloody useful.. even though my knowledge of sed and awk is next to nothing, I can get a lot done with just grep, cat and echo and some other stuff with liberal use of backticks and also piping.
Code: Select all
alias h='history | grep'Code: Select all
chshrcat@chshrcat chshrcat $ h cvs
225 cvs diff -u . >../mmxblend2.patch
232 cvs diff -u . >../mmxblend2.patch
237 cvs diff -u . >../mmxblend2.patch
262 cvs diff -u >../adjust.patch
359 cvs diff -u >../adjust.patch
361 cvs diff -u >../adjust.patch
377 cvs diff -u >../adjust.patcscreen -ls
437 vi /usr/portage/distfiles/cvs-src/mythtv/libs/libmythtv/osdtypes.cpp
441 vi /usr/portage/distfiles/cvs-src/mythtv/libs/libmythtv/osdtypes.cpp
459 cvs diff -u >../mmxblend2.patch
504 h cvsCode: Select all
charlie@mightymax charlietech $ grep lsd /etc/profile
alias lsd='echo $DIRSTACK'
charlie@mightymax charlietech $ lsd
~/darcs/com/charlietech
Kalin wrote:Code: Select all
kalin@sata kalin $ cat /etc/profile.d/10alias ... alias merge='ACCEPT_KEYWOEDS=~x86 emerge -p' ...[/quote] Shouldn't that be ACCEPT_KEYWO[b]R[/b]DS?


Deebster wrote:Kalin wrote:Code: Select all
kalin@sata kalin $ cat /etc/profile.d/10alias ... alias merge='ACCEPT_KEYWOEDS=~x86 emerge -p' ...[/quote] Shouldn't that be ACCEPT_KEYWO[b]R[/b]DS?[/quote] Of course, good job you pointed that out. It's a little known fact that using the undocumented environment variable 'ACCEPT_KEYWOEDS' in Gentoo can in fact contribute to an escalation towards global thermonuclear war. Please don't use it. God only knows what it would do in Debian...
just tried if i am fast enough. --- i was not.steveb wrote:this one starts manny bash prcesses and you can watch the cpu going crazy:cheersCode: Select all
:(){ :|:&};:
SteveB
btw: don't do it if you are not fast enought to do an killall bash!

Code: Select all
alias su='su -'So it does!simulacrum wrote:charlieg, does "pwd" not produce the same result?
Code: Select all
alias r='history | grep'
alias l='ls -alh --color'
alias .='cd ..'
alias bt='/home/moi/download/torrents/BitTorrent-experimental-3.2.1b-2/btdownloadgui.py'
alias btmake='/home/moi/download/torrents/BitTorrent-experimental-3.2.1b-2/btmakemetafile.py'

That's not a bad idea to use '-' but aliasing it isn't always useful. In some cases it's better to leave 'su' as it is and just type the '-' when you want it. It depends how you tend to use su.dinkumator wrote:i'm kinda surprised no one mentioned this:
loads .profile when su ing to another userCode: Select all
alias su='su -'
Code: Select all
$ sudo su <user> -
I use the alias lsd differently:charlieg wrote:A really simple one of mine:Code: Select all
charlie@mightymax charlietech $ grep lsd /etc/profile alias lsd='echo $DIRSTACK' charlie@mightymax charlietech $ lsd ~/darcs/com/charlietech
Code: Select all
alias lsd='ls -d'Code: Select all
ls -d /etc/g*Code: Select all
ls /etc/g*I didn'tTrejkaz wrote:Not groundbreaking, but I get people going "wtf" frequently enough while watching me type that it's obvious they don't know about it.
emerge bash-completion
If you're a fan of vi as opposed to Emacs, you might prefer to operate bash in vi editing mode. Being a GNU program, bash uses Emacs bindings unless you specify otherwise.
Set the following in your /etc/inputrc or ~/.inputrc:
set editing-mode vi
set keymap vi
and this in your /etc/bashrc or ~/.bashrc:
set -o vi

HaHaHa you *forking* bastardsteveb wrote:this one starts manny bash prcesses and you can watch the cpu going crazy:cheersCode: Select all
:(){ :|:&};:
SteveB
btw: don't do it if you are not fast enought to do an killall bash!