Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python' ?
Anyone know this? I've never been able to find an answer. ...
Anyone know this? I've never been able to find an answer. ...
I got a variable in a bash script that I need to replace. The only constant in the line is that it will be ending in "(x)xxxp.mov". Where x's are numbers and can be of either 3 or 4 of length. For example, I know how to replace the value but only if it is a constant: echo 'whiteout-tlr1_1080p.mov' | sed 's/_[0-9]*[0-9][0-9][0-9]p.mov...
[Edit] I've summarized the answer to the following below, the error lies in the line: [Edit] if [$1 ne $value]; then I'm trying to pass a value to a command: #!/bin/bash for value in $(mycommand $1) do echo Found $value if [$1 ne $value]; then echo No match! if done But if I type in the following to execute t...
I'm looking for a way to programatically detect the location of the Apache config directory, and the name of the configuration file. Bonus points if this is in Ruby or Bash. ...
Are there any decent bash plug-ins for Eclipse? My only requirement is syntax highlighting. I've googled about but did not see anything that looked like "the" bash plug-in. ...
I want to change the delimiters bash (or readline) uses to separate words. Specifically I want to make '-' not delimit words, so that if I have the text ls some-file and I press Alt-Backspace it deletes the entire some-file text and not just up to the '-' char. This will also cause deletions of long flags like --group-directories-firs...
I am looking for a way to dump input into my terminal from a file, but when EOF is reached I would like input returned back to my keyboard. Is there a way to do this with Bash (or any other commonly-available *nix shell)? Details: I am debugging a server program which executes a fork to start a child process. Every time I start a debu...
We've got a PHP application and want to count all the lines of code under a specific directory and its subdirectories. We don't need to ignore comments, as we're just trying to get a rough idea. wc -l *.php That command works great within a given directory, but ignores subdirectories. I was thinking this might work, but it is retur...
I have some files across several folders: /home/d/folder1/a.txt /home/d/folder1/b.txt /home/d/folder1/c.mov /home/d/folder2/a.txt /home/d/folder2/d.mov /home/d/folder2/folder3/f.txt How can I measure the grand total amount of disk space taken up by all the .txt files in /home/d/? I know du will give me the total space of a given fold...
I am looking for a reliable method to replace a sequence of chars in a text file. I know that the file will always follow a specific format and that I need to replace a specific range of chars (ie start at char 20, replace the next 11 chars with '#') I have found several examples using sed and awk which accomplish this on most files. ...
Hi. I have 2 files that are generated elsewhere. First one is "what to search", and second one is the replacement. Both files are huge, about 2-3mb each. I need to write a bash script that takes an even bigger file (about 200-300mb) and replaces all occurrences of file1 contents to file2 contents. Problem is, file1 and file2 can conta...
Is there a way to do command substitution in BASH shell without breaking output into multiple arguments? I copy the path of some directory (from the location bar in a GUI file browser) to clipboard and then issue the following command, where the command xsel returns the clipboard content, which is the path of the directory in this case:...
The shellscript shown below will show a warning if the page takes more than 6 seconds to load. The problem is that the myduration variable is not an integer. How do I convert it to integer? myduration=$(curl http://192.168.50.1/mantisbt/view.php?id=1 -w %{time_total}) > /dev/null ; [[ $myduration -gt 1 ]] && echo "`date +'%y%m%d%H%M%S'`...
I have a bunch of screen sessions running on my machine, but all of them are detached and unneeded. Is there a good way to just close all of them, so I have nothing when I type "screen -ls"? ...
I have a file containing text data which are separated by semicolon ";". I want to separate the data , in other words split where ; occurs and write the data to an output file. Is there any way to do with bash script? ...
Need some help with this as my shell scripting skills are somewhat less than l337 :( I need to gzip several files and then copy newer ones over the top from another location. I need to be able to call this script in the following manner from other scripts. exec script.sh $oldfile $newfile Can anyone point me in the right direction? ...
What Linux commands would you use successively, for a bunch of files, to count the number of lines in a file and output to an output file with part of the corresponding input file as part of the output line. So for example we were looking at file LOG_Yellow and it had 28 lines, the the output file would have a line like this (Yellow and ...
Hi, I am running some time-consuming executables with different parameters assigned in a loop as background jobs in parallel. Here is a toy example and its output: bash-3.2$ set -o notify bash-3.2$ for (( i=0 ; i < 4 ; i+=2 )); do > sleep ${i} & > done [1] 32394 [2] 32395 bash-3.2$ [1]- Done sleep ${i} [2]+ Done ...
How would I get just the current working directory name in a bash script, or even better, just a terminal command. pwd gives the full path of the current working directory, e.g. '/opt/local/bin' but I only want 'bin' ...
i'm writing a bash script to automate the build process. there are two major build blocks, one is an ant task and one is a plain old "mvn clean install". i want to do something when there are build error coming from either of this two build processes. and the problem is, these builds will contain test failures or errors from time to ti...