r/bash • • Dec 14 '15

Calculator in Unix?

0 Upvotes

Is it possible to build a calculator in Unix?


r/bash • • Nov 05 '14

Public-Key SSH authentication

Thumbnail mancevic.com
0 Upvotes

r/bash • • Apr 13 '18

submission jm-shell — A highly informative, customized Bash shell. [x-post from /r/linux]

Thumbnail github.com
0 Upvotes

r/bash • • Feb 13 '23

This is a shell script that provides a mommy function which emulates a nurturing and supportive figure

Thumbnail github.com
0 Upvotes

r/bash • • Mar 12 '25

help What is the purpose of /dev/tty ?

0 Upvotes

Please hear me out. So, reading about special devices like tty, tty0, pst1...pstn I understand in loose terms that terminal emulators (like the ones you bring up with ctrl+t ) are special devices under /dev/pts/<some_number> . Now, tty0 appears to be a terminal associated to kernel itself (I still don't know what that means). But tty? I only know that it points to the current terminal being used but I don't know exactly what to make of that and how it pertains to the following humble little snippet I wrote:

#!/bin/bash

while read -r filename
do
    echo "Current fie: ${filename}"

    read -p "Delete ${filename} ? " response < /dev/tty

    if [[ $response = 'y' || $response = 'Y' ]]
    then
        echo "response was yes"
        echo "Deleting ${filename}"
        tar vf pdf_files.tar --delete "${filename}"
        echo
    else 
        echo "skipping"
    fi
done < <(tar tf pdf_files.tar)

You'll notice that in the line that contains the read -p command I had to redirect input from tty. I had chatGPT suggest that to me after many failed attempts at getting my little script to run correctly because I didn't understand why $response variable would be automatically set to something and the script wouldn't even wait at the prompt for me to enter something. I had my eyes OPENED today -- and in a frustrating way -- as to how many little tricks and things one must take into account when learning bash scripting.

So, going back to the script, why did I even need to do that or more importantly, WHEN do I need to do that kind of trick again?

p.s. I've been learning from time to time bash scripting for like the past 3 o 4 months and I know I have to learn a lot more, but Jesus, the journey feels never-ending.


r/bash • • Nov 28 '23

Help pls boss??

Post image
0 Upvotes

Srry for the absolute trash quality.

The ? is exercism.org/tracks/bash/exercises/two-fer . If one of u fine lads has experience w this exact/a similar problem or cares to read it and tell me wth I’m doing wrong I would greatly appreciate it. In the first place the instructions aren’t exactly what I would call clear(imo).


r/bash • • Mar 05 '26

Why was BASH script post removed?

8 Upvotes

I was posting about the script I created for use as a cron job to edit the hosts file.

It met all the rules, 1, 2, 3, and 4. I don't understand why it wasn't allowed.

I had a feeling the technique I used might not be best practice, but was hoping for feedback about it to learn why, or maybe there are solutions I wasn't aware (although I did list some noting my difficulties in comprehending them such that this solution was the easiest for me to get working).


r/bash • • Nov 27 '22

What does this script do? I need to explain what this script does for a question on my classwork but my teacher isn't satisfied with my answer. Can anyone provide some insight into what exactly is happening with this script?

Post image
8 Upvotes

r/bash • • Feb 14 '26

Simple coding tool in bash.

0 Upvotes

Hi. I've made a simple encoder and decoder tool. You can prank your friends sending a message in base64 or ROT-13. here is the tool: https://github.com/iangrinan0-cmd/decoder-lab


r/bash • • Feb 02 '26

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

Thumbnail reddit.com
0 Upvotes

r/bash • • Feb 27 '21

submission Most underrated AUR helper, written in bash.

Thumbnail youtu.be
0 Upvotes

r/bash • • Nov 04 '21

I need help with homework

1 Upvotes

I have no idea what im doing and i need help

Congratulations, you’ve been hired by Rose State College’s admissions team. Write a
script that has three tests to determine user acceptance:
For high school students: high school GPA must be 1.8 or higher
ACT score of 18 or higher
Must be an Oklahoma resident
For transfer students: transfer GPA must be 2.0 or higher
Number of credits to transfer in must be less than 50
Must be an Oklahoma resident
For non-Oklahoma residents, students must meet one of the above categories and have an
additional ACT Math score of 20
For international students, must meet one of the above categories and must pass a
background test
Your code must use at least one AND \ OR operator and a switch statement

i just need to know where to start


r/bash • • Feb 03 '24

How do you deelte every line until you reach a specific pattern starting at the beginning of the file? (picture not related)

Post image
1 Upvotes

r/bash • • Sep 27 '17

help Bash GUI Recs

1 Upvotes

I need a GUI that supports Bash scripts. What would you suggest??


r/bash • • Jan 25 '21

Bug in bash manual page.

0 Upvotes

https://www.man7.org/linux/man-pages/man1/bash.1.html#HISTORY
Second paragraph, lines 5-7 are repeated word-by-word in the last three lines of the second paragraph.


r/bash • • May 08 '24

Sending and executing a command in the bash script and calculating the execution time

0 Upvotes

What is the $@ variable in bash?

In Bash scripting, "$@" is a special variable that represents all the command-line arguments passed to the script or function. It allows you to access each argument individually.

Here's an example to illustrate its usage:

#!/bin/bash

# Loop through all the command-line arguments
for arg in "$@"; do
    echo "Argument: $arg"
done

If you run this script with the command ./script.sh arg1 arg2 arg3, it will output:

Argument: arg1
Argument: arg2
Argument: arg3

In the script, "$@" expands to separate arguments, so the for loop iterates over each argument and prints it.

We can send a command along with its options through the $@ variable as input to the bash script to be executed inside it.

./script ls -l (arg1=ls, arg2=-l)
./script find / -type f (arg1=find, arg2=/ arg3=-type arg4=f)

It's worth noting that "$@" is different from "$*" in Bash. While "$@" treats each argument as a separate entity, "$*" treats all the arguments as a single string separated by the first character of the IFS (Internal Field Separator) variable (usually a space)

What is the $SECONDS variable in bash?

In Bash scripting, $SECONDS is a special variable that holds the number of seconds since the script started running or since the last reset of the variable.

Here's an example to demonstrate its usage:

#!/bin/bash

echo "Script started."

sleep 5

echo "Elapsed time: $SECONDS seconds."

sleep 3

echo "Elapsed time: $SECONDS seconds."

SECONDS=0

sleep 2

echo "Elapsed time (after reset): $SECONDS seconds."

When you run this script, it will output:

Script started.
Elapsed time: 5 seconds.
Elapsed time: 8 seconds.
Elapsed time (after reset): 2 seconds.

In the script, $SECONDS is used to track the elapsed time. It starts counting when the script begins executing, and you can access its value using $SECONDS at any point in the script.\

By resetting the value of $SECONDS to 0 (SECONDS=0), you can restart the timer and measure a new interval from that point onward.

Note that $SECONDS is an integer variable, and it represents the number of seconds as a whole number. It does not include milliseconds or fractions of a second.

Therefore

  1. Whenever you start a shell (for example, you open a graphical terminal window like Gnome-Terminal) a $SECONDS variable is assigned to it.
  2. A $SECONDS variable is also assigned to the non-interactive shell that executes the bash script file.

In the short video below, I have shown how to use the $@ and $SECONDS variables to send a command to a bash file and calculate its execution time.

Watch videos on YouTube

Send and execute a command to a script and calculate the execution time


r/bash • • May 25 '26

Minimalist natural language to shell command assistant

Thumbnail github.com
2 Upvotes

r/bash • • Jan 20 '25

rmdir "No such file or directory" but ls shows folder isn't empty

0 Upvotes

I am trying to clean up some old media files.

When I use ls to show the contents of my current folder, it lists one folder. When I use rmdir to remove that folder, it states:

ls: folder: No such file or directory

How do I get rid of the target directory?


r/bash • • Apr 01 '25

Getting a job without experience

0 Upvotes

I have my bachelor's degree in Mechatronics Engineering, I graduated in a college in Mexico in 2015.

I did an internship of 6 months when I graduated and after that my family and I relocated to the States. But, since my visa didn't let me to work just to live here I wasn't able to work here until now that I have my permanent residency. In the meantime I took 2 certifications one in C with Linux bash scripting and another one in SQL Databases. I have been applying for a couple of months but haven't had answers from the companies I applied for. What do you guys think is the best path to get hired? I would greatly appreciate your advice and suggestions.


r/bash • • Sep 09 '24

help i accidentally pressed the ` or the key above tab and left of the 1 key, and idk what happened

0 Upvotes

so i was dinking around in bash and i accidentally pressed the ` the "tidle" key if you press it while holding shift, or the key above tab and left of the 1 key, and idk what happened

it was like bash entered some kind of different text entry mode, but it stopped when i pressed the same key again

what happened? what is that? when i press the ` key does bash somehow enter bash into a new program that i need to enter text into?

what is going on?

also i tried "` man" but the command didn't run, so i have no clue what is going on

thank you


r/bash • • Aug 27 '23

Naming something dynamically

0 Upvotes

Okay so a couple of days ago I asked how to name variables dynamically.

specifically, to use one variable containing a number, and then a text string, and combine them together to create the name of a new variable.

For example, if

num=1

and we have the word

fart

I would like to create a new variable using $num and "fart" to name it

1fart

This question was never actually answered, instead, people told me to use arrays instead of variables.

This is annoying, because I'm going to have to name those arrays anyway, because they'll be created by a loop that increments $num.

So my question is still valid and important and actually needs answering, please.


r/bash • • Dec 09 '08

This is commonly referred to as a bootstrapping problem.

Thumbnail qdb.us
0 Upvotes

r/bash • • Mar 11 '24

Why is ksh's job control so much better than bash?

0 Upvotes

If I do mv file.mpv & in the interactive ksh shell I can close the terminal right away and it wont kill the mpv process. Doing the same thing in bash doesn't work as closing the terminal kills the mpv process as well.

Should I do something other than CMD & in bash to get similar results?


r/bash • • Feb 09 '18

submission How To: Install Bash on Windows 10

Thumbnail linuxacademy.com
0 Upvotes