Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Answers to Frequently Asked Questions How to prevent sed command removing whole line? Post 302979353 by Don Cragun on Friday 12th of August 2016 05:19:09 PM
Old 08-12-2016
Hi beginner_99,
Note that the suggestions you have received work for your sample input (and any other input that has no comments or exactly one complete comment on each line). The suggestions will not work with the following "code":
Code:
/*
** Multi-line comment.
*/
/* Multiple comments... */ code; /* ... on one line. */

Are either of these limitations a problem for the real data you will be processing?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

removing parts of a line with SED

hi, i'm trying to erase all the characters after, and including, the first test test Output: test1 test2 test3 this is what I tried, but didn't work sed "s/*//" file > testfilename any suggestions? thanks, gammmaman (2 Replies)
Discussion started by: gammaman
2 Replies

2. Shell Programming and Scripting

removing a line containing a pattern in sed

i need to use sed to remove an entire line containing a pattern stored in a variable say $var1 this var1 will be a URL and will therefore contain slashes any help would be greatly appreciated (1 Reply)
Discussion started by: Fire_Storm
1 Replies

3. Shell Programming and Scripting

Sed question (Removing a line of text)

I am working with bash on HP-UX server at school. As practice for scripting, I am trying to make a pretend server admin script that adds a user to the system, deletes a user from the system, and lists all users of the pretend system. I have accomplished this with a select loop. Adding users, and... (2 Replies)
Discussion started by: masterscout1977
2 Replies

4. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

5. UNIX for Dummies Questions & Answers

Removing end of line using SED

Hello Friends, How can I remove the last two values of this line using sed John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638:9/3/90:45900 The result should look like this: John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638 (3 Replies)
Discussion started by: humkhn
3 Replies

6. Shell Programming and Scripting

sed removing until end of line

All: Can somebody help me out with a sed command, which removes the the first occurance of ')' until the end of the line If I have the following input ... (5 Replies)
Discussion started by: BeefStu
5 Replies

7. UNIX for Dummies Questions & Answers

sed or awk - removing part of line?

hi all, I am having trouble finding the right string for this - I dont know whether to use awk or sed.. If I have a file with alot of names and phone numbers like this McGowan,Sean 978-934-4000 Kilcoyne,Kathleen 603-555-1212 Club603,The 617-505-1332 Boyle,William 301-444-1221 And... (11 Replies)
Discussion started by: alis
11 Replies

8. UNIX for Dummies Questions & Answers

sed command for removing symbols

Hi I am trying to remove all the symbols in a file (testfile1) and using the below command to do that. Its not working for me. Can you help me on what is wrong with below script? I want to retain only alphabets in a file and remove all the symbols like *:.+= etc sed 's/^.//g' testfile1 > testfile2 (4 Replies)
Discussion started by: sandeepcm
4 Replies

9. Shell Programming and Scripting

sed - Removing all characters from token to end of line

Hello. The token is any printable characters between 2 " . The token is unknown, but we know that it is between 2 " Tok 1 : "1234x567" Tok 2 : "A3b6+None" Tok 3 : "A3b6!1234=@" The ligne is : Line 1 : "9876xABCDE"Do you have any code fragments or data samples in your post Line 2 : ... (3 Replies)
Discussion started by: jcdole
3 Replies

10. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies
cdc(1)							      General Commands Manual							    cdc(1)

NAME
cdc - Changes the comments in a Source Code Control System (SCCS) delta SYNOPSIS
cdc -rSID [-m] [MRlist] [-y] [comment] file... cdc -rSID -mMRlist -ycomment - The cdc command changes the Modification Requests (MRs) and comments for the SID specified by the -r option for each named Source Code Con- trol System (SCCS) file. OPTIONS
Supplies a list of MR numbers for cdc to add or delete in the SID specified by the -r option. You can use this option only if the file has the v header flag set (see the admin command). A null MR list has no effect. In MRlist, MRs are separated by spaces, tab characters, or both. To delete an MR, precede the MR number with an ! (exclamation point). If the MR you want to delete is currently in the list of MRs, it is changed into a comment line. The cdc command places a list of all deleted MRs in the comment section of the delta and precedes them with a comment line, indicating that the following MRs were deleted. If you do not specify the -m option, and the v header flag is set, MRs are read from standard input. If standard input is a termi- nal, the cdc command prompts you for the MRs. The first newline character not preceded by a (backslash) ends the list on the com- mand line. The cdc command continues to take input until it reads an End-of-File character or a blank line. MRs are always read before comments (see the -y option). If the v flag has a value, cdc interprets the value as the name of a program that validates the MR numbers. If the MR number validation program returns a nonzero exit value, the cdc command stops and does not change the MRs. Specifies the SCCS identification number of the delta for which cdc will change the comments or MRs. Specifies text to replace any comment already existing for the delta specified by the -r option. The cdc command keeps the existing comments and pre- cedes them by a comment line, stating that they were changed. A null comment has no effect. If you do not specify -y, the cdc command reads comments from standard input until it reads an End-of-File character. If the stan- dard input is a terminal, the cdc command prompts for the comments and also allows a blank line to end input. If the last character of a line is a (backslash), the cdc command ignores it and continues to read standard input. If cdc reads standard input for file names (that is, when you specify a file name of - (dash)), you must use the -y and -m options. DESCRIPTION
If you specify a directory name, cdc performs the requested actions on all SCCS files in that directory (that is, all files with names that have the s. prefix). If you specify a - (dash) in place of file, cdc reads standard input and interprets each line as the name of an SCCS file. For more information on SCCS, see the Programming Support Tools. You can change the comments and MRs for an SID only if you made the SID or you own the file and the directory. For more information on the permissions needed to change SCCS files, see the get command. EXIT STATUS
For information about exit values, see the OPTIONS section. EXAMPLES
To change the comment for SID 1.3 of SCCS file s.test.c to new comment, enter: cdc -r1.3 -y"new comment" s.test.c SEE ALSO
Commands: admin(1), comb(1), delta(1), get(1), prs(1), rmdel(1), sact(1), sccs(1), sccsdiff(1), sccshelp(1), unget(1), val(1), what(1) Files: sccsfile(4) Programming Support Tools cdc(1)
All times are GMT -4. The time now is 05:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy