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

learn more… | top users | synonyms (1)

0
votes
1answer
11 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
34 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
43 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 ...
1
vote
0answers
24 views

Outputting PID of Rails server(s) with ps aux | grep - breaks when put into an alias? [migrated]

I'm trying to create an alias for an unwieldy command I'm using to output the PID and some other information about two rails servers I have running. When I simply run the command in terminal (over ...
0
votes
1answer
19 views

Find line within file matching pattern and make a substitution

I'm trying to simplify my life here but I'm stuck. I have a file containing multiple lines. Each line has a user and a number. I'd like to know a bash one-liner to search for a user and change the ...
0
votes
0answers
20 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
28 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
41 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
66 views

How to execute bash script through pxe boot [on hold]

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
41 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
38 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
27 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 ...
1
vote
2answers
38 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
16 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
0answers
6 views

Odd syntax for ssh and bash to run command [migrated]

I'm pretty new to shell/bash scripting and I'm writing a script on OSX to automate some rather tedious efforts. I'm trying to run a portion of my script on a remote host using ssh. There's a common ...
0
votes
2answers
36 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
0answers
33 views

Why mount with nfs is not work into my bash script?

I have got this code in bash script: if ! grep ^$hzvzenter_SERVER_IP:/linuxcoe /proc/mounts 1>/dev/null 2>&1; then mkdir -p /linuxcoe-iso CMD_ERR=`mount -t nfs ...
-2
votes
2answers
36 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
52 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
87 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
0answers
5 views

Unattended build of linux kernel [migrated]

Goal: I am trying to automate the 4.0.4 kernel build to provision it to multiple machines. Since AUFS no longer ships in "extras" package, I am compiling it as well, and then adding via make ...
0
votes
0answers
11 views

How to disable vcstime [migrated]

There's a program /usr/sbin/vcstime which prints the date/time in the top/right corner of your terminals. You can enable it in /etc/kbd/config (on the last line). It's disabled by default. I'm having ...
0
votes
0answers
13 views

Script to automate command in PowerBroker

I'm trying to script my commands that are run inside the pbrun shell. I've tried executing through a normal script, but that doesn't work because, to my understanding, pbrun is executed in its won ...
0
votes
0answers
21 views

linux + how to restore sdaXX.fsa files by the fsarchiver tool

I get the following files (that was backup from some Linux machine ) swap.label sda-partition-info.sfdisk sda.mbr sda1.fsa sda2.fsa sda3.fsa sda.labels sda7.fsa sda5.fsa in order to build ...
0
votes
2answers
19 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
29 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
53 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 ...
3
votes
1answer
152 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 ...
1
vote
2answers
45 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
27 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 ...
0
votes
1answer
13 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
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 ( ...
1
vote
0answers
43 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
1answer
34 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
33 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
26 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
42 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 ...
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
60 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
41 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
32 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
48 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
29 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
58 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
51 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 ...
0
votes
1answer
117 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 ...
0
votes
1answer
82 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
46 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
46 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
27 views

Trying to get pid from a script running as su -c

I am trying to get these scripts to work in an environment where the java application needs to run as user foobar no matter if it is started as root or foobar. So these are my modifications to the ...