I need to depend on few separate executions in a script and don't want to bundle them all in an ugly 'if' statement. I would like to take the exit code '$?' of each execution and add it; at the end, if this value is over a threshold - I would like to execute a command.
Pseudo code:
ALLOWEDERROR=5
run_something
RESULT=$?
..other things...
I have thousands of mp3s inside a complex folder structure which resides within a single folder. I would like to move all the mp3s into a single directory with no subfolders. I can think of a variety of ways of doing this using the find command but one problem will be duplicate file names. I don't want to replace files since I often hav...
I have split a large text file into a number of sets of smaller ones for performance testing that i'm doing. There are a number of directories like this:
/home/brianly/output-02 (contains 2 files myfile.chunk.00 and myfile.chunk.01)
/home/brianly/output-04 (contains 4 files...)
/home/brianly/output-06 (contains 6 files...)
It's import...
I have done this to that programe:
ctrl-z
disown -h %1
bg 1
then logout,
Is it still possible for me to see what that programe outputs to stdout now?
...
ctrl-z
disown -h %1
bg 1
logout
...
How can I determine if a function is already defined in a bash script?
I am trying to make my .bash_login script portable between systems, so I want to add logic to only call a function if it exists.
I want to add __git_ps1() to PS1 only if that function exists on that system. This funciton normally defined in git-completion.bash whic...
I have a log that should have the latest N entries. There's no problem if the file is a bit bigger a few times.
My first attempt is periodically running:
tail -n 20 file.log > file.log
Unfortunately, that just empties the file. I could:
tail -n 20 file.log > .file.log; mv .file.log file.log
However, that seems messy. Is there a be...
Hello,
i need to let sed replace some url in alot of file each file has the following
http://www.expample.com/file.php?id=xxxxxxx
where xxxxx consist of random numbers , random depth in each file like
file 1
_h**p://www.expample.com/file.php?id=xx
file 2
_h**p://www.expample.com/file.php?id=xxxxxxxx
etc
thanks in advance
...
I use Emacs for shell scripts. I know I read somewhere there's some mode to make it easier (code completion, autocomplete, bracket matching, syntax highligting, check syntax) to write Shell scripts on Emacs but haven't been able to find it. In short, I would like to turn Emacs into a Bash IDE.
Also, is there any other tool/IDE to make s...
The following command issued from a terminal gets me yesterday's date:
date --date='1 day ago' +%Y/%m/%d
I'm trying to write a bash script where the number of days is a command line arg. I'd like to be able to store the resulting date in another variable and use it later in my script. Thoughts?
...
EDIT: nothing to see here!!!
127 return means the command wasn't found - had to give an absolute path to the command for some reason :/ (I didn't delete in case someone else has this problem)
Is there a reference of return statuses for common Linux functions like ls? (it doesn't seem to be in the man pages, at least for ls). If not, can...
I'm trying to change the directory of the shell I start the ruby script form via the ruby script itself...
My point is to build a little program to manage favorites directories and easily change among them.
Here's what I did
#!/usr/bin/ruby
Dir.chdir("/Users/luca/mydir")
and than tried executing it in many ways...
my_script (this do...
Hi,
I have a text file which a lot of random occurrences of the string @STRING_A, and I would be interested in writing a short script which removes only some of them. Particularly one that scans the file and once it finds a line which starts with this string like
@STRING_A
then checks if 3 lines backwards there is another occurrence ...
I need that bash file to run periodically,and must as root.
Is that kind of possible?
[root@file nutch-0.9]# locate crontab
/etc/crontab
/etc/sysconfig/crontab
/usr/bin/crontab
/usr/share/man/man1/crontab.1.gz
/usr/share/man/man1p/crontab.1p.gz
/usr/share/man/man5/crontab.5.gz
/usr/share/vim/vim71/syntax/crontab.vim
[root@file nutch-0....
I've got a function that I want to reference and use across different scripts. Is there any way to do this? I don't want to be re-writing the same function for different scripts. Thanks.
...
Ok, so someone "challenged" me to enter this into my OSX Terminal, but I have no idea what it would do:
WARNING to the reader: the following line can be harmful; do NOT enter it unless you know what you are doing:
:(){ :|:& };:
Any ideas?
...
Hi. How would I go about checking whether gcc has succeeded in compiling a program, failed, or succeeded but with a warning?
#!/bin/sh
string=$(gcc helloworld.c -o helloworld)
if [ string -n ]; then
echo "Failure"
else
echo "Success!"
fi
This only checks whether it has succeeded or (failed or compiled with warnings).
-n mea...
I'm thinking of using find or grep to collect the files, and maybe sed to make the change, but what to do with the output? Or would it be better to use "argdo" in vim?
Note: this question is asking for command line solutions, not IDE's. Answers and comments suggesting IDE's will be calmly, politely and serenely flagged. :-)
...
For work I am moving over to windows after being on linux for quite a while. I want to get some scripting skills going for administrative tasks in windows. I am quite good with bash, but bash's "libraries/tools" are missing a lot when it comes to windows. I see vbscript, wsh, powershell, cmd, jscript, etc and wondering what to learn, or ...