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.

Filter by
Sorted by
Tagged with
1
vote
0answers
20 views

Run script in parallel with incremental variable

I would like to run a python script in parallel on several processors on the files in an INPUTDIR. I use the few lines below for that stuff: # define a function pythonprocessing(){ python myscript....
-1
votes
0answers
14 views

Send commands from one client to another via server

I need to have a server with 2 clients that communicate through socket. according to these questions: Q1 Q2 Q3 Q4 i did this on one server with 3 ssh sessions. on first one (server) i ran this ncat -k ...
0
votes
1answer
18 views

User input to search bash array

folks-- I'm getting kinda stuck, here. I have a small script that will be incorporated into a larger script. This small piece is supposed to take a user input, and compare it to a list of stored ...
0
votes
1answer
31 views

How to define the name of a bash function to be a regex

I've searched around and can't find an answer. I want to define a function like this function \d{2} () { echo $1_or_smth } Then if I say in my terminal 12 I want it to echo 12 back.
2
votes
1answer
25 views

How to embed a bash function into a sed expression?

In sed how can I create a replacement string using a bash function, especially a function of one or more of the found parts, normally identified as \1, \2, ...? In other words, I want to do something ...
1
vote
2answers
19 views

Underlying failure after a SIGPIPE

I am getting an error code 141 when running a bash script on a CI server that I cannot reproduce locally. After some searching, it sounds that error 141 indicates a PIPEFAIL, and I have a set -o ...
0
votes
1answer
20 views

Run bash script on network changes

How can I set Ubuntu to run a bash when network changes. Like changing local IP, connecting VPNs, disconnect one interface and connect to another.
0
votes
3answers
41 views

Variables being called with if statement gives -bash: 'Command not found'

I'm modifying my .bash_profile file so that when I run ipy it clears the log file every seven or more days. The problem is when ever I reference a variable within my if statement I get back -bash: ...
0
votes
1answer
13 views

Why does `complete` sort options even with `nosort`?

I can't get this answer to work in Bash 4.4.20 (default shell in Ubuntu 18.04): $ complete -o nosort -W '--color=auto --color=always --color=never' mycommand $ mycommand --<Tab> --color=always ...
1
vote
1answer
25 views

how to change value of parameter recursive under folder

under /etc/sysconfig/network-scripts , we have network configuration files as ifcfg-conf1 ifcfg-conf2 . . . is it possible to change all parameters - PEERDNS to no , if value is yes expected ...
3
votes
1answer
260 views

What is this script doing?

#!/bin/bash echo 123456789 > out.txt exec 3<> out.txt read -n 4 <&3 echo -n 5 >&3 exec 3>&- Was asked the content of out.txt at the end of script, in an interview ...
1
vote
1answer
24 views

Install “info” in Debian

When I run the info command I get bash: info: command not found How can I solve this?
0
votes
0answers
21 views

Building Kali Linux image from inside Live USB with custom build directory

Introduction: Kali Linux has special scripts for self-building the image and everybody can adjust all the parameters (DE, packages, pre- post-install scripts) and make his own ISO. The problem: when ...
0
votes
1answer
21 views

./txtdb: line 9: [: =: unary operator expected

echo "Choose from the following options" echo "1- Display full Database" echo "2 - exit program" read usrChoice if [ $usrChoice -eq 1 ] ; then cat energydrink.txt elif [ $userChoice -eq 2 ] ...
-1
votes
1answer
33 views

echo alias prints space between env variable and first argument

have a weird problem..... Im configuring my arch setup and one of my aliases isnt working..... alias es='echo $SCRIPTDEST/$1' For some reason it prints a space between $SCRIPTDEST/ and $1, ruining ...
-1
votes
0answers
62 views

Linux Internal working of `cat`

TL;DR I was writing a very simple bash script, which goes into each folder in my pwd and find for files with names pid. If yes, echo that file out. pids=$(cat */*/bin/*pid) echo $pids >> ...
0
votes
2answers
78 views

How can I check if a program is installed in the most compatible way?

A BASH script I wrote has two requirements. At the moment I check if they are installed this way and I thought it was a good solution until I had some complaints from users: command -v fping >/...
0
votes
2answers
33 views

Change prompt with echo to show current directory

Problem: I was hoping this would be something simple to do. I currently have my script changing my directory among other things and I was hoping that I could make the script change the line using ...
0
votes
1answer
26 views

How do I specify a date range in a wget script for multiple files to only download what I need?

I am trying to download a lot of data for some research from the CMIP6 website that provides wget scripts for each model. The scripts are for every 6 hours or month from 1850 to 2014. The date ...
0
votes
0answers
9 views

Processing CUPS spooler data file

We are doing image processing of CUPS data file. So we are capturing data files of particular print queue. But we are not able to capture number of copies information in print job. We tried to ...
1
vote
2answers
35 views

How to run Bash Script in background [duplicate]

I am remotely connected to a system using ssh and want to run nmap on a system from there. But every 5 minutes, my SSH connection breaks and so the process running on my shell stops. How can I run ...
2
votes
2answers
55 views

localize shopt options

I would like to temporarily change the value of a certain shopt option in a function. For options which can be set with the builtin set this is possible with local - inside the function body. The ...
0
votes
0answers
14 views

Meaning of uint32:0 in dbus-send and bash syntax

dbus-send --system --print-reply \ --dest=org.freedesktop.DBus \ /org/freedesktop/DBus \ org.freedesktop.DBus.StartServiceByName \ string:org....
1
vote
0answers
21 views

unknown filesystem grub rescue + chroot doesn't find `/bin/bash`

I was installing hyperledger fabric, on Ubuntu 18.04.3 Desktop, through sudo -E, with bootstrap.sh and of another similar one. But after installation, which seemed gone fine, I'm not able to use ...
0
votes
0answers
37 views

Configuring cron from shell script

I have a shell script with the following lines (the full script at the end of post): CRON_BCK_CMD=/home/user/bck.sh CRON_CONF=" */30 * * * * $CRON_BCK_CMD" but when I simply run these in ...
2
votes
0answers
39 views

Why did bash (or PuTTY) interpret the two characters 'cd' as the single character '㏅'?

I ssh'd into a CentOS VM today through PuTTY -- right after I logged in and got a bash shell, I tried to cd to another directory, but the displaying of what I typed lagged a bit, and then instead of '...
0
votes
1answer
23 views

How do I prevent sideways scrolling (and get wrapping instead) of long bash command-lines in CentOS8?

Normally, bash command-lines wrap - which I am used to and works great: [cnd@MacBook-Pro ~]$ echo abcdefgABCDEFGhijklmnopHIJKLMNOPq rsQRStuvTuvWXYZ (I made my window narrow to demonstrate) However -...
1
vote
1answer
27 views

.bashrc or .profile for busybox on windows

I have enough experience with scripting on *nix servers, but busybox on Windows I enjoy first. I installed busybox using scoop. When I run: ash echo $HOME I got -> C:/Users/RO # OK, this is dir ...
0
votes
2answers
53 views

How do I save the output of a script to a file?

I have the following script: LOOKUPS=/tmp/$0.LOOKUPS.$$ OK=/tmp/$0.OK.$$ KO=/tmp/$0.KO.$$ NOVENUE=/tmp/$0.NOVENUE.$$ trap "rm -f $LOOKUPS $OK $KO $NOVENUE" 0 1 2 3 4 5 13 15 tu=`$APP_SERVICE | cut -...
-1
votes
0answers
26 views

smart_script alias [closed]

When I call a certain alias from a bash script on my Linux 16.04, I have to run the script twice to run all the commands. The first time it stops after smart_script (it creates the log file).
1
vote
2answers
47 views

value of loop variable is null after SSH connection

I am trying to write a script that will do ssh and run a few commands on the remote host with help of loop. One of the problems I've run into is that, when I run the for loop, it outputs is null. ...
0
votes
0answers
38 views

Help with bash IF construct [duplicate]

Can someone help me understand what's wrong with this script (ran in cygwin)? $ cat myscript.sh #!/bin/bash if [[ $myfile =~ (.+)-(.+)\.(.+) ]]; then echo "Prefix = ${BASH_REMATCH[1]}" echo "...
1
vote
1answer
63 views

How do I get rid of boxed '?' symbols that appear after every character in tmux?

When I run tmux, every character has a boxed '?' next to it. The boxed '?' symbols also appear after every character I type when I am within vim when I am in tmux. I have been doing research online ...
0
votes
1answer
29 views

Save command line history only if exit code is 0

I looked in ~/.bash_history and I can see all the commands I have executed, even those with typos. Is there a way to save only the commands that have succeeded (i.e. exit code 0)? Note: I am using ...
2
votes
2answers
36 views

Search for a String in a file and save the string after it to a variable

Example: Lets say this is in a file: AB: Test CD: Testing EF: Rest I want a script to search for CD and save "Testing" into a variable. I've tried something with awk but somehow I'm not making any ...
-2
votes
2answers
60 views

What am I doing wrong with my own alias in ~/.bash_aliases? [duplicate]

~/.bashrc My ~/.bashrc contains the following (by default): if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi ~/.bash_aliases My ~/.bash_aliases contains the following (my definition): ...
6
votes
2answers
425 views

Writing a build script with if statements and function calls

My build/deploy script does not behave as I was expecting. If clone or build fails it will still go on and call restart. I suspect its because I return 0, but how should I write if I want to return ...
0
votes
2answers
40 views

delete line and the following one if condition met

I have this kind of file and I use bash: &ACLB032-06|Bos taurus|COI-5P|HM102290 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNCTATTCTATATCAACACTTATTC-------- &CYTC426-12|Bos taurus|atp6 ...
0
votes
2answers
74 views

How can I check if returned value is true in one line?

I'm running the following command in bash: yarn config get workspaces-experimental Which returns the following: true\n \n That is, "true" or "false" followed by two end lines. I want to take this ...
0
votes
1answer
47 views

How to find files in a directory with same name but different extensions? Also restrict some extensions?

I try to find files in a directory that have mp4 mkv extensions only. But I also want that these finded files same name, but different extensions. For example: video.mp4 video.mkv . I tried to ...
0
votes
1answer
24 views

Making the first word I type on terminal of different color from the others

New here. I was trying to make the first word I type on the terminal of a different color from the others. I have looked into the .bashrc file and /etc/inputrc files. I know that I can make use of the ...
0
votes
3answers
60 views

Bash brace expansion with variables for pattern matching

I want to loop through all files matching a pattern of the form for file in {prefix1, prefix2, ...}*{postfix1, postfix2, ...}; do How can I programmatically replace {prefix1, prefix2, ...} with a ...
0
votes
1answer
23 views

Running command in variable under sudo

I am trying to write a script which runs a command as a different user, but under the environment set-up by my own .bashrc. I would like the script to work for our entire team. Here is my attempt to ...
0
votes
3answers
61 views

how can I pass an alias as an argument to a shell command

I have an alias that is set up like this. alias X='`xclip -o --selection primary`' now this works great if I just want to echo my clipboard value. But I would really like to be able to use it as an ...
0
votes
0answers
39 views

/bin/bash Permission Denied

I'm trying to install GRUB onto a separate partition who's volume shares a Windows installation. After having pulled, configured, and made GRUB, I can't grub-mkconfig. Doing some research, I found: ...
0
votes
1answer
19 views

Paste: combine rows for each row, up to only the number of rows in the smallest row-ct file

Suppose I have two files, // foo a b c d // bar x,y,z p,d,q The problem is: paste -d ',' foo bar ... a,x,y,z b,p,d,q c d Instead, I would like to (somehow) produce the following: a,x,y,z b,...
1
vote
2answers
49 views

What Linux command will tell me where a window is in terms of the Z-axis compared to other windows?

I'm looking to give some Linux command a window id as obtained by xprop or wmctrl or similar and have something tell me where in the "z-wards" stacking order that window currently is. For example, if ...
0
votes
3answers
75 views

Bash script in a Perl script hangs

I'm running a small bash script in a Perl script on a Mac, but the bash script seems to hang when finished. The Perl script doesn't pick up and continue. The bash script works great in a shell window. ...
0
votes
1answer
44 views

Running script from .bash_profile does not run it at login. How can I fix?

I have a script to move files from my Downloads folder to Trash if they are more than x days old. I want it to run every time I log in to my mac. However, it only runs once I open Terminal. How do I ...
0
votes
0answers
57 views

Find hidden directory under user profile and echo result

#!/bin/sh USERLIST=$(ls /Users | grep -v Guest \ | grep -v .localized \ | grep -v Shared \ | grep -v administrator \ ...

1 2 3 4 5 373