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

learn more… | top users | synonyms (1)

1
vote
3answers
180 views

How execute perl one-liner from perl script (properly escaped)

I have a perl script from within which I need to execute a simple perl one-liner on a remote host: ssh 192.168.1.1 "perl -pi.bup -e 's/^(\s+?kernel)(.*)(?<!audit=1)$/$1$2 audit=1/' /etc/grub.conf" ...
0
votes
1answer
119 views

Script Works in Terminal, but Not as .sh

I have a script that works in the terminal perfectly, but for some reason won't fire off either in cron or when I run the script manually. I don't know if it makes a difference, but it's running on ...
-1
votes
1answer
57 views

File encryption when limited in storage

Assume: On Linux server we have limited free space. The task is to create archive of a folder (for example /var/www), encrypt it and upload to remote location keeping original unencrypted file in ...
6
votes
1answer
624 views

How to protect from dangerous bash commands? [closed]

When using bash with or without sudo there are many traps. For example when logged in as root between rm -rf ~/bin and rm -rf /bin there is just one character but this difference can make you ...
0
votes
3answers
68 views

How to ssh and use a personal bashrc without getting disconnected

I would like to be able to ssh to a remote host and run some repetitive commands on it before continuing my work. I have been trying the following command with no luck: ssh uname@remotehost.com '...
1
vote
2answers
79 views

User created with useradd instead of adduser loads a wrong Prompt

I've designed my bash prompt like this \u@\h> When i now create the User example with adduser, my prompt looks like example@host> But when i create a User with useradd, my prompt looks like \u@\...
0
votes
2answers
65 views

Read cron schedule from bash script

Is it possible to get the schedule for a running job? If i have this line in my crontab * * * * * /home/test/test.sh Can i read the * * * * * from test.sh, and only for that script? I hoped there ...
1
vote
1answer
106 views

gzip select directories into separate archives

How would I go about compressing a list of directories into separate archives? I have read solutions that just archive all the directories within a given dir, but there are some I want to skip. ...
0
votes
2answers
128 views

Bash move and rename folders

I have a bunch of folders like that: Team A - Folder 01/ Team A - Folder 02/ Team B - 14-12-2003 - Folder XX/ Team B - 21-03-2008 - Folder YY/ ... With the passing time, this list have became very ...
0
votes
1answer
30 views

Searching for files containing text (not string) in bash

How do I find files containing some particular text containing newlines and plenty of other charachters all sorts of quotes and backslashes using terminal?
1
vote
2answers
80 views

Get a file's ctime, atime, mtime and extended attributes

I would like to display a file's ctime, mtime and atime along with whether it has extended attributes or not. There are 2 commands that can do this but I have not been able to combine them into a ...
3
votes
3answers
69 views

How can I delete old log files?

I'm trying to figure out how can I delete old log files, I'm using Centos 6.5 and in my /var/log I see these old log files messages messages-20150802 messages-20150802 also the same in the /var/log/...
0
votes
0answers
36 views

Terminal piping misunderestanding

Folks I have a few questions around this command: echo 'cat //item/*[local-name()="id"]/text()' | xmllint --shell test.xml | sed '1 d;$ d;/^ -------$/ d' | sort | uniq --repeated I thought command ...
0
votes
1answer
156 views

Get all files/directories created before a certain date?

We have a samba share on an Ubuntu box that an office full of macs use. Something has happened recently and various folders now seem to have a created date of 1984 and are greyed out/inaccessible for ...
3
votes
1answer
183 views

The file and dir sizes of du -hs * is not consistent with du -hs

When I run the bash command du -hs ., the output is 1.2G . When I run the bash command du -hs *, the output is 108K action 4.0K activate.php 8.0K browse.php 584K captcha 164K ...
0
votes
2answers
444 views

How to execute bash script through pxe boot [closed]

Can any one tell me how to execute bash scripts via pxe boot. What I am trying to do is when Raw Server boots up I want to deploy cloned image over hard disk via PXE boot. I am aware that there are ...
0
votes
2answers
71 views

Limit user to access only 'docker inspect'?

Is there a way to give access for a user (www-data to be exact) to access ONLY 'docker inspect'? Any working solution is acceptable
0
votes
1answer
150 views

How to set Cron Job to empty cached directory

I have plain Ubuntu based server, i want to set Cron job and it will empty my website cache directory in every 24 hours, due to massive records 'rm -rf ' not work, so manually i used 'find . -name '' |...
0
votes
2answers
149 views

sftp returns code 0 even if there is an error reported “Couldn't create directory: Failure”

I am trying to write a Bash script responsible for creating a folder on a remote server. Snippet: !/bin/bash -e echo "Creating remote folder." echo mkdir test_folder | sftp -oPort=22 192.168.0.11:/...
1
vote
2answers
279 views

How does this variable escaping work in a systemd unit file?

I have a fairly simple unit file for a discovery sidekick service for a server instance I'm running on CoreOS. The unit file looks like this: [Unit] Description=Discovery for frontend server (...
1
vote
1answer
57 views

Python script crashes when run via Cron

I have a python script that completes exactly as expected when run manually as the root user. When I put the script into cron.daily it crashes 100% of the time. The error is a timeout error, but ...
0
votes
2answers
39 views

Amazon Linux : Autoscalling server deleting policy

I have tried many things but not able to save my files. I have an account in aws and I have created an autoscaling group.I want to copy my log files to s3 but when any of the server deleted ...
-2
votes
2answers
213 views

how to replace one url with another using sed inplace replace in multiple files?

As you can see in the script example down there, I'm trying to find and replace (inplace replace) a string which is part of an URL with another string (url part) within ALL files found with that ...
-1
votes
2answers
473 views

How to reload environment variables from within a script

I would like to be able to regenerate the value held by the environment variables inside my testing environment, and have the new values be read by PHP-FPM. I have written a script that regenerates ...
0
votes
4answers
133 views

How do I delete the contents of a directory if there are spaces in the path?

find -name "lastStable" -o -name "lastSuccessful" -exec sh -c "sudo rm -rv {}/*" {} \; As you can see from the above command, I am going through and deleting the contents of the lastStable and ...
0
votes
2answers
27 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 ...
1
vote
1answer
77 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?
-1
votes
1answer
277 views

Bash add entry to fstab by script [closed]

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
289 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
224 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 ) ...
0
votes
1answer
35 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 pages....
0
votes
1answer
23 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.
0
votes
0answers
27 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 ( ...
1
vote
0answers
52 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 ( ...
1
vote
1answer
257 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 ...
1
vote
4answers
177 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 ...
0
votes
1answer
52 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 ...
0
votes
1answer
107 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 oval:com.redhat....
0
votes
1answer
25 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
85 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
279 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 2"....
0
votes
3answers
133 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
2answers
107 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
210 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
160 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
1answer
91 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
2answers
2k 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 ...
1
vote
1answer
494 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 ...
1
vote
1answer
97 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 ...
1
vote
1answer
335 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 (...