01-05-2012
Quote:
Originally Posted by
Corona688
Without seeing your actual input it's difficult to improve on it.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
With the following small script I list the size of documents belonging to a certain user by each time selecting the bytes-field of that file ($7). Now it fills the array with every file it finds so in the end the output of some users contains up to 200.000 numbers. So how can I calculate... (7 Replies)
Discussion started by: Hille
7 Replies
2. Shell Programming and Scripting
:confused:Hi,
I have got results from my simulation and I did extract the time field from the results file into new file. Then I was trying to calculate no. of occurrence for each set of time. However, I couldn't.
For example :
0.2 --
0.2 --
0.21016 --
0.21016 --
0.21016 --
.
.
.... (12 Replies)
Discussion started by: ENG_MOHD
12 Replies
3. Shell Programming and Scripting
Hi All,
I have a txt file which has hundreds of lines and 41 fields. I have a requirement to pick up field 14 from the text file which is a date fiels in the following format.
Field 14 :
Data Type : NUMERIC DATE (YYYYMMDD)
Field Length : 8
Example of Data :20090415
Field 42 :
Data Type... (2 Replies)
Discussion started by: nua7
2 Replies
4. Shell Programming and Scripting
Hey guys, maybe you can help me with this...
I want to read input.dat line by line, while doing a simple calculation between the second column value of the current line and the second column value of the next line (like a difference).
input is something like this:
0 3.945757
1 ... (1 Reply)
Discussion started by: origamisven
1 Replies
5. Shell Programming and Scripting
Hi All,
IS there any 'awk' way to manipulate following data?
Fruit Date Count
Apple 20/08/2011 5
Apple 27/08/2011 7
Apple 05/09/2011 11
Apple 12/09/2011 3
Apple 19/09/2011 25
.
.
.
.
Orange 20/08/2011 9
Orange 27/08/2011 20
Orange 27/08/2011 7
Orange 05/09/2011 15
Orange... (3 Replies)
Discussion started by: aniketdixit
3 Replies
6. Shell Programming and Scripting
Hi All,
I have the following time stamp data in 2 columns
Date TimeStamp(also with milliseconds)
05/23/2012 08:30:11.250
05/23/2012 08:30:15.500
05/23/2012 08:31.15.500
.
.
etc
From this data I need the following output.
0.00( row1-row1 in seconds)
04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies
7. Shell Programming and Scripting
I need to find the average from a file like:
data => BW:123 M:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0'
data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0'
data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0'
data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0'
data => BW:123 N:30 RTD:0 1... (4 Replies)
Discussion started by: Slagle
4 Replies
8. Shell Programming and Scripting
Hi all,
I am attempting to calculate a running variance for a file containing a column of numbers. I am using the formula variance=sum((x-mean(x))^2)/(n-1), where x is the value on the current row, and mean(x) is the average of all of the values up until that row. n represents the total number... (1 Reply)
Discussion started by: Jahn
1 Replies
9. UNIX for Dummies Questions & Answers
Hi, I wanted to calculate cumulative frequency distribution of my data that involves several arithmetic calls. I did things in excel but its taking me forever. this is what I want to do:
var1.txt contains n observations which I have to compute for frequency which is given by 1/n and subsequently... (7 Replies)
Discussion started by: ida1215
7 Replies
10. UNIX for Beginners Questions & Answers
Hello,
I came across a previous thread "awk-calculating-simple-correlation-rows" which calculated correlations across rows in awk.
Code:
awk '{
a = 0; for (i = 2; i <= NF; ++i) a += $i; a /= NF-1
b = 0; for (i = 2; i <= NF; ++i) b += ($i - a) ^ 2; b = sqrt(b)
if... (7 Replies)
Discussion started by: Ross
7 Replies
LEARN ABOUT CENTOS
shell-quote
SHELL-QUOTE(1) User Contributed Perl Documentation SHELL-QUOTE(1)
NAME
shell-quote - quote arguments for safe use, unmodified in a shell command
SYNOPSIS
shell-quote [switch]... arg...
DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
EXAMPLES
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
debug() {
[ -z "$debug" ] || shell-quote "debug:" "$@"
}
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
user_switches=
while [ $# != 0 ]
do
case x$1 in
x--pass-through)
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
shift;;
# process other switches
esac
shift
done
# later
eval "shell-quote some-command $user_switches my args"
OPTIONS
--debug
Turn debugging on.
--help
Show the usage message and die.
--version
Show the version number and exit.
AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
AUTHOR
Roderick Schertler <roderick@argon.org>
perl v5.16.3 2010-06-11 SHELL-QUOTE(1)