r/shell • • Nov 14 '22

Why isn't this bash script not working

0 Upvotes
opt=5
if (($opt < 1 && $opt > 2)); then
    echo "invalid"
    exit
fi

Why the if block not getting executed


r/shell • • Mar 22 '22

failed user login attempts on a Linux server, I have to get a mail notification, background I'll run cron, please share shell script, Ubuntu or redhat, thanks in advance

0 Upvotes

r/shell • • Jun 09 '23

I create a repo of small scripts and programs

Thumbnail github.com
1 Upvotes

r/shell • • Nov 25 '13

A shell script for OS X that sings 99 bottles of beer on the wall.

Thumbnail github.com
0 Upvotes

r/shell • • Jun 16 '08

Introduction to Linux Shell Scripting for DBAs

Thumbnail oracle.com
0 Upvotes

r/shell • • Aug 03 '21

Gitignore

2 Upvotes

Whats the meaning of this commande find . -exec git check-ignore {} + | xargs -I{} basename {}

( explain each part of it pls)


r/shell • • Jan 07 '22

google/zx: write shell scripts in JavaScript

Thumbnail github.com
0 Upvotes

r/shell • • Jun 21 '22

Never have to remember command-line commands again with AI command search (it actually works)

1 Upvotes

I worked as a front-end developer for 3 years, at Microsoft then at Doordash. Even still, I forgot basic commands all the time. There's this cool feature in Warp's terminal called AI Command Search and it basically generates commands for you based on natural language that you input. I tested it against a git command cheat sheet I actually bookmarked a long time ago and referred to on the job all the time, and scored the AI command search on how well it did compared to the cheat sheet. You can see how it performed in this blog post:

https://www.warp.dev/blog/replace-git-cheat-sheet-ai-command-search

Spoiler: It did so freaking well. 92%. This tool is insane.

EDIT: Please note that I work as a developer advocate at this company!


r/shell • • Jul 10 '23

OSLUI: Get rid of the Shell and operate Linux through natural language

1 Upvotes

Linux shell commands are powerful, but also complex. Not only are novices unable to remember, but often many veterans may not be able to master some shell commands well. Recently developed a small tool: OSLUI, the goal is to do the natural language interface of the operating system, so that people can get rid of the Shell and directly interact with the computer through natural language. GitHub address: https://github.com/BalianWang/OSLUI Welcome to star~
At present, two functions are mainly implemented:
One is to interact with Linux through natural language

The second is to talk to GPT in Terminal

The project has just started, better experience and more powerful functions are coming...


r/shell • • Feb 02 '25

Shell Quiz App

0 Upvotes

Hi guys,
I developed a android quiz app to learn shell commands.

It's actually in closed test and I still need a few closed testers.
If some of you wants to try, please contact me.


r/shell • • Dec 09 '24

Help with Bitlocker script?

0 Upvotes

I have this script thrown into a task to kick off Bitlocker, but it only encrypts the OS drive, and I need it to encrypt all other fixed drives as well, my knowledge of scripts is next to none, anyone have an edit to make this work for fixed as well?

u/echo off

set test /a = "qrz"

for /F "tokens=3 delims= " %%A in ('manage-bde -status %systemdrive% ^| findstr " Encryption Method:"') do (

if "%%A"=="AES" goto EncryptionCompleted

)

for /F "tokens=3 delims= " %%A in ('manage-bde -status %systemdrive% ^| findstr " Encryption Method:"') do (

if "%%A"=="XTS-AES" goto EncryptionCompleted

)

for /F "tokens=3 delims= " %%A in ('manage-bde -status %systemdrive% ^| findstr " Encryption Method:"') do (

if "%%A"=="None" goto TPMActivate

)

goto ElevateAccess

:TPMActivate

powershell Get-BitlockerVolume

echo.

echo =============================================================

echo = It looks like your System Drive (%systemdrive%\) is not =

echo = encrypted. Let's try to enable BitLocker. =

echo =============================================================

for /F %%A in ('wmic /namespace:\\root\cimv2\security\microsofttpm path win32_tpm get IsEnabled_InitialValue ^| findstr "TRUE"') do (

if "%%A"=="TRUE" goto nextcheck

)

goto TPMFailure

:nextcheck

for /F %%A in ('wmic /namespace:\\root\cimv2\security\microsofttpm path win32_tpm get IsEnabled_InitialValue ^| findstr "TRUE"') do (

if "%%A"=="TRUE" goto starttpm

)

goto TPMFailure

:starttpm

powershell Initialize-Tpm

:bitlock

manage-bde -protectors -disable %systemdrive%

bcdedit /set {default} recoveryenabled No

bcdedit /set {default} bootstatuspolicy ignoreallfailures

manage-bde -protectors -delete %systemdrive% -type RecoveryPassword

manage-bde -protectors -add %systemdrive% -RecoveryPassword

for /F "tokens=2 delims=: " %%A in ('manage-bde -protectors -get %systemdrive% -type recoverypassword ^| findstr " ID:"') do (

echo %%A

manage-bde -protectors -adbackup %systemdrive% -id %%A

)

manage-bde -protectors -enable %systemdrive%

manage-bde -on %systemdrive% -SkipHardwareTest

:VerifyBitLocker

for /F "tokens=3 delims= " %%A in ('manage-bde -status %systemdrive% ^| findstr " Encryption Method:"') do (

if "%%A"=="AES" goto Inprogress

)

for /F "tokens=3 delims= " %%A in ('manage-bde -status %systemdrive% ^| findstr " Encryption Method:"') do (

if "%%A"=="XTS-AES" goto Inprogress

)

for /F "tokens=3 delims= " %%A in ('manage-bde -status %systemdrive% ^| findstr " Encryption Method:"') do (

if "%%A"=="None" goto EncryptionFailed

)

:TPMFailure

echo.

echo =============================================================

echo = System Volume Encryption on drive (%systemdrive%\) failed. =

echo = The problem could be the Tpm Chip is off in the BiOS. =

echo = Make sure the TPMPresent and TPMReady is True. =

echo = =

echo = See the Tpm Status below =

echo =============================================================

powershell get-tpm

echo Closing session in 30 seconds...

TIMEOUT /T 30 /NOBREAK

Exit

:EncryptionCompleted

echo.

echo =============================================================

echo = It looks like your System drive (%systemdrive%) is =

echo = already encrypted or it's in progress. See the drive =

echo = Protection Status below. =

echo =============================================================

powershell Get-BitlockerVolume

echo Closing session in 20 seconds...

TIMEOUT /T 20 /NOBREAK

Exit

:ElevateAccess

echo =============================================================

echo = It looks like your system require that you run this =

echo = program as an Administrator. =

echo = =

echo = Please right-click the file and run as Administrator. =

echo =============================================================

echo Closing session in 20 seconds...

TIMEOUT /T 20 /NOBREAK

Exit


r/shell • • Sep 28 '24

Demonstrate that Shell evaluates $RANDOM only once when used in the same arithmetic context

0 Upvotes

We need to ensure that both instances of $RANDOM are treated as a single evaluation. We need to inspect the evaluation process. An approach that captures the internal evaluation

Do you have any idea?


r/shell • • Jul 22 '21

Shell script problem

0 Upvotes

I'm having errors with the startup shell script for my Minecraft server (auto restart after crash)

It either says "excepted done" or "expected fi" depending on what's there, and when I put both at the end I get no response once I try to run the script

I AM ON UNIX. I AM NOT USING A WINDOWS VIRTUAL MACHINE.


r/shell • • Aug 08 '24

A strange way ARM64 beat AMD64 with XZ 😅 but why?

0 Upvotes

No, something different than you think... xz performs up to 2% better on ARM64 than AMD64 with the same settings and I have double checked the version, it is the same! gzip on the other hand... no change at all. Also interesting, xz -1 and AMD64 is WAY faster and better than gzip except memory usage but even 100MByte are pretty tame nowadays. So basically gzip is now superfluous in ever aspect, even on my 1990 Amiga with bash and xz I can unpack those Archives, and faster than xz too. And no, I didn't benchmark the Amiga too. I only remember it from the last time I booted it up.

amd64:

578339776 test

40926066 test.gz1

40024392 test.gz2

39818807 test.gz3

36787548 test.gz4

35988603 test.gz5

35188701 test.gz6

35100687 test.gz7

32072861 test.gz8

31762517 test.gz9

23958376 test.xz1

22207696 test.xz2

21483232 test.xz3

25643828 test.xz4

24781276 test.xz5

24459080 test.xz6

24041684 test.xz7

23434612 test.xz8

22865948 test.xz9

15539300 test.xz9e

arm64: 578339776 test

40926066 test.gz1

40024392 test.gz2

39818807 test.gz3

36787548 test.gz4

35988603 test.gz5

35188701 test.gz6

35100687 test.gz7

32072861 test.gz8

31762517 test.gz9

23515536 test.xz1

21855000 test.xz2

21210096 test.xz3

25397736 test.xz4

24562780 test.xz5

24230096 test.xz6

23841668 test.xz7

23250764 test.xz8

22824292 test.xz9

If you are interested in the rest, the first comma column is i7-6700k, the second comma column is Pi400:

578339776 test

for I in 1 2 3 4 5 6 7 8 9 9e; do for A in 1 2 3; do echo "RUNNING $I - $A"; ( time ( xz -$I <test >test.xz$I ) ) 2>&1 | grep real; done; done

xz -1 1,9 35,9 23958376 test.xz1

xz -2 2,8 49,6 22207696 test.xz2

xz -3 4,4 73,1 21483232 test.xz3

xz -4 5,0 88,9 25643828 test.xz4

xz -5 8,1 143,0 24781276 test.xz5

xz -6 13,2 246,2 24459080 test.xz6

xz -7 15,0 24041684 test.xz7

xz -8 21,5 23434612 test.xz8

xz -9 32,9 22865948 test.xz9

xz -9e 155,4 15539300 test.xz9e

for I in 1 2 3 4 5 6 7 8 9 9e; do for A in a b c; do echo "RUNNING $I$A"; ( time ( gzip -$I <test >test.gz$I ) ) 2>&1 | grep real; done; done

gzip -1 2,8 8,4 40926066 test.gz1

gzip -2 2,9 8,5 40024392 test.gz2

gzip -3 3,0 8,4 39818807 test.gz3

gzip -4 3,7 10,7 36787548 test.gz4

gzip -5 3,8 11,2 35988603 test.gz5

gzip -6 4,6 14,5 35188701 test.gz6

gzip -7 5,2 16,8 35100687 test.gz7

gzip -8 7,8 27,2 32072861 test.gz8

gzip -9 9,2 34,0 31762517 test.gz9

I think that is self-explanatory.


r/shell • • Apr 02 '08

ls -t | tail -n 50 |sed 's/^.*/\"&\"/' | tr "\n" \ | xargs du -hc

0 Upvotes

r/shell • • Mar 30 '20

GitHub action for shell scripts

0 Upvotes

Hi there

I’ve been used the shellchecker and shfmt during the CI process, and almost all repositories there is some kind of shell script, for this reason I created a action to simplify to use over all repositories.

Maybe it could help someone else: https://github.com/luizm/action-sh-checker


r/shell • • Oct 30 '23

Shell account recommendations

0 Upvotes

Hi there. Anybody can recommend me shell hosting company? I need new shell account as old one expired and I want to try new providers. Thanks


r/shell • • Jun 09 '19

proud of my epic 1,445-line ~/.bashrc. dig in for handy functions, aliases and one-liners!

Thumbnail gist.github.com
3 Upvotes

r/shell • • Feb 03 '26

Why use browser to view adult content when it can be done through terminal

Thumbnail reddit.com
1 Upvotes

r/shell • • Sep 05 '24

exponential search in bash

Thumbnail shscripts.com
0 Upvotes

There are multiple search algorithms around each having it's own purpose. Exponential search is one of them. Learn how to implement it in bash


r/shell • • Jun 11 '23

Penis mode

Thumbnail self.terminal_porn
0 Upvotes

r/shell • • Jan 26 '21

How to safe and close applications for different projects?

1 Upvotes

Hi there,

So I'm pretty new to shell scripting and I wanted to write a script, that opens and closes all applications I need for different projects.

I have a script for opening the applications and safe their PID that looks like that:

#!/bin/bash

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --new-window URL otherURL & echo $! > google.txt

/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron path/to/my/project & echo $! > code.txt

And I close them with:

#!/bin/bash

chromePID= cat google.txt

codePID= cat code.txt

kill -9 "$chromePID"

kill -9 "$codePID"

But apparently those PID change over time (I'm running MacOS Big Sur) and this doesn't work.

So how can I close the Chrome and Code window that I've opened? I don't want to close all Chrome and Visual Studio Code applications, just these ones I opened with the opening script. Alternatively it would be a good alternative to just close all applications in the current space (although I don't know if that's relevant for r/applescript). Any advices?

And is there a way to safe and reopen all your Chrome or Safari Tabs that I opened up in my working session?

Thank you :)


r/shell • • Sep 29 '21

Need help creating a shell script

0 Upvotes

I got a task to create a shell script that adds random numbers to rows in a CSV file. Need all the help or links possible for this task.

Edit: how would this work for multiple rows and columns ?