10-21-2011
NO in fact I have 56 spaces at the end of the record. But the good news is the last two fields are fixed length which is not the case of all the preceding fields. Arg14= 4 cars Arg15=50 cars + 2 FS=56.
So I need to get from the end of $Arg13 to the EoL into a new variable and then I should be able to cut Arg14 and 15 from their positions.
Can you do a cut backwards from the end of line?
Any ideas welcome?
Zagga
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am new to unix. Is their a way to pass the output of the line below to a variable var1.
ls -1t | head -1.
I am trying something like var1=ls -1t | head -1, but I get error.
Situation is: I get file everyday through FTP in my unix box. I have to write a script that picks up first... (1 Reply)
Discussion started by: rkumar28
1 Replies
2. Shell Programming and Scripting
I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help.
echo $SH_VAR | command_line Syntax.
The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies
3. Shell Programming and Scripting
public class HelloWorld {
public static void main(String args) {
System.out.println("Welcome, master");
}
}
and I compiled using
javac HelloWorld.java
]
Suppose that I execute the following command directly from the shell:
java -XX:OnError="gdb - %p" HelloWorld
Then it works... (8 Replies)
Discussion started by: fabulous2
8 Replies
4. Shell Programming and Scripting
I have a script file. test.sh
I am running it by command
sh test.sh 10102004
where 10102004 is the script argument.
I wan to assign this 10102004 to a variable.
How can i do this?
I tried &1 and awks ARGV its not working :( (2 Replies)
Discussion started by: rohankit
2 Replies
5. Shell Programming and Scripting
hi all
let say I run the ./xxx.bash x x x x or ./xxx.bash x x x or ./xxx.bash x x x x x
the last argument always a filename
the last arugment filename format is 5-10-22.txt
my question is how can I put this arugment into variable and I can use it in sed or any other way that i can use
I... (1 Reply)
Discussion started by: yuesko
1 Replies
6. Shell Programming and Scripting
Hi,
I had written a shell script to pass command line argument to variable in a function.
Here is my code:
main
if ; then
.$1
echo $1
get_input_file
else
echo "input file $1 is not available"
fi
get_input_file()
{
FILE = "$1"
echo $FILE
} (10 Replies)
Discussion started by: Poonamol
10 Replies
7. Shell Programming and Scripting
I am trying to get the details of iowait for last hour using sar. When I give date as argument it works.
# sar -u -s 22:24:00 -e 23:24:00
Linux 2.6.35.13-26 (XX.server.com) 04/11/2012
10:30:03 PM CPU %user %nice %system %iowait %idle
10:40:04 PM all 5.03 ... (2 Replies)
Discussion started by: anil510
2 Replies
8. Shell Programming and Scripting
I have a script.
#!/bin/sh
cur_$1_modify_time=Hello
echo "cur_$1_modify_time"
When I run like
sh /root/script1 jj
I expect value "Hello" being assigned to variable "cur_jj_modify_time" and output being "Hello" ie echoing $cur_jj_modify_time
But the output comes as
# sh... (3 Replies)
Discussion started by: anil510
3 Replies
9. Shell Programming and Scripting
Hi,
I am trying to pass a variable as an argument to another script. While substitution of variable, I am facing a problem.
varaiable "a" value should be -b "FPT MAIN".
When we pass "a" to another script, we are expecing it to get substitue as ./test.sh -b "FPT MAIN". But, it is getting... (9 Replies)
Discussion started by: Manasa Pradeep
9 Replies
10. Shell Programming and Scripting
Hi guys,
I have created a csh script which allows user to pass input argument with the script like:
cluster_on_lev3.csh -t <value> -p <value>
Example:
cluster_on_lev3.csh -t 2.3 -p 0.05
Now I want to create an error code where if user passes input argument without spaces , the code... (16 Replies)
Discussion started by: dixits
16 Replies
proc(n) Tcl Built-In Commands proc(n)
__________________________________________________________________________________________________________________________________________________
NAME
proc - Create a Tcl procedure
SYNOPSIS
proc name args body
_________________________________________________________________
DESCRIPTION
The proc command creates a new Tcl procedure named name, replacing any existing command or procedure there may have been by that name.
Whenever the new command is invoked, the contents of body will be executed by the Tcl interpreter. Normally, name is unqualified (does not
include the names of any containing namespaces), and the new procedure is created in the current namespace. If name includes any namespace
qualifiers, the procedure is created in the specified namespace. Args specifies the formal arguments to the procedure. It consists of a
list, possibly empty, each of whose elements specifies one argument. Each argument specifier is also a list with either one or two fields.
If there is only a single field in the specifier then it is the name of the argument; if there are two fields, then the first is the argu-
ment name and the second is its default value. Arguments with default values that are followed by non-defaulted arguments become required
arguments. In 8.6 this will be considered an error.
When name is invoked a local variable will be created for each of the formal arguments to the procedure; its value will be the value of
corresponding argument in the invoking command or the argument's default value. Actual arguments are assigned to formal arguments strictly
in order. Arguments with default values need not be specified in a procedure invocation. However, there must be enough actual arguments
for all the formal arguments that do not have defaults, and there must not be any extra actual arguments. Arguments with default values
that are followed by non-defaulted arguments become required arguments (in 8.6 it will be considered an error). There is one special case
to permit procedures with variable numbers of arguments. If the last formal argument has the name args, then a call to the procedure may
contain more actual arguments than the procedure has formals. In this case, all of the actual arguments starting at the one that would be
assigned to args are combined into a list (as if the list command had been used); this combined value is assigned to the local variable
args.
When body is being executed, variable names normally refer to local variables, which are created automatically when referenced and deleted
when the procedure returns. One local variable is automatically created for each of the procedure's arguments. Other variables can only
be accessed by invoking one of the global, variable, upvar or namespace upvar commands.
The proc command returns an empty string. When a procedure is invoked, the procedure's return value is the value specified in a return
command. If the procedure does not execute an explicit return, then its return value is the value of the last command executed in the pro-
cedure's body. If an error occurs while executing the procedure body, then the procedure-as-a-whole will return that same error.
EXAMPLES
This is a procedure that accepts arbitrarily many arguments and prints them out, one by one.
proc printArguments args {
foreach arg $args {
puts $arg
}
}
This procedure is a bit like the incr command, except it multiplies the contents of the named variable by the value, which defaults to 2:
proc mult {varName {multiplier 2}} {
upvar 1 $varName var
set var [expr {$var * $multiplier}]
}
SEE ALSO
info(n), unknown(n)
KEYWORDS
argument, procedure
Tcl proc(n)