Sponsored Content
Top Forums Shell Programming and Scripting To read specific line from a file Post 302778257 by saurau on Sunday 10th of March 2013 08:13:58 AM
Old 03-10-2013
To read specific line from a file

Hi,

I have a ldif file like below:
Code:
version: 1

dn: cn=Test Group,ou=Applications,dc=xyz,dc=com
objectClass: groupOfUniqueNames
objectClass: top
cn: Test Group
uniqueMember: uid=abc,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com

dn: cn=Test Sub Group,cn=Test Group,ou=Applications,dc=xyz,dc=com
objectClass: groupOfUniqueNames
objectClass: top
cn: Test Sub Group
uniqueMember: uid=def,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com
uniqueMember: uid=fgh,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com


I need to output from above file as :
Code:
uid=abc,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com
uid=def,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com
uid=fgh,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com

Please help.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A script that read specific fileds from the 7th line in a file

Dear All, I need a unix script that will read the 7th line and especially these fileds from a file Mo speed 16, Mt speed 15 every 15 minutes starting from 00:00 to 23:45 on daily basis and put the result in a txt file and name it MT_MO_20090225.txt, please also note that the system date format... (2 Replies)
Discussion started by: samura
2 Replies

2. Shell Programming and Scripting

How to read the value from a specific line and column BASH

Hi All, I have the same problem as the one posted in https://www.unix.com/shell-programming-scripting/96097-how-read-value-specific-line-column-csh-variable.html but I'm using bash. Can anyone tell me how I have to modify the code to make it bash compatible? eval `awk 'NR==3{print "set... (5 Replies)
Discussion started by: f_o_555
5 Replies

3. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

4. Shell Programming and Scripting

Using awk to read a specific line and a specific field on that line.

Say the input was as follows: Brat 20 x 1000 32rf Pour 15 p 1621 05pr Dart 10 z 1111 22xx My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour" I currently have this line but it is... (6 Replies)
Discussion started by: Bungkai
6 Replies

5. Shell Programming and Scripting

How to read from specific line number in shell script?

I have a text file which is having 30000 lines in it. I have to create a xml file for each 10000 lines until all the lines in the text files are written. Also please help how can i get number of lines in the text file in a shell variable? (19 Replies)
Discussion started by: vel4ever
19 Replies

6. Shell Programming and Scripting

how read specific line in a file and write it in a new text file?

I have list of files in a directory 'dir'. Each file is of type HTML. I need to read each file and get the string which starts with 'http' and write them in a new text file. How can i do this shell scripting? file1.html <head> <url>http://www.google.com</url> </head> file2.html <head>... (6 Replies)
Discussion started by: vel4ever
6 Replies

7. Shell Programming and Scripting

Read file from nth line to specific character

Hi, I want to read the file from nth line (where n is an integer) to until I encounter @ char. Can any one please help me how to do this? Thanks. (3 Replies)
Discussion started by: laalesh
3 Replies

8. Shell Programming and Scripting

How to read particular line in file from specific column?

Hi...friends.... I want to create inventory...information for that I need to read some specific row say 2nd row from 1st 3 column and and write data with particular file used, I have some more column also but I need only 3 column data of first entry after header I attached sample file..those... (12 Replies)
Discussion started by: nex_asp
12 Replies

9. Shell Programming and Scripting

Read command stop on either EOF or a specific line

I'm trying to stop reading a file until the end of the file is reached or a defined delimiter line is reached. Some how I need to test the fail state of the last 2 commands, not just the last command. echo -e "hello\ngoodbye\n####\ntesting" | while read line; ]; do echo "$line"; done hello... (4 Replies)
Discussion started by: Michael Stora
4 Replies

10. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies
kvar(8) 						      System Manager's Manual							   kvar(8)

Name
       kvar - modify RISC kernel variables in memory or on disk

Syntax
       /usr/etc/kvar -r(b|w|l) [options] vmunix
       /usr/etc/kvar -w(b|w|l) [options] vmunix

Description
       The  command  allows you to read or write RISC kernel variables, either in the on-disk image of or the active in-memory image.  The -r form
       of the command does variable reads; the -w form does variable writes.  The variable length qualifiers are:  b  (1  byte),  w  (word,  or  2
       bytes), and l (longword, or 4 bytes).

       Variable contents are displayed in hexadecimal format.

Options
       -a address  Specifies  the  address  of	the  kernel  variable.	Either the -a or -s option must be specified.  The address is specified as
		   either a positive decimal or hexadecimal constant.

       -k	   Instructs to use the in-memory image of The default is to use the on-disk copy.

       -l	   Searches for a local symbol. The default is a global symbol search.

       -o offset   Adds an offset to the address (or address of the symbol name).  The offset value is specified as either a positive  decimal	or
		   hexadecimal constant.

       -s name	   Specifies the name of the kernel variable.

       -v value    Specifies  the  new value to be assigned by the -w form of The -v option is ignored if the -r form of is being used.  The value
		   is specified as either a positive decimal or hexadecimal constant.

Restrictions
       You must have appropriate file access permissions for (and for with the -k option).

       The command is available only on RISC systems.  For VAX systems, use to modify kernel variables.

Examples
       This example reads the variable `udpcksum' from the running kernel image:

	    % kvar -k -rl -s udpcksum /vmunix

       This example sets the `xyz' variable to zero in the running kernel image:

	      % kvar -k -wl -s xyz -v 0 /vmunix

       This example sets the variable `xyz' to -1 in the on-disk image of making this value persistent across reboots:

	      % kvar -wl -s xyz -v 0xffffffff /vmunix

       This example sets to zero 1 byte at offset 2 from address 0x80161a98 in the running kernel image:

	      % kvar -k -wb -o 2 -a 0x80161a98 /vmunix

Files
See Also
       adb(1), dbx(1)

								       RISC								   kvar(8)
All times are GMT -4. The time now is 10:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy