I'm writing a Bourne Shell script that may or may not receive input from stdin (as in foo.sh < test.txt, non-interactively). How do I check whether there is anything on stdin, to avoid halting on while read -r line...?
...
I'm writing a Bourne Shell script to automatically edit a source file.
I get the line number I need like this:
line=`sed -n '/#error/=' test.h`
line=$[$line - 2]
Now I want to insert a few lines of text after this line number, how can I do this?
...
I am currently working on a way to automate the process of adding new targets to my XCode projects. One target has to be added to multiple XCode projects and each target in the different project needs the same source files to be added, same groups to store the source files in the XCode project, and the same build settings. Doing this man...
I want the user to input something at the command line either -l or -e.
so e.g. $./report.sh -e
I want an if statement to split up whatever decision they make so i have tried...
if [$1=="-e"]; echo "-e"; else; echo "-l"; fi
obviously doesn't work though
Thanks
...
I'm currently using the following to split a file into words - Is there some quicker way?
while read -r line
do
for word in $line
do
words="${words}\n${word}"
done
done
...
I'm checking a counter in a loop to determine if it's larger than some maximum, if specified in an optional parameter. Since it's optional, I can either default the maximum to a special value or to the maximum possible integer. The first option would require an extra check at each iteration, so I'd like to instead find out what is the m...
hi, i am using debian. running my program with time command and want the result of time written to a file, doing as follows:
time ./myprog > out.asc
./myprog's output is written to out.asc but not the time's result.
is there any way to send the time's output also to out.asc? thanx!
...
Hello,
I'm not sure how to do this but I figured I would ask here.. I'm trying to create a string of specific environment variables such that:
$A = "foo"
$B = "bar"
$C = "baz"
would give "foo, bar, baz"
Unfortunately, it doesn't seem that the Bourne shell supports arrays, which would have made these easily solvable. The other way I'm...
Hello,
I'm having trouble figuring out a way to properly concatenate several variables together. The idea is to collect several items over time (in this case "foo", "bar", and "baz") and then concatenate together into one string (ex: X = "foo bar baz").
The following is the code I have put together so far:
#!/bin/sh
N=0
# assign foo
e...
I have a shell that runs where the preset env variables include:
FOOCOUNT=4
FOO_0=John
FOO_1=Barry
FOO_2=Lenny
FOO_3=Samuel
I can not change the way I get this data.
I want to run a loop that generates up the variable and uses the contents.
echo "Hello $FOO_count"
This syntax is however wrong and that is what I am searching for......
What is the sh code for image manipulation?
...
I have a process monitor script, procer, that runs as root and launches child processes and then chroots them to become my user and drop priviledges. This all works nicely. The problem I am having though is that I prefer to use tcsh rather than bash for normal day to day command line activities (in Snow Leopard), but the aforementioned (...
What this is meant to do is, collects the arguments which are the names of the image files and checks them if they exist and are readable, then it converts the image to the preview file in the layout (imagename)_preview.jpg and underneath it it would have the size of the orignal file in 'bytes'.
Here is my script.
#!/bin/sh
clear
for i ...
I'm trying to tell unix to print out the command line arguments passed to a Bourne Shell script, but it's not working. I get the value of x at the echo statement, and not the command line argument at the desired location.
This is what I want:
./run a b c d
a
b
c
d
this is what I get:
1
2
3
4
What's going on? I know that UNIX is con...
In Unix, how would one do this?
#!/bin/sh
x=echo "Hello" | grep '^[A-Z]'
I want x to take the value "Hello", but this script does not seem to work. What would be the proper way of spelling something like the above out?
...
Hey Guys,
Here is the scenario:
Have a shell script that calls ant with one argument. The ant in turn executes testng.xml (suite file) passing the same argument and testng in turn executes the test within passing the same argument.
In my case, I am passing the browser string eg.(firefox, iexplore) argument that will specify which brow...
#!/bin/sh
if [ ! -d $1 ]
then echo $1 nu este director
exit1
fi
ls -R $1 >temp
permission= ls -al $1 | cut -d" " -f1
for i in `cat temp`
do
perm= ls -l $i | cut -d" " -f1
if [ $permission -ne $perm ]
then n=`expr $n + 1`
fi
echo $n
done
how can i transform this shell code into python?
please help
...
Suppose I have this sentence:
My name is bob.
And I want to copy the word "is" from that sentence into a variable. How would I access that word, without knowing in advance the word I am looking for? If I know a specific word or string is in the third column of text in a five column text line, how can I take the word in the third colu...