Learn me something about bash that I don't know

Learn me something about bash that I don't know.
Tip : I already know a lot about it.
Will be back tomorrow to check if you brang me something useful.

NB:
- bash, not sh,zsh,ksh etc
- bash, not binaries invoked/combined from it

You can use it to cd into your code directory. I wrote a script to do just that.

>learn me something
>brang me something
You would be better off improving your knowledge of the English language.

#! is called shebang xddddddddd

> Learn me

Teach me*

at the top of your .bashrc goes this:
shopt -s autocd
Now you can type
/tests/this/
If it is a file, then execute it like before. If it is a folder, then you cd into it.

damn, remove the last /

Iterate without seq

{1..5}

didn't know seq existed

for accepts { ...; } instead of do ...; done but while, until, and if don't.

for i in {1..10}; { echo $i; }

You can use for without in list, it acts like in "$@"

f() {
for a; do
echo $a
done
}

f {1..10}

find /var/www/html/ -type f -name "*.php" -exec grep -Hn "base64_" \;

find dem comps

Powershell is better than bash

Some bash fun facts:

>for loops accept any compound command, not just brace groups:
f() for i; do echo "$i"; done

>some builtin names have special parsing rules that functions of the same name will inherit
$ foo() { echo "$*"; }
$ foo a=(b)
bash: syntax error near unexpected token `('

$ declare() { echo "$*"; }
$ declare a=(b)
a


>You can create a file called /bin/bash$'\r' as a wrapper script to have it automatically run scripts with Windows CRLF line terminators

wget a.li/fe

Fuck bash. POSIX shell 4lyfe.

holy shit

renew your domain fag

Daily reminder bash aliases or functions may invoke binaries invoked/combined from it, so in such case are explicitly forbidden.
So it looks like its bash builtins and keywords.
Daily reminder builtins may also have an associated binary, for example
type -a printf
and in such a case, would also be excluded.

Fun fact: The local builtin does the same thing as declare, but will define "local" variables only recognized by a function and it's children.
See help local

Set $EDITOR to your favourite terminal editor (vi, emacs, w/e), and use ^x + ^e to edit whatever is in your prompt, will get run on exit.

Too late damn you.
The nerve gas.
It burns.

Ctrl + l (I know is terminal stuff but still use full)

learn me :D

Ran muh linux mint for months like that, and it werked fine, before I realized there's "update-alternatives"
sudo update-alternatives –config editor

Also, there's FCEDIT for the very cool fc builtin.

>learn me
>>learn me
>>>learn me
>>>>learn me
>>>>>learn me
>>>>>>learn me
>>>>>>>learn me
>>>>>>>>learn me
>>>>>>>>>learn me
>>>>>>>>>>learn me
>>>>>>>>>>>learn me
>>>>>>>>>>>>learn me
>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>>learn me
>>>>>>>>>>>>>learn me
>>>>>>>>>>>>learn me
>>>>>>>>>>>learn me
>>>>>>>>>>learn me
>>>>>>>>>learn me
>>>>>>>>learn me
>>>>>>>learn me
>>>>>>learn me
>>>>>learn me
>>>>learn me
>>>learn me
>>learn me

RUN WHILE YOU CAN

fuck. it's two dashes.
--config

Fun with bash:
compgen -a will list you're aliases
compgen -A function will list functions (-a is already taken)
compgen -b lists builtins (help )
compgen -k keywords (help )
compgen -c commands (man )
Play with the whole shebang:
compgen -abckA function | grep foo
and maybe compgen -c | less because there's quite a few.

You wanna learn something new? zsh is better than bash.

compgen -a aliases (type )
compgen -A function ( -f is for file)

-a alias
-b builtins
-c commands
-d directory
-e exported shell variables
-f file
-g groups
-j jobs
-k keywords
-s service
-u userAlias names
-v shell variables

The following lines are all equivalent:
> >file echo hi hello
> echo >file hi hello
> echo hi >file hello
> echo hi hello >file

>man [
is this actually allowed?

Sure.

Damn. I've only ever used the last one.

type ! { [ [[

>this is a fork bomb

: is the best command. (It always succeeds).
help :

type . : [ [[ ]] ! { }

needs more ()

There's really no reason to use anything but the last one. This is more like something to look out for because it might happen in your script without you wanting it to.

...

petition to rename bin to ebin when

u mean sbin, right?

#!/usr/bin/env bash