Sponsored Content
Top Forums Shell Programming and Scripting how to seperate a variable in 2 variables Post 302221070 by aigles on Sunday 3rd of August 2008 08:56:42 AM
Old 08-03-2008
Quote:
thanks alot for your quick response, but it is including ^M at the end and also entering a blank line.
If you get ^M and/or empty lines, the problem commes from your input datas and not from the read command.
You can modify your awk command to remove ¨M and empty lines :
Code:
for myvar1 in $(awk -F, 'NF {gsub(/\r/, ""); print $1,$5}' $Filename |tr "a-z" "A-Z" )

Another way :
Code:
awk -F, 'NF {gsub(/\r/, ""); print tolower($1),tolower($5)}' $Filename | \
while read var2 var3
do
   sqlplus -s test/test@test @gur.sql $DefaultProduct $var2 $var3
done >>getdata.tmp

Jean-Pierre.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract from string variable into new variables

I have a variable which consists of a string like this: 001 aaabc 44 a bbb12 How do I extract each substring, delimited by the spaces, into new variables - one for each substring? eg var1 will be 001, var2 will be aaabc, var3 will be 44, var4 will be a, etc? I've come up with this:... (2 Replies)
Discussion started by: Sniper Pixie
2 Replies

2. Shell Programming and Scripting

moving variables to another variable as a new avriable

Somehow I can't get it for this basic bash problem. maybe someone can help. What I try to do is: a="world" b="hello" how can I move this into $c so that I can replace "helloworld" with "world hello" in sed like: sed "s/\helloworld/ ${c}... I tried several combinations but all with... (4 Replies)
Discussion started by: lowmaster
4 Replies

3. Shell Programming and Scripting

assigning fields variables value to shell variable

suppose I have a file named abc.txt.The contents of the file is sited below abc.txt maitree,test,test3 Using awk command can I store these 3 values in 3 different variable and in one single line command of awk. suppose variable a b c is there. I don't want like this a=`awk -F"," '{print... (2 Replies)
Discussion started by: maitree
2 Replies

4. Shell Programming and Scripting

Combining multiple variables into new variable

Hello, I am a new joiner to the forum, and have what i hope is a simple question, however I can't seem to find the answer so maybe it is not available within bash scripting. I intend to use the below script to archive files from multiple directories at once by using a loop, and a variable (n)... (10 Replies)
Discussion started by: dring
10 Replies

5. Shell Programming and Scripting

Refering to compound variables with a variable name

Hello, Here is my problem using KSH I have a set of compound variables, let say cmp_var1 cmp_var2 The names of these variables are stored in an indexed array. How can I access the subfields of these compound variables ? I tried: set -A cmp_varnames=(cmp_var1 cmp_var2) for cmp in... (4 Replies)
Discussion started by: luky55
4 Replies

6. Shell Programming and Scripting

How to set a variable name from another variables value?

Experts, I want to set value of variables like this in bash shell: i=5 ; L=100 I want variable d5 (that is d(i) ) to be assign the value of $L , d$i=$L ; echo $d5 Not working Thanks., (3 Replies)
Discussion started by: rveri
3 Replies

7. Shell Programming and Scripting

Variable variables

Hello, Can you please help here? DAY=$1 MONTH_MONDAY_YEAR = 1 2 3 4 for i in ${MONTH_${DAY}_YEAR} do echo ${i} done ./test.sh MONDAY ./test.sh: line 3: MONTH_MONDAY_YEAR: command not found ./test.sh: line 10: ${MONTH_${DAY}_YEAR}: bad substitution (6 Replies)
Discussion started by: vino_hymi
6 Replies

8. Shell Programming and Scripting

Setting a variable using variables in a loop

Hi, I am having a bit of trouble with the below code: file=/path/to/file for i in 03 06 07 21; do if ; then eval count$i=`grep -c word $file-$i` fi done Totalcount=0 for i in 03 06 07 21; do if ; then echo $count$i variable not exist; else Tcount=`expr $Tcount + $count$i`; fi... (3 Replies)
Discussion started by: brunlea
3 Replies

9. Shell Programming and Scripting

Concatenate two variables and form the third variable

Hi Guys, I was scratching my head for this for half a day... finally not successful :confused: Following is the problem I have a variable $ var1=123 $ var2-234 $ var3=345 and another Variable $ i=1 Now i wanted to save these into a Variable as shown below for i in 1 2 3 do... (5 Replies)
Discussion started by: ramprabhum
5 Replies

10. UNIX for Beginners Questions & Answers

Expand Variables and Wildcards into another variable.

Dear Forum members, I am having trouble getting the complete filename (and directory path) in a variable. Output directory mentioned in the code have three files: DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_london.out DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_paris.out... (4 Replies)
Discussion started by: chetanojha
4 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 05:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy