DEV Community

Cover image for 10 Daily Linux Questions and Answers Series (part 11)
Alex Enson
Alex Enson

Posted on

10 Daily Linux Questions and Answers Series (part 11)

In this brief article, I present 10 essential Linux questions along with their answers.
This foundational knowledge is crucial for anyone seeking to master Linux.

Q1: How do you sort based on delimiter-separated fields?

sort -t ',' -k 2 filename
Enter fullscreen mode Exit fullscreen mode



Q2: How do you check if a file is already sorted?

sort -c filename
Enter fullscreen mode Exit fullscreen mode



Q3: How do you sort in reverse order while keeping duplicates unique?

sort -ru filename
Enter fullscreen mode Exit fullscreen mode



Q4: How do you sort human-readable numbers like sizes (KB, MB, GB)?

sort -h filename
Enter fullscreen mode Exit fullscreen mode



Q5: How do you perform a stable sort (preserve the original order for duplicates)?

sort -s filename
Enter fullscreen mode Exit fullscreen mode



Q6: How do you sort based on date format?

sort -k 1,1 filename
Enter fullscreen mode Exit fullscreen mode



Q7: How do you sort based on IP addresses?

sort -t '.' -k 1,1n -k 2,2n -k 3,3n -k 4,4n filename
Enter fullscreen mode Exit fullscreen mode



Q8: How do you use sort with large files efficiently?

sort --buffer-size=4M filename
Enter fullscreen mode Exit fullscreen mode



Q9: How do you sort a CSV file based on a specific column?

sort -t ',' -k column_number filename.csv
Enter fullscreen mode Exit fullscreen mode



Q10: How do you sort a log file based on timestamps?

sort -k 1,1 filename.log  <br>
Enter fullscreen mode Exit fullscreen mode



Connect with me on LinkedIn


#30DaysLinuxChallenge #RedHatEnterpriseLinux
#CloudWhistler #CloudEngineer #Linux
#DevOps #RedHat #OpenSource
#CloudComputing #Automation
#CloudEngineer

Top comments (0)