A bit complex, no? And a waste of resources, if you change more than one line, as you open/read your file, create a temp file, and mv it once per change!
If you know the pattern, why the detour via grep (and the needless sort)? Why not have sed do it all for you, like
? That will comment out any line that has cdc in it, at any position. Anchor the pattern at begin-of-line with ^ , if need be.
For your syntax problem (I presume you have, but you don't post any error message), use a leading double quote, and enclose the variable name in braces. man bash:
Quote:
The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name.
Hi I need to add a comment line at the begining of a text file. The scenario is given below.
1. The number of servers that needs to be updated is around 80
2. The location of the text file in all the servers are the same including the file name.
3. The comment has to be added at the very... (2 Replies)
I want to replace this line : "test compare visible] true" and make it "#test compare visible] true".
How can I do it ? And it should be checked in many sub folder files also. (6 Replies)
I have around 25 hosts and each hosts has 4 instance of jboss and 4 different ip attached to it . I need to make some changes to the startup scripts. Any tips appreciated. I have total of 100 instances which bind to 100 different ip address based on instance name.
For example
File1
... (1 Reply)
Hello.
I want comment or uncomment a ligne in a config file.
The file name : /etc/samba/smb.conf
Normaly the ligne is uncomment :so the line begin with a tab character
followed by passdb backend =\tpassdb backend =
In that case I should comment this line ... (2 Replies)
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)
I need to comment the lines starting with pattern "exclude" or "exclude=". If the work exclude comes at any other part, ignore it. Also, ignore, excludes, excluded etc. Ie only comment the line starting with exclude.
File contents.
exclude
exclude=
hi I am excluded
excludes
excludes=
... (9 Replies)
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)
Hi,
I need to comment out (insert # in the front of a line) a line that has entry Defaults requiretty using command-line as I need to do this on hundreds of servers.
From
Defaults requiretty
To
#Defaults requiretty
I tried something like below but no luck: Please advise,... (3 Replies)
I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file.
Here is the file.
<!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
I will appreciate if you help me here in this script in Solaris Enviroment.
Scenario:
i have 2 files :
1) /tmp/TRANSACTIONS_DAILY_20180730.txt:
201807300000000004
201807300000000005
201807300000000006
201807300000000007
201807300000000008
2)... (10 Replies)
Discussion started by: teokon90
10 Replies
LEARN ABOUT OSF1
cdc
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)