Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

1
vote
1answer
14 views

Fetching Remote Windows System Information From Linux Server

I need a script/command that would fetch Windows System Information (Host Name,User Name, Domain, OS Info, Hardware Info, Memory Info, processor Info, etc) by running it on a Linux Server (RHEL 6.5 ...
0
votes
1answer
26 views

Faillog - unsuccessful login count in Motd

I wish to include a count of failed login attempts whenever a user logs in. I've created: /usr/local/bin/dynmotd which contains #!/bin/bash FAILLOG=`faillog -u` echo -e " $FAILLOG " and ...
1
vote
3answers
69 views

Aggregate and group text file in bash

I have a big text file(with 5m lines) in this format(4 columns, separated by ;): string1; string2; string3; userId The first 3 strings (SHA1s) form a single ID, called appId (so it can be ...
2
votes
2answers
275 views

How you stop 'wget' after it gets a 404?

If you use brace expansion with wget, you can fetch sequentially-numbered images with ease: $ wget 'http://www.iqandreas.com/sample-images/100-100-color/'{90..110}'.jpg' It fetches the first 10 ...
3
votes
1answer
55 views

Is there a way to pass a variable from an awk statement to a bash function as an argument? [on hold]

I am trying to look a for some specific values from (such as 1 or 4 and 2 or 3) a text file using an awk statement in a bash script. If this value is found in the file (within the awk statement), then ...
2
votes
0answers
32 views

Linux: $SSH_CONNECTION is set even without SSHing to the server

I have a remote server and I am writing a script in the server and want it to fire only when I SSH. I thought of using the $SSH_CONNECTION and $SSH_TTY for this purpose. I found out that when I have ...
4
votes
1answer
70 views

PS: what does “ps -o comm= -p $PPID” do

I have a script which does ps -o comm= -p $PPID. The explanation says this gets the parent process name. From the man page I found out -o means user defined format, comm means command and -p means ...
1
vote
2answers
32 views

How to determine the newly closed file within a continuous audit log rotation?

I am attempting to find the best way to determine when the second file (of a matching criteria) is created. The context is an audit log rotation. Given a directory where audit logs are created every ...
5
votes
2answers
54 views

Passing arguments from a file to a bash script

I' ve got this situation: ./ ./myscript.sh ./arguments.txt ./test.sh Inside myscript.sh, i have to run the file test.sh, passing to it the arguments contained inside arguments.txt. myscript.sh is: ...
4
votes
6answers
165 views

Finding the number of time a particular number in a file where range also specified

I have a file with numbers separated by ,(comma). In between it also contains a number range like 300-400. Say for example I have a text file, namely testme.txt which looks like, ...
1
vote
2answers
25 views

Using exec and tee to redirect logs to stdout and a log file in the same time [duplicate]

In a bash script, how can I redirect all standard outputs to a log file and tee the output on the screen using exec ? log_file="$HOME/logs/install.txt-`date +'%Y-%m-%d_%H-%M-%S'`" [ -f "$log_file" ] ...
2
votes
1answer
62 views

Asteriks in filename as wildcard not working [on hold]

So I have a folder with many files like 20140720.457812.tmp and I try to count how many lines they have, I tried this: #!/bin/bash lines=`more /folder/20140720*.tmp|wc -l` but I get this error: ...
4
votes
2answers
58 views

Replace very long string in files recursively

I have a very long and complex string in many files and I want to remove/replace it recursively. The string contains many slashes, backslashes and spaces and any kind of special signs. How do I do ...
-1
votes
1answer
31 views

Launching a sudo gui from desktop

Environment: CentOS 5.10 on 32 Bit. test.sh: #!/bin/bash cd /dump sudo /opt/java/jre1.7.0_60/bin/java -jar mytest.jar mytest.jar will pop a GUI app in the desktop, username is in sudoers with ...
-4
votes
2answers
51 views

How to print numbers horizontally? [duplicate]

I would like to print something as 5,4,3,2,1. This is my program, but it prints the numbers vertically. numbers=5 i=1 while [ "$i" -le "$numbers" ] do echo “$i” i=$(( $i + 1 )) done Do you have ...
10
votes
3answers
717 views

Where is bash's history stored?

If I run history, I can see my latest executed commands. But if I do tail -f $HISTFILE or tail -f ~/.bash_history, they do not get listed. Does the file get locked, is there a temporary location or ...
0
votes
2answers
58 views

Solution to integer expression expected [on hold]

So I when I run this code on my mac there are no errors, and it provides me the perfect output. But when I run it on Ubuntu or CentOS i get the following error integer expression expected ...
2
votes
1answer
67 views

mkdir with date function behaves differently in script

I am trying to create a directory with a timestamp. If I type at the prompt mkdir "$(date +%Y-%m-%d_%H%M%S)" I get a directory named with the date as I would like. If I put the same line in a bash ...
11
votes
3answers
350 views

Comparing two strings in Bash

I have the following if block in my bash script: if [ ${PACKAGENAME} -eq kakadu-v6_4-00902C ]; then echo "successfully entered if block!!" fi The script execution is not entering my if block even ...
1
vote
1answer
51 views

Verify the length of a variable

I've to verify the length of variable read (my script limit to five the characters inserted), I think about something like this: #!/bin/bash read string check=${#string} echo $check if [ $check -ge 5 ...
3
votes
3answers
113 views

“Tuning” tr and sed expression

I have MD5 file which lists filename and MD5 sum in the following way: MD5 (file14n0001.xml.gz) = 04eb2524d271077ec8f1a0021779b171 MD5 (file14n0002.xml.gz) = 07e2b29645e9211cce9daf1ae27e7b99 MD5 ...
2
votes
3answers
43 views

Looking for a way turn multiples commands with same parameter into a one liner

I sometimes end up doing things like: Example: from ~/blah $ mkdir ~/test-tmp $ cp * ~/test-tmp $ cd ~/test-tmp using the destination dir 3 times in a row. Isn't there a way to turn these into a ...
3
votes
1answer
28 views

Openbox pipe-menu script error

This is the weirdest thing. The script works when run from the shell with no problems. When I run it as an Openbox pipe-menu I get the error "Invalid output from pipe-menu". After playing around with ...
2
votes
2answers
306 views

Sudo Su automated login

I want to automate the login process with sudo su. I have seen lot of questions on these, but none of them are working for me. Automate login with sudo and su Here's my what I tried so far echo ...
0
votes
2answers
37 views

Creating Menu list and Executing the Task

I was given the the Task to create a menu in Linux but it appears it's not coming out great. When I select something I want to be able to perform that task then go back to the main menu when I finish. ...
2
votes
1answer
49 views

Why are aliases missing inside of bash command?

When I run in my terminal: alias a list with all my aliases (defined in ~/bashrc and ~/.bash_aliases files) will be displayed on my terminal. That's nice and as expected! But when I run: bash -c ...
5
votes
1answer
35 views

Count duplicate rows with constraint

I have the following file: A B 1990 A C 2001 A C 2013 A B 2001 B C 2013 A D 2001 A D 2014 I need to count duplicate pairs (in the 1st and 2nd column) and to each such pair assign the lowest value ...
1
vote
1answer
29 views

how to use the eval command in order to print the value of parameter

Please advice how to use the eval command in order to print the parameter value for example bash a=1 b=2 c=3 for i in ` echo a b c ` > do > echo "$i=` eval $i ` " > done bash: a: ...
4
votes
2answers
56 views

How to redirect stdout to a file and read from the same file simultaneously with another task?

I want to run a task (which takes quite a long time) remotely in Ubuntu Linux Bash via nohup and redirect stdout to a file, e.g.: nohup task > out.txt & From time to time I would like to ...
1
vote
1answer
32 views

How would you get all users history

I know there is the $HISTFILE variable where i can find the currently logged in users history-file, but how can i be sure to get every history file on the server I was thinking of the ...
1
vote
4answers
52 views

Compare two numbers read from a file

I have a script that reads a file with a standard format where the 9th word is a number. I am trying to compare the number that is read from the file. I am able to read the line correctly and it works ...
2
votes
2answers
52 views

How can I tell if floating point arithmetic is performed in hardware or software?

Well, exactly as the title says: How can I tell if floating point arithmetic is performed in hardware or software? I could find the processor's name and Google it, but is there a way to do it in a ...
2
votes
1answer
54 views

How can I run as another user?

This is the bash code that should be runned. So first it substitutes the user to openproject and than runs all the code su openproject -c "bash -l" cd ~/openproject git checkout Gemfile.lock git ...
0
votes
1answer
36 views

Parse lines of output from bash loop

I'm trying to parse the output of commands run in a bash loop. Here is an example: $ for i in `git log --format='%H'`; do echo $i ; git branch --contains $i; done | head -n 8 ...
1
vote
3answers
26 views

Delete whole line if after “:” less than 4 chars

I have a file with many lines, such as : blue:fish red:tomato black:moon I would like the whole line to be deleted if after ":", there is less than 4 chars. Thanks for your help!
0
votes
2answers
23 views

concatenate .out files

Can I combined multiple .out files with the cat command in bash or csh? Additionally I want only the header of first file to be concatenated and I was thinking of using the tail function for that. ...
3
votes
2answers
47 views

How to make Cron run

I am trying to set up cron to run the mysqlauditgrep command (its the MySQL 5.6 Utilities package). The mysqlauditgrep command is in bash. The command I am looking to run is: mysqlauditgrep ...
1
vote
1answer
30 views

How to set up Cron to run mysqlauditgrep command for 11AM on Friday

I am trying to set up cron to run the mysqlauditgrep command (its the MySQL 5.6 Utilities package). The mysqlauditgrep command is in bash. The command I am looking to run is: mysqlauditgrep ...
4
votes
1answer
128 views

sudo: unable to execute ./script.sh: no such file or directory

I'm stumped. I have a script in my /home directory which is executable: [user@server ~]$ ll total 4 -rwx------ 1 user user 2608 Jul 15 18:23 qa.sh However, when I attempt to run it with sudo it ...
1
vote
4answers
73 views

Use `cut` to extract a list from /etc/passwd

How could I use the cut command to extract a list of usernames and login shells from the /etc/passwd file, where the resulting usernames and login shells are separated by a single space? Sort the ...
0
votes
1answer
23 views

How to dynamically chose PBS queue during job submission

I run a lot of small computing jobs in remote cluster where job submission is managed by PBS. Normally in a PBS (bash) script I specify the queue that I would like to submit the job through the ...
22
votes
4answers
2k views

Is it possible to define a command in bash?

For example, can I set gb = cd /media/Dan/evolution So that everytime I execute gb in bash, I can cd to that particular directory? I find something online, alias command. But It seems can't do the ...
2
votes
2answers
72 views

CSV file + set CSV parameters and values in bash script

I have the following CSV file: Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa 1000,"1 0 0 1",1002,1002,1003,1004,1005,"1 0 ...
1
vote
4answers
97 views

How can I output the difference between 2 files?

My file consists of the the following; roughly: username:username:username:username:username The above line continues to about 600 characters. I use the awk command in order to use it as an ...
2
votes
0answers
90 views

Securing a script a little more

I currently have the following script which works fine: #!/bin/sh user="$(zenity --entry --title="Username" --text="Username")" pass="$(zenity --password --title="Password" --text="Password")" ...
0
votes
1answer
28 views

Reusing user input in a script

I have the following script which works: #!/bin/bash xfreerdp /cert-ignore /f /v:farm.company.com /d:company.com /g:rds.company.com /u:$(zenity --entry --title="Username" --text="Username") ...
0
votes
1answer
56 views

Bash script question - skip enter key press [duplicate]

Here is a portion of my script: read main_menu case "$main_menu" in "0" ) exit ;; "1" ) cp /etc/bamt/cgminer.conf.X11 /etc/bamt/cgminer.conf; sudo mine restart; ...
9
votes
4answers
274 views

How can I tell if the currently executing bash script has been invoked with -x for debugging?

I have a script launch.sh that executes itself as another user so as to create files with the correct owner. I want to pass -x to this invocation if it was originally passed to the script if [ ...
3
votes
2answers
92 views

Add arguments to bash -c

Let say that I want to run a command through bash like this: /bin/bash -c "ls -l" According to bash man page, I could also run it like this: # don't process arguments after this one ...
4
votes
0answers
44 views

KVM reports strange CPU usage peaks (bash infinite recursion)

On a KVM machine running Fedora 20 I ran ulimit -s unlimited (this removes limit on stack size) and an experimental torturing testing script. All this script does is just infinite recursion: ...