Sponsored Content
Top Forums Shell Programming and Scripting Help with Passing the Output of grep to sed command - to find and replace a string in a file. Post 302913697 by balajesuri on Tuesday 19th of August 2014 12:14:41 PM
Old 08-19-2014
Code:
[user@host ~]$ x=20140819; sed "s/=[0-9]\{8\}/=$x/" file
SomeTextGoesHere
[ASD.EXAMPLE@ABCD]
$$TODAY_DT=20140819

[FGH.EXAMPLE@ABCD]
$$TODAY_DT=20140819

[QWE.EXAMPLE@ABCD]
$$TODAY_DT=20140819

This User Gave Thanks to balajesuri For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace all string instances found by find+grep

Hello all Im performing find + grep operation that looks like this : find . -name "*.dsp" | xargs grep -on Project.lib | grep -v ':0' and I like to add to this one liner the possibility to replace the string " Project.lib" that found ( more then once in file ) with "Example.lib" how can I do... (0 Replies)
Discussion started by: umen
0 Replies

2. UNIX for Dummies Questions & Answers

how to use sed or perl command to find and replace a directory in a file

how to use sed command to find and replace a directory i have a file.. which contains lot of paths ... for eg.. file contains.. /usr/kk/rr/12345/1 /usr/kk/rr/12345/2 /usr/kk/rr/12345/3 /usr/kk/rr/12345/4 /usr/kk/rr/12345/5 /usr/kk/rr/12345/6 /usr/kk/rr/12345/7... (1 Reply)
Discussion started by: wip_vasikaran
1 Replies

3. UNIX for Dummies Questions & Answers

sed/grep string replace question

Hi all, I know this question has probably been answered before, but I am struggling with this problem, even after googling a million pages. In a file named rdmt.conf I need a single character replaced, the number in the line below CUR_OC4J_ID=1 It will always appear after... (3 Replies)
Discussion started by: Mike AAA
3 Replies

4. Shell Programming and Scripting

How to find a certain string in a file and replace it with a value from another file using sed/awk?

Hi Everyone, I am new to this forum and new to sed/awk programming too !! I need to find particular string in file1(text file) and replace it with a value from another text file(file2) the file2 has only one line and the value to be replaced with is in the second column. file 1: (assert (=... (21 Replies)
Discussion started by: paramad
21 Replies

5. Shell Programming and Scripting

QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed

QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1 CAR2_KEY0 CAR2_KEY1 CAR1_KEY10 CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1 grep... (1 Reply)
Discussion started by: thibodc
1 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Shell Programming and Scripting

Grep and sed (replace string in patterned lines)

Grep and Sed (replace string in patterned lines) Hi all, I want to grep for "PATTERN" and only if "PATTERN" is in a line, this line shall be used as replacement input e.g. for SED. I don't get it running in one line. NOT RUNNING - just first idea... I don't know how to redirect grep... (2 Replies)
Discussion started by: unknown7
2 Replies

8. Shell Programming and Scripting

Sed: find and replace backwards, until string

Some help please: Need to find string ||(everything in front of it)B0300|| and replace it with ||0|| globally In: 16112121||||0||0||0||0||0||52||52||0||0||0||0||1507200053342B0300||1507200053342B0300||0||0||0||0700 Out: 16112121||||0||0||0||0||0||52||52||0||0||0||0||0||0||0||0||0||0700 ... (4 Replies)
Discussion started by: drbiloukos
4 Replies

9. Shell Programming and Scripting

How to search and replace string in column in file with command sed?

how to search and replace string in column in file with command sed or other search "INC0000003.in" and replace column 4 = "W" $ cat file.txt INC0000001.in|20150120|Y|N|N INC0000002.in|20150120|Y|N|N INC0000003.in|20150120|Y|N|N INC0000004.in|20150120|Y|N|Noutput... (4 Replies)
Discussion started by: ppmanja3
4 Replies

10. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
MBR_CHECK_MEMBERSHIP(3) 				   BSD Library Functions Manual 				   MBR_CHECK_MEMBERSHIP(3)

NAME
mbr_check_membership, mbr_check_service_membership -- check whether a user is a member of a group or service ACL SYNOPSIS
#include <membership.h> int mbr_check_membership(uuid_t user, uuid_t group, int *ismember); int mbr_check_service_membership(uuid_t user, const char *service, int *ismember); DESCRIPTION
mbr_check_membership() tests if a given user is a member of a group (either direct or indirect via a nested group). ismember is set to 1 if the user is a member or 0 if not a member of the group. mbr_check_service_membership() similarly tests if a given user is a member of a ser- vice ACL group. Service ACLs are special groups defined with the prefix "com.apple.access_". The service is then prefixed (e.g., "afp" would check "com.apple.access_afp"). There is a special group that grants accessto all services called "com.apple.access_all_services". Users may belong to any number of groups. mbr_check_membership() should always be used to check group membership, rather than calling getgroups(2) or getgrouplist(2). The setgroups(2) and getgroups(2) routines are limited to a fixed number of gids, and so may not include all of a user's groups. There are two special cases. If the two uuids are equal, then ismember is set to 1. If the group uuid is equal to the reserved "everyone" uuid (ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C), then ismember will be set to 1 for any valid user. Group membership information is managed by opendirectoryd(8). RETURN VALUES
mbr_check_membership() does not test whether group exists or not. Querying membership for a nonexistent group will result in ismember being set to 0. The function returns 0 on success or one of the following error codes on failure: [EIO] Communication with openditectoryd(8) failed. [ENOENT] user can not be found. mbr_check_service_membership() is identical to mbr_check_membership() except that ENOENT means no service ACL has been defined. SEE ALSO
odutil(1), setgroups(2), getgroups(2), mbr_uid_to_uuid(3), opendirectoryd(8) Mac OS X November 5, 2011 Mac OS X
All times are GMT -4. The time now is 09:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy