Sponsored Content
Top Forums Shell Programming and Scripting Update specific lines in a file Post 89720 by aukequist on Tuesday 15th of November 2005 10:15:54 AM
Old 11-15-2005
Update specific lines in a file

Hi all,
I want to add a special character ^M to a line, if the line starts with ORDE.
All the other lines should remain unchanged.
Is there sed or other UNIX function who can do this.

Thanx in advance
Auke Quist
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED: Update Last Line with Number Lines in File

Hi, I have to update last line of a text file with the number of lines in that file. This last line will have text such as 0.0000 and I should replace this with number lines. If lines are 20 then it should be replaced with 00020. Any sed or awk cmd help would be appreciated (3 Replies)
Discussion started by: bmkux
3 Replies

2. UNIX for Dummies Questions & Answers

how to display specific lines of a specific file

are there any basic commands that can display lines 99 - 101 of the /etc/passwd file? I'm thinking use of head and tail, but I forget what numbers to use and where to put /etc/passwd in the command. (2 Replies)
Discussion started by: raidkridley
2 Replies

3. Shell Programming and Scripting

Substitute specific lines with lines from another file

Hello All, I am new to this forum. I am currently facing a problem in manipulating files. I have two files called old-matter and new-matter # cat old-matter abc: this, is a, sample, entry byi: white board, is white in color rtz: black, board is black qty: i tried, a lot asd: no... (1 Reply)
Discussion started by: rahmathulla
1 Replies

4. Shell Programming and Scripting

Update a specific line in a file while reading sequentially

All, I know this is a very naive question but I could not find a way to get this working! I have a file with values like input.file Value1 Value2 server1/mylogin,mypasswd Value3 Value4 And in my code, I am reading the file line by line and processing it. #! /bin/ksh... (6 Replies)
Discussion started by: bharath.gct
6 Replies

5. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

6. AIX

how to find which program that update a specific file

Hello Would you tell me how to find which program that update a specific file? I am implementing migration project. My machines OS are AIX. It is because lack of documentation, some program cannot working properly on new machine. We found the root cause of this problem is that some data... (4 Replies)
Discussion started by: cstsang
4 Replies

7. Shell Programming and Scripting

Update specific field in a line of text file

I have a text file like this: subject1:LecturerA:10 subject2:LecturerA:40 if I was given string in column 1 and 2 (which are subject 1 and LecturerA) , i need to update 3rd field of that line containing that given string , which is, number 10 need to be updated to 100 ,for example. The... (6 Replies)
Discussion started by: bmtoan
6 Replies

8. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

9. Shell Programming and Scripting

awk to update specific value in file with match and add +1 to specific digit

I am trying to use awk to match the NM_ in file with $1 of id which is tab-delimited. The NM_ will always be in the line of file that starts with > and be after the second _. When there is a match between each NM_ and id, then the value of $2 in id is substituted or used to update the NM_. Each NM_... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Shell Programming and Scripting

Update a specific field in file with Variable value based on other Key Word

I have an input file with A=xyz B=pqr I would want the value in Second Field (xyz or pqr) updated with a value present in Shell Variable based on the value passed in the first field. (A or B ) while read line do NEW_VALUE = `some functionality done on $line` If $line=First Field-... (1 Reply)
Discussion started by: infernalhell
1 Replies
indent(1)						      General Commands Manual							 indent(1)

Name
       indent - indent and format C program source

Syntax
       indent input [output] [flags]

Description
       The command is intended primarily as a C program formatter.  Specifically, indents code lines, aligns comments, inserts spaces around oper-
       ators where necessary and breaks up declaration lists as in ``int a,b,c;''.

       The command does not break up long statements to make them fit within the maximum line length, but it does flag lines that  are	too  long.
       Lines  are broken so that each statement starts a new line, and braces appear alone on a line.  Also, an attempt is made to line up identi-
       fiers in declarations.

       The flags that can be specified follow. They can appear before or after the file names.	If the output file is omitted, the formatted  file
       is  written back into input and a ``backup'' copy of input is written in the current directory.	If input is named ``/blah/blah/file'', the
       backup file is named ``.Bfile''.  If output is specified, checks to make sure it is different from input.

Options
       The following options are used to control the formatting style imposed by

       -lnnn	   Determines maximum length of output line.  The default is 75.

       -cnnn	   Determines column in which comments start.  The default is 33.

       -cdnnn	   Determines column in which comments on declarations start.  The default is for these comments to start in the  same	column	as
		   other comments.

       -innn	   Determines number of spaces for one indentation level.  The default is 4.

       -dj,-ndj    Causes declarations to be left justified.  -ndj causes them to be indented the same as code.  The default is -ndj.

       -v,-nv	   -v  turns  on  ``verbose''  mode, -nv turns it off.	When in verbose mode, reports when it splits one line of input into two or
		   more lines of output, and it gives some size statistics at completion.  The default is -nv.

       -bc,-nbc    Forces newline after each comma in a declaration.  -nbc turns off this option.  The default is -bc.

       -dnnn	   Controls the placement of comments which are not to the right of code.  Specifying -d2 means that such comments are placed  two
		   indentation	levels	to  the  left of code.	The default -d0 lines up these comments with the code.	See the section on comment
		   indentation below.

       -br,-bl	   Specifying -bl causes complex statements to be lined up in a space order.  For example,
		      if (...)
		      {
			  code
		      }
		   Specifying -br (the default) makes them look like this:
		      if (...) {
			  code
		      }

       You may set up your own ``profile'' of defaults to by creating the file ``.indent.pro'' in your	login  directory  and  including  whatever
       switches  you  like.  If is run and a profile file exists, then it is read to set up the program's defaults.  Switches on the command line,
       though, always override profile switches.  The profile file must be a single line of not more than 127 characters.  The switches should	be
       separated on the line by spaces or tabs.

       Multiline expressions

       The  command  does not break up complicated expressions that extend over multiple lines.  However, it usually indents such expressions that
       have already been broken up correctly.  Such an expression might look like the following:
       x =
	       (
		   (Arbitrary parenthesized expression)
		   +
		   (
		       (Parenthesized expression)
		       *
		       (Parenthesized expression)
		   )
	       );

       Comments

       The command recognizes the following four kinds of comments:

       1)  straight text

       2)  ``box'' comments

       3)  UNIX-style comments

       4)  comments that should be passed through unchanged

       The comments are interpreted as follows:

       ``Box'' comments    The command assumes that any comment with a dash immediately after the start of comment (i.e.  ``/*-'')  is	a  comment
			   surrounded by a box of stars.  Each line of such a comment is left unchanged, except that the first non-blank character
			   of each successive line is lined up with the beginning slash of the first line.  Box comments are indented (see below).

       ``Unix-style'' comments
			   This is the type of section header which is used extensively in the UNIX  system  source.   If  the	start  of  comment
			   (``/*'') appears on a line by itself, assumes that it is a UNIX-style comment.  These are treated similarly to box com-
			   ments, except the first non-blank character on each line is lined up with the `*' of the ``/*''.

       Unchanged comments  Any comment which starts in column 1 is left completely unchanged.  This is intended primarily for documentation header
			   pages.  The check for unchanged comments is made before the check for UNIX-style comments.

       Straight text	   All	other  comments are treated as straight text.  Indent fits as many words (separated by blanks, tabs, or new lines)
			   on a line as possible.  Straight text comments are indented.

       Comment indentation

       Box, UNIX-style, and straight text comments may be indented.  If a comment is on a line with code it is started in the ``comment  column'',
       which is set by the -cnnn command line parameter.  Otherwise, the comment is started at nnn indentation levels less than where code is cur-
       rently being placed, where nnn is specified by the -dnnn command line parameter.  (Indented comments is never be placed in column  1.)	If
       the code on a line extends past the comment column, the comment is moved to the next line.

Restrictions
       Does not know how to format ``long'' declarations.

Diagnostics
       Diagnostic error messages, mostly to tell that a text line has been broken or is too long for the output line.

Files
       .indent.pro    profile file

																	 indent(1)
All times are GMT -4. The time now is 06:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy