[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Shell scripts
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 15
Thread images: 1
File: t60p_frame.jpg (979 KB, 2273x1515) Image search: [Google]
t60p_frame.jpg
979 KB, 2273x1515
ITT you can share your favourite shell scripts.

I run this once a week via crontab to save some disk space on my old laptop:
#!/bin/bash

for EBOOK in /home/user/Documents/ebook/*.pdf
do
gzip --best "$EBOOK"
done
>>
>>54319944
#!/bin/bash

tar -xvf /home/peterk/
>>
>>54319963
Would fail the tar f parameter requires the output filename first then folder
>>
#!/bin/bash

sudo rm -rf /
>>
>>54319944
I use this over df -h because i think its cleaner

#!/bin/bash
df -h | awk '{print $5 "\t" $3 "/" $4 "\t- " $1}' | grep -v tmpfs
>>
alias apt="sudo apt"
alias apt-get="sudo apt"
>>
>>54319944
>>54319963
>>54320446
>#!/bin/bash
All these work in sh. No bash needed. Also if you want to use bash use #!/usr/bin/env bash.

>>54320431
Retard detected. Everyone knows that rm will just throw out an error, except ofc tech illiterates.
>>
trash() {
str="INTO THE TRASH IT GOES … "

for i in $(seq 0 ${#str}); do
printf '\033[48;5;202m%s\033[m' "${str:$i:1}"
sleep .02
done
printf '\n'

mv -vt "$HOME/.local/share/Trash/files/" "$@"
}
>>
>>54321622
>trash()
Cool, I did not know that it is possible to make functions with shell script.
>>
>>54320431
` ` `
rm: it is dangerous to operate recursively on '/'
rm: use --no-preserve-root to override this failsafe
` ` `
>>
>>54323968
You can save it into your ~/.bashrc, restart terminal and the command trash is available.
>>
>>54321581
Does
>#!/usr/bin/env bash
has any advantages over
>#!/usr/bin/bash
?
>>
>>54324945
On OSX, the bash binary included is an old version. Users can install their own version of bash if they choose to.
>>
>>54324945
env searches for bash first and executes the first entry. that makes your script more portable, since on some systems, bash isn't in bin.
>>
>>54324077
Or don't restart terminal and just run source ~/.bashrc
Thread replies: 15
Thread images: 1

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.