How to Deal With Spaces in Filenames on Linux

If you have a filename with spaces on a Linux system, wrapping your filename in quote marks lets Bash treat it correctly. Tab completion makes entering filenames on the command line easy, even if they contain spaces.

Like most operating systems, Linux supports filenames with spaces in them. But using these filenames on the command line isn’t always straightforward. Here are several ways you can handle filenames containing spaces.

[mai mult...]

How to Delete Files and Directories in the Linux Terminal

Type “rm (filename)” in the Terminal to remove a file on Linux. To remove an entire folder (or directory) and all of its contents, type “rm -r (foldername)” into the Terminal instead.

The rm and  rmdir commands delete files and directories on Linux, macOS, and other Unix-like operating systems. They’re similar to the del and  deltree commands in Windows and DOS. These commands are very powerful and have quite a few options. It is important to note that files and directories deleted using rm and rmdir do not get moved to the Trash. They are immediately removed from your computer. If you accidentally delete files using these commands, the only way you’ll be able to restore them is from a backup.

[mai mult...]

How to Use the wc Command in Linux

The wc command is a small application. It’s one of the core Linux utilities, so there is no need to install it. It’ll already be on your Linux computer. You can describe what it does in a very few words. It counts the lines, words, and bytes in a file or selection of files and prints the result in a terminal window. It can also take its input from the STDIN stream, meaning the text you want it to process can be piped into it. This is where wc really starts to add value.

It is a great example of the Linux mantra of “do one thing and do it well.” Because it accepts piped input, it can be used in multi-command incantations. As we’ll see, this little standalone utility is actually a great team player.

One way I use wc is as a placeholder in a complicated command or alias I’m cooking up. If the finished command has the potential to be destructive and delete files, I often use wc as a stand-in for the real, dangerous command. That way, during the development of the command I get visual feedback that each file is being processed as I expected. There’s no chance of anything bad happening while I’m wrestling with the syntax.

As simple as wc is, there are still a few small quirks that you need to know about.

[mai mult...]