Sponsored Content
Full Discussion: combine variables in one
Top Forums Shell Programming and Scripting combine variables in one Post 302338732 by Lenora2009 on Tuesday 28th of July 2009 06:46:17 PM
Old 07-28-2009
combine variables in one

Within one of my scripts, I have variables extracted from parameters list and want to combine some of them in one (lpath). I tried using awk command..... How do I get it? Thank you.


Code:
 
#!/bin/bash
# ## Read paramlist.txt 
file='/name1/name2/paramlist.txt'
while read line
do
#
key= echo $line | awk -F\| '{ print $1 }'
host= echo $line | awk -F\| '{ print $2 }'
user= echo $line | awk -F\| '{ print $3 }'
ftppass= echo $line | awk -F\| '{ print $4 }'
lpath= echo $line | awk -F\| '{ print $5 $6 $7 $8 $9 }'
echo "$lpath"
fpath= echo $line | awk -F\| '{ print $10 $11 $12 $13 $14}'
email1= echo $line | awk -F\| '{ print $15 }'
email2= echo $line | awk -F\| '{ print $16 }'
 
file_ctr=`egrep -cv '#|^$' $lpath` 
echo "$file_ctr"
#
done </name1/name2/paramlist.txt


Here is the parameters file:

Code:
 
key1|IP1|user1|pass1|lpath1|lpath2|lpath3|lpath4|lpath5|lcount|rpath1|rpath2|rpath3|rpath4|rpath5|email1 |email2
key2|2IP2|user2|pass2|lpath1|lpath2|lpath3|lpath4|lpath5|lcount|rpath1|rpath2|rpath3|rpath4|rpath5|email1 |email2
Key3|2IP3|user3|pass3|lpath1|lpath2|lpath3|lpath4|lpath5|lcount|rpath1|rpath2|rpath3|rpath4|rpath5|email1 |email2

 

10 More Discussions You Might Find Interesting

1. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

2. Shell Programming and Scripting

awk : combine 3 variables into 1

Within one of my awk scripts, I have three variables extracted and calculated on. When done, I simply want to combine the three. The following works, but looks weird. My script reads a field that has text and numbers, knowing the last four comprise MMYY (month and year) # YY are last two... (2 Replies)
Discussion started by: joeyg
2 Replies

3. Shell Programming and Scripting

combine

Hi I am having text file like this 001|ramu|hno221|>< sheshadripuram|delhi|560061>< 002|krishna|hno225|>< newdelhimain|delhi|560061>< i want to combine every two lines as single...line... i.e 001|ramu|hno221|sheshadripuram|delhi|560061 can u pls help me (3 Replies)
Discussion started by: suryanarayana
3 Replies

4. Shell Programming and Scripting

combine

Dear all i am having text file like xxx|yyy|1|2| zzz|rrr|3|4| www|xxx|>< 5|6|>< jjj|kkk|>< 8|9>< i want to join two lines which are having ' >< ' by taking only two lines at a stretch ...using awk command the result output should be xxx|yyy|1|2| zzz|rrr|3|4| www|xxx|5|6|... (2 Replies)
Discussion started by: suryanarayana
2 Replies

5. Shell Programming and Scripting

guide needed to combine 2 variables

readNOW=$(date +"%Y%m%d%H%M") read readTerminal #input B terminalc=$readTerminal echo eqpt_list_QC_$terminalcT_$readNOW how to get display result it: eqpt_list_QC_BT_201209121530 (2 Replies)
Discussion started by: ment0smintz
2 Replies

6. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

7. Shell Programming and Scripting

BASH arrays and variables of variables in C++

Sometimes it is handy to protect long scripts in C++. The following syntax works fine for simple commands: #define SHELLSCRIPT1 "\ #/bin/bash \n\ echo \"hello\" \n\ " int main () { cout <<system(SHELLSCRIPT1); return 0; } Unfortunately for there are problems for: 1d arrays:... (10 Replies)
Discussion started by: frad
10 Replies

8. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

9. UNIX for Dummies Questions & Answers

Combine two lists of variables

Thanks in advance for any advice and help. I have two lists of variables that I want to put into nested for loops. for x in 1 2 3 do for y in a b c do The output I want is: filepath/1/ command modified by a filepath/2/ command modified by b filepath/3/ command modified by c To... (10 Replies)
Discussion started by: wheyhamp
10 Replies

10. UNIX for Dummies Questions & Answers

How to pass variables into anothother variables?

Below are three variables, which I want to pass into variable RESULT1 username1=userid poihostname1=dellsys.com port1=8080 How can I pass these variables into below code... RESULT1=$((ssh -n username1@poihostname1 time /usr/sfw/bin/wget --user=sam --password=123 -O /dev/null -q... (4 Replies)
Discussion started by: manohar2013
4 Replies
DH-EXEC-SUBST(1)						      dh-exec							  DH-EXEC-SUBST(1)

NAME
dh-exec-subst - Debhelper executable file substition scripts SYNOPSIS
#! /usr/bin/dh-exec src/libfoo-*.so.* debian/foo-plugins/usr/lib/foo/${DEB_HOST_MULTIARCH}/ DESCRIPTION
Being a sub-command of dh-exec(1), this program must not be ran directly, but through dh-exec, which automatically runs all available sub-commands if run bare; or explicitly with dh-exec --with=subst. It is a wrapper around the various other substitution helpers, and will pipe the input file through all the available substitution helpers. It is up to these scripts to do the actual work. When a helper fails to expand a variable within its input, it will leave it as-is, so that later in the pipeline it can perhaps be expanded by another program. SCRIPTS
dh-exec-subst-env Substitutes any of the available, exported environment variables into its input. It does not do any kind of filtering: whatever is available in the environment, will be available for substitution, however unsafe that may be. dh-exec-subst-multiarch Attempts to expand any of the variables known to dpkg-architecture(1), mostly useful for multi-arch support. The command will query dpkg-architecture(1) directly, and does not rely on environment variables set (as the called program will prefer already set environment variables anyway). ENVIRONMENT
DH_EXEC_SCRIPTDIR Indicates which directory the command-specific scripts should be sought for. If not specified, scripts will be searched for in /usr/share/dh-exec/. FILES
$DH_EXEC_SCRIPTDIR/dh-exec-subst-* The various scripts for the higher-level program. SEE ALSO
debhelper(1), dh-exec(1) AUTHOR
dh-exec-subst is copyright (C) 2011-2012 by Gergely Nagy <algernon@madhouse-project.org>. 2012-05-03 DH-EXEC-SUBST(1)
All times are GMT -4. The time now is 06:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy