Sponsored Content
Top Forums Shell Programming and Scripting Merging strings which have deviation in frequency Post 302912586 by gimley on Sunday 10th of August 2014 05:49:55 AM
Old 08-10-2014
Yes, I did run the file twice instead of one, which I deduced from the awk syntax and piped it out to an out file.
Maybe this is because I am using DOS and Windows Vista and Gawk32 to accommodate a 32 bit version of Windows.
I thought that maybe it was an OS issue. But Awk runs seamlessly along all OS's.(at least that's what I thought). Maybe this is why your syntax for the file separator did not work. I can see it works beautifully for you: the output is flawless.
Any solution to make the program run in my environment.
Once again many thanks for your patience and time. This is a learning experience for me for which I am grateful.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script for finding standard deviation

I have a CSV file that looks like 0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0 10,11,7,0,4,12,2,3,7,0,11,3,12,4,0,5,5,4,5,0,8,6,12,0,9,3,3,0,2,7,8 19,11,7,0,4,14,16,10,8,2,13,7,15,6,0,76,6,4,10,0,18,10,17,1,11,3,3,0,9,9,8... (7 Replies)
Discussion started by: RJ17
7 Replies

2. Shell Programming and Scripting

Mean and Standard deviation

Hi all, I am new to shell scripting and wanna calculate the mean and standard deviation using shell programming. I have a file with letters that are repeating and their corresponding duration a 0.32 a 0.89 aa 0.34 aa 0.23 au 0.012 au 0.26... (4 Replies)
Discussion started by: lakshmikanth.pg
4 Replies

3. UNIX for Dummies Questions & Answers

Calculating the Standard Deviation for a column

Hi all, I want to calculate the standard deviation for a column (happens to be column 3). Does any know of simple awk script to do this? Thanks (1 Reply)
Discussion started by: kylle345
1 Replies

4. Shell Programming and Scripting

using awk to print average and standard deviation into a file

Hi I want to use awk to print avg and st deviation but it does not go into a file for column 1 only. I can do average and # of records but i cannot get st deviation. awk '{sum+=$1} END { print "Average = ",sum/NR}' thanks (1 Reply)
Discussion started by: phil_heath
1 Replies

5. Shell Programming and Scripting

Standard deviation in awk

Hi all, I need to find the standard deviation of each column of a dataset below for each hour. The data is given in 5 second intervals as shown below DATE TIME FRAC_DAYS_SINCE_JAN1 FRAC_HRS_SINCE_JAN1 EPOCH_TIME ... (11 Replies)
Discussion started by: gd9629
11 Replies

6. Shell Programming and Scripting

AWK script for standard deviation / root mean square deviation

I have a file with say 50 columns, each containing a whole lot of data. Each column contains data from a separate simulation, but each simulation is related to the data in the last (REFERENCE) column $50 I need to calculate the RMS deviation for each data line, i.e. column 1 relative to... (12 Replies)
Discussion started by: chrisjorg
12 Replies

7. Shell Programming and Scripting

Calculate Mean absolute Deviation

Hi, I am trying to use an statistical formula. I tried in excel, but I get different values when I use calculator. The formula is (1/n) ∑|x - mean| n=no. of observations x=each individual expression value mean is median of all observations I have a file with 1000 rows.. So it needs... (1 Reply)
Discussion started by: Diya123
1 Replies

8. Shell Programming and Scripting

Output mean and standard deviation of a row

I have a file that looks that this: 820 890 530 1650 1600 1800 1850 1900 2270 1640 2300 1670 2080 2200 2350 1150 1630 2210 I would like to output the mean and standard deviation of each row so that my final output would look like this 820 890 530 746.667 155.849 1650 1600 1800... (5 Replies)
Discussion started by: kayak
5 Replies

9. Ubuntu

Merging strings that have identical rownames in a dataframe

Hi I have a data frame with repeated names in column 1, and different descriptors in column 2. I want to merge/cat strings that have same entry in column 1 into one row with any separator. Example for input: Cvel_1 KOG0155 Cvel_1 KOG0306 Cvel_1 KOG3259 Cvel_1 ... (4 Replies)
Discussion started by: Alyaa
4 Replies

10. Shell Programming and Scripting

Replicate merging and frequency calculation

Hello, I have a 2 column file with an ID column and a column with some string. ID String EN03 typehellobyedogcatcatdog EN09 typehellobye EN08 dogcatcatdog EN09 catcattypehello EN10 typehellobyedogcatcatdog EN10 typehellobyedogcatcatdogdog I would like to count the amount of times... (9 Replies)
Discussion started by: verse123
9 Replies
exec(n) 						       Tcl Built-In Commands							   exec(n)

__________________________________________________________________________________________________________________________________________________

NAME
exec - Invoke subprocess(es) SYNOPSIS
exec ?switches? arg ?arg ...? _________________________________________________________________ DESCRIPTION
This command treats its arguments as the specification of one or more subprocesses to execute. The arguments take the form of a standard shell pipeline where each arg becomes one word of a command, and each distinct command becomes a subprocess. If the initial arguments to exec start with - then they are treated as command-line switches and are not part of the pipeline specifica- tion. The following switches are currently supported: -keepnewline Retains a trailing newline in the pipeline's output. Normally a trailing newline will be deleted. -- Marks the end of switches. The argument following this one will be treated as the first arg even if it starts with a -. If an arg (or pair of arg's) has one of the forms described below then it is used by exec to control the flow of input and output among the subprocess(es). Such arguments will not be passed to the subprocess(es). In forms such as ``< fileName'' fileName may either be in a sep- arate argument from ``<'' or in the same argument with no intervening space (i.e. ``<fileName''). | Separates distinct commands in the pipeline. The standard output of the preceding command will be piped into the standard input of the next command. |& Separates distinct commands in the pipeline. Both standard output and standard error of the preceding command will be piped into the standard input of the next command. This form of redirection overrides forms such as 2> and >&. < fileName The file named by fileName is opened and used as the standard input for the first command in the pipeline. <@ fileId FileId must be the identifier for an open file, such as the return value from a previous call to open. It is used as the standard input for the first command in the pipeline. FileId must have been opened for reading. << value Value is passed to the first command as its standard input. > fileName Standard output from the last command is redirected to the file named fileName, overwriting its previous contents. 2> fileName Standard error from all commands in the pipeline is redirected to the file named fileName, overwriting its previous con- tents. >& fileName Both standard output from the last command and standard error from all commands are redirected to the file named fileName, overwriting its previous contents. >> fileName Standard output from the last command is redirected to the file named fileName, appending to it rather than overwriting it. 2>> fileName Standard error from all commands in the pipeline is redirected to the file named fileName, appending to it rather than over- writing it. >>& fileName Both standard output from the last command and standard error from all commands are redirected to the file named fileName, appending to it rather than overwriting it. >@ fileId FileId must be the identifier for an open file, such as the return value from a previous call to open. Standard output from the last command is redirected to fileId's file, which must have been opened for writing. 2>@ fileId FileId must be the identifier for an open file, such as the return value from a previous call to open. Standard error from all commands in the pipeline is redirected to fileId's file. The file must have been opened for writing. >&@ fileId FileId must be the identifier for an open file, such as the return value from a previous call to open. Both standard output from the last command and standard error from all commands are redirected to fileId's file. The file must have been opened for writing. If standard output has not been redirected then the exec command returns the standard output from the last command in the pipeline. If any of the commands in the pipeline exit abnormally or are killed or suspended, then exec will return an error and the error message will include the pipeline's output followed by error messages describing the abnormal terminations; the errorCode variable will contain addi- tional information about the last abnormal termination encountered. If any of the commands writes to its standard error file and that standard error isn't redirected, then exec will return an error; the error message will include the pipeline's standard output, followed by messages about abnormal terminations (if any), followed by the standard error output. If the last character of the result or error message is a newline then that character is normally deleted from the result or error message. This is consistent with other Tcl return values, which don't normally end with newlines. However, if -keepnewline is specified then the trailing newline is retained. If standard input isn't redirected with ``<'' or ``<<'' or ``<@'' then the standard input for the first command in the pipeline is taken from the application's current standard input. If the last arg is ``&'' then the pipeline will be executed in background. In this case the exec command will return a list whose elements are the process identifiers for all of the subprocesses in the pipeline. The standard output from the last command in the pipeline will go to the application's standard output if it hasn't been redirected, and error output from all of the commands in the pipeline will go to the application's standard error file unless redirected. The first word in each command is taken as the command name; tilde-substitution is performed on it, and if the result contains no slashes then the directories in the PATH environment variable are searched for an executable by the given name. If the name contains a slash then it must refer to an executable reachable from the current directory. No ``glob'' expansion or other shell-like substitutions are performed on the arguments to commands. PORTABILITY ISSUES
| Windows (all versions) | Reading from or writing to a socket, using the ``@ fileId'' notation, does not work. When reading from a socket, a 16-bit DOS | application will hang and a 32-bit application will return immediately with end-of-file. When either type of application writes to | a socket, the information is instead sent to the console, if one is present, or is discarded. | The Tk console text widget does not provide real standard IO capabilities. Under Tk, when redirecting from standard input, all | applications will see an immediate end-of-file; information redirected to standard output or standard error will be discarded. | Either forward or backward slashes are accepted as path separators for arguments to Tcl commands. When executing an application, | the path name specified for the application may also contain forward or backward slashes as path separators. Bear in mind, however, | that most Windows applications accept arguments with forward slashes only as option delimiters and backslashes only in paths. Any | arguments to an application that specify a path name with forward slashes will not automatically be converted to use the backslash | character. If an argument contains forward slashes as the path separator, it may or may not be recognized as a path name, depending | on the program. | Additionally, when calling a 16-bit DOS or Windows 3.X application, all path names must use the short, cryptic, path format (e.g., | using ``applba~1.def'' instead of ``applbakery.default''). | Two or more forward or backward slashes in a row in a path refer to a network path. For example, a simple concatenation of the root | directory c:/ with a subdirectory /windows/system will yield c://windows/system (two slashes together), which refers to the mount | point called system on the machine called windows (and the c:/ is ignored), and is not equivalent to c:/windows/system, which | describes a directory on the current computer. The file join command should be used to concatenate path components. | Windows NT | When attempting to execute an application, exec first searches for the name as it was specified. Then, in order, .com, .exe, and | .bat are appended to the end of the specified name and it searches for the longer name. If a directory name was not specified as | part of the application name, the following directories are automatically searched in order when attempting to locate the applica- | tion: | The directory from which the Tcl executable was loaded. | The current directory. | The Windows NT 32-bit system directory. | The Windows NT 16-bit system directory. | The Windows NT home directory. | The directories listed in the path. | In order to execute the shell builtin commands like dir and copy, the caller must prepend ``cmd.exe /c '' to the desired command. | Windows 95 | When attempting to execute an application, exec first searches for the name as it was specified. Then, in order, .com, .exe, and | .bat are appended to the end of the specified name and it searches for the longer name. If a directory name was not specified as | part of the application name, the following directories are automatically searched in order when attempting to locate the applica- | tion: | The directory from which the Tcl executable was loaded. | The current directory. | The Windows 95 system directory. | The Windows 95 home directory. | The directories listed in the path. | In order to execute the shell builtin commands like dir and copy, the caller must prepend ``command.com /c '' to the desired com- | mand. | Once a 16-bit DOS application has read standard input from a console and then quit, all subsequently run 16-bit DOS applications | will see the standard input as already closed. 32-bit applications do not have this problem and will run correctly, even after a | 16-bit DOS application thinks that standard input is closed. There is no known workaround for this bug at this time. | Redirection between the NUL: device and a 16-bit application does not always work. When redirecting from NUL:, some applications | may hang, others will get an infinite stream of ``0x01'' bytes, and some will actually correctly get an immediate end-of-file; the | behavior seems to depend upon something compiled into the application itself. When redirecting greater than 4K or so to NUL:, some | applications will hang. The above problems do not happen with 32-bit applications. | All DOS 16-bit applications are run synchronously. All standard input from a pipe to a 16-bit DOS application is collected into a | temporary file; the other end of the pipe must be closed before the 16-bit DOS application begins executing. All standard output or | error from a 16-bit DOS application to a pipe is collected into temporary files; the application must terminate before the temporary | files are redirected to the next stage of the pipeline. This is due to a workaround for a Windows 95 bug in the implementation of | pipes, and is how the standard Windows 95 DOS shell handles pipes itself. | Certain applications, such as command.com, should not be executed interactively. Applications which directly access the console | window, rather than reading from their standard input and writing to their standard output may fail, hang Tcl, or even hang the sys- | tem if their own private console window is not available to them. | Macintosh | The exec command is not implemented and does not exist under Macintosh. | Unix | The exec command is fully functional and works as described. | SEE ALSO
| error(n), open(n) | KEYWORDS
| execute, pipeline, redirection, subprocess | Tcl 7.6 exec(n)
All times are GMT -4. The time now is 08:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy