Logo Miradil's Blog
  • Home
  • About
  • Skills
  • Experiences
  • Education
  • More
    Projects Publications Recent Posts
  • Posts
  • Dark Theme
    Light Theme Dark Theme System Theme
Logo Inverted Logo
  • Tags
  • Backend
  • Basic
  • Binary Search Tree
  • BinarySearch
  • Bit Manipulation
  • C
  • Caching
  • Codeforces
  • Disjoint Set
  • Django
  • DSA
  • Easy
  • Eolymp
  • File Structure
  • File System
  • ForBeginners
  • Formatted I/O
  • HackerRank
  • HowTo
  • ICPC
  • Interactive
  • Interview
  • Intro
  • Leetcode
  • Library Functions
  • LinkedList
  • Linux
  • Medium
  • Open Source
  • Podcasts
  • Programming
  • Public Speaking
  • Python
  • Roadmap
  • Stack
  • System Calls
  • The Diary of a CEO
  • Tricky
  • Vinh Giang
  • Web Development
Hero Image
Let's Rewrite Linux 'ls' command: Sorting and formatting the output. The Finale.

In this article we will apply flags from previous post and format output ls command. If you want to know more about command, please read Part 1. If you want to know how we configured tests, check Part 2. If you want to know how we collected info about files, check Part 3. If you want to know how we processed the flags, check Part 4 Note: Source codes can be found at: https://github.com/Miradils-Blog/linux-ls

Thursday, September 28, 2023 | 12 minutes Read
Hero Image
Let's Rewrite Linux 'ls' command: Processing flags

In this article we will start processing some flags of ls command. If you want to know more about command, please read Part 1. If you want to know how we configured tests, check Part 2. If you want to know how we collected info about files, check Part 3. Note: Source codes can be found at: https://github.com/Miradils-Blog/linux-ls Introduction In previous part we collected all necessary info of all files and printed them out. However, we used them only for printing, nothing else. For some flags, we don’t even need the info of certain files (by default, we do not need info of hidden files, or in case of -A we do not need data of current (.) and previous (..) directory, etc.). So, we need to process the flags to know which files we need to collect data of, and how to print the needed output. So, let’s start with flags, which affect our printing style.

Tuesday, May 23, 2023 | 11 minutes Read
Hero Image
Let's Rewrite Linux 'ls' command: Getting the list of files and their info

In this article we will start collecting info about files If you want to know more about command, please read Part 1. If you want to know how we configured tests, check Part 2. Note: Source codes can be found at: https://github.com/Miradils-Blog/linux-ls Getting the list of files First things first, our file structure looks like this (tree command was used for output): We have separate folder with different types of files for us to cover all cases. For now, we will hard-code the folder where listing will happen, just focusing on functionality. So, how do we get the list of all files and their respective data about ownership, size, links etc.? Lucky for us, C provides function for this (and honestly, for everything else as well):

Wednesday, May 10, 2023 | 9 minutes Read
Hero Image
Let's Rewrite Linux 'ls' command: Starting with C

In this article we will start the first steps to rewrite ls command. If you want to know more about command, please read Part 1. Note: Source codes can be found at: https://github.com/Miradils-Blog/linux-ls The easy way Actually, C provides a function to run any OS command, and print its output: system. From the example in the reference, we see that, we can just take arguments from shell and pass it to that function, and it is done. The following code is just a showcase, and is far from optimized:

Friday, May 5, 2023 | 4 minutes Read
Hero Image
Let's Rewrite Linux 'ls' command: Command, file types and flags

Note: For the whole series, Zsh is used, for which, output can be different compared other shell profiles. Introduction The ls command is one of the most commonly used commands in Linux/UNIX. This command is used to list the contents of a directory. Without any flags, we have the following output: What are these colorful file names? Well, let’s find out! File Types There are 8 main types of files in Linux:

Friday, April 28, 2023 | 3 minutes Read
Navigation
  • About
  • Skills
  • Experiences
  • Education
  • Projects
  • Publications
  • Recent Posts
Contact me:
  • miradil.zeynalli@gmail.com
  • mmzeynalli
  • Miradil Zeynalli
  • @mmzeynalli
  • Miradil Zeynalli
  • @mmzeynalli

Toha Theme Logo Toha
© 2024 Copyright.
Powered by Hugo Logo