What I'm trying to accomplish:
On Ubuntu 10.04 I'd like to display a small notification image in the corner of the screen and have the image fade out. I'd like to do it from the command line for use with bash scripts. Similar to "notify-send", "zenity", or "dialog" except
it displays images as well.
What I've found so far:
ImageMagi...
I am usually using zsh, which provides the chpwd() hook. That is: If the cwd is changed by the cd builtin, zsh automatically calls the method chpwd() if it exists. This allows to set up variables and aliases which depend on the cwd.
Now I want to port this bit of my .zshrc to bash, but found that chpwd() is not recognized by bash. Is a ...
I need to process a number of directories, determine what files in them are symlinks, and what they link to. This sounds simple, but I have no control over the presence of control or other characters in the file names, and I need a robust solution.
So, given a file of arbitrary name, how do I safely determine what it links to, when the ...
Hey there,
I need to some homework ... The Question is :
How can you print the path of the current directory (working directory) and how can you use it as a variable?
The first part of the question is easly answered:
pwd
But how can I use it as a variable ?
...
I crafted a Bash prompt that, When the working directory is a Git repository, displays the name of the current repository. Besides, it contains the current ongoing task and the time spent doing it (from a homebrew timekeeping tool). This, of course, means that just displaying the prompt means running two processes.
This has the drawback...
I read price from user input. When i multiply the input with int like this
T="$((PRICE*QTY))"|bc; gives
line 272: 12.00: syntax error: invalid arithmetic operator (error token is ".00")
or .50
depending on user input. How do i multiply these two variables and get a total with 2 decimal points?
...
Hi
i have the output of cat /proc/loadavg and
/proc/meminfo MemFree: 1191220 kB
i need a to know who will i get a script to get then added in a logfile every 5 mins.
eg: CPU; Mem;
10.0; 1191220
and so on so the next entry will be below that
eg: CPU; Mem
10.0; 1191220
5.0; 2229882
Thanks in advance
...
I have the following shell script:
#! /bin/sh
while read page_section
page=${page_section%%\ *}
section=${page_section#* } #NOTE: `%* }` is NOT a comment
wget --quiet --no-proxy www.cs.sun.ac.za/hons/$page -O html.tmp & wait
# echo ${page_section%%\ *} # verify correct string chopping
# echo ${page_section#* } # verify ...
I'd like to use Bash to run a test suite automatically when I save any file in a given directory.
Is there a mechanism for bash to execute a given script on save events?
Thanks.
::EDIT::
I should have mentioned that I'm on using OSX.
...
Hi,
I'm new to UNIX, having only started it at work today, but experienced with Java, and have the following code:
#/bin/bash
echo "Please enter a word:"
read word
grep -i $word $1 | cut -d',' -f1,2 | tr "," "-"> output
This works fine, but what I now need to do is to check when word is read, that it contains nothing but letters and ...
I have a bunch of scripts (which can't be modified) written on Windows. Windows allows relative paths in its #! commands. We are trying to run these scripts on Unix but Bash only seems to respect absolute paths in its #! directives. I've looked around but haven't been able to locate an option in Bash or a program designed to replace and ...
I know I can translate upper to lower case letters by
echo 'linux' | tr "a-z" "A-Z"
who would I translate or replace an occurrence of & with %20%26%20. Maybe something like this
echo '&' | tr "&" "%20%26%20"
...
Is it possible to add spaces to the left of every output to stdout (and stderr if possible) when I run commands in a bash shell script?
I'd like to do something like:
#!/bin/bash
echo Installing: Something
echo " => installing prerequisite1"
## INSERT MAGICAL LEFT SPACES COMMAND HERE ##
apt-get install -q -y prerequisite
## ANOTH...
I'm trying to write a bash script that will let me download multiple web pages using curl. For each webpage, I want to be able to pass curl the page and the referer link. I want to be able to supply multiple webpages at once.
In other words, I want to be able to loop through the webpages I supply the script, and for each page, pass the ...
At the shell, I enter a single-quote and then carriage return and then a series of lines and then another single-quote:
root@aim:/root > '
> @stat = lstat($ARGV[0]);
> if (!@stat) {
if (@stat = lstat($ARGV[0]);) {
> print "nil\n";
> exit 0;
> }
> '
However, if you notice the interpreted output from the shell:
bash:
@stat = lstat($A...
I'm using giternal, which compresses the .git directory of the external references into a .tgz file. Unfortunately, every time I "freeze" the external, a new .tgz file is created for the repo.
Even though the contents of the .git directory are the same, a new .tgz file, with diffs, is created. This leads to repo bloat.
Is there a way t...
I'm trying to write a post-commit hook for SVN, which is hosted on our development server. My goal is to try to automatically checkout a copy of the committed project to the directory where it is hosted on the server. However I need to be able to read only the last directory in the directory string passed to the script in order to chec...
I'm using xcodebuild to compile my project. I use this on the command line:
xcodebuild -sdk iphoneos4.0 -configuration Distribution
It returns with the regular build information scrolling by, then shows this:
** BUILD SUCCEEDED **
Bus error
The package is built fine, so I'm not sure what is causing the Bus error after a su...
I can run this command fine, with the output I want:
ifconfig eth0 | grep HWaddr | awk '{print $5}'
However, when I set the command to a variable, and print the variable, I get an error:
CASS_INTERNAL=`ifconfig eth0 | grep HWaddr | awk '{print \$5}'`
$CASS_INTERNAL
my internal xxx ip: command not found
The weird thing - my intern...
I have the following code:
#!/bin/bash
for f in `find . ! -type d`;
do
line=`grep -i 'todo' $f | sed 's/^[ \t]*//'`
if [ $line ]; then
echo "$f:"
echo "$line"
fi
done
but the condition is not working as I would expect it, I need it to only work if something other than an empty s...