bash

shell script output to clipboard

is there any easy way to implement the copy to clipboard option from the output of a shell script ? ...

Bash. How compare two strings in "version" format

Is there any way to compare such strings on bash: 2.4.5 and 2.8 and 2.4.5.1 etc ...

Attach bash script to apache start

I have a bash script that I want to be executed before apache starts or restarts. I want my bash script to be executed when apache starts during the bootup process and when I manually run "/etc/init.d/apache2 restart/start". There is an init.d script "/etc/init.d/apache2" but I rather not touch that file. Google is not very helpful :)...

Using ANSI-C quoting in sed

Hello, I have a file named "insert.txt". It can look like this (or uglier): ASDFG?|??|?\/\HJKL<MNBVCXZQWERTYUIOP zxvbnmlkjhgfdsaqwertyuiop 123"'`~4567890987654321!@#$%^&*() @#$%^&*()+_}{":?> And I want to replace a block of text in a target file (target.txt) which is delimited by "STARTSTACKOVERFLOW" to "STOPSTACKOVERFLOW". (I am sim...

How to script Excel or Numbers on a mac, and launch from bash?

Hi, I want to write a bash script for a mac which takes a text file containing a table of numbers (can be .csv), converts the numbers to a chart, saves the chart (any file format that I can display on my web page), and exits. It must do this unattended. No user interaction. I know bash, perl, and a little AppleScript, and I can learn...

bash: Is there a shortcut to copying a file to multiple places without looping/bash script?

I tried cp initial.txt {foo,bar,baz} but get baz is not a directory. And cp initial.txt foo bar baz doesn't work either. Is there a way I can do this without making a shell script and looping and invoking cp multiple times? I'm thinking there has to be a succinct way of doing this. ...

How do I change the display name in terminal (os x 10.6)

I have used this script to install imageMagick: Google: maddox magik-installer - its the first hit My terminal name is a string of cryptic letters and numbers. See image here: http://i302.photobucket.com/albums/nn92/wandoledzep/terminal.jpg Keep in mind my computer name in the "Sharing" system preferences is localhost. Any ideas how...

Pass a string with spaces as an argument to Bash function

Given the following string variable VAR="foo bar" I need it to be passed to a bash function, and accesses it, as usual, via $1. So far I haven't been able to figure out how to do it: #!/bin/bash function testfn(){ echo "in function: $1" } VAR="foo bar" echo "desired output is:" echo "$(testfn 'foo bar')...

bash script, line 30: syntax error: unexpected end of file

I`v wrote some script, and have unexpected end of file echo off if [$JAVA_HOME = ""]; then goto no_java_home fi if [$SRV_HOME = ""]; then goto no_srv_home fi echo Uses JAVA_HOME=$JAVA_HOME echo Uses SRV_HOME=$SRV_HOME export ACP="" export ACP=$ACP;$JAVA_HOME/lib/tools.jar export ACP=$ACP;$SRV_HOME/ant/lib/ant.jar export ACP=$ACP;$SRV_...

stty: standard input: Inappropriate ioctl for device

perl script.pl --f1="t1" --f2="t2" --f3="t4" --f4 < /home/joe/a.txt script.pl use Getopt::Long; my ($f1, $f2, $f3, $f4) ; GetOptions ( 'f1=s' => \$f1, 'f2=s' => \$f2, 'f3=s' => \$f3, 'f4' => \$f4, ); if ( $f1) { system('stty -echo'); print "Password:"; $pwd = <STDIN>; syst...

redirecting complete make output to a file

Hi I want to redirect complete make output to a file. I tried redirecting the stdout and stderr with the following command: make >aks_file.txt 2>&1 & But that is not redirecting the EXACT complete output which is otherwise generated by issuing just make (some lines are missing) Am I missing something? ...

How to create a .conf file on the fly in Bash

I have a proprietary command-line program that I want to call in a bash script. It has several options in a .conf file that are not available as command-line switches. I can point the program to any .conf file using a switch, -F. I would rather not manage a .conf file separate from this script. Is there a way to create a temporary do...

Find all files with a filename beginning with a specified string which may match thousands of files

Hi there, I have a directory with roughly 100000 files in it, and I want to perform some function on all files beginning with a specified string, which may match tens of thousands of files. I have tried ls mystring* but this returns with the bash error 'Too many arguments'. My next plan was to use find ./mystring* -type f but thi...

Writing to an IO stream in Ruby instead of sanitizing user input and sending to the shell?

I was just reading a blog post about sanitizing user input in Ruby before sending it to the command line. The author's conclusion was: don't send user input it to the command line in the first place. In creating a contact form, he said he learned that What I should do instead is open a pipe to the mail command as an IO stream an...

Is there a way to prevent sh/bash from performing command substitution?

From a C program I want to call a shell script with a filename as a parameter. Users can control the filename. The C is something like (initialization/error checking omitted): sprintf(buf, "/bin/sh script.sh \"%s\"", filename); system(buf); The target device is actually an embedded system so I don't need to worry about malicious use...

Replacing a *specific* term in an XML file

I want to replace the text PATHTOEXPORT with the contents of a variable passed on the command-line that would have a folder path in it (for example, /Dev_Content/AIX/Apache) I came across this article that discusses how to use sed to replace a value in an XML file with another. However, not having used sed before, I'm unsure how to rea...

Force `tee` to run for every command in a shell script?

I would like to have a script wherein all commands are tee'd to a log file. Right now I am running every command in the script thusly: <command> | tee -a $LOGFILE Is there a way to force every command in a shell script to pipe to tee? I cannot force users to add appropriate teeing when running the script, and want to ensure it log...

Find file ending with .sh OR .bin

How can I find all the files ending with .sh OR .bin in a given folder. I know I can do: find /path/to/folder -name "*.bin" to find all bin file. What must I add to also look for .sh files ? ...

bash version-sorting question

In the directory "data" are these files: command-1.9a-setup command-2.0a-setup command-2.0c-setup command-2.0-setup I would like to sort the files to get this result: command-1.9a-setup command-2.0-setup command-2.0a-setup command-2.0c-setup I tried this find /data/ -name 'command-*-setup' | sort --version-sort...

How to get only last IP from one or many divided by comma on beginning of the line

Hi, I would like to parse log files, I need to get only last IP from one or many divided by comma on beginning of the line: This is how the lines look like: 80.250.5.1 - - [26/Oct/2010:13:10:14 +0200] ... 80.250.5.1, 80.250.5.2 somethingA - [26/Oct/2010:13:10:14 +0200] ... 80.250.5.1, 80.250.5.2, 80.250.5.3 - somethingB [26/Oct/2010:1...