I like to write bash shell scripts on my iPhone, put them in an app folder with an icon, plist, etc., so they execute like apps by tapping their icon on SpringBoard. This is not interactive like MobileTerminal since there is no way to get output, but it has its uses.
It works great for simple scripts, but long scripts get timed out with...
I want a bash script that'll do:
for c in computers:
do
ping $c
if ping is sucessfull:
ssh $c 'check something'
done
If I only do ssh and the computer is iresponsive, it takes forever for the timeout. So I was thinking of using the output of ping to see if the computer is alive or not. How do I do that? Other ideas will be...
Hi all,
I have a huge tab-separated file formatted like this
X column1 column2 column3
row1 0 1 2
row2 3 4 5
row3 6 7 8
row4 9 10 11
I would like to transpose it in an efficient way using only using commands (I could write a ten or so lines Perl script to do that, but it should be slower to execute than the native bash functions). So...
How can I check the file encoding in a shell script?
I need to know if a file is encoded in utf-8 or iso-8859-1.
Thanks
...
The system beep/bell happens frequently (ie, when I type a few letters then type tab to autocomplete when there are a few options).
How can I turn this off?
I googled it and tried:
set bell-style none (the command went through but nothing changed)
and
setterm -blength 0 (got a bash command not found)
Thanks!
...
Hello all,
I am creating a quick backup script that will dump some databases into a nice/neat directory structure and I realized that I need to test to make sure that the directories exist before I create them. The code I have works, but it seems that there is a better way to do it. Any suggestions?
[ -d "$BACKUP_DIR" ] || mkdir "$BACK...
I'm trying to iterate over each file in a directory. Here's my code so far.
while read inputline
do
input="$inputline"
echo "you entered $input";
if [ -d "${input}" ]
then
echo "Good Job, it's a directory!"
for d in $input
do
echo "This is $d in directory."
done
exit
my output is always just one...
When one reads a file lets say a dd image or we read from a hard drive itself with cat /dev/sda, the output is usually mush in some form of Hex. Since these are actually binary files is there a way to see the binary instead of the hex.
Add: So here is the output of a windows 7 dd image of a hdd. As you can see it is just hex mush. I...
I'm trying to search Google but the keyword 'go' makes it difficult to find any useful answers.
Reading the http://golang.org/ page doesn't turn up anything useful either.
Right now, I have a simple function in my bash.rc:
function gogo() {
6g -o gotmp.tmp $@;
6l -o go.out gotmp.tmp;
rm -f gotmp.tmp;
}
However, this is no...
Given the input
echo abc123def | grep -o '[0-9]*'
On one computer (with GNU grep 2.5.4), this returns 123, and on another (with GNU grep 2.5.1) it returns the empty string. Is there some explanation for why grep 2.5.1 fails here, or is it just a bug? I'm using grep -o in this way in a bash script that I'd like to be able to run on di...
I'm on Snow Leopard and installed ruby, rubygems and rails the hivelogic way. When I change to my new jekyll project (~/Documents/blog/jekyll), and run
[jekyll]$jekyll --server-bash
I get:
[jekyll]$jekyll --server-bash: /usr/bin/jekyll: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such fil...
I'm attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined). Note that Samual has rejoined.
[Sun Nov 15 14:12:50 2009] [GAME: Tower Defense Join Fast!] player [Samual|192.168.1.115] joined the ga...
I'm writing a script to batch resize images. Originally I was applying an operation for file in $(ls $1), but I would like to be able to use globbing, so I'm looking at something more like for file in $(echo $1). The problem is that dotglob may or may not be enabled, so echo * could return hidden files (notably, .DS_Store), which cause c...
I have a directory that looks like this:
pages/
folder1/
folder1.filename1.txt
folder1.filename2.txt
folder2/
folder2.filename4.txt
folder2.filename5.txt
folder3/
filename6.txt
I want it to look like this:
pages/
folder1/
filename1.txt
filename2.txt
folder2/
filename3.txt
filename4.txt
folder3/
filename5.txt...
How do I extract the last directory of a pwd output? I don't want to use any knowledge of how many levels there are in the directory structure. If I wanted to use that, I could do something like:
> pwd
/home/kiki/dev/my_project
> pwd | cut -d'/' -f5
my_project
But I want to use a command that works regardless of where I am in the dire...
Hi,
with a previous bash script I created a list of files:
data_1_box
data_2_box
...
data_10_box
...
data_99_box
the thing is that now I need to concatenate them, so I tried
ls -l data_*
but I get
.....
data_89_box
data_8_box
data_90_box
...
data_99_box
data_9_box
but I need to get in the sucession 1, 2, 3, 4, .. 9, ..., 89, 90,...
I've been learning about gems lately, and one error I get is:
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/Alex/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
ERROR: Error installing rubygame:
ffi requires rake (>= 0.8.7, runtime)
I u...
Is it possible to capture bash output to the OS X clipboard?
...
I have a file containing the string
ipAddress=10.78.90.137;10.78.90.149
I'd like to place these two IP addresses in a bash array. To achieve that I tried the following:
n=$(grep -i ipaddress /opt/ipfile | cut -d'=' -f2 | tr ';' ' ')
This results in extracting the values alright but for some reason the size of the array is returned...
while executing a shell script in Unix Bash Shell, say any file in another folder and that is referenced by the script references some other file like ../../file_system_1/public/dir1/dir2/file2.xml
script.sh --> references dir1/file1 as "./dir1/file1"
dir1/file1 references another file as ../../file_system_1/public/dir1/dir2/file2.xml...