Questions tagged [bash]
Bash is a free shell for Unix-like operating systems from the GNU Project.
11,722
questions
1
vote
1
answer
3k
views
whereis does not return anything
I want to know where my jupyter notebook executable is located. Which one is my python environment using.
So I type
>whereis jupyter
in my terminal. But it returns nothing. When I do the same ...
1
vote
1
answer
84
views
How does bash alias understand "$@"?
I am trying to write an alias to do 2 things
$alias cde='cd "$@" && echo'
but for some reason when I call it with
$cde test
test
all that happens is it echos test:
It looks like my ...
2
votes
3
answers
738
views
How to append a string to a bash command line?
I am sure this is a recurrent question but I failed to find one that had an answer that would fit my problem.
What I want to do is something like this:
alias disexit = " & disown & exit"
...
2
votes
1
answer
6k
views
Running multiple rsync executions in script
I'm trying to run multiple rsync commands from a bash script but only the first one fires. I've tried linking the commands with && and ; but neither work.
#! /bin/bash
rsync -ahPr --delete-...
1
vote
0
answers
3k
views
Use nginx to invoke a script
I want to use a specific URL to invoke a maintenance script (related to my other question). I don't want to have to manage this maintenance script as a service/server because it will usually only be ...
4
votes
1
answer
2k
views
ssh is stuck at sending command, but login without a command works
I am able to ssh to machine xyz:
$ ssh xyz
mitchus@xyz's password:
Last login: Fri Sep 1 12:37:10 2017 from 192.168.1.23
mitchus@xyz:~$
but I can't scp to it, nor can I send a command via ssh. ...
5
votes
3
answers
380
views
How do I abort building the list for tab completion without losing the command?
some_very_long_command_line --arg1 --arg2=555 --arg4 ... ... ... && <now Tab pressed>
(Now it works. I want to cancel before the following message)
Display all 6936 possibilities? (y or ...
3
votes
1
answer
74
views
Bash macro that does not let me "git push" after 3am
Alright, so basically I've managed to cause problems by pushing very late at night. How could I change git push (without forcefully changing git write-protected files) to need "Are you sure?" dialog ...
0
votes
2
answers
819
views
Modifying a file with sed using redirection
this works as I expected:
$ cat in
abc 123
$ sed -E -i .bk 's/[0-9]+/(&)/' in
$ cat in
abc (123)
$ cat in.bk
abc 123
But not this:
$ cat in
abc 123
$ sed -E 's/[0-9]+/(&)/' in
abc (123)
$...
0
votes
0
answers
2k
views
Automating web page login with bash script
I have been looking to write a bash script to automate login on an internal company website that is used as a Ping Board to monitor a network of IP connected cameras. I am pretty new to bash scripting ...
2
votes
1
answer
251
views
How to quit reverse-i-search without moving the cursor?
In Bash, I often encounter below situation when doing reverse-i-search (using emacs keybinding in Bash):
(reverse-i-search:ccc) aaa bbb |ccc ddd
I am in the middle of reverse-i-search for 'ccc', and ...
6
votes
1
answer
3k
views
Bash variables with space (directories)
I'm trying to echo all of the files in /foo while preserving the spaces within listed directories. Currently, a directory titled "bar1 bar2" will echo out as /path/to/foo/bar1/ then /bar2 then file....
2
votes
1
answer
1k
views
Recursively find all subfolders' files and symlink them with their containing folder's name
Hopefully such a thing is possible, I would like to scan all the files in the subfolders of
/home/user/source/
and create symlinks to these files in a different folder with a different file ...
0
votes
1
answer
320
views
Script executed as other user from root creates files in wrong directory (root)
I'm running a bash script from a root perspective which then starts a program in the script
su -c "sh /home/user2/script.sh" -m user2
The problem is that the program started by this script, while ...
5
votes
3
answers
11k
views
Moving files and renaming when a file exists in destination folder
I used to do this with Hazel. I'd move everything from ~/Downloads/ to ~/Downloads/Archive/Pictures, ~/Downloads/Archive/Documents, ~/Downloads/Archive/Videos etc. based on the file extension, and ...
0
votes
1
answer
216
views
What are pros and cons of using && or || versus if/elif/else?
In bash, I can make a test condition utilize && and/or || rather than an if/elif/else block.
When applicable, I use tend to use && and/or || rather than building out an if block. Are ...
2
votes
1
answer
572
views
rsync: large exclusion list adding 10 hours to sync
I have had an rsync backup script running on a Centos 6 box that has been syncing ~410gb of data from a local (LAN) server over a gigabit connection. This script runs hourly, and if there are no new ...
0
votes
1
answer
1k
views
SSH Port forwarding with Bash on Windows
I've recently migrated from Mac OSX to Windows 10 and am getting an error when attempting to mirror the ssh local port forwarding setup in my ~/.ssh/config file as follows:
host myhost
HostName ...
0
votes
0
answers
2k
views
Using 'cat' from local file to remote file while ssh'd into server
If my file something.txt is on a local client and I am ssh'd into a remote server, can I not:
cat /path/on/local/client/something.txt >> /path/on/server
I was able to do what I wanted via:
...
0
votes
0
answers
2k
views
cannot create temp file for here-document: No space left on device [duplicate]
I have debian on my VPS server and suddenly it stops to work. It says that
root@vps-16746:/# cd ~
root@vps-16746:~# mkdir 3
mkdir: cannot create directory `3': No space left on device
If I press TAB ...
7
votes
1
answer
12k
views
Using rsync on WSL (Bash for Windows 10) for incremental backups
I was an avid user of Linux for many years but switched to Windows. One thing that I have always missed is using rsync to make incremental snapshots for the purposes of backup. You use a command like ...
2
votes
2
answers
917
views
Override bash command and be able to pass it as a param to xargs
I'd like to be able to pass in a modified grep command to xargs. I am overriding a command with a function in bash similar to Is it possible to override the command line's built in "cd" ...
1
vote
4
answers
95
views
Rotate odd numbered pictures
I write a little script to rotate all the odd numbered pictures of a directory but i can't get it to work. Here is the code.
#!/bin/bash
count=1
for picture in `ls -v *.png`
do
if ["$picture" ==...
1
vote
1
answer
2k
views
How to call a function inside a bash script on Raspbian?
I have this script that I use on Centos for many years. I am calling the same script on Raspberry Pi now and I get this error:
/media/Backups/backup_all.sh: 2: /media/Backups/backup_all.sh: source: ...
1
vote
1
answer
2k
views
Bash on Ubuntu on Windows logging bash sessions
My professor wants us to log our bash sessions by submitting a log of our bash (terminal) session. I am using Bash on Ubuntu on Windows with the Windows 10 Creator's Update.
When using the command &...
2
votes
1
answer
347
views
Why does du -sk fail to report the size of a fifo?
There is a concept in bash called process substitution. You can run a command and use the output as a file.
e.g.
$ cat -n <(seq 3|tac)
1 3
2 2
3 1
I am curious why the ...
3
votes
1
answer
16k
views
bash: git: command not found
When I attempt to run git --version (or any git command) in git-bash, I get the following error:
bash: git: command not found
In Windows, I have C:\Program Files\Git\cmd in my Path system variable.
...
1
vote
2
answers
304
views
How to terminate a cli app when stdout contains a certain string?
I've got a command line app that outputs lots of information to stdout.
How can I terminate the program when stdout contains a certain string?
e.g. something like:
my_program | ...
4
votes
1
answer
24k
views
How do I fix a cipher mismatch issue with sftp?
I'm running into an issue where a server was upgraded to RHEL 6.5, and we have automated bash scripts on an RHEL 5.9 install that connects through sftp and ssh commands.
Now, the new server only ...
0
votes
1
answer
117
views
Add Q + column number as header for x number of columns
I have a number of tab delimited files, for which the script user will be choosing one based on a particular threshold. All files have different amount of columns (1 to n depending on a previously ...
0
votes
0
answers
151
views
Remove / reset permanent rbind mounts on Bash on Ubuntu for Windows (10)
Apparently Bash on Ubuntu for Windows (10) cannot be used to run chroot environments for testing purposes.
I tried to setup a Funtoo chroot-installation and it actually worked all fine,
until I ...
96
votes
3
answers
66k
views
Does rm -rf follow symbolic links?
I have a directory like this:
$ ls -l
total 899166
drwxr-xr-x 12 me scicomp 324 Jan 24 13:47 data
-rw-r--r-- 1 me scicomp 84188 Jan 24 13:47 lod-thin-1.000000-0.010000-0.030000.rda
drwxr-...
0
votes
0
answers
304
views
MDADM RAID 6 creation on debian/openmediavault
I installed openmediavault on my san, which is buggy and I wouldn't be using it unless it was the only one that installs on it since it's older. Im bypassing the UI and am creating the RAID device, ...
1
vote
2
answers
5k
views
Bash script to open SSH reverse tunnel at startup
I am trying to run a script at startup on a Debian Jessie machine, among other things it creates a SSH reverse tunnel.
The thing is that I have put this script at if-up and either in rc.local to ...
1
vote
2
answers
3k
views
How to increase file numbers in a for loop (ffmpeg)
I try to get a solution to make screens from videos with ffmpeg.
Most of the found examples involve decoding the whole video to get the images. This is - for larger videos - rather slow.
A better ...
8
votes
1
answer
2k
views
Bash partial glob expansion
I have a question similar to this one, but different: I want bash to use a glob expansion in auto-completion, if possible. For example, I would like
$ ls *2.<TAB>
To give me:
$ ls mydoc2.
...
9
votes
3
answers
7k
views
Run mplayer from bash in background without extra bash
I would like to watch a movie with mplayer from bash in the background, like I do with all programs and there has never been any problems:
mplayer Kick* &
if you'd like to see Kickboxer, for ...
0
votes
2
answers
868
views
Link in HTML cannot execute .sh file
I have an index.html with a link which must remove all *.zip from /mnt/sda1/down.
When I click on the link it start to download not to execute the sh script.
Here is the index.html and the sh ...
2
votes
1
answer
796
views
ypchsh not changing to some shells
I am currently in bash but I want to change my shell to tcsh. I used ypchsh, entered my password when prompted and then changed the login shell to /bin/tcsh. And it seemed like it worked because I get ...
11
votes
6
answers
25k
views
Is there a way to escape single-quotes in the shell?
E. g. I want to say
perl -e 'print '"'"'Hello, world!'"'"', "\n";'
Is there a less awkward way to do it, e. g. escaping single-quotes?
Yes, I know that I can write
perl -e 'print q[Hello, world!], ...
0
votes
2
answers
1k
views
scheduled bash script : how to transfer a file from HTTPS web server to FTP server
I need to automate a task that downloads an XML file on a https:// web server (with authentification) and upload it on an FTP server (with another authentification).
So I think the best approach is ...
3
votes
2
answers
2k
views
Adding Bash on Ubuntu on Windows 10 to Explorer Context Menu (Issues)
I have successfully added the Bash on Ubuntu prompt to the context menu by adding the following registry keys
[HKEY_CLASSES_ROOT\Directory\shell\bash]
@="Bash Here"
[HKEY_CLASSES_ROOT\Directory\shell\...
6
votes
3
answers
12k
views
How can I start new window in the same screen session automatically?
I read How can I start multiple screen sessions automatically?, but I don't understand the first accepted reply:
screen -dmS "$SESSION_NAME" "$COMMAND" "$ARGUMENTS"
In my case I need to ...
0
votes
1
answer
383
views
Why isn't `uptime -s` output constant?
I have 6 Raspberry Pi 3. A Bash script works on 5 of them, not on 1.
I use uptime -s > file1 [or -p, tried both] then later I cp file1 file2 at the end of my script.
The next time I run the ...
4
votes
1
answer
2k
views
Tab completion for command arguments fail in Cygwin due to `.exe` extension
Is there a configuration option in Cygwin so that when Bash completes the name of the command, the filename’s .exe suffix is ignored (not included)?
Explanation of the problem
When using tab ...
4
votes
2
answers
8k
views
Confused about jq parser
I'm trying to use jq parser in my bash scripts and I'm confused about how it works, could someone explain what am I doing wrong?
Here is the original file from the external service and I need to get ...
1
vote
3
answers
2k
views
Crontab + .sh + php
I'm trying to call a shell script every 5 minutes, witch executes php file under root.
# crontab -l
*/5 * * * * /home/regularuser/call.sh
permissions:
-rw-rw-rw- 1 root root 162 Jun 6 23:...
3
votes
1
answer
204
views
Manage SFTP web project on multiple remote web hosts at the same time
I have already done some research but unfortunately I could not find a solution that I could do in my case.
So, work on LAMP stacks and for a customer there is the problem of having to work ...
2
votes
1
answer
401
views
How to pipe from clipboard to firefox?
This might be a amateur question. But I have a problem with piping.
I want to pipe my clipboard to firefox via the terminal.
In my clipboard is a url like https://www.google.com. Than I want open ...
2
votes
1
answer
761
views
First match in wildcard linux
I have the below part in my bash script:
for file in $(cat $csmtdirpath/$images_to_remove); do mv -v -f /$currentimages/*"$file"* $oldimages >> "$log_image_to_move" 2>> "$...