Linux Basic Commands With Examples In Hindi - Part 1
Linux adduser Command In Hindi
Linux cat command Example | Linux print file content on terminal
Linux netstat Command : Linux Networking
Syntax Error In JavaScript In Hindi | JS SyntaxError
Time Travel In Snowflake In Hindi | Snowflake Time Travel Example
Java Program to check whether number is Palindrome or not | Java Find Palindrome Number
If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Linux में sort
Command का use files को sort करने में , या file content को किसी particular order में arrange करने के लिए किया जाता है। By default sort command file content को characters wise ascending order में sort करती है, लेकिन आप number या size के according भी sort कर सकते हैं।
by default , आप sort filename
command run कर सकते हैं , लेकिन जैसा अभी आपने पढ़ा कि इसे हम कई तरह से use कर सकते हैं , So different - different task के किए लिए different options भी हैं। sort command के सभी options देखने के लिए आप sort --help
command run कर सकते हैं।
$ sort --help
Example के लिए हम एक test.txt
name की file बनाकर उसमे content insert करेंगे , फिर sort command का use करके अलग अलग तरीके से content को sort करेंगे।
$ touch test.txt $ cat > test.txt rahul ravi mohit john tom press ctrl+d to save and exit.
Example में use की गयी touch Command का use file create करने के लिए और cat Command का use file में content write और concatenate करने के लिए किया जाता है।
अब , sort command का use करके file को sort करते हैं -
$ sort test.txt john mohit rahul ravi tom
reverse (descending) order में sort करने के लिए -r
option का use किया जाता है।
$ sort -r test.txt tom ravi rahul mohit john
-o
, option का use करके आप किसी existing file content को sort करके new file में write कर सकते हैं।
$ sort -o test.txt > newfile.txt $ cat newfile.txt john mohit rahul ravi tom
file को numeric sort करने के लिए -n
command का use किया जाता है। Example के लिए हम फिर से test.txt
में numeric data enter करके sort करेंगे।
$ cat > test.txt 200 3 56 23 90 press ctrl+d to save and exit.
$ sort -n test.txt 3 23 56 90 200
पिछले example में use किया गया -r
option का use -n
के साथ numeric data को reverse order में print करने के लिए -rn
का use करेंगे।
$ sort -rn test.txt 200 90 56 23 3
Loading ...
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