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

learn more… | top users | synonyms (1)

0
votes
0answers
3 views

Move all ls output and symlink

I want to move some of my files in directory to another drive and create symlink for each of them in the old directory that will point to the new directory. For example, [root@localhost olddir]# ls ...
0
votes
1answer
17 views

Solaris + date + what is the same equivalent for Solaris

on Linux the syntax for date with seconds is: date +%s 1438587288 from MAN PAGE - %s seconds since 1970-01-01 00:00:00 UTC what is the same equivalent for Solaris?
0
votes
2answers
2k views

How to delete all ufw rules for a certain port?

I am using ansible to configure ufw on my DB servers to only let accept connections from certain servers connection to a specific port (lets say 1234). When a server that used to have access is taken ...
109
votes
9answers
52k views

Keeping a linux process running after I logout

I'm connecting to a Linux machine through SSH, and I'm trying to run a heavy bash script that makes filesystem operations. It's expected to keep running for hours, but I cannot leave the SSH session ...
-1
votes
1answer
35 views

Bash add entry to fstab by script [on hold]

I'm newbies in bash scripting and i try to write script that add entry for cifs windows share to fstab. I writed a litle script but i'm not shure if it will work fine. I haven't linux to test it Can ...
2
votes
1answer
137 views

linux + at command + how to kill the job

I use the at command in order to run the task (test script ) every one min at -f /tmp/test now +1 minute commands will be executed using /bin/tcsh job 1438153690.a at Wed Jul 29 10:08:10 2015 ...
0
votes
2answers
38 views

top command + how to verify iowait value for one hour

my target is to check iowait value that not higher than 50 from top command and if value is higher than 50 for more then one hour , then need to give alarm about this ( by script or other option ) ...
3
votes
1answer
2k views

Linux- Permission denied?

I'm installing Neo4j server as a linux service, but when I install it, I get the following message: /sbin/insserv: Permission denied What is this? What should I do? I'm running everything with ...
-1
votes
0answers
22 views

Why should I use a Dockerfile instead of a batch script? [migrated]

I'm new to Docker and feeling my way around. My plan is to build a typical web app using Nginx+Rails+Postgress, all of which will be in the one container. I'm not (currently) doing anything complex ...
1
vote
2answers
4k views

Fork a process inside a bash shell script

I've a simple shell script like #!/bin/bash sh -c "sleep 60" & exec sleep 120 In using the pstree command, I found something like `-sleep(11681)---sleep(11682) The first sleep is due to the ...
0
votes
1answer
23 views

Pass output of an expression to the standard input of another program

I'm trying to generate some data to pass to another program, which takes the argument from standard input, and requires confirmation of that argument. How do I do this in bash? From the manual ...
8
votes
4answers
8k views

Determine if file is in the process of being written upon?

I need to deploy an automated process (via 1 min cron script) that looks for tar files in a specific directory. If a tar file is found, it is untarred to the appropriate location and then the tar file ...
0
votes
1answer
11 views

Bash find file with specific permission for group, no matter permission for user and others

Using only octal notation, I need to find file that have only read permissions for group, no matter which owner and other permission are. Which is the right command? I can't find it. Thank you.
1
vote
0answers
42 views

bash scripting comparing 2 things [closed]

My problem is that i have to check what files are included in the $directory, then i have to make a new file with name specified by me and compare if the name doesn't already exist in this directory ( ...
0
votes
0answers
24 views

bash scripting and comparing 2 directories - Beginner [duplicate]

My problem is that i have to check what files are included in the $directory, then i have to make a new file with name specified by me and compare if the name doesn't already exist in this directory ( ...
3
votes
3answers
3k views

Can't run AWS CLI from CRON (credentials)

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without ...
8
votes
4answers
16k views

cp command prompts on overwrite even with -f

I am trying to copy all newer jpgs from one folder to another using the following command cp -u --force /home/oldfolder/*.jpg /home/newfolder/ and I get the following promt: cp: overwrite ...
1
vote
4answers
29 views

find command with parameters in variable

> find /etc -name 'shells' /etc/shells # good !! > SEARCH="-name 'shells'"; find /etc $SEARCH # nothing found - bad !! Why "find" command can't take params in variable? Other commands ...
-1
votes
0answers
22 views

Command Run Differently Depending on How Logged In? [migrated]

Is there a way to have one command run differently, depending on the manner in which one is logged into the session launching it? Basically, we have a command that when run, launches vim to display ...
0
votes
1answer
27 views

cron and lftp issue

I have the following scripts running on raspbian. start #!/bin/bash /root/config/commands 2>&1 > /root/log/$HOSTNAME.log commands #!/bin/bash source /root/config/variables echo TestLine ...
-3
votes
0answers
27 views

Change ip address while surf web pages

I am looking for command line browser like lynx but with --bind-address command line argument, like wget does. so i can browse the webpage with one of my ip address in server
0
votes
1answer
24 views

find files which are not currently in use

I'm trying to archive some older files, but don't want to touch all the files which are currently in use. What's the best way to ask find to exclude "in use" files? Right now I'm working on this ...
5
votes
0answers
262 views

Renaming: How to attach a word or rename multiple files [migrated]

I have multiple files in my directory. for example: eventDataLog.txt.2015-04-23-22 eventDataLog.txt.2015-04-23-23 eventDataLog.txt.2015-04-24-01 eventDataLog.txt.2015-04-24-02 ...
7
votes
3answers
328 views

How to execute a command for each file in a deep directory structure, recursively?

I have a deep directory structure, with a large number of files (about 1M). I'd like to execute a command against each. (In my case the files are pngs which I'd like to run optipng against.) I've ...
7
votes
5answers
2k views

Pass a pipe to a command that expects a filename

Say I have a command foo which takes a filename argument: foo myfile.txt. Annoyingly, foo doesn't read from standard input. Instead of an actual file, I'd like to pass it the result of another command ...
0
votes
1answer
33 views

OpenSCAP incorrectly reporting false for RHSA-2014:1306: bash security update (Important)

I'm using the following command to test for RHSA-2014:1306 on CentOS 5.9: oscap oval eval --id oval:com.redhat.rhsa:def:20141306 com.redhat.rhsa-all.xml The result is: Definition ...
3
votes
3answers
7k views

Using sed to remove both an opening and closing square bracket around a string

I'm running this command in a bash shell on Ubuntu 12.04.1 LTS. I'm attempting to remove both the [ and ] characters in one fell swoop, i.e. without having to pipe to sed a second time. I know square ...
0
votes
1answer
23 views

Is there a way to prevent the Screen progarm from killing all windows?

I have a server application whose output is can be viewed through the Screen application on linux. However, I noticed when using the command-line application I noticed that this command can terminate ...
1
vote
1answer
58 views

Best way to show architecture of a specified file system?

Admitting a filesystem is installed in ~/FS/ (which is its root), how can I check its architecture without chroot? I tried with dpkg --root=~/FS/ --print-architecture but it still prints me the ...
0
votes
1answer
26 views

bash rsync is Killed by signal 2

Problem: I am trying to prevent the user to cancel the script by using ctrl + c. The following script executes completely, except rsync that insists on dying, displaying the error "Killed by signal ...
0
votes
2answers
23 views

Strange behavior of SCP through .sh file

I'm hitting a strange issue with SCP on cygwin, scp $HOME/deploy.sh user@host:/tmp works fine, files get copied to the remote system. But the same command inside a test.sh won't work. I can see ...
0
votes
1answer
20 views

Whats the proper what to terminate a script using start-stop-daemon?

I am using a start-stop-daemon to make a INIT script for my script. I am using --make-pidfile cause my script doesnt make its own pid. I can start my script using start and pid file generates with ...
0
votes
3answers
54 views

Multiple servers Rsync into one NAS simultaneaus

Scenario: 1 NAS at our main office (Synology Cubestation CS407) 20 remote servers in various physical retail stores (1 server per store) Network between HQ and stores are in an MPLS/VPN. I have ...
0
votes
2answers
42 views

rsync - How can I exclude from all instances of a file while using relative paths for each file?

I am coding a deployment script that uses rsync to sync cloned repository files with a website target directory. I am trying to allow my users the ability to place a .exclude file anywhere in their ...
0
votes
1answer
48 views

php-fpm and Nginx dynamic environment variable

FPM configration stats that you can retrieve variables from your current environment. However, on ubuntu using Nginx and PHP-FPM, I can not find a way to retrieve the variable value from the ...
0
votes
1answer
43 views

Different values in bash and Zabbix WebUI

I would like to ask you for any hint regarding following issue. I'm using external scripts for checks in Zabbix 2.2. I try to develop some script which will get timestamp of certain file on remote ...
2
votes
6answers
3k views

Running ssh-agent from a shell script

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The ...
-3
votes
3answers
660 views

What's the short cut for fg in linux? [closed]

ctrl-z is the short cut for bg,what's for fg? Anyone knows this?
2
votes
0answers
19 views

Bash: How to avoid variable name substitution when using auto-completion? [migrated]

I'd like Bash to stop removing variable names from paths and replacing them by their values. I tried several 'shopts' settings in various bash versions but was not successful in keeping a variable ...
1
vote
1answer
1k views

Improper output in SSH session on OSX using FreeSSHd on Windows with cygwin bash/sh shell

I am testing out running an SSH server on a local Windows VM. I have installed FreeSSHd and set the command shell to "c:\cygwin\bin\sh --login -i" (bash as well) with "Use new console engine" ...
143
votes
4answers
53k views

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is posix-compliant, found in sh and the former is an extension ...
-2
votes
0answers
27 views

echo text after curl command on same line [migrated]

#!/bin/bash echo "$(curl -s -I https://google.com|grep Server)" abc returns: abcer: gws and bash -x shows: ++ grep Server ++ curl -s -I https://google.com ' abco 'Server: gws abcer: gws but echo ...
2
votes
1answer
1k views

Calculate average of every 5 samples with rrdtool or other languages

I want to make an average of 5 samples and calculate a single value: Current output - I put resolution of 5 minutes but receive 5 samples: $ rrdtool fetch file.rrd AVERAGE -r 300 --start 1200000000 ...
8
votes
4answers
4k views

zcat/gzcat works in linux, not on osx. general linux/osx compatibility

First the specific problem: In linux, I use zcat to list a .zip file. In osx, zcat seems to automatically append .Z to the file name. Various people suggest replacing zcat with gzcat; however, gzcat ...
0
votes
1answer
67 views

Shell script for docker ps -a | grep to find number of certain containers running

I want to write a script that is executed by my development build server that will remove any 'similar' docker containers before building and running a new container. Below is pseudo code for the ...
21
votes
5answers
63k views

How do I sleep for a millisecond in bash or ksh

sleep is a very popular command and we can start sleep from 1 second: # wait one second please sleep 1 but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ? ...
1
vote
1answer
1k views

JBoss EAP 6.2 on RHEL 6: ./bin/init.d/jboss-as-standalone.sh hangs while calling via SSH

I'm using jboss-as-standalone.sh to manage JBoss EAP standalone as a service. I can start/stop the service with "service jboss-as-standalone.sh start/stop" while I'm on a terminal. But I would like ...
0
votes
1answer
193 views

path as variable

BACKUP_SERVER_NAME="name" BACKUP_SERVER_USERNAME="user" COPY_FILE_TO_WINDOWS="/cygdrive/c/unix_test_copy" scp -r /$1/ $PRIMARY_SERVER_USERNAME@$PRIMARY_SERVER_NAME:$COPY_FILE_TO_WINDOWS How can I ...
1
vote
1answer
38 views

How do I run TomEE as a service on RHEL6?

cat /etc/passwd (last line): tomee:x:990:987::/home/tomee:/bin/false I need to make an init.d script to run Tomcat EE like service tomee start. So I have 2 problems: How I can execute command ...
1
vote
1answer
41 views

Command substitution into bash script $1 value

I have this simple script which changes permissions on my apache2 websites /var/www/html# cat permissions_setup.sh chown -R root $1 chgrp -R www-data $1 chmod -R 750 $1 chmod g+s $1 I have two .sh ...