Based on an assoziative array in a bash script I need to iterate over it to get key & value.
#!/bin/bash
declare -A array
array[foo]=bar
array[bar]=foo
I actually don't understand how to get the key while using a for-in loop.
Thanks in advance!
...
I need to process the shared library dependencies of a library from a bash script. The for command processes word-by-word:
for DEPENDENCY in `otool -L MyApplication | sed 1d`
do
...
done
What is the way to process the results line-by-line?
...
I am working on a PHP script that needs to read log files in reverse line order.
I currently do the following:
<?php
shell_exec("tac logfile.log > tmpfile.log");
$rFile = fopen("tmpfile.log", "r");
while (!feof($rFile))
{
//logic
}
unlink("tmpfile.log");
?>
This works nicely as it switches the order of the lines in the file and ...
Actually I am in great agony recoverying a corrupt gzip file, possibly due to interrupted ftp transfer and then resume. After googling I found Recovering a damaged .gz file and am trying as it reads.
What I'm doing now is merging a gzip header file with some last part of the damaged file varying the size of the last part. Then I test th...
I accidently deleted /var/run/screen/S-root/25771.pts-0 and when I try to run screen again
screen bash ...
it reports:
/var/run/screen/S-root/25771.pts-0: No such file or directory
How can I recover it?
...
I'm trying to make a filter that capture all the .exe file lines. For example, from this:
[05/Apr/2010:11:00:01 -0300] /~mauro/Lista_conceitos_BD_2004.DOC 200 46080
[05/Apr/2010:11:00:54 -0300] /~lucia/articles/PROPOR96-Rino.pdf 200 153253
[05/Apr/2010:11:01:32 -0300] /~daniel_leite/RenomearTudo/setup.exe 200 1692017
[05/Apr/2010:11:...
I was reading the concept of OSX Services and it seemed very cool to me to have utilities like Dictionary, highlight-text-and-open-in-browser and a million other services that provide functionality based on what the user is currently doing.
I have heard it mention that this mechanism is more similar to how pipes work in *nix, rather tha...
Hi all,
I've got a little puzzler here for the bash scripting experts... I have a bash script that needs to create a small (80 byte) binary file when it runs. The contents of the file need to be contained inside the script itself (i.e. I don't want to just package the file along with the script).
My script currently does it like this:...
I've got some issues on scripting... if someone could help me, it would be really good !
My script has:
VISITS=$((WR + RD));
SERVICE_DEMAND=$((VISITS*SERVICE_DEMAND));
And I'm getting this error:
./calc_serv_demand.sh: line 12:
0.0895406: syntax error: invalid arithmetic operator (error token is
".0895406")
Can someone hel...
In a bash script, I need to launch the user web browser. There seems to be many ways of doing this:
$BROWSER
xdg-open
gnome-open on GNOME
www-browser
x-www-browser
...
Is there a more-standard-than-the-others way to do this that would work on most platforms, or should I just go with something like this:
#/usr/bin/env bash
if [ -n $...
Hi,
I just discover the magic of using vi style in bash. Immediately, I'm trying to use C-c to escape from insert mode (into what's called movement mode) as I'm used to C-c to escape to command mode in vim.
I searched around and found the command to rebind key in bash:
"bind -m vi-insert C-c:vi-movement-mode"
Then, I used "bind -P"...
I've got a couple packages in PyPI, and I'd like to include autocompletion features with both of them. How would you check that Bash autocompletion should be installed at all (check for /etc/bash_completion, maybe?), and how would you install it with setup.py (preferably using setuptools)?
...
For an assignment I need to determine the creation time of a random file. As far as I know, Unix does not store the creation time (in contrast to *-BSD). I think I've read somewhere that you should ask for the modification time instead but I don't know where and asking Google doesn't give me a non-ambigious answser either.
Any ideas?
...
I just want that Mac OS X 10.6 does a hardware beep sound like in open suse and other distributions. I tried following approaches
Terminal -> beep = -bash: beep: command not found
Terminal -> say beep = voice speaks out beep (Not a Hardware beep but awesome ;) )
applescript -> beep = Macintosh bell (I want a Hardware beep!)
Does anyb...
In a BASH script, I'm trying to detect whether a file exists. The filename is in a variable but the -e command seems to be unable to detect the file. The following code always outputs "~/misc/tasks/drupal_backup.sh does not exist"
filename="~/misc/tasks/drupal_backup.sh"
if [ -e "$filename" ]; then
echo "$filename exists"
else
ech...
I'm writing a script to backup a database. I have the following line:
mysqldump --user=$dbuser --password=$dbpswd \
--host=$host $mysqldb | gzip > $filename
I want to assign the stderr to a variable, so that it will send an email to myself letting me know what happened if something goes wrong. I've found solutions to redirect stde...
Hi!
I'd like to add custom command-line options to my Java program. Here's an example:
java -cp my.jar package.Main -i input.data -o output.data
How can I achieve this. Currently I only get
JVMJ9VM007E Command-line option unrecognised: -i
Edit: The output of java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Stand...
I would like to load some man pages onto my iPad in PDF format.
I have very quickly put this together:
#!/bin/bash
output_directory="/Users/Shared/Local/Media/E-Books/Man_Pages/Mac_OS_X"
man_pages_directory=/usr/share/man
for man_pages_section in "${man_pages_directory}/man"?; do
for man_page_path in "${man_pages_section}/"*; do
...
Hey there everyone ... I have the following data, and I need to put it all into one line...
I have this:
22791
;
14336
;
22821
;
34653
;
21491
;
25522
;
33238
;
I need this:
22791;14336;22821;34653;21491;25522;33238;
If anyone could help me it would be a great !!
Thanks in advance!
--------- EDIT
No of these commands...
I'm having a curious problem with a little script to make a VNC connection to a remote host. The script just makes an SSH tunnel for the VNC session and then opens the viewer. It's only two lines, and when copied into the shell manually, it works fine. However, invoking the script causes the VNC viewer to fail with this error:
main: ...