Sponsored Content
Top Forums Shell Programming and Scripting Comment lines in FSTAB using perl Post 302671641 by ajaincv on Friday 13th of July 2012 09:39:09 PM
Old 07-13-2012
Comment lines in FSTAB using perl

Hi All,

I need to comment specific Two Lines in fstab & want to do using & also want to ensure that is done corretly.

I am trying the below method. But its giving Search pattern not terminated.

################
Code:
b36376 67 % cat linux-fstab_testing | perl -i -wnl -e '/^('\Q zin46fil01:\/vol\/fil01vol09\/soft1\/\_TOOLS_\/dist \/_TOOLS_\/.dist15 ')/  and print "#$1" or print'
Search pattern not terminated at -e line 1.
b36376 68 %

#################

Please help on this

Regards

Ankit

Last edited by Franklin52; 07-14-2012 at 06:35 AM.. Reason: Please use code tags for data and code samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to comment multiple lines in unix

hi all, please help me how to comment multiple lines in unix script. thanks in advance --bali (3 Replies)
Discussion started by: balireddy_77
3 Replies

2. UNIX for Dummies Questions & Answers

comment lines

Is there a command to put a comment (#) in a whole part of a shell script? (5 Replies)
Discussion started by: vero_81
5 Replies

3. Shell Programming and Scripting

using awk to comment out lines to the end of file

Hello, I have a file as follow a b c c d d e I would like to write a awk command to insert # from the first occurence of "c" to the end of the files. OUTPUT should be like this a b #c (5 Replies)
Discussion started by: phamp008
5 Replies

4. Shell Programming and Scripting

Need perl regular expression to remove the comment

I need a perl substitution to remove only the comment in the line . That line may have '#' with in double quotes .I used the following , s/(^.*\".+?#.+?\".+?)(#.*)/$1/g It works for , print " not a comment # not a comment " . "not a comment # not a comment" ; # It is a comment ... (3 Replies)
Discussion started by: karthigayan
3 Replies

5. UNIX for Dummies Questions & Answers

Trying to show lines in INI files until the comment character (#)

I have a working directory on a server with over 100 INI files. For the most part, they are configured the same way. Each line will contain 1 or none variables listed from the first character in the line such as VariableName=0. Unfortunately there are comments everywhere using the... (4 Replies)
Discussion started by: hindesite
4 Replies

6. Shell Programming and Scripting

How can i comment out a section between two particular lines

I want to find out which files under /etc have the the following section: and then i would like to comment out the above section in all the files. Please help. (3 Replies)
Discussion started by: proactiveaditya
3 Replies

7. UNIX for Dummies Questions & Answers

Comment lines in file without vi editor

Legends, Can you please help me in following. I need to comment lines from “/tmp/a.txt” from the line A to line B through the command prompt only. Please use variables not direct values like 2 or 5 It can be done with VI editor but it's not matches with my requirement (: 2,5 s/^/#/g). ... (1 Reply)
Discussion started by: sdosanjh
1 Replies

8. Shell Programming and Scripting

Comment ( -- ) lines from 10 to 25 for every .sql file

Platform : RHEL 5.4 I have several .sql files in a directory. I want to comment lines 10 to 25 for all .sql files. How can I do this ? The symbol for comment in SQL is -- eg: -- select salary from emp where empname = 'URS' ; (3 Replies)
Discussion started by: omega3
3 Replies

9. Shell Programming and Scripting

Perl one liner to wrap comment lines

Greetings fellow scripters. I find myself editing multiple files, sometimes with the same bits of information. My bash script, a changelog, and a plist file (OS X). Once I realized this, I thought why not script part of this process (and so it begins). In any case, I've solved several of the... (1 Reply)
Discussion started by: reid
1 Replies

10. UNIX for Beginners Questions & Answers

Remove Comment Lines From Script/Input File

Hello, I have a SAS code that predominantly has comments line and the real code like below and i want to remove ONLY THE COMMENTS from the code in the single line or spanned across multiple lines. /******************************************************************** *** This Is a Comment... (4 Replies)
Discussion started by: arooonatr
4 Replies
PG(1)								   User Commands							     PG(1)

NAME
pg - browse pagewise through text files SYNOPSIS
pg [-number] [-p string] [-cefnrs] [+line] [+/pattern/] [file...] DESCRIPTION
pg displays a text file on a CRT one screenful at once. After each page, a prompt is displayed. The user may then either press the new- line key to view the next page or one of the keys described below. If no filename is given on the command line, pg reads from standard input. If standard output is not a terminal, pg acts like cat(1) but precedes each file with its name if there is more than one. If input comes from a pipe, pg stores the data in a buffer file while reading to make navigation possible. OPTIONS
pg accepts the following options: -number The number of lines per page. Usually, this is the number of CRT lines minus one. -c Clear the screen before a page is displayed, if the terminfo entry for the terminal provides this capability. -e Do not pause and display (EOF) at the end of a file. -f Do not split long lines. -n Without this option, commands must be terminated by a newline character. With this option, pg advances once a command letter is entered. -p string Instead of the normal prompt :, string is displayed. If string contains %d, its first occurrence is replaced by the number of the current page. -r Disallow the shell escape. -s Print messages in standout mode, if the terminfo entry for the terminal provides this capability. +number Start at the given line. +/pattern/ Start at the line containing the Basic Regular Expression pattern given. USAGE
The following commands may be entered at the prompt. Commands preceded by i in this document accept a number as argument, positive or neg- ative. If this argument starts with + or -, it is interpreted relative to the current position in the input file, otherwise relative to the beginning. i<newline> Display the next or the indicated page. id or ^D Display the next halfpage. If i is given, it is always interpreted relative to the current position. il Display the next or the indicated line. if Skip a page forward. i must be a positive number and is always interpreted relative to the current position. iw or iz Behave as <newline> except that i becomes the new page size. . or ^L Redraw the screen. $ Advance to the last line of the input file. i/pattern/ Search forward until the first or the i-th occurrence of the Basic Regular Expression pattern is found. The search starts after the current page and stops at the end of the file. No wrap-around is performed. i must be a positive number. i?pattern? or i^pattern^ Search backward until the first or the i-th occurrence of the Basic Regular Expression pattern is found. The search starts before the current page and stops at the beginning of the file. No wrap-around is performed. i must be a positive number. The search commands accept an added letter. If t is given, the line containing the pattern is displayed at the top of the screen, which is the default. m selects the middle and b the bottom of the screen. The selected position is used in following searches, too. in Advance to the next file or i files forward. ip Reread the previous file or i files backward. s filename Save the current file to the given filename. h Display a command summary. !command Execute command using the shell. q or Q Quit. If the user presses the interrupt or quit key while pg reads from the input file or writes on the terminal, pg will immediately display the prompt. In all other situations these keys will terminate pg. ENVIRONMENT VARIABLES
The following environment variables affect the behaviour of pg: COLUMNS Overrides the system-supplied number of columns if set. LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES See locale(7). LINES Overrides the system-supplied number of lines if set. SHELL Used by the ! command. TERM Determines the terminal type. SEE ALSO
cat(1), more(1), sh(1), terminfo(5), locale(7), regex(7), term(7) NOTES
pg expects the terminal tabulators to be set every eight positions. Files that include NUL characters cannot be displayed by pg. AVAILABILITY
The pg command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. util-linux April 2001 PG(1)
All times are GMT -4. The time now is 06:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy