Bash is a free shell for Unix-like operating systems from the GNU Project.

learn more… | top users | synonyms

0
votes
1answer
9 views

Shell script to pass multiple arguments with options in command line

I have the script, I need to execute this script like this: ./create_endpoint.sh --controller-ip 10.20.20.1 --controller-name User1. But its executing like this: ./create_endpoint.sh 10.20.20.1 ...
1
vote
2answers
29 views

Adding non-executable (Tex/text) files to my PATH?

I have two files that I would like to call from any one of multiple working directories on my computer, so I added them to a folder of resources that I've added to my path (and then sourced my ...
-2
votes
0answers
20 views

How to get total records affected in database: A shell script

I have written a shell script to update the records on database server. The query.sql file contains variable number(almost 600 to 800)of insert queries. As I am running the script, it runs fine and ...
0
votes
1answer
10 views

I am trying to run a cronjob but it is not executing correctly

I have the following line in my crontab */1 * * * * /usr/bin/screen -S lftp /bin/bash /media/c419d280-9833-4432-b5a5-520f040b87ec/NASDataDisk1/Other/autolftp-sftp.sh >> ...
0
votes
0answers
17 views

Group permission doesn't work for group

I'm trying to give me permissions to write on a file owned by www-data me@home $ touch my_tralala && chmod 660 my_tralala me@home $ sudo chown www-data:www-data my_tralala me@home $ groups me ...
1
vote
1answer
16 views

Error with command cut: the delimiter must be a single character

I am trying to run this command from console: # HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` But got this error: Try `cut ...
0
votes
1answer
15 views

Remove version information from maven generated war file

I am trying to automate the deployment of war files that are generated by our build server using maven. I need to be able to extract the project name from the war filename so I can rename the file ...
-1
votes
0answers
22 views

How to find the newest file in web directory using bash?

How can I find the newest file in web directory (having link) with bash? Linux It would be great to have something similar to ls -tr | tail -n 1 but with wget probably
0
votes
2answers
27 views

Accessing shell variables inside 'sudo' block : export doesn't work

I am writing a script to fix a missing 'F' letter in a mail log file. The mail log file is continuously updating. I am getting a file name, after that I am doing 'sudo su' to get superuser access. ...
0
votes
1answer
12 views

Variable as argument to Wine

The variable $INPUT_FILES in Case 1 has the same content (string) that is used in Case 2. Why in Case 1 I have problems with spaces in the name "2015 01 09.1.txt", but in Case 2 not? How can I fix ...
0
votes
0answers
20 views

RHEL 6 converting a BASH script to a CSH script

I have a BASH script( running on RHEL 6 ) that brings up a GNOME terminal, opens multiple tabs in that terminal, starts a server in each tab, names the tab after that server, and inserts the command ...
0
votes
0answers
21 views

RHEL 6: GNOME: staring a *.desktop file in a shell different from the system default

I'm in RHEL 6 with bash as my default shell. I have a script called startServers I made a startServers.desktop file which I put on my desktop so I can have the convenience of clicking on an icon to ...
0
votes
1answer
50 views

What does this bash script?

In theory, this snippet from pentoo-installer finds all partitions on the selected disc, but it doesn't find my sda1 partition, so I would love to understand it and modify so it does. ...
0
votes
1answer
41 views

“/bin/bash: bad interpreter: Text file busy” even though the file editor closed the file

I have a script on Linux that I edit under Windows (through Samba), that starts with the shebang line #!/bin/bash. Even though: I finish editing, save, and close the file in the editor make sure ...
0
votes
0answers
30 views

Fedora 22 Docker Container unable to network

I have been struggling with Fedora 22 and getting Docker images to be able to communicate with the outside world. Not sure how to start testing this, or even where to start to look. Let me explain ...
0
votes
1answer
42 views

How to recover the Linux VM after accidentally deleting all root folders?

I have a CentOS Linux VM running in VirtualBox. I wrote a bash script to do some automated tasks. But I accidentally deleted all root folders because I put a line in the script rm -r $my_dir/* ...
1
vote
1answer
16 views

Clear Bash quoting with JSON

I looked at similar questions before, but does not exactly answer my issue. I'm using cURL to send a JSON request, like this: curl -X POST -H "Content-Type:application/json" "$HOST" -d '{"uri": ...
-4
votes
0answers
42 views

How to convert a string to decimal values? [on hold]

I would like to convert word (i.e., a string) to decimal ASCII values, separated by dots, in bash. Example word: test123 Expected result: 116.101.115.116.49.50.51 This is what I have tried so ...
0
votes
2answers
33 views

Bash - using grep on user-defined strings

Sometimes I would find it very useful to be able to use grep on a string (without the string being in a file). For example: var="Some random string" $var | grep -e "Some" I guess I could use echo ...
0
votes
3answers
38 views

How to append multiple .txt files to one file without header line

I have 100,000 .txt files with format below: bygrp,colnum,beta 100005,1,0.629519434191718 100005,2,-0.500000000026516 100005,3,0.560850895321124 100005,4,0.119624318119292 100005,5,0.257676682753309 ...
0
votes
1answer
24 views

Bash - enable execution only if script is run from a specific directory

I need to write a shell script that can only be executed if it is run from the home directory of the currently signed-in user, and I have no idea how to check that from the script itself. Any help ...
0
votes
0answers
17 views

bash change directory with “shortcuts”

On my windows computer I use JPSofts "Take Command" a.k.a. TCMD as command.com or shell replacement. One tcmd feature I really miss when working with bash on Linux/Os X, is the extended directory ...
1
vote
1answer
13 views

ConEmu and ASCII characters

I've been using ConEmu for quite a while, and I'm having some problems with ASCII characters in it. This doesn't happen with other terminal emulators, such as urxvt or mintty, here's a shot with the ...
0
votes
2answers
23 views

How to reflect changes in PATH as done by a user script

I have a script which does some basic root PATH integrity check and inputs a line in ~/.bash_profile to source my script, so that changes my script made in root's PATH is permanent across restarts: ...
2
votes
1answer
31 views

chroot: failed to run command ‘/bin/bash’:

I am trying to modify a kernel image before using it for qemu. I am trying to add a compiled binary to the image. I am using 64 bit Linux 14.02. What I am doing is, linaro-media-create --image_file ...
0
votes
0answers
10 views

SELinux issue with php_shell_exec

I have a php site on CentOS7 that needs to use some shell scripts using php_shell_exec. But the scripts do not run due to SELinux (that I require). None of the scripts use sudo, I understand that ...
0
votes
0answers
5 views

Name a tab in iterm2, even with pane splits

I see there are solutions to name tabs in iterm2 when there is a single pane, but it doesn't work well with multiple panes/splits. So if I have two terminals open in a split under a tab, I would need ...
3
votes
1answer
17 views

Accidently running perl-script with sh, how to detect that and take actions?

I had a bash-backup-script for quite some time which worked ok for me, but now I needed some features and put them into a perl-script. It works perfectly fine, and I'm happy. But my muscle-memory ...
1
vote
1answer
13 views

Construct command for bash exec

I have a shell script that runs exec to replace itself with another command. The other command takes some optional arguments. exec mycommand $ARG1 $ARG2 $ARG3 Any of these arguments could be ...
1
vote
2answers
19 views

Compare list of files from a database using find to locate missing files

I have a list of 2000 files from a database that looks like this: ./aa/0f/unique-string/IMG_0987.JPG ./ab/cf/unique-string/IMG_0987.JPG I want to compare that list to the actual directory contents ...
0
votes
1answer
48 views

What's the difference between $(…) and `…` in Bash

I got expected result with `...`, but failed with $(...) kill $(ps ux | grep S..\.tcl | grep -v grep | awk '{print $2}') Illegal variable name. kill `ps ux | grep S..\.tcl | grep -v grep | awk ...
0
votes
2answers
19 views

Bash script to process files using multiple processes

Most batch file processing Bash scripts could be sped up by spawning multiple processes to utilize all the cores. I want to make a script that will process a bunch of files, dividing the number of ...
0
votes
1answer
24 views

Why does sh not find files in my path that do exist?

When I type this in sh it outputs : $ $PATH sh: 12: /bin:/usr/bin: not found But, I do have a /usr/bin folder, and it's fuuuuull of stuff. Same thing with zsh: ▶ $PATH zsh: no such file or ...
1
vote
4answers
40 views

How do I CD to parent of deleted directory? (bash: cd: ..: No such file or directory)

I was running some simple commands in bash, and one of the commands I ran deleted my current working directory (nothing destructive, I just used git to checkout a branch where that directory doesn't ...
1
vote
2answers
20 views

cannot set uid with mount

mount -o uid=1000 /dev/sdb1 /mnt mount: wrong fs type, bad option, bad superblock on /dev/sdb1, missing codepage or helper program, or other error In some cases useful info is found in syslog - ...
0
votes
1answer
27 views

How to safely synchronize two folders without duplicates?

I have an account on mega and I want to synchronize it with a folder on my computer. The problem is, that this account is public to some extent so I can't just use rsync with --delete in case someone ...
0
votes
1answer
21 views

grep returns no results

Came up to a strange problem - was running a trivial command grep -F "INSERT" new.sql >& output.txt on a new.sql that is 76MB large. The funny thing here is that none results are returned ...
1
vote
2answers
18 views

How to delete all files and directory except one named directory from a specific folder in centos [duplicate]

I want to delete all files and directories from a specific directory except for one directory. For the same operation I had run this command # rm -R -df !(dir_name_not_to_delete) It works in Ubuntu ...
0
votes
2answers
35 views

Add a newline after each terminal command except at the beginning

I want to add a newline after every command I enter in the terminal. Right now, I have this line in my .bash_profile file: export PS1="\n\u$ " This works as expected: However the issue with ...
1
vote
0answers
12 views

Controlling a Canon Powershot with a CGI/Bash Script

I am trying to control my camera through the program chdkptp by using a CGI/Bash script. I have successfully controlled the camera by typing in the commands by hand: pi@camerapi /var/www/chdkptp $ ...
0
votes
1answer
20 views

How does isatty() get the information from the terminal?

I noticed that if I type: ls --color=auto or ls --color=auto | cat ls --color=auto > >(cat) I don't see the same output. Therefore I assume a program has an hability to know whether its ...
-1
votes
3answers
37 views

How to iterate through all the files/folders in a folder

I'm making a script to go through a folder renaming all the files and folders in it to VAR1, VAR2, VAR3, etc.. where VAR is a user specified variable. I wrongly assumed this would be simple. All I ...
2
votes
1answer
24 views

Why does ZSH local variable assignment fail?

I was reading this question and answer: zsh - variable assignment isn't working. The post explains how to fix it, but not why. Why does the local variable assignment fail in that case ? There ...
0
votes
1answer
23 views

Git Installation Returns Error 404 On RHEL

I am trying to install Git in my REHL but failed. I have also clean up metadata and everything else by running sudo yum clean metadata and sudo yum clean all but still, the error persists again and ...
1
vote
3answers
37 views

Error extracting data from a text file, with grep command in bash

I generate an output file named "silence.txt" with ffmpeg. When I try to extract lines containing the word "silencedetect", I've got a strange extract. Here is my original "silence.txt" file : ...
1
vote
1answer
42 views

nested if statement, multiple conditions for if statement

I have a situation to write a script where $MacBook and $SERVER are variables. There is a file that is being read to find the server name. And using another file, I can pull the hardware model (if ...
0
votes
0answers
16 views

What is the alt+~ hotkey on the bash terminal?

I was switching between windows today (alt+`) and had my finger on shift as well it seems - this popped up in my terminal, avahi user mysql ...
0
votes
0answers
15 views

How to rerun a program if word `error` is detected on STDERR?

I am using a compiler that is pretty moody. Sometime it crashes for an unknown reason. Inside my Makefile I would like to rerun the build in case of an error. So far I wrote this: TRY=3 until [ ...
2
votes
0answers
22 views

Program options have sometime one or two dashes (-foo, --foo) [duplicate]

In gcc every command line arguments have one dash. In some other tools, options that are not a single character have a two dashes prefix. Why is there two standards, which one is the most common? ...
1
vote
2answers
28 views

understanding tilda,slash command in bash

I have confusion in the meaning of command ~/ if x is a directory, then what is the meaning of ~/x in bash. Please guide me