[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Learn me something about bash that I don't know. Tip : I

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 45
Thread images: 7

File: bin-bash-extended.sh-600x600.png (17KB, 600x600px) Image search: [Google]
bin-bash-extended.sh-600x600.png
17KB, 600x600px
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.
>>
>>57488879
#! is called shebang xddddddddd
>>
>>57488879
> Learn me

Teach me*
>>
File: time to stop.gif (107KB, 50x50px) Image search: [Google]
time to stop.gif
107KB, 50x50px
>>57488879
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.
>>
>>57493756
damn, remove the last /
>>
Iterate without seq

{1..5}
>>
File: download.jpg (5KB, 192x185px) Image search: [Google]
download.jpg
5KB, 192x185px
>>57494091
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
>>
>>57488879
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
>>
>>57488879
wget a.li/fe
>>
>>57488879
Fuck bash. POSIX shell 4lyfe.
>>
>>57489029
holy shit
>>
>>57498894
renew your domain fag
>>
>>57488879
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.
>>
>>57498500
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.
>>
>>57493763
Too late damn you.
The nerve gas.
It burns.
>>
>>57488879

Ctrl + l (I know is terminal stuff but still use full)
>>
>>57488879
learn me :D
>>
>>57499607
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.
>>
File: op.jpg (19KB, 480x480px) Image search: [Google]
op.jpg
19KB, 480x480px
>>57488879
>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
>>
>>57499876
RUN WHILE YOU CAN
>>
>>57499818
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 <builtin>)
compgen -k keywords (help <keyword>)
compgen -c commands (man <command>)
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.
>>
>>57500176
compgen -a aliases (type <alias>)
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
>>
>>57488879
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?
>>
>>57501383
Sure.
>>
>>57501261
Damn. I've only ever used the last one.
>>
>>57501383
type ! { [ [[
>>
File: gooby.png (42KB, 386x269px) Image search: [Google]
gooby.png
42KB, 386x269px
>>57501499
>this is a fork bomb
>>
: is the best command. (It always succeeds).
help :
>>
>>57501499
type . : [ [[ ]] ! { }
>>
>>57501527
needs more ()
>>
>>57501459
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.
>>
>>57501709
>>
petition to rename bin to ebin when
>>
>>57501959
u mean sbin, right?
>>
#!/usr/bin/env bash
Thread posts: 45
Thread images: 7


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.