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
1answer
37 views

How to pass strings stored in variables to find command

I need to pass strings stored in a variable to a find command string. What I do: s="\( ! -path \"/path/to/1/Recycle Bin\" \) -or" s="${s} \( ! -path \"/path/to/2/Recycle Bin\" \)" exec=$(find "/path/...
3
votes
2answers
169 views

whereis returns different path to which

I utilize command whereis $ whereis rm /bin/rm when it come to which $ which rm /usr/local/opt/coreutils/libexec/gnubin/rm They are different, which path I actually applied when issue command ...
0
votes
1answer
31 views

Run a script on boot

I have a script to start a java application automatically. # colors red='\e[0;31m' green='\e[0;32m' yellow='\e[0;33m' reset='\e[0m' echoRed() { echo -e "${red}$1${reset}"; } echoGreen() { echo -e "$...
0
votes
2answers
47 views

Output the current PATH to text file using BASH script [on hold]

I am trying to output the PATH used by the computer to a simple text file. Something like echo PATH >PATH.TXT or >>PATH.TXT With the double >>, it works but gives each on a different line and if I ...
1
vote
2answers
39 views

How can I move content of a txt file to another using Bash Script?

I want to copy the whole content of the file into another multiple files as group wise. Suppose If I select 10 .txt files then the contents of those files should be copy and paste in a another one new ...
0
votes
0answers
16 views

How to install custom service in ubuntu 18 and windows both via bash file for both OS [on hold]

i have to deploy a custom service on cloud which they need to install and start i have to create script for start them and stop them as well and install them too
0
votes
0answers
19 views

How to put special characters with lynx script?

I'm writing a script to send any code to a page by making the lynx to type it completely but I don't know how to make it print some special characters: '*' , key * doesn't work '\t', key <tab> ...
1
vote
1answer
48 views

What kind of code do keyboard “custom shortcuts” accept

The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's ...
0
votes
0answers
13 views

How to Change Base Folder Date

I have a backup drive and keep seven rolling backups for the past seven days using Days of the week within a Bash script. day-1/home/username/.config day-2/home/username/.config When I look at that ...
0
votes
0answers
19 views

Launching vscode from bash gives the following error

Output of code --verbose: [main 3:45:14 PM] Error: listen EACCES /run/user/0/vscode-4369ae7e-1.29.1-main.sock at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort ...
3
votes
2answers
116 views

how to compare list of functions from 2 files?

I wanted to list all functions in 2 files I have, so I used: cat <file_A> | grep -E "^function" cat <file_B> | grep -E "^function" How can I compare the outputs and highlight the ...
3
votes
1answer
68 views

How to close a named pipe (thereby enabling it for cat)?

I need help closing a named pipe. I created a named fifo via mkfifo myfifo, then some C++ executable files wrote/read from myfifo, and now I wish to close it (so I can cat its contents to read them). ...
0
votes
1answer
73 views

Executable program will not run

I was trying to run Monero-cli one my Ubuntu laptop and it wont let me run the executable file after the start.sh file. It said Permission denied on both the executable and start.sh and I could not ...
0
votes
0answers
28 views

Running a SHC encrypted file on other system

long time ago (2-3 years ago) I had a dedicated that had a SHC encrypted shell script (script.sh.x file) And I do have that file til now but not that dedicated, it died long time ago, now I used SHC ...
1
vote
1answer
51 views

Assigned variable for pipeline is not working

I have a shell script to check port status. After checking the port if it is busy then will kill it. #check port and kill checkPort(){ check=$(sudo netstat -nlpt | grep 2020 | awk '{print $6}') ...
0
votes
0answers
25 views

What Files to Exclude for a Backup

It took me forever to get my current apps and themes configured just the way I want them. I'm looking for a way to include all these configurations, the apps themselves, and any of my personal files ...
0
votes
0answers
32 views

sftp not to rewrite existing file

i have created a bash file to run sftp transfer between two server. All working fine now but i just want to ask how do i transfer a not existing file only? Right now when the server run the bash file, ...
0
votes
1answer
24 views

Changing text on a file using scripts [duplicate]

I want to change the PASS_MIN_DAYS = (whatever value is set) to PASS_MIN_DAYS = 15 using a script.The file it's in is /etc/login.defs.
3
votes
4answers
54 views

How to show 'similar' commands when you forget the exact command [duplicate]

If I get this: No command 'pdf' found, but there are 16 similar ones pdf: command not found How do I see the 16 similar commands?
-1
votes
0answers
15 views

Script to delete users not on a text file [duplicate]

I have a list of users I want to keep on my computer, but I want to delete all the other users with a script. Can anyone help? I'm new to scripting. Make it so only users greater than 10000 get ...
0
votes
0answers
31 views

-bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: Permission denied

I have an Ubuntu(16.4) server which is accessible via putty(No GUI configured) Yesterday I changed the /usr/bin permissions from the default 755 to 750 and now I am unable to change it back. Command ...
0
votes
1answer
19 views

use $x variable in with cut command parameter

i have this bash line current_part= `echo "${lines[$i]}" | cut -d , -f$x` is it possible to use variable $x with cut's parameter -f ? i want -f1, -f2, -f3 and so on with each iteration of $x
-1
votes
0answers
23 views

I cant get cron to work [duplicate]

sudo crontab -e >> { *1 * * * * date +'%d/%m/%Y %H:%M' >> ultimoscript.txt } My goal is to make a script scriptexample that crontab program me. I want you to write in ultimoscript.txt the ...
1
vote
1answer
66 views

How to write a shell script to check port and kill it?

I have a command to check the port and kill specific pid running on that port. But I want to modify it to, Check port is busy or available If the port is busy then kill the pid How can I do this? ...
-1
votes
0answers
28 views

How to check if screen is locked from bash? [closed]

How to check whether the computer screen is locked or active?. I would like to do that from shell script.
0
votes
2answers
50 views

How to separate output of variables [closed]

I want to write a script to separate outputs. Output should be like this: 192.168.94.139 middle of loop 192.168.94.140 middle of loop After separating to the new line I want to run some ...
0
votes
0answers
15 views

Bash script to automaticly change a given user's password [duplicate]

So, I know that the passwd command allows me to change my own password, and if run with sudo, allows me to change anyone's password, but what if I want a script to do it? I have a script that grabs a ...
-3
votes
2answers
51 views

Using the result of a command as an argument in bash? And a little more [closed]

I am really a beginner in the field of language, please excuse me in advance. I would like to return the value of a command in a parameter, ie return the value of ls -l in $1. I also can't do the ls ...
-2
votes
1answer
60 views

syntax error near unexpected token `newline' in .bashrc

I'm trying to add script function proxyset() { proxy_enabled=true NO_PROXY_DOMAINS=".abc.com," LOCAL_ADDRESSES="localhost" USER=<USER_ID> PASSWORD=<...
0
votes
0answers
51 views

First bash script: computer to dropbox backup help

I have the following script in /.backup with a symlink to cron.weekly. The goal is to have my entire system encrypted, compressed, and saved to dropbox every week. This is my first bash script and I'm ...
0
votes
1answer
37 views

runaway regular expression error in awk

I have a script which converts expressions in different units to standard units like: distance=1km -> distance=1000m. This is my code: #!/bin/bash cat "$1" | grep '=' | awk -F= '{switch ($2) { ...
0
votes
0answers
74 views

wi-fi adapter not found

I am having hp-EliteBook 8470p I am getting an error like "no wifi device recently I was run a command chmod 7777 on root by mistake and now I am getting this https://i.stack.imgur.com/f03OZ.png
0
votes
0answers
19 views

Can we run shell scripts which are located in gitlab from Jenkins

I have a Jenkins parameter job to deploy artifacts to the remote server. I wrote a shell script to check whether there is a directoy called backup in /var/www/test.com path if not create a directory. ...
1
vote
2answers
46 views

Create a file to automatically check user list for users specified

I am realitively new to bash scripting, but have created this from my intense googling I am attempting to create a bash script to run on Ubuntu that will check the user list and find any users that ...
1
vote
2answers
40 views

Sort the file by its numerate number

I have the following files $ ls *.md | sort -n 1.pythonPrimer.md 10.mapsHashTablesAndSkipLists.md 11.searchTree.md 12.sortAndSelection.md 13.textProcessing.md 14.graphAlgorithms.md 15....
0
votes
0answers
38 views

Startup command with variable settings

I have Xubuntu 16.04 for 2 days. I am trying to set an entry in Session and Startup>Application Autostart that will set several bash variables and execute a command. I have managed how to do it ...
0
votes
0answers
47 views

Extract specific field in matrix

I am trying to extract some fields from a .txt file to generate another table. It is a matrix (size varies time to time) separated with ; (further by \ in header), each field can have >= 1 numerical ...
2
votes
1answer
36 views

how to create a regex string where you don't know what to escape

I have a passwd file with the line containing root being: root:6UZSjeWUui3JQ:0:0:root:/root:/bin/sh I want this line to be changed to: root:$1$dog$cNv/OuAd7CMNdrhWsHXAR.:0:0:root:/root:/bin/sh ...
1
vote
1answer
61 views

trying to write bash script that sends email with output from two variables ubuntu 18.04

The problem I am having is that the action I am looking for is for sendemail to send myself an email that contains both w output from the ssh user and output from doing an lsof -u on $SSH_USER to see ...
8
votes
4answers
1k views

How can SSH work with an if condition?

I have an if statement to calculate files and delete all except the latest three files. But I want to run this command remotely. How can I combine ssh with an if condition? I tried this but no ...
1
vote
1answer
35 views

argument not recognized for-loop

I'm new pretty new when it comes to creating scripts in linux (I also don't really know on which terms to use like bash/shell), but I have the following command in a script which I want to execute ...
3
votes
3answers
291 views

Edit text file to add space

I have a text file which looks like this ../pool/main/a/aalib/libaa1_1.4p5-44build2_amd64.deb ../pool/main/a/accountsservice/accountsservice_0.6.45-1ubuntu1_amd64.deb ../pool/main/a/accountsservice/...
3
votes
2answers
168 views

Use read line to iterate over variables

I have the following files: $ ls *.png | egrep -i "am|pm" output-0 11.42.30 AM.png output-0 5.10.12 PM.png .... I want to remove them but get this error: $ ls *.png | egrep -i "am|pm" | while read ...
1
vote
1answer
31 views

convert pdf to png and starts with numeral 1

I tried to convert an pdf to multiple pngs $ convert -density 150 1.primer.pdf -quality 100 output.png it work well but the output starts with 0 $ ls | grep png | sort -n output-0.png output-1....
2
votes
1answer
100 views

read input from a file and append that values to variables using shell

I'm trying to write a bash script to read a file as input and append the values/data in that file into variables and the values of the variables should be updated each iteration based on the input ...
2
votes
0answers
37 views

upgraded to Ubuntu 18.04 LTS and now there is error found when loading /home/[user]/.profile

My laptop used to have Ubuntu 16.04 LTS. I upgraded it to Ubuntu 18.04 LTS. After upgrading, every time I boot it, it shows this error message: Error found when loading /home/[user]/.profile: ...
0
votes
1answer
31 views

the attributes of files demonstrated by ls -l [duplicate]

I tried greedy@algorithms:~$ ls -l / total 2097292 drwxr-xr-x 2 root root 4096 11月 28 15:55 bin drwxr-xr-x 3 root root 4096 11月 28 16:34 boot drwxrwxr-x 2 root root 4096 5月 ...
1
vote
1answer
47 views

Command not found after setting source in bash script [duplicate]

Following the instructions here, and everything works fine manually. However, when I use the instructions in a bash script, I get rbenv command not found because the source ~/.bashrc didn't execute ...
2
votes
1answer
41 views

Save all command and all output (using script across terminals)

For a short period of time, I want to save the command history and output of every command I run in any terminal I open. It should all go in the same file. So basically I want to run a command (or ...
2
votes
2answers
110 views

Script for merging files in multiple nested directories by symbolic link

Basically I am looking for a script to automate stuff (See picture below) in Ubuntu. I'm thinking of using a bash script but other solutions (eg. python?) would also be excellent. 1) Suppose I have a ...