Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bash]

Bash is a free shell for Unix-like operating systems from the GNU Project.

0
votes
0answers
12 views

ssh does not quit even after remote host reboots

I am using a command of the form: dd if=/my/block/device | ssh myuser@otherserver "gzip > file.gz" in my script. The block device being copied is very large (17GB). In many cases, I see that even if ...
0
votes
0answers
6 views

Disabling bracketed paste mode also disables the 'p' key?

Since upgrading to 10.13 (I think that was the release), macOS has supported bracketed paste mode. This is extremely annoying, because I frequently find myself getting garbage characters in Bash that ...
0
votes
2answers
21 views

How to check for exit code of the ssh tunnel?

I have a command of the form: dd if=/my/block/device | ssh myuser@otherserver "gzip > file.gz" How to check if the ssh command failed due to connectivity problems? Thanks.
0
votes
1answer
20 views

How to repeat a character N times with printf

I have a function that a pass a string. I want this function to pad this string with * in a line. Lets say I pass foo bar I want it to print something like *************** *** foo bar *** ************...
0
votes
1answer
41 views

Using `ls` to show real name of file owners

Unix users can have their real names listed in /etc/passwd/. The finger command can display the real names. Can ls -l show these real names of file owners next to the files? If ls cannot do this ...
0
votes
0answers
10 views

How do I close a single instance of one application using bash?

I have three instances of RStudio running. Each instance is showing me a project. project1 project2 project3 How can I close one specific project (instance of RStudio) via Bash? I know how to ...
0
votes
0answers
26 views

Lookup-table text replacement in bash

We have weird usernames in our Linux system (like user0001). I would like to pipe results of ls -l through a lookup-table replacement of the weird usernames by their real names. I can make such a ...
0
votes
2answers
31 views

bash prompt messed up on arrow up

I have made some modification to my prompt with use of colors via tput. It looks like now when I try to do an arrow up lookup after few moves up, the prompt is being cut into half, what I mean by ...
0
votes
2answers
20 views

How to display colour text in terminal?

I want to display colour text in terminal(bash shell). Tried with this approach: echo -e "\e[1;31m This is red text \e[0m" But it doesn't change the text colour to red.
1
vote
1answer
20 views

find matched file_ids within the dat files in the directory and copy them to a different directory

I have a file_id = 840920 and I have to pick only the child files that belong to the file_id = 840920. The names of the dat file are different but within all the dat file, the parent file id is ...
0
votes
0answers
12 views

Can omxplayer receive keystroke if started by a service?

Debian w/ systemd. Here my autostart service: [Unit] Description=Autostart After=network.target [Service] ExecStart=/home/pi/bin/videoplayer.sh Restart=on-failure RestartSec=3 User=root Group=root [...
0
votes
1answer
36 views

Bash ignores zip -x arguments [duplicate]

The script below ignores all the -x exclude arguments when run from bash, but it works fine from command line: #!/bin/sh TIMESTAMP=$(date +%u) ulimit -s 65536 WEEK=`date +"%V"` if [ $(($WEEK%2)) -eq ...
0
votes
1answer
27 views

In bash scripts, is the brackets notation better than back-quotes?

When I learnt to write bash scripts, I put the output of a command in a variable using back-quotes, e.g., ALLPDFS=`find . -name \*.\[pP\]\[dD\]\[fF\]` but most of the 'official' scripts (the ones ...
-1
votes
1answer
33 views

Launching a Bash Shell from Powerpoint

Does anyone know of a way to launch a Bash Shell directly from a PowerPoint presentation? I've seen a lot of GOLANG Gophers running code from their powerpoint presentation (or at least I thought they ...
0
votes
0answers
23 views

Cygwin permission problems? Rsync works from command line but not inside a bash script [on hold]

I have a short bash script that runs a few rsync commands. I'm running this script in Cygwin (Windows 10). If I run the rsync commands directly on the cygwin command line, they work correctly (i.e. ...
0
votes
1answer
20 views

How to generate a SHA-256 hash in base64 format from commandline?

How do I generate a SHA-256 hash in base64 format from commandline? I want a piped commands kind of solution.
0
votes
0answers
32 views

Remount USB disk to read-only at MacOS. Flapping many disk

Script works perfectly if external device have one or two partitions, but if more all partitions many times remount. How to fix it? #!/bin/bash diskutil activity|while read line do if [[ "${line}" ==...
2
votes
1answer
61 views

How to get IP address and the connected interface name in bash

PC with onboard linux has several network interfaces, e.g. two ethernet cards and one wifi adapter (numbers and types may vary). Each of that interfaces could be connected to a network (and could be ...
0
votes
1answer
28 views

Pipeline after sourcing a bashscript

I have a code # Inside Child.sh ChildVariable=BigChild # Inside Parent.sh source ./Child.sh echo "ChildVariable=${ChildVariable}" Output: ChildVariable=BigChild But, # Inside Parent.sh source ....
0
votes
0answers
13 views

fedora 26 disable firewalld use iptables startup script

the firewalld zones and rules etc are a complete pain in the butt compared to regular old iptables. My main goal is to get my iptables rules to run at startup and not have to recreate them all with ...
0
votes
2answers
30 views

How to sort a list of numbers and null values in ascending order, with null values at the end?

I have a list of numbers and null values. How can I sort them in a way such that the null values come to the end of the list using sort in GNU coreutils? Sample Input (input.data) 0.9000 23 1 2 5 -...
0
votes
2answers
33 views

Automatically removing part of the file name (bash script) [on hold]

I have the following files in the following format: S1A_IW_SLC__1SDV_20151028T141631_20151028T141658_008354_00BCA5_7569.zip S1A_IW_SLC__1SDV_20151028T141656_20151028T141724_008354_00BCA5_4D9E.zip ...
0
votes
2answers
32 views

Linux : double-quote variables and for file loop

In another question, I was advised to "double-quote $variables" in my script to avoid errors. After reading a lot of info about double-quotes, I presume I can/must exclude wildcards from double-quote ...
0
votes
0answers
16 views

Fast navigation in Midnight Commander Shell link mode

Is it possible to achieve the same behavior as on the local machine with Ctrl+O allowing navigating directly in shell, when connected to SSH server (Left / Right -> Shell link...)? Or is there any ...
0
votes
0answers
21 views

docker print path of detached container

I'm running an Anaconda Docker container on Windows host. I'd like to run the container in detach mode and print $PATH. However $PATH appears to be blank unless I start an interactive session. How do ...
0
votes
1answer
23 views

how to create a the following bash script alias for git based deployment

i would like the following deploy dev to be alias to git checkout deploy/dev && git merge master && git push so that dev is a parameter. thanks!
0
votes
1answer
44 views

Linux : secure recursive delete within scripts

I'm working on automated scripts running on a Linux box (Debian). Those scripts are started from a scheduler and are manipulating files within their own directories. At the end of the scripts, I need ...
13
votes
4answers
1k views

How to recursively replace characters with sed?

Is it possible to replace occurrences of a character sequence recursively without iterating over the same sequence again? By performing a sed as in the following scenarios I can get the mentioned ...
0
votes
1answer
21 views

Parse pstree output to list parent and child PIDs of a given process name

I am running two instances of a program called SMU, hence there will be two separate processes with the same name SMU. And each SMU process will create one (can be more than 1) child process, hence ...
0
votes
1answer
32 views

Tmux in bash script executing too fast

I am trying to write a bash script that performs the following actions: open 8 tmux terminals each of the terminals connects in ssh to a remote server start a script X on 3 server, and when it's done ...
0
votes
1answer
24 views

How to get git auto-completion to work again (Ubuntu 18.04)? [on hold]

My git auto-completion just stopped working after a recent update. I haven't touched anything in my bashrc file. Currently I have git-completion.bash in my home directory, and I have that file ...
1
vote
1answer
23 views

Bash double brackets [[ with sudo

I've got a command that is working when run as the current user but if I prefix sudo to the command, it gives me an error. I'm trying to remove a file if it's a directory (but not if it's a symlink ...
0
votes
2answers
14 views

Set up `cron` job and mailto on error, on Arch

I use postfix linked to an commercial smtp server for cron jobs to send their owners an email in case of error/warning. This is a one box Arch setup. postfix works. So does cronie. But although the ...
0
votes
1answer
44 views

how to make curl request undisturbed in a bash script?

In a bash script, I want to make a curl request that the user should not disturb. trap "cleanup" 1 2 3 13 15 TMP_OUT=$(curl -H "Content-Type: application/json" -X POST -d "$DATA" "${HOST}:${PORT}"'/...
0
votes
1answer
29 views

How do I not download certain websites with wget?

What I'm currently doing right now is wget www.example.com -m --warc-file="example.com" which works fine for most sites, but for this particular site that I'm saving, there are over a thousand ...
0
votes
1answer
87 views

What am I doing wrong in this bash script?

I'd like to know what's wrong with my code? What am I missing? Why isn't the IF statement working correctly? Why does it show one output only? Why isn't the elif statement working? I am trying to host ...
0
votes
0answers
15 views

Ending lftp Session - Cron Job Not Running

I need to move a file via ftps from our server to a remote server and have this run every 30mins using a cron job. The shell script I have is: #!/bin/sh # @description: Transfer inventory update ...
1
vote
3answers
32 views

OSX Command line Find Duplicate Filenames with different extensions

I've gone through all the similar questions + installed few command line utilities like duff but with no sucess. In my Images directory, I have images with same name but with different extensions (...
0
votes
2answers
15 views

popd back to other directory and simultaneously pushd current dir

A lot of times I'm working between two directories. While it's nice to be able to /working/dir/1 $ pushd /other/working/dir /other/working/dir $ do something /other/working/dir $ popd /working/...
1
vote
1answer
34 views

Bash script for SSH and echo [duplicate]

I want to have something like this: #!/bin/bash ssh 10.0.0.1 vncviewer However, I want "vncviewer" command to be launched at the same time, and so that it does not interrupt with SSH asking me for ...
0
votes
1answer
38 views

Extract version info from a string

I want to extract versionCode and versionName from this string: package: name='com.turastory.mysampleapp' versionCode='11' versionName='1.1.4' I think I should do these actions: find versionCode in ...
0
votes
1answer
24 views

CPU Frequency Scaling BASH Script

I've written a script to run when my PC starts up and it's supposed to overwrite "energy_performance_preference" and "scaling_governor" with ones that have different values. What's happening is only ...
9
votes
4answers
858 views

convert text file of bits to binary file

I have a file instructions.txt with the contents: 00000000000000000000000000010011 00000010110100010010000010000011 00000000011100110000001010110011 00000000011100110000010000110011 ...
0
votes
2answers
33 views

Why does #!/usr/bin/env show “$@” as 1?

If I have test.sh: #!/usr/bin/env bash echo "$@" bash test.sh results in 1 Any idea why the result is 1? Also, why shebang to env instead of directly to bash? UPDATE: Sorry, I missed some code, ...
-1
votes
1answer
49 views

find and grep produce different output if executed from script file or command line

I'm using these commands to to search in multiple pdfs, given a file path: >>find /home/ad0x/Documents/Skola/Flervariabel/Tentor -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-...
0
votes
1answer
25 views

How to save output of bash whilst preserving colored text?

When I use some command in bash like npm audit, I can see the output with some colored text. I want to save the output with colored text preserved. I have tried selecting the text and saving in ...
1
vote
1answer
36 views

Scheduling tasks in parallel on Linux

I have N = 128 (say) tasks, task 0, task 1, ... task N-1, that I need to complete. Each task will take an unknown amount of time to complete, and they may be completed in any order. I am on a machine ...
1
vote
0answers
46 views

Change Title of Bash on Ubuntu on Windows

Is it possible to change the title that Bash on Ubuntu on Windows displays in its title bar? By default it's set to <username>@<computername>:<CWD>. I'd like to, say, add Bash on ...
15
votes
1answer
3k views

I changed my “HOME” variable and now cannot find “~/.bash_profile” to change it back

I was messing around with environment variables on my Mac, trying to learn how to use them and I used the command nano ~/.bash_profile where I then added the line HOME=/Users/MyCompName/Desktop to ...
0
votes
0answers
56 views

How to connect from windows bash ssh to a synology docker and view a picture using python [closed]

I'm doing some work with python on a Synology ds218. To do it, I download a docker python image. I'm connecting to the container using windows bash ssh. The python script dynamically modifies images. ...