Sponsored Content
Top Forums Shell Programming and Scripting How to execute the rest of the code after commenting multiple lines? Post 302154813 by Yamini Thoppen on Wednesday 2nd of January 2008 01:58:47 AM
Old 01-02-2008
What exactly I want is......

Quote:
Originally Posted by rubin
It looks like there is some confusion here.
What fpmurphy is trying to say is that you need to comment out the lines (if needed) that don't need to be executed using # sign, like this:

Code:
#  :<<COMMENTBLOCK
# if [ "$month -eq 3 ] || [ "$month -eq 6 ]
# then
# echo "inc = 1"
# else
# echo "inc = 2"
# fi
# COMMENTBLOCK


In case you are trying to use a HERE document, as suggested you need to get rid of the colon : in front of the sign <<, and no space at the final COMMENTBLOCK :



So if you need those lines commented out you need to use the first code.

If you are trying to achieve something else with your script, then you need to look in your script and change it accordingly, or post here what are you trying to achieve.
Hi Rubin,

Thanks for your explanation. I will write exactly what I need

Like in C or in C++, we have multiple lines of comments start like

/*
bla bla bla
*/

Likewise, I need the same kind of comments in Shell scripts. Is it possible here ?

1 #! /usr/bin/ksh
2 month=`date +"%m"`
3 echo $month
4
5 <<COMMENTBLOCk
6 if [ "$month" -eq 3] || [ "$month" -eq 6]
7 then
8 echo "inc = 1"
9 else
10 echo " inc = 2"
11 fi
12 COMMENTBLOCK
13
14 case $month in
15 3|6|9|12) echo "Yes";;
16 *) echo "No";;
17 esac
18
19 echo "This is the last line"

Query : I need to block the line number from 5 to 12 (except # option and line no from 14 to 19 should execute as usual. Can you pls give the solution for it?

Many of Unix Experts are replied for my query. Many thanks to you.

Thanks
Yamini
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Want to execute rest of the script after the file is ready ...

Hi All I have a requirement like, where a file gets generated in a particular dir and once the file is ready and available then I want to execute rest of the script, because untill and unless the file exists and is available there is no use of running rest of the commands in that script. ... (5 Replies)
Discussion started by: csaha
5 Replies

2. UNIX for Dummies Questions & Answers

Commenting lines

How to comment a set of lines in a script? we use # to comment a single line , is there ant other cmd to comment a block? (2 Replies)
Discussion started by: rolex.mp
2 Replies

3. Shell Programming and Scripting

Commenting lines

Hi can any body pls help me : I have a file Which Content is like following: p3:s1234:powerfail:/usr/sbin/shutdown -y -i5 -g0 >/dev/msglog 2<>/dev/msglog ca:3:respawn:/opt/GoldWing/currentPM/local/critagt > /dev/msglog 2<>/dev/msglog ca:3:respawn:/opt/GoldWing/currentPM/local/startcia.sh... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

4. UNIX for Dummies Questions & Answers

How get only required lines & delete the rest of the lines in file

Hiiii I have a file which contains huge data as a.dat: PDE 1990 1 9 18 51 28.90 24.7500 95.2800 118.0 6.1 0.0 BURMA event name: 010990D time shift: 7.3000 half duration: 5.0000 latitude: 24.4200 longitude: 94.9500 depth: 129.6000 Mrr: ... (7 Replies)
Discussion started by: reva
7 Replies

5. Shell Programming and Scripting

commenting out lines between two delimiters

Hi All, I am struggling to get my head around the following issue. I am having to comment out lines between two delimiters by placing an asterix in position 7 but retain all lines in the file and in the same order. so for example a file containing: ... ... DELIM1 ... ... DELIM2... (2 Replies)
Discussion started by: Bruble
2 Replies

6. Shell Programming and Scripting

Commenting lines in Shell script

Hi All, I know we can comment by using "#" .... I want to know... is there any way to comment a whole big script easily.... In a file i need to comment more than 15 lines ........ and check the script and un comment back. I am learning VI now so its taking lot of time to comment and un... (4 Replies)
Discussion started by: firestar
4 Replies

7. UNIX for Dummies Questions & Answers

Commenting multiple lines

Hi, Can anyone let me know how to comment multiple lines in VI editor? Many thanks. Regards, Venkat. (3 Replies)
Discussion started by: venkatesht
3 Replies

8. Shell Programming and Scripting

perl: Help with commenting out specific lines

Hi I'm trying to comment out specific lines from /etc/fstab file, for simplicity I'm trying to use perl one liner but it errors out, Below is the Perl oneliner I'm using, perl -wlp -i -e 'BEGIN{$flag=0}if (!/root/) && (!/boot/) && (!/tmpfs/) ) {$flag =1;} elsif (/^$/) {$flag=0} if ($flag)... (2 Replies)
Discussion started by: mbak
2 Replies

9. Shell Programming and Scripting

Commenting Multiple lines using Shell Script

I have an xml file which has following code : <abc-ref> <abc-name>abc.efg.hij.klm</abc-name> </abc-ref> I want to comment this whole section out and I have written the following script : (where "hij" is unique string in the file) TEMPFILE=replaceYY.tmp file=hello.xml sed -n... (6 Replies)
Discussion started by: Dish
6 Replies

10. Web Development

Javascript to check field is empty then execute rest of script

I have found this bit of code that nearly does what I want. Basically 3 input fields, I want to copy t2 to t3 as it's typed but only if t1 contains data AND t3 is empty: <input type="text" id="t1" /> <input type="text" id="t2" /> <input type="text" id="t3" /> <script> var t2 =... (4 Replies)
Discussion started by: barrydocks
4 Replies
REPERTOIREMAP(5)						 Linux User Manual						  REPERTOIREMAP(5)

NAME
repertoiremap - map symbolic character names to Unicode code points DESCRIPTION
A repertoire map defines mappings between symbolic character names and Unicode code points when compiling a locale with localedef(1). Using a repertoire map is optional, it is needed only when symbolic names are used instead of now preferred Unicode code points. Syntax The repertoiremap file starts with a header that may consist of the following keywords: <comment_char> is followed by a character that will be used as the comment character for the rest of the file. It defaults to the number sign (#). <escape_char> is followed by a character that should be used as the escape character for the rest of the file to mark characters that should be interpreted in a special way. It defaults to the backslash (). The mapping section starts with the keyword CHARIDS in the first column. The mapping lines have the following form: <symbolic-name> <code-point> <comment> This defines exactly one mapping, <comment> being optional. The mapping section ends with the string END CHARIDS. FILES
/usr/share/i18n/repertoiremaps Usual default repertoire map path. CONFORMING TO
POSIX.2. NOTES
Repertoire maps are deprecated in favor of Unicode code points. SEE ALSO
locale(1), localedef(1), charmap(5), locale(5) GNU
2014-06-02 REPERTOIREMAP(5)
All times are GMT -4. The time now is 04:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy