Questions tagged [bash]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
15 views

How to curl and parse endpoint data with Bash?

I am trying to hit an endpoint http://myapp.com/health and get the version value. How would I do that? Note that I plan to run this script in TeamCity. Response from http://myapp.com/health: { "...
0
votes
0answers
11 views

What's the best way to run the Debian DHCP server in a different network namespace?

I'm using Raspbian, which is based on Debian 10. I have a complex networking setup which requires me to run a DHCP server on eth1, which is part of the ns2 network namespace. Normally, to run a ...
0
votes
0answers
18 views

bash: How avoid expanding variables etc?

Sorry about the somewhat vague subject. What I am after is a way to ssh to a server while copying my preferred profile to the server. The general idea is to do something like ssh -t [server] "cat ...
0
votes
1answer
24 views

How can I change user and keep my .profile

I often have to work as root (using sudo), but I want to keep my settings from my login profile - I have had this working in the past, but I don't quite remember how I made it work. This is what I've ...
0
votes
1answer
9 views

foreground bash script putting itself in background

I'm having a bash script whose behaviour is roughly. #!/bin/bash if some_condition ; then echo please enter some integer read a else a=3 fi # here 'd like to switch in the background ...
0
votes
0answers
11 views

ssh on environment variables on remote machine

how to export environment variables to the remote machine to the specific user. I am using below command to do export but the echo is returning empty. I thought to approach in another way by ...
-2
votes
1answer
33 views

What is a windows bat analog of cd $(dirname $0)?

I've looking pretty long to get answer on this simple question and finally got it. Want to share with those who will port shell scripts to the bat analogs.
1
vote
2answers
29 views

copy binaries from /sourcedir and its subdirs to /destdir

I want to copy all binaries from /sourcedir and its sub-dirs to /destdir. Basically, all files with: no extension, and all files with *.a, *.so, *.ko, and exclude from copy: Makefile and *.depend. ...
0
votes
1answer
16 views

bash color not working

I have some issues with color. It works fine on one line but not on the other 2 echo " \e[35mWeather.......:\e[0m `echo "\e[36m$weather\e[0m" | head -1`" echo " \e[35mToday.........:\e[0m `...
0
votes
0answers
18 views

Terminal start-up stuck after upgrading to Mac OSX Catalina

I just upgraded my Mac operating system to 10.15.1 (Catalina), and I'm now unable to interact with my terminal properly. When I open the Terminal application (or iTerm), it outputs the last attempted ...
0
votes
0answers
21 views

permissions issue when running rsync via crontab

I'm using rsync to backup directories on my local machine to a remote server. I have SSH key-based access set up and working for my user, so when I run the command: rsync --update -razvP --progress ~/...
0
votes
2answers
41 views

Monitor folder size

Is there a way to monitor and log folder size in Bash/Ubuntu? I'm running some computations and I need to know how much disk space they need. They may create some temporary folders for a few minutes/...
0
votes
0answers
21 views

Why is conda activated by default in a physical linux session but not via ssh?

I have installed Anaconda python on my Ubuntu 18.04 machine. When I log in to that machine in a physical session, my default conda environment is activated by default. My prompt looks like this: (...
0
votes
1answer
30 views

How to test if a directory contains only hidden files (including both *NIX and Windows filesystems)?

I'm using bash 5.0.11 on macOS Catalina. Is there a good way to test if a directory contains only hidden files? I'm looking for something that will work for both macOS and Windows filesystems.
0
votes
0answers
35 views

What is the difference between “screen -dm” and “screen -Dm”

I'm been looking for an explanation for the difference between screen's -dm and -Dm options. I know that both options are used to make the screen run in the background / detach it after creation. I've ...
0
votes
1answer
17 views

Editing an .ini file using regex or some form of pattern matching

I have a file texstudio.ini, inside that file there is the following line Tools\Commands\pdflatex=\"/usr/texbin/pdflatex" -synctex=1 -interaction=nonstopmode %.tex I would like to change the above ...
0
votes
2answers
38 views

Can I give a script elevated file access and run it from my current user?

I have a script (I call it dusort.sh) I use to gauge which files are taking up the most space on my drive in a given folder. It essentially boils down to this: #!/bin/bash du --all --human-readable -...
0
votes
2answers
27 views

How to expand shell variable in `tmux send-keys`?

I'm trying to script a small utility to more easily start my day with a custom tmux window. My variable doesn't seem to be evaluated before tmux sends it's keys, however: #!/bin/bash MY_WORKSPACE=/...
0
votes
1answer
24 views

append program's output to a file and display first n lines with a pipeline

What I'd like to do is to run a command, write all output to a file and display the first n lines. in this example n=10 One solution I don't really like is: ./program > tempfile ; cat tempfile &...
0
votes
2answers
72 views

showing degree symbol bash/tcl

im trying to get a login script to display degree symbol but it doesn't display it. Here is the weather.sh METRIC="1" # 0 for F, 1 for C # Fill in form to find your weather code here: # http://...
2
votes
0answers
26 views

Docker container entry points complain “cannot execute binary file: Exec format error”

I've been stumped trying to run Nextcloud via docker for the past few weeks. I've tried using ownyourbits/nextcloudpi, nextcloud, and the example docker-compose scripts provided by the Nextcloud team, ...
0
votes
1answer
25 views

How to connect to a Microsoft SQL Server from Linux shell?

I have the following problem: I am working on an Ubuntu Linux server (I have access only to the shell, no desktop environment) and I have to interact with a Microsoft SQL server to create some tables ...
0
votes
2answers
34 views

How to repeat option with filenames?

I have a command which is of the form #!/bin/bash command -f hello.txt -f world.txt -f bonjour.txt hello.txt, world.txt and bonjour.txt are files which are in the directory /directory. Since in ...
0
votes
1answer
17 views

Disconnecting PuTTY with Amazon Web Services EC2

I am using PuTTY to submit a bash file to Amazon Web Services EC2 to run R files. The cursor in PuTTY disappears when I submit the bash file and does not reappear until all of the R files have ...
0
votes
0answers
25 views

How to open an image on remote computer via SSH? (Ubuntu)

I am looking for a way to display an Image Remotely For example, 1. user foo is viewing Ubuntu 16.04 computer via monitor 2. I am connected through SSH to user's foo computer 3. I want to display ...
0
votes
0answers
14 views

Using a variable with sed to return a section in an ini file

I need to use a defined variable in a script using sed to return the contents between section titles of an ini file. The code I've come up with works only with hard coded titles. I want to be able to ...
0
votes
0answers
32 views

ssh-add prompting for PEM pass phrase for unknown reason

So some background: I have a collection of systems I use to access a server, which authenticate with a fingerprint key over ssh. On my other systems (android, windows 10, centos 7) I have no issues ...
0
votes
0answers
46 views
+50

How to setup fonts in Linux subsystem?

I'm trying to use the Linux subsystem for windows (a bit of an adventure for me not knowing Linux). I've installed starship.rs and noticed I've got a number of badly rendering symbols. I've read that ...
1
vote
1answer
25 views

Git doesn't pickup chmod change from 0775 to 0774

Git is ignoring a chmod change from 0775 to 0774. I want to deny public execution of a certain file. 0775: Owner: Read, Write, Execute Group: Read, Write, Execute Public: Read, Execute 0774: Owner: ...
0
votes
0answers
35 views

How to upgrade ModemManager from source

I am not able to send sms from command line using mmcli, it only work with modem-manager-gui. I want to upgrade ModemManager and compile from source, I see there is 1.12.0 available https://github....
0
votes
1answer
56 views

In Bash how to get the position of a substring, within a string, starting the search at character position n

I am new to Bash scripting, I've used Visual Basic in Windows before and am looking for a bash equivalent string function for VB's inStr(). example in VB : strMain = "abcABC123ABCabc" searchStartPos ...
0
votes
0answers
26 views

How make one linux directory path “point” to a different path

I just changed distros and I have umpteen bash and vim scripts throughout various file systems which reference the path '/mnt/0' that now need to reference the path '/media/q/fs-uuid' instead. Is ...
0
votes
0answers
6 views

linux: I want to change the pagesize of a particular page in a pdf

I am working on a linux operating system and i am looking for a command line which can change the page size of particular page in the pdf. I dont know how to attac the pdf file in stack. So i am ...
0
votes
0answers
21 views

Why does the GNU C Preprocessor cpp freeze my MSYS2 bash (mintty.exe) when writing to stdout, even post SIGINT?

Using the MINGW64 Bash from MSYS2 on Windows 7 64 Bit I'm getting a weird behavior for the following command sequence: echo "Hello World" > foo cpp foo - It outputs the following (correctly): # ...
1
vote
2answers
36 views

Bash time command output is different with environment variable assignment

Usually, the time command outputs three lines: > time sleep 2 real 0m2.003s user 0m0.000s sys 0m0.006s However, when prepended with variable assignment, the output becomes one line: &...
1
vote
0answers
32 views

Adding a path to login.conf in Bash / FreeBSD

Due to the fact that freebsd pkg repos (binary) do not come with support for lame mp3, and I don't want to complicate things by having a dual dependency tree, I'm attempting a workaround by installing ...
2
votes
1answer
18 views

Capture matched pattern in a cp/mv command

I want to rename files that are named like db_backup_2019_11_22-12_13_00.gz to db_dump_2019_11_22-12_13_00.sql.gz. Is there a way to do this using pattern match? I mean like this: mv db_backup_*-*....
-1
votes
0answers
33 views

Copying files from usb flash drive to desktop in Bash

How can I copy files from my usb drive to my desktop using the Bash terminal? I tried the following but it didn't work. cp/media: No such file or directory i have tried this and it has failed ...
0
votes
1answer
23 views

List files with path and size using terminal

MY folder structure on mac is as below Folder-1 testfile.txt 12 kb subfolder file2 14 kb file3 10 mb Folder -2 subfolder-1 testfile 13 kb subfolder 1.1 ...
0
votes
0answers
31 views

Invoking a new CMD window from WSL without waiting

Is it possible (without using a terminal emulator) to invoke a new CMD (or bash) instance in a new Window from within WSL, without having the calling command wait on the new CMD? The usual way to ...
0
votes
0answers
18 views

How to remove Chrome login keyring requirement in Ubuntu 18.04 via command line

I'm writing some bash scripts to set up an Ubuntu 18.04 LTS (Bionic Beaver) environment As described in this question, I've been prompted with an unlock your login keyring request every first time I ...
0
votes
1answer
75 views

How to remove a parameter set in an alias from command line

I have an alias for "ls" set like this: alias ls='ls -lh' If at some point I wanted to perform a one-time regular ls without either of those parameters (without l or without h), how would I do that ...
0
votes
0answers
29 views

Using SVG package in Latex on macOS Catalina

Compilation fails because inkscape: command not found. But I'm able to convert svg manually in terminal The following command works 👍 and produce the img.pdf file. inkscape img.svg --export-type=...
1
vote
1answer
42 views

How to run ./configure command on macOS?

I want to install Pure-FTPd on my Mac running with 10.14.6 (18G1012) using this manual https://download.pureftpd.org/pub/pure-ftpd/doc/README.MacOS-X When opening the Terminal app and tying ./...
65
votes
4answers
6k views

Messed up my .bash_profile remotely, can't ssh back in

I'm using a GNU/Linux system remotely, via SSH. I mistakenly added something into my $HOME/.bash_profile scriot which causes an error. (To be specific: I added an exec foo command instead of . foo, ...
1
vote
0answers
29 views

Load multiple hosts files

Think I already know the answer. But looking for a unicorn. Anyone know if there is a way to link one hosts file to another, or load 2 or more different hosts files? I have a hosts file that has ...
0
votes
1answer
22 views

Directories appearing twice in $PATH

Following advice from a course, I added the following line to my .bashrc: export PATH=/home/dodgycoder/kafka_2.12-2.3.1/bin:$PATH Now, when I open a terminal window I get this directory shown twice: ...
2
votes
1answer
65 views

how to run a linux program faster after its first execution

I use a Sophos antivirus program to scan email in antispam software ASSP, server OS Centos 7.4, MTA EXIM. It run in this way /usr/local/bin/savscan -sc -s -archive /file It works very well to block ...
0
votes
1answer
21 views

Print XML as table in Bash

When I have an XML file like this: <guests> <guest> <name>Adam</name> <music>Silence</music> <dish>Vegetables</dish> ...
0
votes
1answer
38 views

Running *.sh files without typing their .sh extension

Is there a way to set up bash so that it executes any file with a .sh extension, say for example mycommand.sh, just by typing mycommand, in the same way that in Windows you can execute mycommand.bat ...