bash

Flatten a java project directory structure prepending the path to the file.

Hi there, I am trying to write a script (preferably in bash) to flatten a java projet directory structure prepending the path to the file. Example: | src | org | apache | file2.java | file1.java would result in: | src | org|apache|file2.java | org|file1.java The script should be recursive since the directory co...

How to output an array's content in columns in BASH.

I wanted to display a long list of strings from an array. Right now, my script run through a for loop echoing each value to the standard output: for value in ${values[@]} do echo $value done Yeah, that's pretty ugly! And the one column listing is pretty long too... I was wondering if i can find a command or builtin helping me to d...

Sed not working inside bash script

Hello. I believe this may be a simple question, but I've looked everywhere and tried some workarounds, but I still haven't solved the problem. Problem description: I have to replace a character inside a file and I can do it easily using the command line: sed -e 's/pattern1/pattern2/g' full_path_to_file/file But when I use the same l...

scons + windows: Cannot execute shell script in Command() builder

I have a command builder as such: jsontar = Command("bundle.tar", bundleDir, "mkvgconf $SOURCE $TARGET") mkvgconf is a shell script $SOURCE is a path to a directory $TARGET is a path to a file When attempting to execute under windows, SCons does not recognize vgmkconf as an executable. Google turns up: http://www.scons.org/wiki/Using...

How to authenticate passkey from a Tcl script calling bash?

I have a tcl script that calls a lot of functions from bash including ssh. The part I'm struggling with looks like this: proc connect {where} { set bash c:/cygwin/bin/bash catch {exec $bash -c "ssh $where"} result puts $result } connect user@localhost I get the authentication failed message: Pseudo-terminal will not be al...

escape from a linux cli for loop

I'm doing something like this: for f in `find -iname '*.html'`; do scp $f remoteserver:$f; done; I've got through about 3 of the 1000 files and I've decided I want to abort the operation. CTRL+C only escapes the SCP login prompt and takes me to the next one, rather than escaping the for loop. Is there a better way than hitting CTRL+...

How do you read a csv file into a two dimensional array in BASH?

How do you read a csv file into a two dimensional array in BASH? The script needs to be dynamic enough where it can take csv files with variable number of rows and columns. For example, if I have a csv file that looks like AVERAGE STDEV MAX 17 18 19 or AVERAGE STDEV MAX MIN 17 18 ...

Missing 'read' prompt in bash when using ssh?

Please tell me I'm missing something really obvious here: $ cat ~/bashplay/f #!/bin/bash read -p 'RDY> ' x echo $x $ ~/bashplay/f RDY> direct execution direct execution $ ssh somehost ~/bashplay/f indirect via ssh indirect via ssh Note the missing "RDY>" prompt when using ssh. I see the same thing in python when using the "readline"...

Bash script question

Say I have a bash script as follows while read $f; do cat $f >> output.txt; echo "aaa" >> output.txt; done Yet the second echo statement isn't executed. At all. What am I doing wrong? I'm running this via tail -f /var/log/somelog | ./script.sh $f should not be empty. It's only supposed to output when tail notices a change in th...

Using terminal to record/save a data stream

I want to be able to save a data stream which i am returning using the curl command. I have tried using the cat command, and piping it the curl command, however i'm doing it wrong. The code im currently using is: cat > file.txt | curl http://datastream.com/data Any help would be appreciated. ...

How netbeans installation file (bash file) contains Java code?

Hi folks, I wonder, how a bash file can contain a Java code that is responsible about the installation of netbeans IDE which is as known is a Java based program? this is the case of netbeans: $ file netbeans-6.8-ml-java-linux.sh netbeans-6.8-ml-java-linux.sh: POSIX shell script text executable $ more netbeans-6.8-ml-java-linux.sh #!/b...

how to insert new line in bash shell for variable??

I have two variables var1 and var2. The contents of each variables come from bash shell grep command. echo $var1 prints 123 465 326 8080 echo $var2 prints sila kiran hinal juku Now I want to print the above into following formats in Linux bash shell 123 sila 465 kiran 326 hinal 8080 juku So how can I print this way in bash shell??...

how to print bash varibles contents into two dimensional array bash shell

how do print bash shell variables contents into multidimensional array?? Thanks ...

ps forrest for session id

Often I want to get a nice readout what process are running and their relationship; I usually by habit runs ps auxfww and eventual grep for the process in question. Having been thinking about the problem I tried to create an oneliner to get the process tree in ps ufww format for all processes which has the session id specified by arbitr...

Sort files by last edited after finding them in a specific directory?

I'm looking to combine find . -mtime 0 and ls -lt To find all files modified in the last day in the current working directory, sorted by last modification date. ...

Capture log4J output with grep

Hi, I know that log4j by default outputs to stderror. I have been capturing the out put of my application with the following command: application_to_run 2> log ; cat log | grep FATAL Is there a way to capture the output without the auxiliary file? ...

Redirect PHP-Shell-Script output

Hi Folks, i have got a php-script foo.php #!/usr/bin/php -c /etc/php5/cli/php.ini -q <?php echo 'hello'; // & do some stuff ?> I call this script not wrapped by a sh-script but using it directly in a cron job. To get rid of it's output i normally would just create a sh-file which calls /usr/bin/php -c /etc/php5/cli/php.ini -q foo....

Extract a specific string from a curl'd result

Given this curl command: curl --user-agent "fogent" --silent -o page.html "http://www.google.com/search?q=insansiate" * Spelling is intentionally incorrect. I want to grab the suggestion as my result. I want to be able to either grep into the page.html file perhaps with grep -oE or pipe it right from curl and never store a file. T...

I need to pad IP addresses with Zeroes for each octet

Starting with a string of an unspecified length, I need to make it exactly 43 characters long (front-padded with zeroes). It is going to contain IP addresses and port numbers. Something like: ### BEFORE # Unfortunately includes ':' colon 66.35.205.123.80-137.30.123.78.52172: ### AFTER # Colon removed. # Digits padded to three (3) and fi...

Concatenation awk outputs

I'm using regex to parse NMAP output. I want the ip addresses which are up with the corresponding ports open. Now I've a very naive method of doing that: awk '/^Scanning .....................ports]/ {print substr ($2,1,15);}' results.txt awk '/^[0-9][0-9]/ {print substr($1,1,4);}' results.txt | awk -f awkcode.awk where awkcode.awk con...