'How to add 10 spaces at the frontend | Unix |
I have a text file : ABC.txt which contain below data
A Apple a day keeps a doctor away
B I like to play with Ball
C I have cat at my home
D My Dog name is bob
I want to display output on my screen with 10 spaces in a frontend and then my file data
Expected output :
A Apple a day keeps a doctor away
B I like to play with Ball
C I have cat at my home
D My Dog name is bob
I have tried this but not working
Command :
cat ABC.txt | column -t
Solution 1:[1]
prefix=' '
sed "s/^/$prefix/" ABC.txt
^ matches the beginning of the line, and this replaces it with 10 spaces.
If the number of spaces can vary, you can calculate the prefix variable instead of hard-coding it. See How can I repeat a character in Bash?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
