Suppose I have two lists of numbers in files f1, f2, each number one per line. I want to see how many numbers in the first list are not in the second and vice versa. Currently I am using grep -f f2 -v f1 and then repeating this using a shell script. This is pretty slow (quadratic time hurts). Is there a nicer way of doing this?
...
I've gone through the academic Scheme stuff (read SICP, The Little Schemer, The Seasoned Schemer, TSPL) and been playing with Scheme as a toy for a while.
But I want to get practical.
Today I needed to write a shell script to do some batch file processing, and thought "why not do it in Scheme?". I did, and it was a joy.
Now I'm forced ...
I have an xml configuration file which works fine in Java, and I'm trying to parse out some info from it using XMLStarlet inside a script. The error I'm getting is:
xml sel -t -m "Config/Application" -v "@rmiPort" -n config.xml
namespace error : Namespace prefix log4j on configuration is not defined
<log4j:configura...
I want to grab the color of a pixel with known coordinates on my Linux desktop.
Until now, I've used "import -window SomeWindow -crop 1x1+X+Y /tmp/grab.jpg"
then extracting the pixel value using Python and PIL.
This does the job, but since import grabs the whole window before cropping, it's very slow :(
Are there any clever way to gra...
I have a bash shell script which has the line:
g=$(/bin/printf ${i})
when ${i} contains something like -6, printf thinks its being passed an option. It does not recognize the option so produces an error.
if wrap ${i} in quotes, printf still thinks its being passed an option.
g=$(/bin/printf "${i}")
if I escape the quotes, variab...
I want to test whether a phone number is valid, and then translate it to a different format using a script. This far I can test the number like this:
sed -n -e '/(0..)-...\s..../p' -e '/(0..)-...-..../p'
However, I don't just want to test the number and output it, I would like to remove the brackets, dashes and spaces and output that....
I have a variable in my shell script that works as per my expectations.
But when I use that variable as filename, I get ?? at the beginning of the string. How do I trim the junk characters?
I use $(some command) to create this variable.
...
in applescript if i do:
do shell script "echo \"G:\\CRE\\MV Studios\\Exhibition Projects\"|tr \"\\\\\" \"/\""
I'd expect all my backslashes to come back forward slashes. To make it slightly easier to understand he tr command would look like this without all the escapes
tr "\\" "/" #there's still an escaped \ for the shell
But what ...
What is the correct way to parse a string using regular expressions in a linux shell script? I wrote the following script to print my SO rep on the console using curl and sed (not solely because I'm rep-crazy - I'm trying to learn some shell scripting and regex before switching to linux).
json=$(curl -s http://stackoverflow.com/users/fl...
How to compare two property files in two different folders using shell script
input can be path of the two folders?
There are multiple files in both folders and each files needs to be checked
...
I've been trying to automate some configuration backups on my cisco devices, i've already managed to do the script that accomplishes the task but I'm trying to improve it to handle errors too.
I think that's necessary to catch the errors on two steps, first just after the 'send \"$pass\r\"' to get login errors (access denied messages) a...
I have a procedure I want to initiate only if several tests complete successfully.
One test I need is that all of my NFS mounts are alive and well.
Can I do better than the brute force approach:
mount | sed -n "s/^.* on \(.*\) type nfs .*$/\1/p" |
while read mount_point ; do
timeout 10 ls $mount_point >& /dev/null || echo "stale...
I want to split a file containg HTTP response into two files: one containing only HTTP headers, and one containg the body of a message. For this I need to split a file into two on first empty line (or for UNIX tools on first line containing only CR = '\r' character) using a shell script.
How to do this in a portable way (for example us...
Have two folders with approx. 150 java property files.
In a shell script, how to compare both folders to see if there is any new property file in either of them and what are the differences between the property files.
The output should be in a report format.
...
Hello all,
I'm working on a solaris box. How do I go about deleting all files in a folder, which have the word"Failure" in them ?
i'm trying something in the lines of the following, but it doesn't seem to remove anything.
rm -rf | find ./*.log -exec grep 'Failure' \;
Appreciate your inputs.
...
I have a a large text file (over 70mb) and need to count the number of times a character sequence occurs in the file. I can find plenty of scripts to do this, but NONE OF THEM take in to account that a sequence can start and finish on different lines. For the sake of efficiency (I actually have way more than 1 file I am processing), I ca...
I'm looking for a simple way to find the longest line in a file. Ideally, it would be a simple bash shell command instead of a script.
...
Hello,
i am testing with the shell script below:
#!/bin/ksh -x
instance=`echo $1 | cut -d= -f2`
if [ $instance == "ALL" ]
then
echo "strings matched \n"
fi
It's giving this error in the if condition:
: ==: unknown test operator
is == really not the correct syntax to use?
I am running on the command line as below
test_lsn_2 INST...
How do I determine the uptime on a SunOS UNIX box in seconds only?
On Linux, I could simply cat /proc/uptime & take the first argument:
cat /proc/uptime | awk '{print $1}'
I'm trying to do the same on a SunOS UNIX box, but there is no /proc/uptime.
There is an uptime command which presents the following output:
$ uptime
12:13pm up ...
Hi,
I have been trying to make an init script using start-stop-daemon. I am stuck on the arguments to the daemon. I want to keep these in a variable at the top of the script but I can't get the quotations to filter down correctly.
I'll use ls here so we don't have to look at binaries and arguments that most people wont know or care abou...