Bootstrap FreeKB - Linux Commands - fold (wrap text)
Linux Commands - fold (wrap text)

Updated:   |  Linux Commands articles

Let's say foo.txt contains a very long string, like this.

asdfakjdslkfjkllk343lk434l3klkjvsdfsiwqepoqwpisdfsddslkjpizndf3498sdf

 

The fold command with the -w option can be used to wrap the content of foo.txt. In this example, the string will be wrapped at every 10th character.

fold -w 10 foo.txt

asdfakjdsl
kfjkllk343
lk434l3klk
jvsdfsiwqe
poqwpisdfs
ddslkjpizn
df3498sdf

 

Note that fold will not actual update the file in question. Redirection can be used to create a new, folded file.

fold -w 10 foo.txt > bar.txt

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter d399fb in the box below so that we can be sure you are a human.