Sponsored Content
Top Forums Shell Programming and Scripting The last argument contains spaces, how do I get it into a variable? Post 302566800 by Franklin52 on Friday 21st of October 2011 06:59:05 AM
Old 10-21-2011
Quote:
Originally Posted by zagga
Thanks very much Franklin52, your solution works fine while arguments 14 and 15 are populated. Unfortunately I omitted to mention that these fields are optional.
After testing: if Arg14 and Arg15 are null, then Arg15 contains the same value as Arg13.
If Arg15 only is null, the it recuperates the value of Arg14.
I figured I would add tests on each field to set to "NONE" if null, unless you have a better trick up your sleeve?

Regards

Zagga
Do you have 2 spaces (field separators) at the end of the line if the last 2 fields are empty?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing the command line argument in a variable

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

Strip leading and trailing spaces only in a shell variable with embedded spaces

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

problem with spaces and argument parsing

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

how to assign script argument to a variable

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

about an argument with variable in sed

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

Pass command line argument to variable

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

pass variable as sar argument

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

Variable passed as argument

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

Passing variable as an argument to another script

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

Check for spaces in input argument!

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
JOIN(1) 						      General Commands Manual							   JOIN(1)

NAME
join - relational database operator SYNOPSIS
join [ options ] file1 file2 DESCRIPTION
Join forms, on the standard output, a join of the two relations specified by the lines of file1 and file2. If one of the file names is the standard input is used. File1 and file2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined, normally the first in each line. There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con- sists of the common field, then the rest of the line from file1, then the rest of the line from file2. Input fields are normally separated spaces or tabs; output fields by space. In this case, multiple separators count as one, and leading separators are discarded. The following options are recognized, with POSIX syntax. -a n In addition to the normal output, produce a line for each unpairable line in file n, where n is 1 or 2. -v n Like -a, omitting output for paired lines. -e s Replace empty output fields by string s. -1 m -2 m Join on the mth field of file1 or file2. -jn m Archaic equivalent for -n m. -ofields Each output line comprises the designated fields. The comma-separated field designators are either 0, meaning the join field, or have the form n.m, where n is a file number and m is a field number. Archaic usage allows separate arguments for field designators. -tc Use character c as the only separator (tab character) on input and output. Every appearance of c in a line is significant. EXAMPLES
sort /etc/passwd | join -t: -1 1 -a 1 -e "" - bdays Add birthdays to the /etc/passwd file, leaving unknown birthdays empty. The layout of /adm/users is given in passwd(5); bdays con- tains sorted lines like tr : ' ' </etc/passwd | sort -k 3 3 >temp join -1 3 -2 3 -o 1.1,2.1 temp temp | awk '$1 < $2' Print all pairs of users with identical userids. SOURCE
/src/cmd/join.c SEE ALSO
sort(1), comm(1), awk(1) BUGS
With default field separation, the collating sequence is that of sort -b -ky,y; with -t, the sequence is that of sort -tx -ky,y. One of the files must be randomly accessible. JOIN(1)
All times are GMT -4. The time now is 07:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy