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

learn more… | top users | synonyms

0
votes
1answer
17 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
10 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 ...
2
votes
2answers
348 views

How to get Bash colours in a Word or PDF document

I've got a Bash script that outputs results with pretty Bash colours, and I need to include the output with colors in a Word document. I would like to avoid putting a screenshot as the ouput is ...
0
votes
2answers
18 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: ...
0
votes
0answers
14 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
29 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/* ...
-4
votes
0answers
31 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 ...
1
vote
1answer
14 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": ...
0
votes
0answers
20 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
33 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
22 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 ...
2
votes
5answers
2k views

How to work around shell limitation of 'Argument list too long'?

How can I work around the bash shell limitation of 'Argument list too long' when using filename wildcards that match a ton of files in /tmp/? [my-centos4 tmp] rm -rf /tmp/myLocalFiles* bash: /bin/rm: ...
0
votes
0answers
16 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 ...
13
votes
5answers
21k views

Continuously re-execute a command when it finishes in Bash

I'm trying to figure out a simple way to keep re-executing a command whenever it finishes, for any reason (error or otherwise). What would be the best way to approach this? EDIT: I wasn't clear ...
1
vote
1answer
12 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 ...
11
votes
4answers
26k views

How do I rename files with spaces using the Linux shell?

I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't ...
2
votes
1answer
26 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 ...
1
vote
2answers
4k views

How to auto commit to my git repository using cron?

I look into a lot of answers about this subject, but something is wrong here, let me explain. I create this script, to make my cron cleaner :) #!/bin/bash cd ...
0
votes
0answers
9 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
16 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
2answers
57 views

bash: find and zip all subfolders of a folder

how would one find all subfolders of a folder and zip them separately ? folder structure ./folder -subfolder_1 -subfolder_2 -subfolder_3 expected result: ./folder ...
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
votes
1answer
44 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 ...
1
vote
3answers
33 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 : ...
0
votes
2answers
32 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 ...
0
votes
2answers
18 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 ...
1
vote
2answers
18 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
23 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
18 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 - ...
6
votes
2answers
6k views

How to tar/untar the output on the fly

What is the idiomatic way to do the following tar to stdout read this tar output from stdout and extract to some other folder. My solution is tar --to-stdout .. | tar -C somefolder -xvf - But ...
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 ...
1
vote
2answers
17 views

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

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
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
0answers
10 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
19 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
29 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 ...
0
votes
1answer
16 views

Sharing variables between applescript and bash script in same script

Is it possible, in a bash script, to have a variable, but also allow applescript (with osascript) to use that variable?
2
votes
1answer
18 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 ...
1
vote
0answers
14 views

Sourcing .bashrc does not enable use of nvm

I'm trying to set up a shell script to run in the context of a user account after the creation of a virtual machine using vagrant; I am a windows user so I've limited exposure to bash scripting. I'm ...
1
vote
1answer
41 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 ...
14
votes
4answers
13k views

Find files filtered by multiple extensions

What is the correct syntax for: find . -type f -name \*.\(shtml\|css\) This works, but is inelegant: find . -type f -name \*.shtml > f.txt && find . -type f -name \*.css >> f.txt ...
0
votes
1answer
17 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 ...
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
14 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 [ ...
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
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? ...
0
votes
1answer
28 views

SLURM allows jobs using more CPUs than requested to start

The problem I am facing with SLURM can be summarized as follows. Consider a bash script test.sh that requests 8 CPUs but actually starts a job using 10 CPUs: #!/bin/sh #SBATCH --ntasks=8 stress -c 10 ...
0
votes
1answer
11 views

ssh session stuck after some time of idleness

I'm using fedora 19 and bash 4.2.53(1)-release If I leave an ssh connection opened for some minutes and don't do anything with it, the terminal get stuck. Here's netstat's output: tcp 0 ...