11-06-2008
merge files with: for i in `cat myname.txt`
cat myname.txt
John Doe I
John Doe II
John Doe III
-----------------------------------------------------------------------
for i in `cat myname.txt`
do
echo This is my name: $i >> thi.is.my.name.txt
done
-----------------------------------------------------------------------
cat thi.is.my.name.txt
This is my name: John Doe I
This is my name: John Doe II
This is my name: John Doe III
-----------------------------------------------------------------------
cat yourname.txt
Mark A
Mark B
Mark C
-----------------------------------------------------------------------
for i in `cat myname.txt` && for y in `cat yourname.txt`
do
echo This is my name: $i and this is your name: $y >> me.and.you.txt
done
-----------------------------------------------------------------------
The result should be:
cat me.and.you.txt
This is my name: John Doe I and this is your name: Mark A
This is my name: John Doe II and this is your name: Mark B
This is my name: John Doe III and this is your name: Mark C
I don't figure it out how to use "for i in" and "for y in" at the same time to read both files myname.txt and yourname.txt in the same line to put them together in one single line.
I'm a newbie but i don't want to prompt for homework problems, i would appreciate any help, even a description would be helpful, thanks.
9 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Greetings --
I'm curious as to an effective way for a user (not root) to set-up a supplemental rgb.txt file for personal use on an X11 system. It's easy
to set up the rgb.txt file (with only new colors) in my directory, but
how can I use it in addition to the standard rgb.txt file.
Thanks.... (0 Replies)
Discussion started by: slapshot_paulie
0 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I have a .txt file
Sample:
=====================
NEXT HOST
=====================
AEADBAS001
ip access-list extended BLA_Incoming_Filter
ip access-list extended BLA_Outgoing_Filter
access-list 1 permit xxxxxxxxxxxxxx
access-list 2 permit xxxxxxxxxxxxxx
=====================... (4 Replies)
Discussion started by: I-1
4 Replies
3. Shell Programming and Scripting
The file country.txt contains
$ cat country.txt
|ORG MU|
|ORG OM|
WHen in script, I wrote this
for i in `cat $TEMP_DIR/country.txt`
It doesnot read the country file first line followed by next line
Instaed it reads as |ORG in first loop and then reads MU| in next loop
I want the for... (1 Reply)
Discussion started by: sureshg_sampat
1 Replies
4. Shell Programming and Scripting
Hi there,
Can show some hit why i got this error?
For eg i have a.txt in which consist of contents as below
1|781494-0015|IV\|I||C|RECHARGE|Success\|V\|\||2007-12-04 02:33:13.000|
2|762405-0405|IV\|I||C|RECHARGE|Success\|V\|\||2007-12-04 02:33:17.000|
In fact , i want to perfrom to have... (2 Replies)
Discussion started by: rauphelhunter
2 Replies
5. Shell Programming and Scripting
I have a file with a single filename in it, which I want to assign to a BASH variable, so I've been trying:
c=$(head -1 somefile)
echo $c
which outputs correctly, but them when I do
...
somecommand $c
it says it can't find the file, is that because it's grabbing the whole line, and... (5 Replies)
Discussion started by: unclecameron
5 Replies
6. Shell Programming and Scripting
cat & telnet
hello,
I need some help on using a file with the cat command. I want to set up a telnet connection with a network device with the ip-adress 10.3.0.1. Just executing the command 'telnet 10.3.0.1' gives a menu. For example, to show the help of the menu, you... (2 Replies)
Discussion started by: michealvh
2 Replies
7. UNIX for Dummies Questions & Answers
I am trying to find all the files listed in a filelist.txt.
Why cant I use something like this
cat filelist.txt | xargs -n1 find $path (2 Replies)
Discussion started by: dragonpoint
2 Replies
8. Shell Programming and Scripting
Hi,
I am not being able to open txt files with 'cat'. One thing to mention is, the filenames start with #. I guess one can have a unix filename that starts with a special/wildcard character. I have filenames starting with @ and they are opening perfectly with cat. (5 Replies)
Discussion started by: Subhasis
5 Replies
9. UNIX for Dummies Questions & Answers
Team,
we use below command to store the contents in a logfile.
cat a.txt > a.log
a.txt content is
123
345
Is there any options available to store the command used also?
for eg a.log may show as
cat a.txt
123
345 (5 Replies)
Discussion started by: sid2013
5 Replies
LEARN ABOUT PHP
ldap_control_paged_result
LDAP_CONTROL_PAGED_RESULT(3) 1 LDAP_CONTROL_PAGED_RESULT(3)
ldap_control_paged_result - Send LDAP pagination control
SYNOPSIS
bool ldap_control_paged_result (resource $link, int $pagesize, [bool $iscritical = false], [string $cookie = ""])
DESCRIPTION
Enable LDAP pagination by sending the pagination control (page size, cookie...).
PARAMETERS
o $link
- An LDAP link identifier, returned by ldap_connect(3).
o $pagesize
- The number of entries by page.
o $iscritical
- Indicates whether the pagination is critical of not. If true and if the server doesn't support pagination, the search will
return no result.
o $cookie
- An opaque structure sent by the server (ldap_control_paged_result_response(3)).
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
The example below show the retrieval of the first page of a search paginated with one entry by page.
Example #1
LDAP pagination
<?php
// $ds is a valid link identifier (see ldap_connect)
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$dn = 'ou=example,dc=org';
$filter = '(|(sn=Doe*)(givenname=John*))';
$justthese = array('ou', 'sn', 'givenname', 'mail');
// enable pagination with a page size of 1.
ldap_control_paged_result($ds, 1);
$sr = ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
echo $info['count'] . ' entries returned' . PHP_EOL;
The example below show the retrieval of all the result paginated with 100 entries by page.
Example #2
LDAP pagination
<?php
// $ds is a valid link identifier (see ldap_connect)
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$dn = 'ou=example,dc=org';
$filter = '(|(sn=Doe*)(givenname=John*))';
$justthese = array('ou', 'sn', 'givenname', 'mail');
// enable pagination with a page size of 100.
$pageSize = 100;
$cookie = '';
do {
ldap_control_paged_result($ds, $pageSize, true, $cookie);
$result = ldap_search($ds, $dn, $filter, $justthese);
$entries = ldap_get_entries($ds, $result);
foreach ($entries as $e) {
echo $e['dn'] . PHP_EOL;
}
ldap_control_paged_result_response($ds, $result, $cookie);
} while($cookie !== null && $cookie != '');
NOTES
Note
Pagination control is a LDAPv3 protocol feature.
SEE ALSO
ldap_control_paged_result_response(3), RFC2696 : LDAP Control Extension for Simple Paged Results Manipulation.
PHP Documentation Group LDAP_CONTROL_PAGED_RESULT(3)