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 (Bourne-Again SHell), is the shell used in Ubuntu's command-line interface by default.

0
votes
0answers
16 views

how to replace a variable in middle of reoccuring commands

I'm in a middle of a merge and I'm trying to find specific variables that went missing in the following way: grep -Rn "<variable string>" <old_branch> | grep -v Binary | grep -v metadata ...
0
votes
1answer
32 views

Having trouble getting .sh working with crontab

I've checked this link for suggestions but I can't seem to get a .sh script working. I'm new to Ubuntu and Linux (from Windows). Why crontab scripts are not working? Here is the dummy .sh I'm ...
2
votes
1answer
24 views

What does `fd01h/64769d` mean in Device and `142368` in Inode?

When I checked the state of a file: [root@iz2ze9wve43n2nyuvmsfx5z ~]# stat test.py File: ‘test.py’ Size: 33 Blocks: 8 IO Block: 4096 regular file Device: fd01h/64769d Inode:...
1
vote
2answers
19 views

Search recursively for all files with a .sql extension and pass them to mysql as argument

Given: Directory tree that contains files with .sql extension. Requred Find them all recursively and pass found files one by one to mysql client as: mysql < ./dir/subdir/subsubdir/schema.sql ...
2
votes
2answers
71 views

Call scripts in directories relative to main script

Currently, I am working with a shell script and make a system where I write a shell script say main.sh and the same directory there is a directory containing other shell scripts. The structure is: ...
0
votes
1answer
23 views

shell script test a telnet connection

I'm Trying to make a scipt that checks if my own specific port is open and can be connected. I tried doing it by netcat by nc -vz localhost 25565 but this only tells me if the port is open. I need ...
0
votes
1answer
9 views

Ubuntu 16.04 boot as init=/root/init.sh and exec init 3 in shell, but why X11 started?

Ubuntu 16.04.5 default environment. I want to do some custom job before init. grub.cfg as linux /boot/vmlinuz ... ro init=/root/init.sh init.sh: #!/bin/bash # do some task exec init 3 after ...
1
vote
1answer
24 views

How to unbind a shortcut in a terminal

Ubuntu 18.04 I'm using embedded terminal in my IDE and there is IDE-binding Ctrl8 which is pretty useful and convenient and I would not like to rebind it. However the Ctrl8 shortcut works as ...
-2
votes
0answers
23 views

How to replace string in file with variable

The command is like below: new_value="some string to be replaced" sed -i "s/old_string/$new_value/g" file_name The explanation: new_value is the variable name s is substitute command $...
0
votes
0answers
17 views

Avoid trailing whitespace when copy/pasting from bash/byobu terminal

I wrote a bash script that computes information and echoes it into my byobu terminal. I then select the whole thing with my mouse and paste it into a Gmail conversation after editing it a bit. ...
0
votes
0answers
15 views

problem cs231n launching jupyter notebook from bash terminal

I'm a student currently working on cs231n. http://cs231n.github.io/gce-tutorial/ This link tells a step-by-step setup guide to setting up ubuntu vm machine. Currently working in windows environment. ...
1
vote
2answers
44 views

Make ShellScript run with custom CLI command [duplicate]

I have a shell script i use frequently to manually clear the dentries, inodes and page cache in my RAM: ramflush.sh #!/bin/bash echo " ██▀███ ▄▄▄ ███▄ ▄███▓ " echo "▓██ ▒ ██▒▒████▄ ▓██▒▀█...
0
votes
1answer
12 views

Nslookup function within script

I am trying to create a script which can perform a DNS lookup for a web address. This is the start of my script #! /bin/bash echo "enter web address : " read address echo "Entered web address : $...
0
votes
1answer
45 views

Delete Users From List

I'm working on a script to delete users from a .txt file but give the option to delete as a final failsafe. The text file is called badUsers.txt I'm basically modifying this script which I know ...
0
votes
1answer
21 views

Can not root: after removing ZSH and returning to default bash

I can not $ sudo su everytime, I enter the command, the terminal says : can not execute /usr/bin/zsh no such file or directory How to return to default bash of Ubuntu and make bash as default ...
0
votes
0answers
13 views

Changing the Background Template in Dialog GUI Menus

I am working with the Dialog menu System for my bash scripts and I am wondering if it was possible to change the background color from the default blue, to either a custom image of my choice, or at ...
0
votes
0answers
25 views

monitor service user account activity

I've a service account that has a full root access "user1 All=(ALL:ALL) NOPASSWD:ALL" . The user account is not used by a human user but it is used by an application which is running some bash and ...
1
vote
1answer
51 views

bourne shell script

I'm trying to convert this line of C program to bash script: C: bin = bin+d*10^n-1; bin,d,n are declared as int. bash: bin=`exp $bin+$d\*10^n-1` but it's incorrect
0
votes
0answers
27 views

Cron can't seem to run python script

I have a python script that does a bunch of stuff. I need cron to run that script, but it doesn't seem to work. Here's my cron job: * * * * * /home/deploy/bin/monitor Here's that script that handles ...
0
votes
0answers
27 views

Command line social media? [duplicate]

Is there a command line program whereby I can post to multiple social media accounts, i.e Facebook, Twitter, Reddit, at al? I am not talking about spam. This is for all the corporate communications ...
0
votes
1answer
44 views

Another desktop's application showing on current desktop task bar

I'm having this annoying problem and need some help. The thing is, I have a script which opens/closes chrome windows to run some macros. In order to keep my desktop clean, I put this script on desktop ...
0
votes
2answers
29 views

Proper method for storing user input in bash scripts

I would like to make a chat bot using bash. And I was just wondering if anyone in the community knows of a proper / preferred method for storing user input as a variable in a shell script. For ...
0
votes
1answer
51 views

BASH Alert Script for Ubuntu 16.04

We see the running PHP scripts with this command below on terminal: echo 'User | ProcID | CPU | MEM | ----------------------- START | ELAPSED ---------- COMMAND'; ps aux --forest | grep php; I ...
0
votes
1answer
32 views

Ceate a yes/no dialog box to verify user entries

I am writing a bash script that prompts for for several user entries prior to the start of the script. I am looking for the best way to use dialog to have the users verify the information. I am trying ...
2
votes
1answer
50 views

How to get a log of at what points in time a directory was modified?

In my present working directory, there is a subdirectory called modelled_data I wish to get information on last few (may be 10) modifications of the subdirectory (including its subdirectories and ...
0
votes
1answer
499 views

nproc produce results inconsistent with hardware report

I check the manual to count cpu DESCRIPTION Print the number of processing units available to the current process, which may be less than the number of online processors it output $ ...
4
votes
1answer
37 views

update-alternatives for sh reports bash is used, but I still get dash

I just upgraded to Ubuntu 18.10 from Ubuntu 17.10. I have my box configured to use bash as the default shell rather than the default dash. I've made this change with sudo update-alternatives --...
1
vote
1answer
29 views

Why isn't shell expanding the braces in the shell script? [duplicate]

I am trying the following script for listing the archived files in my current directory. #!bin/sh for file in *.{zip,jar} do echo $file done which gives the output: *.{zip,jar} Why isn't shell ...
-1
votes
0answers
33 views

How to open port for Local Network Access [closed]

I've ubuntu 17.10. and want to open the port 5000 for the network access. Want to access from other computer as : 192.168.1.76:5000 Following are the commands: $ ip addr 1: lo: <LOOPBACK,UP,...
0
votes
1answer
44 views

Bash closes on launch. Might be due to switching development modes

When trying to launch 'Ubuntu' or 'bash' the window opens and immediately closes. The reason might have been that I switched to different Insider Edition of Windows 10 or developer mode, and forgot ...
1
vote
1answer
40 views

After a system upgrade, when I `su -` I get bash-4.4 as a prompt instead of root@hostname

I just upgraded my system. After logging in as root using su - there is no root username in my prompt, it's just -bash-4.4# What should I do here? Thanks.
-1
votes
1answer
22 views

BSD has 58 more builtins

I read the builtins from bsd builtin(1) and gnu version from Ubuntu Manpage: bash-builtins - bash built-in commands, see bash(1) In [25]: print(bsd_bins) ...
-1
votes
1answer
20 views

parse error: Objects must consist of key:value pairs at [closed]

I want to get many values from one key using json and jq my json looks like { "hn":"ME Cloud","d":"Backdoors","Payloads","Files" } i want that echo $json | jq -r '.d' returns me Backdoors ...
0
votes
0answers
13 views

xdotool with the --sync option can take a few seconds in bash script

I am working on some scripts to tile windows on portion of the scripts. Something similar to the keyboard shortcuts available to tile windows, but with my own sizes. I would like to use the --synch ...
0
votes
0answers
22 views

Too many levels of symbolic links while installing pipenv

I've python3.6 and python2.7 install in the system. When I run the command: python --version it shows : python 2.7.15rc1 But when I run: python3 --version it shows nothing. Also, it shows nothing ...
0
votes
0answers
17 views

Data From repository cant´be authenticated, failed to fetch

I am having problems using apt-get update it always said to me connection failed, failed to fetch... I am using bash Ubuntu on Windows /etc/apt/sources.list deb http://archive.ubuntu.com/ubuntu/ ...
0
votes
0answers
21 views

Cron Task stops at same time every day?

I have a bash script which runs, reliably, every 15 minutes until 08:30 each day. No errors are generated by the task itself which leads me to believe there may be something else causing cron tasks to ...
-1
votes
0answers
13 views

How I can search directory, that have name with two dublicate numbers [closed]

So, I have a lot of directory with name from 0/0/0 to 9/9/9/ (for exampe 3/5/1) and all directory have 1 file with name 1.txt . Example for search ../1/0/3/1.txt or ../3/5/3/1.txt
0
votes
1answer
21 views

When should spaces be provided and when not in bash scripting?

I am really confused as to when should one provided spaces between any operator or operand and when not. I have often encountered this problem which gives error on running.
1
vote
1answer
84 views

“Error found when loading /etc/profile” on login after upgrade

I upgraded Ubuntu 16.04 to 18.04. After upgrading, on the login I get the message Error found when loading /etc/profile. The error is in /usr/share/modules/init/sh file on line 43 and line 61. ...
0
votes
1answer
47 views

echo command echo the blank output instead of Variable value in Ubuntu 18.04

can you please help me with very strange situation, I have Ubuntu 18.04 and running some bash script and my script looks like this. #!/bin/bash FOLDER="$1" FILE="$2" BASENAME=$(/bin/...
0
votes
0answers
16 views

How to skip anything that doesn't start with a character [duplicate]

I'm writing a simple script in python to automate my job, and it deals with standard output from commands to make decisions. First airmon-ng is entered, the output is piped to ack, and everything that ...
0
votes
1answer
40 views

How do you bulk move files into folders corresponding to the name of each file?

I have several movies in a folder. For example: ~/Downloads/Movies/Movie A (1998).mkv ~/Downloads/Movies/Movie B (1999).mkv ~/Downloads/Movies/Movie C (2000).mkv I would like to put each file ...
1
vote
2answers
67 views

Want to print output of two background shell functions sequentially

I have two functions in my shell scripts I run in background: function foo { # do a bunch of things # print a lot of output } function bar { # do more things # print out more things } foo &...
0
votes
1answer
32 views

Simple Ping Tool Failing

I am trying to apply what I learned about shell scripting to a ping tool, but I can't seem to work out what I'm doing wrong. I want my ping tool to contain a prompt that creates a variable for the ...
0
votes
0answers
85 views

Simple password generator and adding a user automated shell script [on hold]

This is the code I used to generate a password and add the user using the generated password but some error occurred during execution. #!/bin/bash echo "simple password generator and user add" echo ...
0
votes
1answer
27 views

echo an environment variable in bash

I don't understand why this doesn't work: TEXT="blah" echo $TEXT #echoes nothing I thought it might be because echo is a builtin, so I tried this: TEXT="blah" `which echo` $TEXT #still ...
2
votes
1answer
46 views

Running script on startup

I'm trying to run a script on startup. Script contents are: #!/bin/bash #this script changes trackpoint settings on startup echo 'start script' xinput set-prop 'TPPS/2 Elan TrackPoint' 'libinput ...
-1
votes
0answers
47 views

while loop breaks out after one run when tried to create folders in remote server using ssh

while read -r dir; do ssh -q "$HOST" [[ -d "$dir" ]] if [[ $? -eq 1 ]]; then echo "directory is not present creating one" ssh $HOST 'mkdir -p $dir' <...
4
votes
3answers
648 views

Bash script using output of mount as a variable throws numerous errors

Ubuntu 18.04 server + LXDE. I can't get the hang of this bash scripting. This is my script "start" (with line numbering): #!/bin/bash reply=sudo mount 192.168.0.2:/home/dk/NFS /home/dk/NFS if $reply =...