To skip operations in UNIX shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To skip operations in UNIX shell
# 1  
Old 05-02-2014
To skip operations in UNIX shell

hi i am having a acript for which i need to skip the execution of some lines and to continue with remaining lines for eg

Code:
script.sh
rm text
for i in *
do 
.
.
.
.
.
if [x = y]
then 
rm

i want to skip the execution of the lines and to start with

Code:
if [x = y]
then 
rm

# 2  
Old 05-02-2014
Put them in a condition thats never true.
Code:
if [ 1 == 0 ];then
script.sh
 rm text
 for i in * 
do
.
.
.
.
 .
done
fi
if [x = y] 
then
 rm

# 3  
Old 05-02-2014
Put comment signs in front of the lines:
Code:
# rm text
# for i in *
# do 
# .
# .
# .
# .
# done
# .
if [x = y]
then 
rm

This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 05-02-2014
hi

i dont wanted to comment each line since the script is very huge
# 5  
Old 05-02-2014
If you dont want to comment it out, then you can use the "if" condition.
# 6  
Old 05-02-2014
Well, if you use vi you can use:
Code:
:1,/if \[x = y\]/s/^/# /

And then delete the last comment...


--
Quote:
Originally Posted by chacko193
Put them in a condition thats never true.
Code:
if [ 1 == 0 ];then
[..]

The correct syntax is
Code:
if [ 1 = 0 ]; then

But you could also use:
Code:
if [ ]; then

or
Code:
if false; then


Last edited by Scrutinizer; 05-02-2014 at 04:39 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 7  
Old 05-02-2014
If your shell allows for here documents, you could try
Code:
script.sh
<<EOF
rm text
for i in *
do
.
.
.
.
.
EOF
if [x = y] then  rm

Make sure that the token (here:EOF) does not occur anywhere in the portion to be skipped.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell operations from C++

Hi everyone, I need little help in shell operations from C++ program. Here I furnish the details of problem: 1. Lets say my current working path is myWorkingPath. 2. In my working path I have list of name directories and each name directory has two more sub directories say A/B. (now path to... (5 Replies)
Discussion started by: linuxUser_
5 Replies

2. Shell Programming and Scripting

How to skip the first line of the script in shell using python?

How to skip first line of the script in shell, using python. (3 Replies)
Discussion started by: KarthikPS
3 Replies

3. Programming

shell cursor operations

Hi I need to save the actual cursor position into variable in my script. How can I do it ? thx for help. (1 Reply)
Discussion started by: presul
1 Replies

4. Shell Programming and Scripting

Unix Shell scripting -How to skip User Standard input section from another script

All, problem Description: For example: I have two shell scripts(executables). let name it as script1 and script2.I'm trying to execute script1 from script2. while executing script2, script1 is asking for manual input(input from keyboard). Now i need to know how I can skip this user input... (3 Replies)
Discussion started by: techie99
3 Replies

5. IP Networking

What is the best Unix-like for firewalling operations

Hello from France, I'd like to have your opinion on this : What unix-like would you choose for high bandwidth netwoking operations like a cluster of statefull firewalls ? NetBSD, Linux, others ? Thank you. Best regards. Vincent. (0 Replies)
Discussion started by: vrzs
0 Replies

6. Shell Programming and Scripting

Date operations in Unix?

Hi Friends, I need help in below requirements, 1. I have to get current datetime + <mins> into a variable 2. I have to compage dates like, A=01-JAN-2009 10:20:10 B=01-JAN-2009 10:30:00 C=<same format date as above> I have to find whether, 1. C is less than A OR, 2. C is greater... (7 Replies)
Discussion started by: smr_rashmy
7 Replies

7. Shell Programming and Scripting

Unix File operations

Hi, Iam having the two files as follows: file1: ASQWEDFR09876543121234512 POIUYTREW09876512345676788 ZXCVBNMKS1209888888888888 file2: ASQWEDFR09876543121234516 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990---- CXADFGTU09876543121234789 asdcvfgbtg@abc.com ... (14 Replies)
Discussion started by: nivas
14 Replies

8. Shell Programming and Scripting

Unix file operations(shell script)

Hi, I want to compare two files. Files will look like as follows: file1: ASDFGHJU|1234567890123456 QWERTYUI|3456789098900890 file2: ZXCVBVNM|0987654321234567 POLKIJUYH|1234789060985478 output file should be: ASDFGHJU|1234567890123456 QWERTYUI|3456789098900890 Thnaks in advance (6 Replies)
Discussion started by: nivas
6 Replies

9. UNIX for Dummies Questions & Answers

mathematics operations in unix

Hello guys! Can say me anybody about operatios with unix, I don't to make operations, only inside in a variable, like this #y=4 #x=2 #let z=$y-$x #echo $z # 2 but I can't to make mathematical operations with decimal like this #y=3.2 #x=1.5 #let z=$y-$x #echo $z # 3 this... (2 Replies)
Discussion started by: cesar720213
2 Replies
Login or Register to Ask a Question