Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Search for a string,delete the line and replace with new string in a file Post 302956246 by sea on Monday 28th of September 2015 10:55:00 AM
Old 09-28-2015
Quote:
Originally Posted by sea
Hi Pradhikshan

Any attempts from your side yet?
<...>
Thank you
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how can search a String in one text file and replace the whole line in another file

i am very new to UNIX plz help me in this scenario i have two text files as below file1.txt name=Rajakumar. Discipline=Electronics and communication. Designation=software Engineer. file2.txt name=Kannan. Discipline=Mechanical. Designation=CADD Design Engineer. ... (6 Replies)
Discussion started by: kkraja
6 Replies

2. Shell Programming and Scripting

search string and delete the line

Hi All, I have a file from Mainframe which has one of the lines with so many words... i tried to fold, format to 80 chararcter.. stil did not work. So i have decided to search for a string in that line Ex.FLIGHT PLAN and once if it is found i want to delete the entire line. Please help... (2 Replies)
Discussion started by: digitalrg
2 Replies

3. Shell Programming and Scripting

search string in a file and retrieve 10 lines including string line

Hi Guys, I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same. can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies

4. UNIX for Dummies Questions & Answers

Search a string in the file and then replace another string after that position

Hi I am looking for a particular string in a file.If the string exists, then I want to replace another string with some other text.Once replaced, search for the same text after that character position in the file. :wall: E.g: Actual File content: Hello Name: Nitin Raj Welcome to Unix... (4 Replies)
Discussion started by: dashing201
4 Replies

5. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

6. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

7. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

8. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

9. UNIX for Beginners Questions & Answers

Need help with how to search a file for a variable string and delete that line

Hi, I have a working script. It does what I am intending it to but a bit confused whether the sed part is supposed to be working or not. Further down is the script with the sed part that should have been working but not and the grep -v part which is the workaround that I am using at the... (10 Replies)
Discussion started by: newbie_01
10 Replies

10. UNIX for Beginners Questions & Answers

Search partial string in a file and replace the string - UNIX

I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this. string(Scenario 1)- user::r--,user::ourfrd:r-- String(Scenario 2)- user::r-- File **** # file: /local/Desktop/myfile # owner: me # group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies
dseditgroup(8)						    BSD System Manager's Manual 					    dseditgroup(8)

NAME
dseditgroup -- group record manipulation tool. SYNOPSIS
dseditgroup [options] [parameters] groupname options: -o operation perform (read, create, delete, edit, checkmember) operation with given groupname -p prompt for authentication password -q disables interactive verification -v verbose logging to stdout parameters: -m member username to use for checkmember option -n nodename directory node location of group record -u username authenticate with admin username -P password authentication password -a recordname name of the record to add -d recordname name of the record to delete -t recordtype type of the record to add or delete -T grouptype type of group to create or modify -L maintain ComputerLists in parallel with ComputerGroups -i gid gid to add/replace -g guid GUID to add/replace -S sid SID to add/replace -r realname realname to add/replace -k keyword keyword to add -c comment comment to add/replace -s timetolive seconds to live to add/replace -f n | l change the group's format - 'n' for the new group format and 'l' for the legacy group format DESCRIPTION
dseditgroup allows manipulation of a single named group record on either the default local node or the specified DirectoryService node. For the "read" operation the authentication search policy (/Search node) is consulted. Default behaviour is presented below after a discussion of each operation and the possible parameters. Options and their descriptions: -o operation If "read" then the parameters of the specified groupname will be displayed. This is the default option. The authentication search policy (/Search node) will be used. If "create" then create a group with the specified groupname on either the default local node or the specified DirectoryService node. If "delete" then delete a group with the specified groupname on either the default local node or the specified DirectoryService node. If "edit" then edit a group with the specified groupname on either the default local node or the specified DirectoryService node. If "checkmember" then check if the user specified with -m or current logged in user is a member of the specified groupname. The authentication search policy (/Search node) is used to find the member. The specified node (defaults to the authentication search policy) is used to find the group. If the specified node is not on the authentication search policy the behaviour is undefined. -p You will be prompted for a password to use in conjunction with the specified username. -q This disables interactive verification of replace or delete operations. -v This enables the logging of the DirectoryService API calls and their return codes. Parameters and their descriptions: -m member The username of the account to verify group membership when using -o checkmember -n nodename Directory Service node name such as /LDAPv3/ldap.company.com and whose default value is the local node. "." can also be used to specify the local node. -u username Username of a user that has administrative privileges on this computer. -P password Password to use in conjunction with the specified username. If this is not specified, you will be prompted for a password. -a recordname The name of the record to be added to the group specified by groupname. This name is related to the first record found on the authentication search policy when a search is made with this recordname and the given recordtype. -d recordname The name of the record to be deleted from the group specified by groupname. This name is related to the first record found on the authentication search policy when a search is made with this recordname and the given recordtype. -t recordtype The type of the record to be added to or deleted from the group specified by groupname. Valid values are user, computer, group, or computergroup. -T grouptype The type of the group record to be created or modified as specified by groupname. Valid values are group or computergroup. -L If used with computergroup will also maintain the computerlist if it exists or create it if a computergroup is created. -i gid This is a group id. This will be automatically created if not specified for a create. -g guid This is a text representation of an 128 bit id. This will be automatically created if not specified for a create. -r realname This is a simple text string. -k keyword This is a simple text string. -c comment This is a simple text string. -s timetolive The number of seconds that this record is deemed valid as a cached value. There will be no automatically created default value if not specified for a create. DEFAULT BEHAVIOUR
dseditgroup mygroup This simple version of the command will default to: dseditgroup -o read -n . -u $USER mygroup The output will be the parameters of the "mygroup" group record if the shell user has read access to the local node's group record of name "mygroup". EXAMPLES
dseditgroup extragroup dseditgroup -o read extragroup The attributes of the group extragroup from the local node are displayed. dseditgroup -o create -n /LDAPv3/ldap.company.com -u myusername -P mypassword -r "Extra Group" -c "a nice comment" -s 3600 -k "some keyword" extragroup The group extragroup is created from the node /LDAPv3/ldap.company.com with the realname, comment, timetolive (instead of default of 14400 = 4 hours), and keyword atttribute values given above if the user myusername has supplied a correct password and has write access. dseditgroup -o delete -n /LDAPv3/ldap.company.com -u myusername -P mypassword extragroup The group extragroup is deleted from the node /LDAPv3/ldap.company.com if the user myusername has supplied a correct password and has write access. dseditgroup -o edit -n /LDAPv3/ldap.company.com -u myusername -p -a username -t user extragroup The group extragroup from the node /LDAPv3/ldap.company.com will have the username added if the username is in a user record on the search policy and if the correct password is presented interactively for the user myusername which also need to have write access. dseditgroup -o edit -n /LDAPv3/ldap.company.com -u myusername -P -a mysubgroup -t group extragroup The group extragroup from the node /LDAPv3/ldap.company.com will have the mysubgroup added if the mysubgroup is in a group record on the search policy and if the user myusername has supplied a correct password and has write access. dseditgroup -o edit -n /LDAPv3/ldap.company.com -u myusername -p -d username -t user extragroup The group extragroup from the node /LDAPv3/ldap.company.com will have the username deleted if the correct password is presented interactively for the user myusername which also need to have write access. dseditgroup -o checkmember extragroup Will write out a message specifying if the current user is a member of extragroup on the authentication search policy. dseditgroup -o checkmember -n . extragroup Will write out a message specifying if the current user is a member of extragroup on the local node. dseditgroup -n /LDAPv3/ldap.company.com -o checkmember -m user extragroup Will write out a message specifying if user (found in /Search) is a member of extragroup on the specified node /LDAPv3/ldap.company.com. The specified node /LDAPv3/ldap.company.com needs to be on the authentication search policy for a valid answer. Mac OS March 01 2004 Mac OS
All times are GMT -4. The time now is 10:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy