Stack Exchange Network

Stack Exchange network consists of 175 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]

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.

0
votes
0answers
6 views

How to validate pbrun working or not but not really doing pbrun

I am developing and health check script for our application and we need to validate few things after every major change and/or patching . One of the checks is whether the pbrun access is working or ...
0
votes
0answers
303 views

Continuum Anaconda Fedora 22 path

After an update to Windows 10 caused problems in my dual boot system I had to reinstall Fedora 22. So, starting with a fresh system I reinstalled my work environment. The one installation that has ...
-1
votes
2answers
45 views

How to find avg, min, max and all for all file statistics (unix bash shell scripting)

I have a question regarding finding the average, minimum, maximum through shell scripting. Background: I have directories ranging from 1998-2019, there are 1,000 files within these directories. Each ...
1
vote
0answers
24 views

Execute a shell script on the remote server in the background

I have a list of servers and Bash scripts that need to be executed on a server. For example, I have a script that schedules a cronjob (with the command that the user has specified) on a server. This ...
0
votes
2answers
58 views

How to do vi edit on bash Linux?

Almost 5 years ago, used to do something like VIEDIT (forgot exact word I used to use). Usecase - when I want paste bunch of lines of program or strings I do something like viedit (again I forgot the ...
0
votes
5answers
1k views

Sum all file sizes

I'm new to bash and I need to do a little script to sum all file sizes, excluding subdirectories. My first idea was to keep the columns when you do ls -l. I cannot use grep, du or other advanced ...
0
votes
4answers
199 views

Bash multiple rename in one line: is possible?

Is possible to rename and substitute on fly with bash? for example i have VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB I want to rename for use in mencoder with movie_1.avi movie_2.avi,etc.. I know ...
2
votes
3answers
718 views

Bash script to wait for a process to finish on multiple servers [duplicate]

I wanted to ssh to multiple servers remotely and check whether any processes running on those servers and wait until the process to get finished. I have written the below code but this checks only for ...
0
votes
1answer
27 views

Maths revision program [closed]

I have created a program that will randomly select two numbers out of a range and ask a multiplication question from it. It looks very messy and repetitive. What I would like help with is "How would ...
0
votes
2answers
4k views

Creating script to move files based on date or filename

I have an FTP process that is constantly putting files into a directory. The date created is part of the filename in a format like this: YYYY-MM-DD-HH-MM-SS-xxxxxxxxxx.wav I would like to move the ...
1
vote
1answer
154 views

Updating a bunch of Macs via SSH

allI'm working on a script that'll be running from our Mac server, and it will (hopefully) update all of our Macs via Munki (repo is on the same server) and the built-in softwareupdate command. Here'...
1
vote
4answers
507 views

Bash command to “search and replace” file in changing directory tree

I've built a collection of files for research in a central repository on my server. I'm continually curating the repo changing the directory's tree structure by renaming and moving directories. And I'...
1
vote
1answer
43 views

Compiling bash from source in a custom env - custom profile is not being read

I just compiled bash 4.4.12 for my arm-based NAS. The NAS has a custom environment. The prefix is /ffp/ instead of /usr/. Starting the fresh compiled bash /ffp/etc/profile/ is not beeing read/...
-4
votes
1answer
554 views

Run a script command from one server on another

I have a go daddy account and also a vps in germany. In my vps, I run a code script (we will call it codegen). When I run ./codegen, I am asked how many codes I want to make and with that answer on ...
-1
votes
1answer
134 views

Writing a Bash script pulling every word separated by a comma out of a text file

I'm trying to write a Bash script that will read a text file and pull out every word that is followed by a comma on a new line. I tried using grep but it prints the whole line that has a comma in it, ...
5
votes
1answer
1k views

Writing bash function as one-line alias

How do I write this as an alias? p() { DIR=~/projects/$@ pushd "$DIR" } This is as far as I got, but it's piping stdin to pushd instead of xargs: alias p="xargs printf ~/projects/%s | pushd"...
-3
votes
1answer
37 views

Help required in logic

I have a below requirement. I am validating one of my code-file using one utility in shell script and writing that Error,Warning messages to an output file. Now i need to write a logic like if i ...
1
vote
1answer
342 views

BASH dd problem

i am trying to learn bash and now im trying to do a script for burning isos. I made the number "4" command to make sure the variables were right. the message i get when i complete my program and ...
5
votes
3answers
2k views

How to completely detach a process

I want to spawn a process and run it at the top level so that when the shell exits, the process keeps running. I had mistakenly thought that nohup would do this, but when I exit from the shell (the ...
0
votes
0answers
1k views

Trying to run a bash script in zabbix and automate the IP/Hostname

I'm trying to run a bash script on a zabbix server that will pull running configs from hosts to a TFTP server. I have the following script and it works well. The only issue is that where it says ...
0
votes
0answers
832 views

Bash Script - How can I concatenate several strings containing special characters? [on hold]

This is a simplified version of a script I'm working on. I'm reading numbers, which contain line breaks, from a file. I need to concatenate each number with other strings, and I need to pass that ...
0
votes
1answer
21 views

Reading an argument and creating a tempfile from it to use within the script

I am trying to write a script that would count the number of columns in a file. However, I don't know what the name of the file will be. I am trying to create a file called tempfile which has the ...
3
votes
2answers
49 views

Bash ignoring SIGINT trap when 'select' loop is running

When i use 'trap' combined with select loop, namely when i try to hit CTRL+C to break out while options are displayed, it will just print ^C in terminal. If i remove 'trap' from script it will ...
0
votes
1answer
21 views

How to start and disown a process in a single line?

I noticed that many times I need to start a process and disown it immediately. I trying to achieve this in a single line. Any ideas how to do it?
3
votes
4answers
70 views

bash command to create array with the 10 most recent images in a dir?

I'm writing a bash script and I need to create an array with the 10 most recent image files (from new to old) in the current dir. I consider "image files" to be files with certain extensions, like ....
0
votes
3answers
1k views

How to compare bash variable with double quotes

I have this code STATUS=`echo "test"` if [ $STATUS == "test" ]; then exit 0 fi I have tried everything and i am not able to make it true. I tried "$STATUS" == "test" eval $STATUS == "test" ${...
1
vote
1answer
51 views

How do I add this field?

I'm trying to print the signal strength of two wifi devices connected to a hotspot. I manage to do this script that prints the ip, hostname, mac and signal. In the script below the macs are stored in $...
66
votes
8answers
122k views

How to solve the issue that a Terminal screen is messed up? (usually after a resizing)

Sometimes, a terminal screen is messed up, and when we use man ls to read the manpages, or press the UP arrow to go to previous commands in history, the screen will show characters not as the right ...
1
vote
1answer
38 views

Ubuntu for Windows — Can't open PDF files via xdg-open

My default application for opening PDF files is Adobe Acrobat XI Pro. I would like to be able to open PDF files using this program via the Windows Subsystem for Linux. Currently when I run xdg-open ...
0
votes
0answers
15 views

Passing variable to jq to edit a json file

I am trying to pass a variable into jq like this '.Linux.date.$var' so far I have tried quoting them by name which is working fine. But I want to use variable to call them. I have this, which is ...
-1
votes
1answer
22 views

How to append * to the String and assigning a prepared SQL Query to another variable? i.e., (select * from …)

I'm trying to create a SQL Query and trying to assign it to some variable but I couldn't do that. TABLENAME=foo QUERY="select * from $TABLENAME" echo $QUERY I'm expecting the Query would be select * ...
0
votes
0answers
22 views

sed Shell Script not working correctly

I have this shell script that is supposed to go through a file and replace its primitive types with other specific text (it's for an assignment). The script is below: #!/bin/bash #Goes through an ...
0
votes
1answer
18 views

Find file while other file exist in same directory

I'm trying to do "one line script" or really small bash script. It have to find file (for example ./xxx/one.php) and if that file exist edit (with printf or echo) other file IN SAME directory (for ...
1
vote
1answer
21 views

Starting wpa_supplicant via script in systemd not working properly

I've written a script to manually start the wpa_supplicant function on a Fedora/Centos7 machine with a wireless NIC. Due to static routing issues, I cannot use NetworkManager (nor do I want do with ...
0
votes
2answers
261 views

Time slot definition in a Bash script [closed]

I need to define a time slot over midnight. When the script is triggered it should test if the time is between 05.00pm and 08.00am. Only if it's true an command should run. I tried the following and ...
0
votes
1answer
24 views

compare a certain number of lines between columns of two files

I have a thousand files and I need to verify if they all have exactly the same information in the second column up to a certain number of lines. Below an example. I would like to print the names of ...
56
votes
10answers
60k views

Is there a way to make “mv” fail silently?

A command like mv foo* ~/bar/ produces this message in stderr if there are no files matching foo*. mv: cannot stat `foo*': No such file or directory However, in the script I'm working on that case ...
2
votes
2answers
44 views

goto a specific line in awk to start processing [on hold]

I want the awk to go to the beginning of the block of lines to start processing it again once it hit the bottom of that block and processed its last line. Basically, if block of text is <START ...
11
votes
3answers
1k views

Trap 'Ctrl + c' for bash script but not for process open in this script

I tried to have an interactive program in a bash script : my_program And I wish to be able to close it with 'Ctrl + c'. But when I do it my script is closing as well. I know about. trap '' 2 ...
0
votes
1answer
45 views

Why can't I execute .bashrc directly and what is “sourcing”?

My .bashrc has the following permissions: -rwxr-xr-x So it's labeled "executable". My newbie brain tells me I should therefore be able to just run it. But when I try $ ./.bashrc I get: ./.bashrc:...
0
votes
2answers
100 views

Unable to run code in screen

I have following code to execute some commands on a virtue screen: screen -R << EOF cd /home/users/devops_tester/apps/Selenium-Webdriver export DISPLAY=:99 npm start EOF It gives ...
0
votes
2answers
962 views

Editing metadata with bash

I have a bunch of photos(jpeg, bmp, png) that I have arranged in such a manner that the metadata is in html form in a separate file. I would like create some script to read this html file and edit ...
1
vote
2answers
3k views

script to add users to otrs

I'm looking for a fast way to import customer users into otrs (ticket system) I have an export from Active Directory with: firstname lastname password email username There is a script in the otrs/...
-1
votes
0answers
13 views

Dynamic Log Remove

I want to delete logs in Linux machines and the path example below. /test1/test2/test3/x/a/b /test1/test2/test3/y/a/b /test1/test2/test3/z/a/b Thing is directory changes after the "test3" folder I ...
0
votes
2answers
2k views

How to change the format of the bash prompt?

My Gnu/Linux system is red hat and I ssh it from xshell. The command prompt format is like this: [xuemeng.cyn@e92e01494.em21 /home/qihang.gqh/online/h5_reco/user_level_1.0] $vi dn_click.py I ...
0
votes
3answers
6k views

Run a script in a new terminal window

I am looking to run a script that is separate from my parent script in another terminal window while keeping the current window usable. The reasoning behind this is I wish to allow the user to be ...
0
votes
0answers
12 views

Merge multiple files with different extensions using a loop in bash script [duplicate]

I have 100's of files of the form filename.0 filename.1 filename.2 filename.3 And they all have identical layouts which I want to merge together into one file using a loop in my bash script, I have ...
0
votes
4answers
56 views

How to extract the CSV file name from each line of this file

I have a file which contains lines like those: -rw-rw-rw 1 root root 6379 May 24 2016 test1.CSV -rw-rw-rw 1 root root 23249 May 25 2016 test2.CSV -rw-rw-rw 1 root root 2995 May 26 2016 test3.CSV ...
0
votes
2answers
23 views

creating OS environment variables using ExecStartPre on Systemd

I have the following unit file: [Unit] Description=Panel for Systemd Services After=network.target [Service] User=pysd Group=pysd PermissionsStartOnly=true WorkingDirectory=/opt/pysd ExecStartPre=/...
-1
votes
0answers
33 views

Script that checks a process's running status

I need to make a script that checks if a java jar is running on a particular port or not.If the jar is not running then the script should run it automatically. let's say I want to check if my jar xyz....