Trending March 2024 # Thirteen Useful Tools For Working With Text On The Command Line # Suggested April 2024 # Top 7 Popular

You are reading the article Thirteen Useful Tools For Working With Text On The Command Line updated in March 2024 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested April 2024 Thirteen Useful Tools For Working With Text On The Command Line

GNU/Linux distributions include a wealth of programs for handling text, most of which are provided by the GNU core utilities. There’s somewhat of a learning curve, but these utilities can prove very useful and efficient when used correctly.

Here are thirteen powerful text manipulation tools every command-line user should know.

1. cat

Cat has a number of useful options, notably:

-A prints “$” at the end of each line and displays non-printing characters using caret notation.

-n numbers all lines.

-b numbers lines that are not blank.

-s reduces a series of blank lines to a single blank line.

In the following example, we are concatenating and numbering the contents of file1, standard input, and file3.



file1 - file3 2. sort

As its name suggests, sort sorts file contents alphabetically and numerically.

3. uniq

Uniq takes a sorted file and removes duplicate lines. It is often chained with sort in a single command.

4. comm

Comm is used to compare two sorted files, line by line. It outputs three columns: the first two columns contain lines unique to the first and second file respectively, and the third displays those found in both files.

5. cut

Cut is used to retrieve specific sections of lines, based on characters, fields, or bytes. It can read from a file or from standard input if no file is specified.

Cutting by character position

The -c option specifies a single character position or one or more ranges of characters.

For example:

-c 3: the 3rd character.

-c 3-5: from the 3rd to the 5th character.

-c -5 or -c 1-5: from the 1st to the 5th character.

-c 5-: from the 5th character to the end of the line.

-c 3,5-7: the 3rd and from the 5th to the 7th character.

Cutting by field

Fields are separated by a delimiter consisting of a single character, which is specified with the -d option. The -f option selects a field position or one or more ranges of fields using the same format as above.

6. dos2unix

GNU/Linux and Unix usually terminate text lines with a line feed (LF), while Windows uses carriage return and line feed (CRLF). Compatibility issues can arise when handling CRLF text on Linux, which is where dos2unix comes in. It converts CRLF terminators to LF.

In the following example, the file command is used to check the text format before and after using dos2unix.

7. fold

To make long lines of text easier to read and handle, you can use fold, which wraps lines to a specified width.

Fold strictly matches the specified width by default, breaking words where necessary.




chúng tôi breaking words is undesirable, you can use the -s option to break at spaces.





chúng tôi iconv

This tool converts text from one encoding to another, which is very useful when dealing with unusual encodings.







output_file input_file

“input_encoding” is the encoding you are converting from.

“output_encoding” is the encoding you are converting to.

“output_file” is the filename iconv will save to.

“input_file” is the filename iconv will read from.

Note: you can list the available encodings with iconv -l

9. sed

sed is a powerful and flexible stream editor, most commonly used to find and replace strings with the following syntax.

The following command will read from the specified file (or standard input), replacing the parts of text that match the regular expression pattern with the replacement string and outputting the result to the terminal.








g filename

To modify the original file instead, you can use the -i flag.

10. wc

The wc utility prints the number of bytes, characters, words, or lines in a file.

11. split

You can use split to divide a file into smaller files, by number of lines, by size, or to a specific number of files.

Splitting by number of lines



num_lines input_file output_prefix

Splitting by bytes



bytes input_file output_prefix

Splitting to a specific number of files



num_files input_file output_prefix 12. tac

Tac, which is cat in reverse, does exactly that: it displays files with the lines in reverse order.

13. tr

The tr tool is used to translate or delete sets of characters.

A set of characters is usually either a string or ranges of characters. For instance:

“A-Z”: all uppercase letters

“a-z0-9”: lowercase letters and digits

“n[:punct:]”: newline and punctuation characters

Refer to the tr manual page for more details.

To translate one set to another, use the following syntax:



For instance, to replace lowercase characters with their uppercase equivalent, you can use the following:




To delete a set of characters, use the -d flag.




To delete the complement of a set of characters (i.e. everything except the set), use -dc.



SET Conclusion

There is plenty to learn when it comes to Linux command line. Hopefully, the above commands can help you to better deal with text in the command line.

Karl Wakim

Karl Wakim is a technical author and Linux systems administrator.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

You're reading Thirteen Useful Tools For Working With Text On The Command Line

Linux Desktop: Command Line Vs. User Interface

In the Linux desktop world, the graphical user interface is here to stay. Old Unix hands may grumble, but the fact remains that, without all the efforts poured into GNOME, KDE, Xfce and others, Linux would not be as successful as it is today.

The reason for the desktop’s success is obvious. A desktop requires much less knowledge than a command line, and is suited to maybe 80% of the most common tasks that an average user needs. If the desktop needs much larger applications, that hardly seems a problem on a modern computer.

In fact, for many administrative tasks, the command line is actually easier than the desktop. Looking through my BASH history, I can see at least five circumstances in which I generally choose the command line over the desktop:

Whether you are copying, moving, or deleting files, the BASH shell gives you far more options than KDE’s Dolphin or GNOME’s Nautilus. Such desktop file managers do their best, but they can only plan for the average use cases, and add confirmation dialogs to prevent users from doing something rash.

Moreover, because menu and toolbars rarely have entries for symbolic links, a whole generation of desktop users are unaware that the possibility even exists, or when to use them.

By contrast, consider all the possibilities of a simple command such as cp (copy). To start with, you can decide whether you want an indication of progress, or the ability to confirm before overwriting files. If you want you can archive or backup files. You can choose to create symbolic links instead of copying, and whether to preserve file attributes, and you can ensure that you remain on the same filesystem or not. Other file management commands are similarly versatile, although some of the details differ.

Another practical consideration is that, when moving large numbers of files — for instance, when you are doing a backup — desktops tend to freeze, no matter how much RAM your machine has. Consequently, you can be left waiting for your file management to complete, unable to do anything else. Or, even worse, you can be left uncertain whether you have actually succeeded what you are doing. These problems simply don’t exist at the prompt.

Just as with the file management commands, the ls command gives you far more versatility than any desktop display. True, by definition you can’t have an icon view, but you can you use colors or symbols to indicate different types of files.

You also have all the filters available in desktop file managers, including whether to show hidden and backup files, as well as the ability to sort listings by extension, file size, time modified, and file version.

However, what I appreciate most about ls is that when you use the -l or -g option, all the information about file attributes is printed on a single line.

By contrast, in the average desktop file manager, you choose the default attributes to display, or at least their order (which, in anything less than a full-sized window, often comes down the same thing). Often, too, permissions are listed on a separate tab, and four or five keystrokes away.

Some applications simply defy a graphical interface. Oh, you can make one, if you insist, but the result is always proof (if you need any) that slapping everything into a window does not necessarily make for user friendliness.

That is especially true of applications with hundreds of options, such as Apache. However, it can also be true of much smaller utilities such as crontab. I have yet to see a crontag graphical interface that was not more intimidating than the command itself. By the time I have finished deciphering a desktop of crontab, I could have scheduled half a dozen jobs to run at a latter time.

Both apt-get and yum, the leading package management tools, have had graphical front ends for years. However, just as with file managers, you can practically hear graphical package tools like Synaptic or the Ubuntu Software Centre grinding away when processing large numbers of files. In fact, when you update, many of these desktop tools simply freeze — often while giving very little indication of what is happening.

Moreover, if you want to install something too soon after you log in, often the graphical tools have a conflict with the update applet. When that happens, you either have to wait or decide which one to close.

Next Page: Command line and desktop resources….

Chkdsk Command Line Options, Switches, Parameters In Windows 11/10

Check Disk or chúng tôi is a built-in Windows utility used to check for errors in the disk media and in the file system. If you face problems ranging from blue screens, to inability to open or save files or folders, one can run the Check Disk utility. Whenever we need to detect and fix the file system or disk corruption, we run the built-in Windows Check Disk tool. The Check Disk utility or chúng tôi checks file system errors, bad sectors, lost clusters, and so on. Check Disk can run automatically, in the case of an abrupt shutdown or if it finds the file system to be ‘dirty’.

We can say that there are “two versions” of this utility in Windows 11/10. One is the basic version which most of us use and the other is the command-line version, which has more sets of options. The basic version of the Check Disk utility can be accessed as follows:

Here you have options to Automatically Fix File System Errors and Scan For And Attempt Recovery Of Bad Sectors.

You may have to schedule the chkdsk at reboot if the drive to be checked, is in use.

Command Line ChkDsk

And then there is this command-line version of chkdsk, which offers you several options, apart from just allowing you to set up regular disk checking using the Task Scheduler.

To use the command line check disk version, open a Command Prompt using the ‘Run As Administrator’ option. Type chkdsk at the prompt. This will run Chkdsk in a Read-Only mode and display the status of the current drive.

Typing chkdsk /? and hitting Enter will give you its parameters or switches.

To get a report for, say, drive C, use chkdsk c:.

You can also use the following parameters at the end of the command to specialize its operations.

The following are valid on FAT32 / NTFS volumes.

/f  Fixes errors detected.

/r  Identifies Bad Sectors and attempts recovery of information.

/v  Displays a list of every file in every directory, on FAT32. On NTFS, is displays the cleanup messages.

The following are valid on NTFS volumes only.

/c  Skips the checking of cycles within the folder structure.

/I  Performs a simpler check of index entries.

/x  Forces the volume to dismount. Also invalidates all open file handles. This should be avoided in Desktop Editions of Windows, because of the possibility of data loss/corruption.

/l[:size]  It changes the size of the file that logs NTFS transactions. This option too, like the above one, is intended for server administrators ONLY.

Do note that, when you boot to the Windows Recovery Environment, Only two switches may be available.

/p  It performs an exhaustive check of the current disk

/r  It repairs possible damage on the current disk.

The following switches work in Windows 11/10, Windows 8 on NTFS volumes only:

/scan Run online scan

/forceofflinefix Bypass online repair and queue defects for offline repair. Needs to be used along with /scan.

/perf  Perform the scan as fast as possible.

/spotfix  Perform spot repair in offline mode.

/offlinescanandfix Run offline scan and perform fixes.

/sdcclean Garbage collection.

These switches are supported by Windows 11/10 on FAT/FAT32/exFAT volumes only:

/freeorphanedchains Free up any orphaned cluster chains

/markclean Mark the volume clean if no corruption is detected.

Also note:

ChkDsk /f scans for and attempts to repair errors in the file system.

ChkDsk /r includes /f, but it also scans the entire disk surface for physical errors and attempts to repair them as well.

So you could run a command like the following to check and repair disk errors on your C drive:

chkdsk c: /r Cancel a CHKDSK scan

To cancel a scheduled check, at a command prompt, type

chkntfs /x d:

and hit Enter. Here d is the drive letter.

Users of Windows 11/10 may have noticed that Disk Error Checking is a bit different from the earlier versions of Windows. Read this post on Disk Error Checking in Windows to learn more.

This post on how to format External Drive or run Check Disk using Command Prompt may interest some of you.

How To Get Octal File Permissions From Command Line In Mac Os

Command line users are likely familiar with using chmod to set file permissions in numerical or octal format, for example running a command like ‘chmod 755 filename’, but have you ever wondered how you can get file permissions in octal format?

If you want to see or view the octal numerical value of permissions of any file or folder via the command line, you can turn to the stat command in Mac OS to do so.

How to Get Numerical chmod Permissions Values on the Mac

To get started, launch the Terminal app from /Applications/ on the Mac and use the following commands:

stat -f %A file.txt

For example, that command may output something like the following:


Where, in this example, ‘644’ is the octal value of that files permissions.

Alternatively, you can use -f and %OLp (yes that’s an upper case ‘o’ and not a zero), the output will be the same assuming the file is too:

stat -f %OLp /Applications/System

Example output for that command may look like the following, showing the numerical octal value permissions for the target item:


In this example, the “System Preferences” application has a octal permissions value of 775.

You should not need to use quotations, though if you need for some reason to escape a file name or path, or for scripting purposes, they’re easy to place like so:

stat -f "%OLp" '/Applications/System'

The -f flag is for format, you can read more about specific formatting options for the stat output from the manual page on stat with ‘man stat’.

In the latter command case, the “O” (upper case o) is specifically for achieving octal output.

Knowing the exact numerical permissions of a file or folder is wildly useful for so many reasons, and it can be helpful to know this if you’re adjusting the permissions of various items, or even if you’re moving files on the Mac and want to maintain the exact permissions and to verify it after the fact. There are countless other uses as well, particularly if you’re running a server of any sort from the Mac.

These commands should work the same for retrieving octal permissions in just about any version of macOS, MacOS, or Mac OS X, regardless of how the naming convention is capitalized. Notably however, is that the approach to getting octal permissions on the Mac is different from the rest of the Linux world, thus if you’re coming to the Mac from the Linux world you’ll need to adjust the stat command flags to accurately get the permissions in octal format, we’ll cover that quickly next.

Getting Octal File Permissions from Command Line in Linux

For the sake of being thorough, we’ll briefly discuss getting octal permissions values in the Linux world as well, where you can use the following to get the octal file permissions:

stat -c "%a %n" /Path/To/File

You can also more simply use the stat -c command:

stat -c %a /Path/To/File.txt

The numerical value output will be the same regardless, as long as the inputted target file is the same of course.

Again, these latter two approaches are linux specific, and you’ll need to use the methods outlined further above to get octal values of permissions of a file in Mac OS.


What Is The Command Key On Windows Keyboard?

The command key is known by many names, cmd key or the Apple key. However, it is only known to those who are familiar with the Apple ecosystem. As for Windows users, it might sound foreign.

The alternative to the Command key makes no sense for someone who has recently switched from Mac to Windows. But, thankfully, there is a solution.

Is There a Command Button on the Windows Keyboard?

There is no command button on a Windows-based keyboard. The closest buttons that work similarly to the Cmd key are:

Start/Windows key with the Windows logo label

Control key with Ctrl label

How to Do a Command Key on a Windows Keyboard?

The command key is mostly used to perform routine shortcuts on a Mac. To access the same shortcut on a Windows keyboard, you can use the Control key. The ctrl key can be used similarly to the command key. Here are a few examples.

ShortcutOn Mac keyboardOn Windows keyboardPrintCommand + PControl + PSaveCommand + SControl + SCopyCommand + CControl + CPasteCommand + VControl + VSelect allCommand + AControl + A

Where Is the Command Key on the Windows Keyboard?

There is no command key on the Windows keyboard. If you connect a Windows keyboard to a Mac system, the computer does what we call a key substitution. This means that the command key is mapped to a different key on the Windows keyboard. Unless changed, the Command key can be achieved by pressing the Control or Ctrl key on your keyboard.

How to Map the Command Key on a Windows Keyboard?

By default, the command key is mapped to the Control key. Or, you can map it to a different modifier key by following these steps on a Mac OS.

Go to the Apple menu and select System Preferences.

Select Keyboard.

On the Keyboard tab, select Modifier Keys.

Select the keyboard that you want to change the mapping for.

Select the dropdown list next to the Command key and choose a different option.

Test your new command key to suit your needs.

Note that, Whichever key you map it to, make sure that key isn’t being used by a different modifier key. For example, if you map the command key to the option then make sure the option key is mapped to the command.

How to Change the Command Key on Windows?

To change the command key on windows, follow these steps.

Download and install the Mouse and Keyboard Center by Microsoft.

Open the app from the Start Menu.

Select the command key that you want to change.

Select the target key.

If your keyboard is not detected by the app, use this software called SharpKeys to change the key. This app is works on all versions of Windows including Windows 11.

Open SharpKeys from the Start Menu.

Select Add.

Under the From key, scroll down and select Left Ctrl.

Under the To key, select a different key such as Left Windows or Fn.

Press OK.

How to Fix the Command Key Not Working on the Windows Keyboard?

If the command key is not working, first you need to check if the key is physically damaged. By default, the system maps the command key to the Control key.

Use an online checker like this to press the key on your keyboard. If the on-screen button doesn’t light up, the button is physically inaccessible. Using SharpKeys, you can map the command key to a different button instead. Just make sure that the From key is set to Left Ctrl and change the To key to a working button.

There are tons of keyboard mapping apps available online. This website lists some popular alternatives to SharpKeys.

How to Disable the Command Key on Windows?

Windows does not provide a built-in method to disable the command key. There are many third-party apps that make disabling easier. SharpKeys is primarily used to map the command key on Windows. But, we can also use it to disable the key entirely. Make sure that the To key is mapped to Turn Key Off at the beginning of the list.

Top 35 Generative Ai Tools By Category (Text, Image…)

As Gartner states, generative AI is one of the top strategic technology trends of 2023.

Based on a function-based classification, we will examine the top generative AI tools in this article.

Visual Generative AI Image Generators Video Generators

Generative AI enables  text-to-video conversion within minutes. These AI-generated videos are used in the sectors of education, marketing, and social media.

ToolsPricingFree VersionFeatures Synthesia$30 per month for ‘Personal’ packageYes (Except customization and video editing)Enables text-to-video conversion; provides more than 70 avatars; offers its services in more than 65 languages Lumen5$19 per month for ‘Basic’ packageYes (Limited to 720p video resolution)Offers templates to create original videos based on presentations, or online meeting recordings Flexclip$5.99 per month for ‘Basic’ packageYes (Limited to 12 projects)Supports video creation; offers video editing tools, such as adding transitions, filters, or removing backgrounds$12 per month for ‘Basic’ packageFree (Limited to 250MB upload size)Video generation and editing, adding subtitles, removing background noises, and resizing the videos

Design Generators

Using generative AI, personalized web designs, color palettes, logos, and other design elements can be created. Social media content creation and graphic design are the main beneficiaries of these tools.

ToolsPricingFree VersionFeatures KhromaFreeYesAllows training a personalized algorithm to create genuine color palettes

Audio Voice Generators

ToolsPricingFree VersionFeatures Replica$24 for 4 hours speechYes (Limited to 30 minutes)Enables text-to-speech conversion, and offers AI-generated voices Murf$11.58 per month for ‘Basic’ packageYes (Limited to 10 minutes of voice generation)Creates voice overs for different contexts, enables adding punctuation, and provides the commercial rights of the content$14.25 per month for ‘Personal’ packageYes (Limited use of conversion)Provides AI-generated voices useful for various commercial purposes, offers services in more than 140 languages, and enables text-to-speech conversion$17.49 per month for ‘Personal’ packageYes (Limited download option)Enables text-to-speech conversion, generates realistic and emotive AI-generated voiceover

Music Generators

Through generative AI, users can create music and lyrics based on their preferences of style, genre, etc. There are many uses for these tools in creative fields, including games, movies, and education.

ToolsPricingFree VersionFeatures AIVA$11 per month for ‘Standard’ packageYes (Limited download option)Creates authentic music based on your preferred style, and gives the copyright of the produced content Amper AI$5 per month for ‘Personal’ packageYes (Without providing license)Produces royalty-free music based on the preferred genre, length, instruments, and provides perpetual license JukeboxContact vendor for pricingContact vendor for free versionCreates authentic music with AI-generated lyrics, provides users with different genre options Soundraw$19.99 per month for ‘Solo’ packageFree trialEnables original music creation and commercial use of the produced content Evoke$8 per month for ‘Personal’ packageFree trial for 14 daysGenerates AI-generated and royalty-free music collection

Text Generators

ToolsPricingFree VersionFeatures Peppertype$35 per month for ‘Personal’ packageFree trialOffers ready-made templates for creating meta descriptions, articles, and e-mails; enables commercial use of the produced content$49 per month for ‘Pro’ package including 40K wordsYes (Limited to 2,000 words)Enables the generation of blog posts, social media posts, and e-mails, provides multi-user choice, and offers content creation service for more than 25 languages

Code Generators

Text-to-code conversion is made possible by generative AI, and AI-powered code generators optimized for various programming languages are capable of code completion and custom model suggestions.

ToolsPricingFree versionFeatures Tabnine$12 per month for ‘Pro’ packageFree trial for 14 daysProvides the users with whole-line code completion, and learns coding patterns K-ExplorerContact vendor for pricingContact vendor for free versionMakes code completion and custom model suggestions PyCharm$9.90 per month for professional developersYesProvides the users with code completion, highlights errors, and enables automated refactoring KiteFreeYesProvides the users with multi-line code completions, supports more than +16 languages OpenAI CodexContact vendor for pricingContact vendor for free versionConverts the natural language to code, usable in more than +12 programming languages

Note: The information above is all based on vendor claims.

Cem regularly speaks at international technology conferences. He graduated from Bogazici University as a computer engineer and holds an MBA from Columbia Business School.





Update the detailed information about Thirteen Useful Tools For Working With Text On The Command Line on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!