Sponsored Content
Full Discussion: Data manipulation with Awk
Top Forums Shell Programming and Scripting Data manipulation with Awk Post 302346993 by Franklin52 on Monday 24th of August 2009 03:08:15 PM
Old 08-24-2009
Quote:
Originally Posted by protocomm
Hi!!

Franklin 52, could you explain, your command line....i don't understand the part...

Code:
{s=n?s " " c++:c++;

Thanks by advance.
I've used a conditional operator, the form is :

Code:
expr ? action1 : action2

If expr is true, return action1 else return action2

Code:
s=n?s " " c++:c++

Explanation:

if n != 0 then s = s " " c++ else s = c++

Regards

Last edited by Franklin52; 08-24-2009 at 04:21 PM.. Reason: Correction of explanation: if n != 0 instead of if n = 0
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

data manipulation script

I have a folder called {homedata} Within this folder there are 12 subfolders 200601.......200612 Within each subfolder there are 8 sets of files Each filename commences with A B C D E F G or H, so {filename}* can be used. I am trying to write a script which will from the top level go... (1 Reply)
Discussion started by: grinder182533
1 Replies

2. UNIX for Dummies Questions & Answers

Data Manipulation

Hello I am currently having problems in mapulating a certain file which contains vaious data. Belos is a sample content Event=<3190> Client IP=<151.111.11.143> DNS=<abc.sbc.com> TransCount=<139> Client IP=<150.222.133.163> DNS=<xyz.yuu.com> TransCount=<3734> Event=<3120> Client... (11 Replies)
Discussion started by: khestoi
11 Replies

3. Shell Programming and Scripting

Data manipulation from one file

HI all i have a file consisting of following numbers 0000 0000 0000 0000 0000 1010 0000 0100 0000 0000 0000 1111 0000 1010 0000 0100 (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

4. Shell Programming and Scripting

awk data subsets manipulation

Hi, I'm working on a data file with the following structure val1,val2,flag 214.7332983,979.0259,1 12.87435571,205.7679,1 1.365976384,19.01616,1 44.08584096,205.7679,2 7.034721792,383.8778,2 189.5685503,979.0259,2 1.96352032,19.01616,2 where the field 'flag' identifies different... (10 Replies)
Discussion started by: Linoleum
10 Replies

5. Shell Programming and Scripting

Help with data manipulation script

Y,T,,H05,6,6,0,0 -> TH05_6 D,5,BT,B -> BT_KIOSK P,KQC222 -> KQC222 G,B,2 -> BRANI_GATE_2 fileA TPM658 Y,T,,H05,6,6,0,0 TPM110 D,5,BT,B TPM136 P,KQC222 TPM180 P,BQC913 TPM575 Y,B,,T05,14,14,0,0 IPM760 G,B,2 TPM011 I need to use second column $1,$2,$3,$4..... if first char... (6 Replies)
Discussion started by: ment0smintz
6 Replies

6. Shell Programming and Scripting

Data manipulation using shell

Dear all I have a dataset (in text format,delimited by tab) which have 100 variables (say, var0-var99) and more than 100,000 observations. I want to do the following: 1. for variable var0-var49, I want to add "00" in front of each data (for example, "1" would become "001") 2. for variable... (8 Replies)
Discussion started by: littlewenwen
8 Replies

7. UNIX for Dummies Questions & Answers

Data manipulation

Hallo Team, I need to manipulate existing data file. Have a look at current data and expected data: Current Data: 27873517141 27873540000 27873515109 27873517140 27873540001 27873540000 27873501343 27873540000 27873517140 27873511292 27873645989 27873540000 27873540000... (7 Replies)
Discussion started by: kekanap
7 Replies

8. UNIX for Dummies Questions & Answers

Data/date manipulation

Hallo Team, I need your help. I would like to change field9 format to yyyy-mm-dd it should be for example 2013-11-16 instead of 20131116 0780112843,0873599381,E,ISOL,ZAR,0.0035,O,1,20131116,4373200,0.21 0733001720,0873516499,E,ISOL,ZAR,0.0035,O,1,20131116,4331600,0.21... (3 Replies)
Discussion started by: kekanap
3 Replies

9. UNIX for Dummies Questions & Answers

Data Manipulation

Dear Sir, I have file input RGR001|108.28|-2.86489|100-120|RANGGAR RGR002|108.071|-2.69028|80-100|RANNGAR RGR003|108.168|-2.97053|50-80|RANNGAR RGR007|108.192722222|-2.766138889|0-50|RANGGARI want to create files by joining each rows with each rows below Output as below ... (4 Replies)
Discussion started by: radius
4 Replies

10. Shell Programming and Scripting

Data manipulation, Please help..

Hello, I have a huge set of data that needs to be reformatted. Here is a simple example to explain the process. I have number n=5 and a input with many numbers separated with comma: ... (11 Replies)
Discussion started by: liuzhencc
11 Replies
return(1T)						       Tcl Built-In Commands							return(1T)

__________________________________________________________________________________________________________________________________________________

NAME
return - Return from a procedure SYNOPSIS
return ?-code code? ?-errorinfo info? ?-errorcode code? ?string? _________________________________________________________________ DESCRIPTION
Return immediately from the current procedure (or top-level command or source command), with string as the return value. If string is not specified then an empty string will be returned as result. EXCEPTIONAL RETURN CODES
In addition to the result of a procedure, the return code of a procedure may also be set by return through use of the -code option. In the usual case where the -code option isn't specified the procedure will return normally. However, the -code option may be used to generate an exceptional return from the procedure. Code may have any of the following values: ok (or 0) Normal return: same as if the option is omitted. The return code of the procedure is 0 (TCL_OK). error(1) Error return: the return code of the procedure is 1 (TCL_ERROR). The procedure command behaves in its calling context as if it were the command error result. See below for additional options. return(2) The return code of the procedure is 2 (TCL_RETURN). The procedure command behaves in its calling context as if it were the command return (with no arguments). break(3TCL) The return code of the procedure is 3 (TCL_BREAK). The procedure command behaves in its calling context as if it were the command break. continue(4) The return code of the procedure is 4 (TCL_CONTINUE). The procedure command behaves in its calling context as if it were the command continue. value Value must be an integer; it will be returned as the return code for the current procedure. The -code option is rarely used. It is provided so that procedures that implement new control structures can reflect exceptional condi- tions back to their callers. Two additional options, -errorinfo and -errorcode, may be used to provide additional information during error returns. These options are ignored unless code is error. The -errorinfo option specifies an initial stack trace for the errorInfo variable; if it is not specified then the stack trace left in errorInfo will include the call to the procedure and higher levels on the stack but it will not include any information about the context of the error within the procedure. Typically the info value is supplied from the value left in errorInfo after a catch command trapped an error within the procedure. If the -errorcode option is specified then code provides a value for the errorCode variable. If the option is not specified then errorCode will default to NONE. EXAMPLES
First, a simple example of using return to return from a procedure, interrupting the procedure body. proc printOneLine {} { puts "line 1" ;# This line will be printed. return puts "line 2" ;# This line will not be printed. } Next, an example of using return to set the value returned by the procedure. proc returnX {} {return X} puts [returnX] ;# prints "X" Next, a more complete example, using return -code error to report invalid arguments. proc factorial {n} { if {![string is integer $n] || ($n < 0)} { return -code error "expected non-negative integer, but got "$n"" } if {$n < 2} { return 1 } set m [expr {$n - 1}] set code [catch {factorial $m} factor] if {$code != 0} { return -code $code $factor } set product [expr {$n * $factor}] if {$product < 0} { return -code error "overflow computing factorial of $n" } return $product } Next, a procedure replacement for break. proc myBreak {} { return -code break } SEE ALSO
break(1T), catch(1T), continue(1T), error(1T), proc(1T), source(1T), tclvars(1T) KEYWORDS
break, catch, continue, error, procedure, return ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl 7.0 return(1T)
All times are GMT -4. The time now is 01:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy