bash

Ending tail -f started in a shell script

What I have is following . A java process writing logs to the stdout A shell script starting the java process Another shell script which executes the previous one and redirects the log I check the log file with tail -f command for success message. The problem is even if I have exit 0 in the code I cannot end the tail -f process....

How to catch value of parameter in Apache2 CGI

Hello folks, I have a little apache2 CGI application on the Ubuntu. The CGI handler is bash shell script. My client application is search.html: <html> <body> <form action="/cgi-bin/search.sh" method="post"> <input type="text" name="searchKey" size="10"></input> <input type=SUBMIT value="search"> <form> </body> </html> firstly...

Do I need to escape characters in this MATLAB string?

I would like to call the following bash command in MATLAB: grep "Up to" ~/test_linux/vision1.1/log | awk '{print $7}' I use system() in MATLAB, but it turns out to have errors: >> [status string]=system('grep "Up to" ~/test_linux/vision1.1/log | awk '{print $7}' '); ??? [status string]=system('grep "Up to" ~/test_linux/vision1.1...

Why my bash can't execute R script ?

My script use an access to mysql to get command arguments to launch Rscript. Its use is as follows : Rscript $RFILE $ARGUMENTS (RFILE corresponding to path to Rscript, and ARGUMENTS corresponding to path file used and agr). I try, different way, but I still have errors, here a copy of my bash script : #!/usr/bin/env bash # Execute R pr...

How is bash scripting affected by the bash4 release?

bash4 looks good on paper, and I think I'll build it and give it a test drive. In the meantime... Anyone who has done the same care to share their expierence? It would be particularly interesting to hear of any issues with old bash code. ...

Wget with input-file and output-document

I have a list of URLs which I would like to feed into wget using --input-file. However I can't work out how to control the --output-document value at the same time, which is simple if you issue the commands one by one. I would like to save each document as the MD5 of its URL. cat url-list.txt | xargs -P 4 wget And xargs is there bec...

What does this bash syntax mean? (Featuring: case, exec)

What is the purpose of this bash script? (It is a portion of a larger script.) if [ $# -gt 0 ] then case $1 in -*) ;; *) exec $* ;; esac fi A related question: http://stackoverflow.com/questions/2046762/problem-with-metamap-inappropriate-ioctl-for-device ...

Change Directory in MATLAB from Terminal/JAVA

Hi all, I need to be able to change the working directory in MATLAB without interacting with the command window. I'm launching MATLAB from a Java application. Right now the only solution I've come up with is closing MATLAB, changing directory from JAVA and relaunching. Is there some streamlined way to send MATLAB the 'cd' command from J...

Search and sort data from several files

Hi, I have a set of 1000 text files with names in_s1.txt, in_s2.txt and so. Each file contains millions of rows and each row has 7 columns like: ccc245 1 4 5 5 3 -12.3 For me the most important is the values from the first and seventh columns; the pairs ccc245 , -12.3 What I need to do is to find between all the in_sXXXX.txt files, ...

Automatically run a program if another program returns an error

I have a program (grabface) that takes a picture of the face of a person using a webcam, and I also have a shell script wrapper that works like this: On the command line the user gives the script the name of a program to run and its command line arguments. The script then executes the given command and checks the exit code. If there was...

Bash or Python for extracting blocks from text files

Hi, I have a huge text file, which is structured as: SEPARATOR STRING1 (arbitrary number of lines) SEPARATOR ... SEPARATOR STRING2 (arbitrary number of lines) SEPARATOR SEPARATOR STRING3 (arbitrary number of lines) SEPARATOR .... What only changes between the different "blocks" of the file is the STRING and the content between the se...

bash Linux - Massive folder rename

On our Linux file server (RedHat Enterprise) we have some folders that we need to rename that have client work in them. The old folder format (ones that need to be changed) was clientcode_jobnumberjobname. The new format is clientcode_jobnumber_jobname. We basically need to change the old folder names by adding the extra underscore to th...

Command/Syntax for specifying dynamic profile name in cygwin

Hi all: What is the syntax for specifying a dynamic profile name in linux command? E.g. perl genhtml /home/$(usrProfile)/* What is the syntax to replace usrProfile if it is dynamic? Thanks. EDIT: I'm running this in Windows Command line under cygwin. UPDATE: I have tried doing the following: $ECHO $HOME chmod 444/home/~username/...

cannot write to pty - linux

i am the owner of the pty device created like this permissions are crw-w---- mknod pty1 c 1 1 cat > pty1 tells me operation not permitted. what i want to do later is that i open the file from a program using open and call write to send output to the terminal, as if it is a disk file. why is cat not working. can we write to a pty or ...

Bash arrays: Need help with white space

I'm trying to create an array in bash from a file with the following sample format: data, data, interesting data, data, more interesting The way I'm populating the arrays: read -r -a DATA1 <<< $(cat $FILE | awk -F, '{ print $1 }') read -r -a DATA2 <<< $(cat $FILE | awk -F, '{ print $2 }') read -r -a DATA3 <<< $(cat $FILE | awk -F, '{...

Awk, bash or python for converting a regular file?

Hi, I have a text file with lots of lines and with this structure: [('name_1a', 'name_1b', value_1), ('name_2a', 'name_2b', value_2), ..... ..... ('name_XXXa', 'name_XXXb', value_XXX)] I would like to convert it to: name_1a, name_1b, value_1 name_2a, name_2b, value_2 ...... name_XXXa, name_XXXb, value_XXX I wonder what would be the...

Are Bash and Linux shell the same?

I often getting confused with bash and shell. Are they same? If I want to learn the bash, will it be covered with Linux shell programming related books? I use Ubuntu Linux. Edit: (Added after getting two answers.) How bash is associated with terminal? ...

Bash syntax question: variable in brackets {} with # comments?

I just saw some code in bash that I didn't quite understand. Being the newbie bash scripter, I'm not sure what's going on. echo ${0##/*} echo ${0} I don't really see a difference in output in these two commands (prints the script name). Is that # just a comment? and what's with the /*. If it is a comment, how come it doesn't int...

local variable inside the loop issue

Hello I have some issue while exit loop,variable is 0 ,please se code below max=0 cat tmp|while read line do temp=$(echo $line|tr -d "\n"|wc -c) if [ $temp -gt $max ];then max=$temp echo $max fi done echo -n tmp $max cat tmp 12345 123456 OUTPUT 5 6 tmp 0 I can't understand why max 0 after exiting loop,because iside the loop it ge...

Shell Script Variable Quoting Problem

I have an sh script that contains the line $PHP_COMMAND -r 'echo get_include_path();' I can not edit this script, but I need the eventual command line to be (equivalent to) php -d include_path='/path/with spaces/dir' -r 'echo get_include_path();' How can I achieve this? Below is a script that demonstrates the problem. #!/bin/sh...