Questions tagged [bash]
Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead. For shell scripts with errors/syntax errors, please check them with the shellcheck program (or in the web shellcheck server at https://shellcheck.net) before posting here.
26,711
questions
1
vote
3
answers
385
views
recursively remove newline from directory names
I have few directories whose names looks like the following:
I want to remove the newline from the end recursively.
I checked Recursively rename directories
I also checked Remove newlines in file ...
1
vote
2
answers
3k
views
Automatically entering ssh password from Busybox terminal
I currently am attempting to reboot a modem via ssh using a bash script. For reasons I don't feel like explaining, I NEED to start on an ubuntu server computer, ssh into a setup running busybox 1.21.1 ...
0
votes
2
answers
30
views
Bash script to compress nested directories not traversing correctly
I have a folder structure that looks like this:
0/1/2 and the numbers goes from {0..9}
I tried writing a bash shell script so that I can compress each of the folders like this:
#!/bin/bash
for i in {0....
0
votes
2
answers
41
views
variable with hyphen in bash script
db1="community-service-data"
db2="ecomm-data-test"
drop_db="DROP DATABASE ${db1}"
sudo -u postgres -S /bin/bash -c "psql -U postgres -d postgres -c \"${drop_db}...
0
votes
1
answer
43
views
Command not found on shell opening
Every time I open the shell, the first line on the terminal is "bash: n: command not found". I tried to look at /etc/profile, ~/.bashrc, ~/.profile and ~/.bash_profile but I was not able to ...
0
votes
1
answer
3k
views
Installation of latest version R for linux
First I typed
sudo gedit /etc/apt/sources.list
after that I got one sources list then I typed
deb http://cran.rstudio.com/bin/linux/debian wheezy-cran3/
then I get the error like this
No command '...
2
votes
2
answers
5k
views
Ping hosts based on filter and return dead or alive
I am trying to create a script that is capable of pinging multiple hosts from a text file in my directory. The hosts are with specific naming conventions and are grouped. E.g in the text fie
10.10.10....
34
votes
3
answers
9k
views
running script with ". " and with "source "
I was wondering if the following two ways of running a bash script
are equivalent?
. ./myScript.sh
source myScript.sh
Are they both running the content of the script instead of running the script, ...
50
votes
5
answers
99k
views
How to execute a shellscript when I plug-in a USB-device
I want to execute a script when I plug in a device in my Linux machine. For example, run xinput on mouse or a backupscript on a certain drive.
I have seen a lot of articles on this, most recently ...
-1
votes
3
answers
64
views
Bash AND operator (&&) causes unexpected token if used within an if statement
I have found && to cause an error in bash when used within an if-statement. I am wondering if anyone has an explanation as to why this occurs and if there is a way to only run command3 if ...
26
votes
2
answers
3k
views
The old ticks vs parentheses issue: confused
Since being corrected many years ago, I switched from backticks to $() for command expansion.
But I still prefer the backticks. It is fewer keystrokes and does not involve the Shift key.
I understand ...
0
votes
2
answers
49
views
How to write an alias or bash script that renames a single file using the same syntax as the `ren` command of Windows?
I am a long-term a Windows user, so I find the syntax of the ren command both simple and convenient:
ren C:\pathTo\myFile\oldFileName.txt newFileName.txt
I want to be able to use the same syntax on ...
-1
votes
1
answer
58
views
when is .bashrc read?
I have been scratching my head trying to figure out why & how my ~/.bashrc file is read :/
I'm connecting to my Debian bookworm server through ssh. It's an interactive login shell.
According to ...
6
votes
1
answer
324
views
Why does redirecting stderr interfere with bash's handling of $COLUMNS and the `checkwinsize` option?
I'm scripting a testing framework in bash and am running into a weird situation.
A couple things I'm doing in this post for illustration purposes:
Adding echo lines to the scripts; these are not part ...
0
votes
1
answer
25
views
view a bunch of text files in the terminal [duplicate]
I've got a bunch of text files and pdfs in a directory.
If I enter
evince *.pdf
..all the pdfs open up in separate windows, I do this quite often.
When I enter
cat *.txt
..was pleasantly surprised ...