The input was come from a api command's output and the format as follows:
and I want to have the output from awk -F'|' '{print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10}'` becomes:
then finally set the output from awk to the variable Table (for some reasons that I don't want to use file so that's why I keep using pipe and then put all result records into a variable)
Paul
Last edited by rbatte1; 05-26-2015 at 01:20 PM..
Reason: Added CODE tags for data
Hi All,
file_1.txt contains
aaa bbbb hhhh
vvvvv mmmmm iiiii
What i want is to search for the first coloumn of each line using awk.i.e as below:
awk '/aaa/ {printf(<>)}' file_1.txt
The print part (<>) should contain all the values(or coloumns ) in the particular line(here it... (8 Replies)
I want a user to be able to paste in a string like "01 3F 20 1F" and have the script reformat it to "013F201F" to pass it on to the next step.
I was trying to figure it out with awk but wasnt working well.
Never mind, found answer. did not know about tr :) (7 Replies)
Hello All,
I am trying to remove all tabspaces and all blankspaces from my file using sed & awk, but not getting proper code. Please help me out.
My file is like this (<b> means one blank space, <t> means one tab space)-
$ cat file
NARESH<b><b><b>KUMAR<t><t>PRADHAN... (3 Replies)
Hello all,
I want to list the file contents of the directory and number them. I am using la and awk to do it now,
#ls |awk '{print NR "." $1}'
1. alpha
2. beta
3. gamma
The problem I have is that some files might also have some spaces in the filenames.
#ls
alpha beta gamma ... (7 Replies)
How to print the strings within a line between two spaces .
<ns1:providerErrorCode>141</ns1:providerErrorCode> <ns1:providerErrorText>business_rule_exception-Server.404:Cannot proceed because the subscriber with phone number is either suspended or the account has an unpaid... (8 Replies)
When I use:
find . -ls | awk 'BEGIN { OFS = ";"} {print $1,$2,$11}'I get a nice result, yet the files with spaces in it show only the first word and all other characters after the blank space are not printed.
e.g. 'file with a blank space'
is printed
file
'file_with a blank space'
is... (7 Replies)
I have a one-line command,
lsusb | awk '{ $1=""; $2=""; $3=""; $4=""; $5=""; $6=""; print $0 }'
It works, and gives the results I expect, I was just wondering if I am missing some easier way to nullify the first 6 column variables?
Something like,
lsusb | awk '{ $(1-6)=""; print $0 }'
But... (10 Replies)
Hi,
I'm using awk to print columns from a tab delimited text file:
awk '{print " "$2" "$3" $6"}' file
The problem I have is column 6 contains text with spaces etc which means awk only prints the first word.
How can I tell awk to print the whole column content as column 6?
Thanks, (10 Replies)
Discussion started by: keenboy100
10 Replies
LEARN ABOUT MOJAVE
apply
apply(n) Tcl Built-In Commands apply(n)
__________________________________________________________________________________________________________________________________________________NAME
apply - Apply an anonymous function
SYNOPSIS
apply func ?arg1 arg2 ...?
_________________________________________________________________DESCRIPTION
The command apply applies the function func to the arguments arg1 arg2 ... and returns the result.
The function func is a two element list {args body} or a three element list {args body namespace} (as if the list command had been used).
The first element args specifies the formal arguments to func. The specification of the formal arguments args is shared with the proc com-
mand, and is described in detail in the corresponding manual page.
The contents of body are executed by the Tcl interpreter after the local variables corresponding to the formal arguments are given the val-
ues of the actual parameters arg1 arg2 .... When body is being executed, variable names normally refer to local variables, which are cre-
ated automatically when referenced and deleted when apply returns. One local variable is automatically created for each of the function's
arguments. Global variables can only be accessed by invoking the global command or the upvar command. Namespace variables can only be
accessed by invoking the variable command or the upvar command.
The invocation of apply adds a call frame to Tcl's evaluation stack (the stack of frames accessed via uplevel). The execution of body pro-
ceeds in this call frame, in the namespace given by namespace or in the global namespace if none was specified. If given, namespace is
interpreted relative to the global namespace even if its name does not start with "::".
The semantics of apply can also be described by:
proc apply {fun args} {
set len [llength $fun]
if {($len < 2) || ($len > 3)} {
error "can't interpret "$fun" as anonymous function"
}
lassign $fun argList body ns
set name ::$ns::[getGloballyUniqueName]
set body0 {
rename [lindex [info level 0] 0] {}
}
proc $name $argList ${body0}$body
set code [catch {uplevel 1 $name $args} res opt]
return -options $opt $res
}
EXAMPLES
This shows how to make a simple general command that applies a transformation to each element of a list.
proc map {lambda list} {
set result {}
foreach item $list {
lappend result [apply $lambda $item]
}
return $result
}
map {x {return [string length $x]:$x}} {a bb ccc dddd}
-> 1:a 2:bb 3:ccc 4:dddd
map {x {expr {$x**2 + 3*$x - 2}}} {-4 -3 -2 -1 0 1 2 3 4}
-> 2 -2 -4 -4 -2 2 8 16 26
The apply command is also useful for defining callbacks for use in the trace command:
set vbl "123abc"
trace add variable vbl write {apply {{v1 v2 op} {
upvar 1 $v1 v
puts "updated variable to "$v""
}}}
set vbl 123
set vbl abc
SEE ALSO
proc(n), uplevel(n)
KEYWORDS
argument, procedure, anonymous function
Tcl apply(n)