Hi,
I get in a bashscript, in the follwoing line
echo $AAAA" "$DDDD" "$MOL_TAG >> ${OUPUT_RESULTS}
the error:
line 46: ${OUPUT_RESULTS}: ambiguous redirect
Why?
Thanks
Hi,
this is probably a very stupid question; in a bashscript, given the output of, for instance;
awk '{print $7}' temp
it gives 0.54546
I would like to give this to a variable, so I tried:
read ENE <<< $(awk '{print $7}' temp)
but I get
Syntax error: redirection unexpected
Could you tell me why, and what is the easiest way to do this assignment?
Thanks
In my bashscript I have an external (received from user) string, which I should use in sed pattern.
REPLACE="<funny characters here>"
sed "s/KEYWORD/$REPLACE/g"
How can I escape the $REPLACE string so it would be safely accepted by sed as a literal replacement?
NOTE: The KEYWORD is a dumb substring with no matches etc. It is not supplied by user.
I need a bash command that will convert a string to something that is escaped. Here's an example:
echo "hello\world"|escape|someprog
Where the escape command makes "hello\world" into "hello\\world". Then, someprog can use "hello\world" as it expects. Of course, this is a simplified example of what I will really be doing.
I've found many useful Bash commands that can execute OS X behaviors from the command line such as:
screencapture -x -C $FILENAME
Is there such a command that can check if the screen saver is active?
Hi,
how can one turn off the error messages of a bash script?
I want to turn it off, and handle the expected ones by myself
For instance, when it does not find some files, to show my specific error message.
Thanks
Is there any variable in bash that contains the name of the .sh file executed ?
The line number would be great too.
I want to use it in error messages such as:
echo "ERROR: [$FILE:L$LINE] $somefile not found"
Thank you
Greetings!
I have a text file with parameter set as follows:
NameOfParameter Value1 Value2 Value3 ...
...
I want to find needed parameter by its NameOfParameter using regexp pattern and return a selected Value to my Bashscript.
I tried to do this with grep, but it returns a whole line instead of Value.
Could you help me to find as approach please?
In perl you can simply write print "-" x 20 and you get a line with dashes...but i need the same thing in bash/commandline on linux without perl/(g)awk etc. any ideas? The intention is to use it in the -exec of the find command and i want to prevent using simple echo "---------" ...
I'm trying to wrap a standard sequence of steps in a shell script (linux/bash) and can't seem to figure out how to tell of the execution of svn status returned anything. For example
~/sandbox/$svn status
? pat/foo
~/sandbox/$echo $?
0
If I delete the foo file, then the
svn status
return nothing, but the echo $? is still 0
I want to not do some steps if there are uncommitted changes.
Pointers greatly appreciated.
I'm writing a bashscript to modify a config file which contains a bunch of key, value pairs. How can i read the key and find the value and possibly modify it?
Each day an application creates a file called file_YYYYMMDD.csv where YYYYMMDD is the production date. But sometimes the generation fails and no files are generated for a couple of days.
I'd like an easy way in a bash or sh script to find the filename of the most recent file, which has been produced before a given reference date.
Typical usage: find the last generated file, disregarding those produced after the May 1st.
Thanks for your help
Hi,
I am having a look af a big C++ project with more than 100 files. Given a certain function name, how can one find just using bash tools like find or grep, the declaration and the defintion of a function?
Thanks
I want to create a near 100% load on a Linux machine. It's quad core system and I want all cores going full speed. Ideally, the CPU load would last a designated amount of time and then stop. I'm hoping there's some trick in bash. I'm thinking some sort of infinite loop.
Hi!
I have a file
line a - this is line a
line b - this is line b
line c - this is line c
line d - this is line d
line e - this is line e
The question is: How can I output the lines starting from "line b" till "line d" using bash commands?
I mean, to obtain:
"line b - this is line b
line c - this is line c
line d - this is line d"
i have text such as
http://pastebin.com/H8zTbG54
we can say this text is set of rules splitted by "OR" at the end of lines
i need to put set of lines(rules) into buckets (bash array members) but i have character limit for each array member which is 1024
so each array member should contain set of rules but character count for each array member can not exceed 1024
can anybody help me to do that
solaris 10
I often have to modify files such as sysctl.conf, and I'm familiar with using sed to replace existing values.
Is there a way to append the new key/value pair to the file if sed wasn't able to replace it?
For instance, using this example: modify config file using bashscript
sed -c -i "s/\($TARGET_KEY *= *\).*/\1$REPLACEMENT_VALUE/" $CONFIG_FILE
How could I add the $TARGET_KEY = $REPLACEMENT_VALUE new line to $CONFIG_FILE using the same sed expression with slight changes?
And on a related topic, how can I force creation of $CONFIG_FILE if it didn't exist?
Dear all,
I'm a newbie in bash and I would like to pass as parameter to a python function all files in a directory that don't match a given pattern. sth. like:
$myscripts/myprog.py $myfiles/!(bonjovi)
The above example should retrieve all files that don't match to "bonjovi".
Best wishes
Hi,
in bash I need to compare two float numbers, one which I define in the script and the other read as paramter, for that I do:
if [[ $aff -gt 0 ]]
then
a=b
echo "xxx "$aff
#echo $CX $CY $CZ $aff
fi
but I get the error:
[[: -309.585300: syntax error: invalid arithmetic operator (error token is ".585300")
What is wrong?
Thanks
Hi,
when compiling some projects on linux terminal, I get usually a long output consisting of a lot of information. Usually this information is MONOCHROME. I wonder if bash can be modified somehow, so in all outputs or in some specific outputs (like from Makefile, etc) I can get different colors dependeing on, for instance:
make[1]: Leaving directory
or
g++ -DHAVE_CONFIG_H -I.
etc.
Thanks
Input:
hello world "22" bye world
I need a regex that will work in bash that can get me the numbers between the quotes. The regex should match 22.
Thanks!
I want to know if there is a built-in BASH command that prints some text on stderr, just like the echo command that prints text on stdout. I don't want to use temporary io-redirection. I use a built-in command to generate an error on stderr such as ls --asdf (ls: unrecognized option '--asdf') but I want something neater,