The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+2 votes

What will be the output of the following Unix command? $rm chap0\[1-3\]

  1. Remove file chap0[1-3]
  2. Remove file chap01, chap02, chap03
  3. Remove file chap$\text{\[1-3\]}$
  4. None of the above
in Others by Veteran (103k points)
recategorized by | 650 views

2 Answers

+1 vote

ans is A

Square brackets can surround a choice of single characters (i.e., one digit or one letter) you’d like to match. For example, [Cc]hapterwould match either Chapter or chapter, but [ch]apter would match either capter or hapter. Use a hyphen (-) to separate a range of consecutive characters. For example, chap[1-3] would match chap1,chap2, or chap3.

But if escape sequence(\) is used then it literally matches with that after \

so $rm chap0\[1-3\] will remove 

Remove file chap0[1-3]


by Boss (48.5k points)
edited by
what does '\' signify in chap0\ and [1-3\]
Will it not be option B according to your logic
+1 vote
Escape character in front of the brackets removes their meanings.


Hence it just deletes a file named chap0[1-3]
by (21 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,339 questions
55,765 answers
90,818 users