How to read a delimited string and assign fields to incremented variables?
How can I read a string delimited on spaces and assign the fields to incremented variables.
For example:
Given $exts= txt dat mov
I want to read in $exts and have "txt" "dat" and "mov" assigned to incremented variables like $ext1, $ext2, etc. I would like to do this in a loop so that I can read in any any given number of extensions.
I have tried the following:
But this does not work. Any suggestions on how to achieve the desire outcome?
Thanks.
Last edited by Franklin52; 07-14-2011 at 05:07 PM..
Reason: Please use code tags for data and code samples, thank you
Is anyone able to help with writing a program that will do the following:
1. Read the contents of a file, line by line, and on each line, assign each of the two columns to a shell variable.
2. perform an action on the variables
3. Read the next line.
Here is what I've gotten so far. ... (3 Replies)
Hello,
I have a cat.dat file, i would like shell to read each 3 lines and set this 3 lines to 3 different variables.
my cat.dat is:
11
12
+380486461001
12
13
+380486461002
13
14
+380486461003
i want shell to make a loop and assign 1st line to student_id, 2nd line to... (4 Replies)
Man it has been too long since I have had to do this type of stuff...
OK I have a file with lines in it looking like this:
bob:johnson:email@email.com (most lines)
john:F.:doe:email2@email.com (but some are like this)
I need to loop through and assign vars to the values:
var Fname =... (29 Replies)
Hi,
I need a simple csh script to read a file containing data like this
Buy Transactions : 175
Sell Transactions : 212
Server: sepo2
i want to read both field and its value and assign variables to each.. (2 Replies)
Hi,
I have requirement to assign values to variables which are created dynamically.
Below is the code which i am using to achieve above requirement.
#!/bin/ksh
oIFS="$IFS"; IFS=','
STR_FAIL_PARENT_IF_FAILS="WF_F_P_IF_FAILS1,WF_F_P_IF_FAILS2,WF_F_P_IF_FAILS3"
set -A... (1 Reply)
For eg: I have sample.txt file with 4 rows of record like:
user1|password1
user2|password2
user3|password3
user4|password4
The username and password is sepsrated by '|'
I want to get the 1st row value from the file and assign it to two different variables(username and password)
in my... (1 Reply)
I am trying to read a input file which has two columns separated by space
Input file
server1 server2
server3 server4
server5 server6
When i execute the below while code it reads line by line and a and b variables are able to successfully fetch the values
while read a b
do
echo "$a"
echo... (5 Replies)
Hi guys,
New to the forum, and been messing around with Linux for about a year now. I'm still very much a rookie, so just assume that I'm a total idiot:
I currently have a shell that spits out a CSV number string of about 8 numbers as follows:
1.00,2.00,3.00 ... ,8.00I need to assign a... (7 Replies)
Hello
Just edited the entry to make it easier to understand what i want
How can i achieve this: GOAL:
read 2 field from a table with PSQL
result of this PSQL command is this
INSTALLEDLANG=$(su - postgres -c "psql -A -t -q -c -d ${DBNAME} -t -c 'SELECT code, iso_code from res_lang'")
... (0 Replies)
Hej guys,
I am trying to read a csv file line by line, save it's fields as variables per line so I can use them as parameters and execute stuff.
I am new to shell scripting and was just strictly following a tutorial. Somehow my version seems to ignore the loop. Any help?
TY! :)
#!/bin/bash... (12 Replies)
Discussion started by: Splinter479
12 Replies
LEARN ABOUT LINUX
ldap_is_ldap_url
LDAP_URL(3) Library Functions Manual LDAP_URL(3)NAME
ldap_is_ldap_url, ldap_url_parse, ldap_free_urldesc - LDAP Uniform Resource Locator routines
LIBRARY
OpenLDAP LDAP (libldap, -lldap)
SYNOPSIS
#include <ldap.h>
int ldap_is_ldap_url( const char *url )
int ldap_url_parse( const char *url, LDAPURLDesc **ludpp )
typedef struct ldap_url_desc {
char * lud_scheme; /* URI scheme */
char * lud_host; /* LDAP host to contact */
int lud_port; /* port on host */
char * lud_dn; /* base for search */
char ** lud_attrs; /* list of attributes */
int lud_scope; /* a LDAP_SCOPE_... value */
char * lud_filter; /* LDAP search filter */
char ** lud_exts; /* LDAP extensions */
int lud_crit_exts; /* true if any extension is critical */
/* may contain additional fields for internal use */
} LDAPURLDesc;
void ldap_free_urldesc( LDAPURLDesc *ludp );
DESCRIPTION
These routines support the use of LDAP URLs (Uniform Resource Locators) as detailed in RFC 4516. LDAP URLs look like this:
ldap://hostport/dn[?attrs[?scope[?filter[?exts]]]]
where:
hostport is a host name with an optional ":portnumber"
dn is the search base
attrs is a comma separated list of attributes to request
scope is one of these three strings:
base one sub (default=base)
filter is filter
exts are recognized set of LDAP and/or API extensions.
Example:
ldap://ldap.example.net/dc=example,dc=net?cn,sn?sub?(cn=*)
URLs that are wrapped in angle-brackets and/or preceded by "URL:" are also tolerated. Alternative LDAP schemes such as ldaps:// and
ldapi:// may be parsed using the below routines as well.
ldap_is_ldap_url() returns a non-zero value if url looks like an LDAP URL (as opposed to some other kind of URL). It can be used as a
quick check for an LDAP URL; the ldap_url_parse() routine should be used if a more thorough check is needed.
ldap_url_parse() breaks down an LDAP URL passed in url into its component pieces. If successful, zero is returned, an LDAP URL description
is allocated, filled in, and ludpp is set to point to it. If an error occurs, a non-zero URL error code is returned.
ldap_free_urldesc() should be called to free an LDAP URL description that was obtained from a call to ldap_url_parse().
SEE ALSO ldap(3)
RFC 4516 <http://www.rfc-editor.org/rfc/rfc4516.txt>
ACKNOWLEDGEMENTS
OpenLDAP Software is developed and maintained by The OpenLDAP Project <http://www.openldap.org/>. OpenLDAP Software is derived from Uni-
versity of Michigan LDAP 3.3 Release.
OpenLDAP 2.4.25 2011/03/26 LDAP_URL(3)