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

learn more… | top users | synonyms (1)

0
votes
1answer
12 views

Not able to restrict the user to particular directory in unix

Below are the steps I performed: I created group sftponly. Added one user named sftpusers to that group. Added Subsystem sftp internal-sftp to file /etc/ssh/sshd_config Added this line to the file ...
1
vote
1answer
18 views

how to get the desired value in bash shell from the lshw output?

I want to extract the info from lshw output where it says *-cpu product: ...... I want only the product info of this -cpu How can I do that with awk or sed,
0
votes
2answers
27 views

Shell Script to connect to Database and execute query [on hold]

#!bin/bash Query="update table_name set colume ='i' where column_name is NOT NUll" mysql -u username -p password mysql <<EOF $query; EOF The above script is not working
9
votes
0answers
446 views

Why is my Bash script returning a syntax error? [migrated]

I am writing a script which loops into recent files in a folder and executes a command... #!/bin/bash cd /home/Downloads recent_files = ($(ls -t | head -20)) for file in "${recent_files[@]}" do ...
-2
votes
1answer
26 views

Uphold variable life in Bash loop [on hold]

I am trying to find the number of files with executable permission by the owner. I am doing this but giving me error cmd> ls -la /myScript.sh myScript.sh is the following z=0 while read line do ...
0
votes
1answer
49 views

Add cronjob with bash script - No crontab for root [duplicate]

I have a deployment script and in it I'm trying to add a cron job. This is the code I am using which I found on stackoverflow. I'm running debian 8. # ADD CRON crontab -l > mycron echo "10 * * * * ...
0
votes
0answers
22 views

Bash variable name is result of concatenation [migrated]

I'm trying to do : declare -a array=(first second third) for i in ${array[@]}; do ${i}_arg=$(some commands here...) done Expected result: first_arg=something1 second_arg=something2 ...
1
vote
1answer
34 views

Bash Script to set Linux OS

I'm working on a bash script and ran into an issue. I'm pushing what I know from using normal if/fi statements and trying to use them to set variables related to picking up the OS version, such as RH ...
5
votes
0answers
98 views

How to check from bash if package exists in debian [migrated]

I would like to make a installation bash script, where I would like to install mysql server. On linux mint I had followed code: apt-get -y --force-yes install mysql-server-5.6 but I installed new ...
0
votes
1answer
44 views

bash script doesn't run properly in crontab but runs fine manually

I wrote a small script to determine the average IOPs per hour in which I later manually convert to a graph and spreadsheet for management to discuss a potential SAN upgrade for an upcoming expansion ...
-1
votes
1answer
27 views

Linux - Print specific line from output [closed]

I am used to working with single line output and can use $1 $4 $8 to specify certain items in that line, but I have never worked with multiple line outputs and would like to just print one line ...
0
votes
2answers
43 views

Print last column containing spaces and special characters

I need a full path/command thats been execued to start a process thats exposed on the network - listens on tcp/udp . I did manage to get all of that using below "one liner": netstat -nlp46|tail -n +3 ...
1
vote
2answers
55 views

password check in bash script calling on expect

Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all ...
0
votes
1answer
64 views

Nagios bash syntax error

I want to refer with this question to the following post where I got the Skript: Post with Script I'm using Bash 4.1.2(1) and when I try to execute the script, I get following error messages: ...
0
votes
1answer
18 views

Export or Forward /var/spool/mail/USER (readable for customer)

there are some bounce mails in the /var/spool/mail/USER directory that failed to send. Now the customer receives all of those mails from us because he does not have direct access to them. I can ...
1
vote
1answer
47 views

Why is PATH wrong with cron entry? [duplicate]

I have an entry in cron.d: 31 17 * * * root /home/some_user/.bash_profile; /home/some_user/bin/some_script The profile sets a specific path, and I echo the current path in the profile to ensure its ...
1
vote
0answers
20 views

Recover last argument of the last command in bash' vi mode [migrated]

When using bash's vi mode (set -o vi), is it possible to recover the last argument of the last executed command? This is done in emacs mode with ESC + . , and I would like to do it in vi mode as well. ...
0
votes
0answers
13 views

Remap cursor keys in bash vi mode to <nop> (disable cursors) [migrated]

When using vi mode (set -o vi) with Bash, is it possible to remap the cursor keys to so that they don't work (and be forced to use h, j, k and l movement keys)? Under vim (the editor), I can do it ...
1
vote
1answer
23 views

ssh remote command execution quoting

I found this solution that works for me, but I don't understand how it does work given that the sed command encloses its own parameter in single quotes, and the whole ssh command is also passed in ...
4
votes
2answers
479 views

Faster way to ping URL than curl [closed]

What would be the fastest way to check whether the specified URL is working? (responding in OK http status code)? For now I'm using curl, but I have bunch of URLs to test in a loop, so I'm looking ...
0
votes
0answers
37 views

BASH: bash completion function in a custom script

How I can add existing function to a custom script? complete -F _known_hosts test.sh - this works on the command line however when I tried to add this to my custom script it's not working as ...
14
votes
2answers
295 views

How to uninstall newly installed dependencies for a RPM package?

Is there an easy way to make a list of the dependencies a newly installed RPM package will install with yum? Example: If you do yum install ruby then it will also install some rubygems. But when I ...
0
votes
2answers
25 views

Why my netcat connection doesn't send the file correctly?

I wrote this script to send a file using netcat. My intention is to open the netcat port in the destination server from the origin, this way I do everything with just one script instead of having one ...
0
votes
1answer
28 views

convert for loops to while loops comparing arrays

On occasion (like 4 or 5 times in an 8hr shift) I have to check that the sites from being served from a shared server are loading. I currently have a script that does this, however I am using nested ...
0
votes
1answer
25 views

Remote bash script execution via ssh causes local script to stop

I have a setup which behaves in a way i cannot get my head around. So I have a local bash script generateTrafficOnHosts.sh which reads IP addresses from a file. It then calls a bash script ...
0
votes
1answer
43 views

Custom Live Boot PXE ISO Script

Currently I am using an open source PC auditing software called Open-Audit to audit PCs my company receives off lease from school districts. The software uses snmap to pull hardware information over a ...
-1
votes
0answers
32 views

How to include single quotes in bash folder expansion? [migrated]

Edited* I have the following definitions in my bash script: DATE_SUFIX=$(date +%F_%H-%M-%S) NAME="MyBackup_" FILE_NAME=$NAME$DATE_SUFIX TMP_DIR="/tmp/" TMP_BKP=$TMP_DIR$NOME_ARQ"/" TAR_CMD="tar czPf ...
0
votes
0answers
28 views

VNC/SSH: How to execute a command after logging in? [migrated]

I'm looking for a way to create a VNC console user that executes the command screen or bash immediately after logging in so they get their own restricted shell for executing commands etc. Screen/bash ...
1
vote
0answers
55 views

Why do I get different results with the same user and the history command? [migrated]

I work with Linux for quite some time and have seen this behaviour but I never got a good explanation. Probably it's even very simple. If I login twice with the same user (bash) in the same server ...
0
votes
0answers
28 views

How to automatically execute a script after saving it? [duplicate]

I'm developing a bash script and, after every save, i have to switch windows and re-run. Is it possible to execute the script automatically every time the file is saved?
0
votes
0answers
52 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
vote
1answer
63 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-}" ...
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
57 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
143 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 ...
0
votes
2answers
54 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 ...
-2
votes
1answer
34 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 ...
2
votes
2answers
84 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
39 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
24 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
688 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
42 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
154 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 ...
0
votes
2answers
48 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
56 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 ...
-1
votes
1answer
49 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
30 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
169 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) ...