Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

learn more… | top users | synonyms (1)

0
votes
0answers
19 views

What is the difference between setting the environment variables in these 2 ways?

For a project I'm working on, we require nginx and lua, and we start it like this: MYVAR1=some_value MYVAR2=some_value /usr/local/openresty/nginx/sbin/nginx -p `pwd`/ -c nginx.conf And everything ...
-1
votes
1answer
29 views

What does a minus sign inside of dollar brackets of a shell script mean?

In an existing shell script, I'm seeing some variables referenced that either include or end with a minus sign. For example: PID=${PID-/run/unicorn.pid} and: run_by_init() { ([ "${previous-}" ...
0
votes
0answers
17 views

Mirror specific Files from website [on hold]

I am trying to archive collections from several websites. I want to be able to maintain them is some sort of organization. So it would be ideal to store them in a mirrored dir structure. Below is my ...
4
votes
0answers
154 views

Persistent Bash Prompt Prefix Linux [migrated]

I want to have the FQDN as bash prefix instead of just using the hostname. So I can change root@web: ~$ to root@web.domain.tld: ~$ I already know that that is possible by using: ...
0
votes
1answer
42 views

Bash linux increment variable

i am trying to increment a variable name inside a for loop to get 4 dynamic variable in each loop, this is an example while read line do for n in `seq 1 4` do ...
0
votes
1answer
24 views

Nginx how to run shell script on page load via lua module os execute and then serve directory listing?

So I have a bash script that I want to execute/run on each "page load" of url so that it will modify (creating symlinks) to a /public/html/ folder that I want the server to then serve. The problem ...
-2
votes
0answers
28 views

Scripting a menu with selection indicator in bash [migrated]

I'm really new in bash scripting and I'm currently automating my project creation process. I've done a lot of work right now but i'm thinking about changing my installation plugins part... Could ...
-2
votes
0answers
50 views

Syntax Error: unexpected end of file — Bash script [migrated]

I am trying to create an spritz app! Everything was working fine, but since yesterday I keep getting this error: ./spritz: line 176: syntax error: unexpected end of file I have checked the script ...
-1
votes
0answers
9 views

celery monitoring - how to do it [on hold]

Do you know of a way that I can monitor the status of tasks that are running on celery? I want to know if some tasks have failed or succeeded and send a mail to me. Ideally I want to do this in bash.
-1
votes
0answers
38 views

ubuntu script two different outputs [duplicate]

So I have a script that checks with curl if a website is redirect. If the website is redirected, an e-mail will be sent. If the website is not redirected, an if-statement is called where I get the ...
0
votes
2answers
88 views

can't execute sudo in a php script ran from http [closed]

I am not able to run any sudo command in any exec call from php script if the php was execute from the browser. However if the same scripts runs under bash shell, it works just fine. I suspect there ...
0
votes
2answers
44 views

Can I get an array as an option argument in bash script

I am writing a shell script and wants to pass multiple options in an argument. Is it possible to do that like using getopts? Requirement example: ./shell.sh -d db1 db2 should pass the values db1 ...
-1
votes
0answers
37 views

How to send custom signal to bash daemon process? [migrated]

I have simple bash daemon running (with root privileges ) in background which suppose to do action1 or/and action2 when notified. How do I notify it/send some kind of signal on which it will react? ...
0
votes
0answers
10 views

How to correct malfunctioning Terminal in Mac [migrated]

Terminal commands like ls, sudo, cp, mv, rm are not recognised in my Mac terminal. I face this problem after I edited the .bash_profile file. (I installed Tomcat and added PATH and CATALINA_HOME ...
0
votes
0answers
17 views

Delete folders which not match a list [migrated]

I need practical example how get rid folders which are not in the list in UNIX. So i do not need to compare its contents or md5sums, just compare folders names. For example, one folder has few ...
-2
votes
1answer
28 views

bash: variable increment does not occur

I have a problem in one of my bash shell scripts. Asked a few colleagues, but they all just shake their heads (after some scratching), so I've come here for an answer. According to my understanding ...
-1
votes
0answers
9 views

How do I perform xargs grep on grep output that has spaces? [migrated]

I'm searching for files based on a regular expression, and then I'm trying to search those files for content. So, for example, I have something like #Find all C++ files that match a certain pattern ...
2
votes
2answers
47 views

bash: convert date from to unix timestamp changes timestamp

Running the following command at the xen-servers (either DOM0 or DOMU) at $company gives me a negativ number, on every other system zero (0) (even in my cygwin). date -d "1970-01-01T00:00:00" "+%s" ...
0
votes
1answer
21 views

Logrotate executes postrotate even if file not rotated

I have a problem with my rsyslog and imfile that fails when one of my log file gets truncated.. So to workaround the problem I have modified the logrotate script as follow: ...
1
vote
2answers
23 views

How to cp only into the latest directory name?

mkdir test_dir test_dir1 test_dir2 test_dir3 touch file1 file2 file3 cp -v file* test_dir*/ This copies only to test_dir3 and not in test_dir, test_dir1, test_dir2. Why? For that matter it copies ...
4
votes
3answers
660 views

Is mv with wildcard still atomic

My understanding is that mv dir1/file1 dir2/ is atomic, Is mv dir1/* dir2/ also atomic? As an example, assume there are 10 files in dir1 that are 10GB each.
-1
votes
1answer
29 views

Bash FTP login into Microsoft FTP Service, Invalid command

This is my script. As you can see it executes only 1 command (cd /) after connecting to a remote FTP server. It's very simple... but it doesn't work and give me "Invalid command". I don't understand ...
0
votes
1answer
79 views

FTP file transfer, loop through a directory and copy old files

I would like to move files older than 30 days and copy them into a remote FTP server. I've already written this script, that is able to connect via FTP. Usually, to move files, I would run this ...
-1
votes
0answers
6 views

remove ^M from solaris by perl one liner on the same file [migrated]

usually in order to remove the ^M from file we do dos2unix test.txt test.txt tr -d ‘\r’ <old.file > <new.file> but this approach insist to create new file if we not want to create a ...
-6
votes
0answers
53 views

Linux 'w' command, get IDLE time in seconds [migrated]

I need to get idle time of all users in seconds (not minutes or days), how do i go about doing it ? This command lists the idle times of all connected users : w | awk '{if (NR!=1) {print $1,$5 }}' ...
1
vote
0answers
25 views

Parsing part of a file name to use as a variable in bash [migrated]

I need to get the DB name and use it as a variable from part of a file name. Currently I have it pulling in the name of the file from a ls command. This is what it returns: Test-20150311-1200.sql I ...
0
votes
0answers
31 views

Advanced Wget usage [migrated]

I have a list of about 200 servers which contain links to individual files, for this question, let's just pretend they're .txt files. I need to download every file, however some servers only have the ...
0
votes
1answer
30 views

linux-tomcat - add command to startup.sh

How can I add a command at the end of the tomcat startup.sh script to execute a file. I think it is something like this. Assuming my file needs start as command passed to it below: exec ...
0
votes
2answers
50 views

Bash scripting: Using wildcard

I have two different folders. The first one contains symlbolic links named with the names of my servers (for example: udcedpai101). The second one contains the inventory of my servers where the ...
0
votes
0answers
38 views

Is shell parent of all the processes in linux [migrated]

I have been trying to understand shell scopes and environment in depth. I have been reading about how if we do export VARIABLE=VALUE it will be available in subshell. So I wanted to ask a question I ...
-1
votes
1answer
46 views

understanding the result of this bash script [closed]

I have this simple bash script #!/bin/bash -x for line in `tail /home/user/line` do echo $line done but dont know why it echos all words instead of each line below is output ++ tail ...
0
votes
3answers
28 views

bash variables: expanding the values of variables whose names match a pattern

Let's say in bash I have several variables: POD3_1, POD3_A, POD3_2, POD3_B, etc. Each of the variables names begins with "POD3". Let's say I want to expand the value of all the variables on the ...
-1
votes
4answers
150 views

How to test if two given files are identical?

Just updated the code... I get out everytime on the "else" sequence. You can download the update.sh file from my server. it only contains echo "Hallo update" Updated code (03.11.2015) ...
-1
votes
1answer
47 views

SED multiline recursive find and replace [duplicate]

I have a large number of sites with the same bit of php inserted in all files that contain footer in their filenames. //###==### malicious code //###==### How to use SED or another command to ...
1
vote
1answer
32 views

Is using su to drop root in shell scripts a security risk?

When searching for how to drop root permissions in shell scripts, I often see answers using su. However, when you're done using su you can just type logout and be back at the shell of the original ...
0
votes
3answers
51 views

Load users environment variables in a cronjob

How can I load the users environment variables in a cronjob? I have a cronjob which should start a script every minute on my Ubuntu machine: * * * * * /home/user/myscript.sh; In this script I ...
3
votes
4answers
35 views

Bash evaluation baffling

I'm trying to get a script to do something when one number is bigger than another, in this case, when the system load average exceeds a defined value. All of it is working aside from the evaluation ...
1
vote
0answers
21 views

how to filter sar -d disk output tidily

sar -D output-I would like a suitable command to run alongside stress -hdd but this is the output which sar -D 1 10 gives. I have filtered it using both awk |'NR > 1 {printf ...
1
vote
1answer
49 views

How to make a simple script that increases a number character by 1

I have to add a single command for MANY vlans, and wondering if I can generate a simple text file somehow? Then I can simply paste the text file into the network switch and it will add the needed ...
1
vote
1answer
39 views

How can I know the absolute path of a running process? on solaris

this is the command to view the process path on Linux ps -auxwe | grep 24466 ( 24466 is only example ) but please advice is it possible to view the path of running process on Solaris if yes ...
0
votes
1answer
54 views

Straight forward way to run ssh-agent and ssh-add on login via SSH?

I'm trying to have the following commands be auto-executed when I login to my server via ssh: ssh-agent /bin/bash ssh-add ~/.ssh/id_rsa My ssh key has a passphrase and I'm fine with entering it ...
0
votes
1answer
19 views

Should I be adding aliases to /etc/profile instead of /etc/basrhc?

I've been adding them to /etc/basrhc, and that works most of the time. But I noticed that when I su to another user, I lose all my aliases. It turns out that /etc/bashrc is only loaded when the ...
0
votes
1answer
18 views

Resolve packages not found and errors during configure,make,make install in a script

I need to have a script that will install a package from source in a Linux system and need to know how to take care of the errors that usually come up as a result of the first step ./configure maybe a ...
0
votes
1answer
39 views

Issue with Bash Script On FreeBSD

I have the below bash script set to run every hour via cron as the root user. The purpose of this script is to email us when files have been uploaded to our sftp server and send us the logins. Here is ...
0
votes
1answer
56 views

How to automate input for a repetitive script! Expect in Bash?

I am a junior sys admin. Reason I'm asking this question is because we don't have a senior sys-admin here who is proficient with scripting. Senior guys are at the head office and too busy for ...
1
vote
2answers
27 views

Find process with most TCP sockets?

How can I find the process with the most TCP sockets that is currently running with bash ? I would like to only output the process name
0
votes
1answer
53 views

Bash: Output of a command is written only to screen and not to another file while using tee, what could be the reason?

In order to troubleshoot some ftp connection error, I've been instructed to write a bash script which will infinitely connect to a remote frp server and get one file from there. ftpuser="ftpuser" ...
1
vote
2answers
64 views

Locally deny login to users authenticated via LDAP

I have a RedHat Linux server that are is use for more than 1000 users Users names are coming to the server via LDAP protocol, so login authentication is from the LDAP My question: is it possible to ...
2
votes
0answers
25 views

Linux: What could be the reason for random fails in updating passwd.byuid by running yppasswd?

In order to allow NOC users in my company to manage users through NIS I've created the following script: #!/bin/bash # This script will simplicate NIS user management. # You will not be able to ...
2
votes
1answer
34 views

Linux: How can I get a different exit code from the find command if no files matching the pattern I used are found? [duplicate]

I have a script which runs the next command: find /storage2/hpfiles_staging/ -name \*.gz -mmin +600 And then rsync's the files to a remote location. Sometimes the find command returns no output ...