seq Command In Linux

Blogs ❯❯ Linux

Image could not load

Image by pixabay

What is seq Command in Linux

Linux में seq command का use sequence में numbers को print करने के लिए किया जाता है। numbers हमेशा incremented order में ही print होते हैं , हालाँकि आप particular gap और limit भी set कर सकते हैं। इसे आप programming के for Loop की तरह समझ सकते हो।

seq Command Example

by default , seq के बाद pass किये गए number तक sequence print हो जाता है

$ seq 5
1
2
3
4
5

seq Set start & end

आप numbers के start और end number को भी set कर सकते हैं , इसके लिए आपको दो parameters pass करने पड़ेंगे।

For example -

$ seq 3 7
3
4
5
6
7

seq Set Gap Between Numbers

start और end numbers के बीच में आप sequence का gap भी define कर सकते हैं।

$ seq 2 2 10
2
4
6
8
10

seq Print floating point numbers

जरूरी नहीं आप normal number ही pass करें , आप कोई floating number भी pass कर सकते हैं।

$ seq 2.5 2.5 12.5
2.5
5.0
7.5
10.0
12.5
seq Print Numbers Horizontally

अभी तक सभी numbers vertical print हो रहे थे , लेकिन -s option का use करके आप sequence को horizontally भी print कर सकते हैं।

Example -

$ seq -s " " 5 5 50
5 10 15 20 25 30 35 40 45 50 

-s के बाद use की गयीdouble quoted string " " में आप कुछ भी pass कर सकते हैं -

$ seq -s " - " 3 3 30
3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - 27 - 30

seq Format Sequence

seq command के साथ -f या --format option का use करके आप , sequence को format भी कर सकते हैं।

$ seq -f "num_%g" 5
num_1
num_2
num_3
num_4
num_5

% के बाद आपको format के according flag pass करना है , need के according आप ‘%a’, ‘%e’, ‘%f’, ‘%g’, ‘%A’, ‘%E’, ‘%F’, ‘%G’ में से कोई भी flag pass कर सकते हैं।

I Hope, आपको Linux में seq command के बारे में अच्छे से समझ आया होगा।

Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook