Get first 5 characters from a string in Linux

The cut command is your best friend when it comes to tasks like this. In the following examaple I want to extract only the first 5 characters from a database export file.

example.txt contains

This is your solution:

To export this result into another file:


Alternative approaches



(170 Posts)

20 years of coding and working as software engineer but I am still eager to learn more. I am very passionate when it comes to open source, Linux and Java. But I made my peace with Windows long ago to fully enjoy my PC gaming hobby. I have a soft spot for 90s electronic music and Babylon 5. In the evenings you will find me roaming the endless space in Warframe (IGN k05h).