LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-14-2017, 08:38 AM   #1
rokyo
Member
 
Registered: Oct 2012
Distribution: Ubuntu Mate 18.04 (production), Arch rolling (tinkering)
Posts: 102

Rep: Reputation: Disabled
Remove numbers, spaces, line breaks & paragraphs from .txt on CLI


Hi everybody!

I am looking for a way to strip all non-letter characters (i.e. spaces, numbers, line breaks and paragraph breaks) from a .txt file using the terminal, so that afterwards the .txt file will be just a loooooooong single line of letters. I want to keep upper and lower case, though.

Thank you in advance for any help!

rokyo
 
Old 08-14-2017, 08:59 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,129

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
"man tr"
Can be achieved with a single invocation.
 
1 members found this post helpful.
Old 08-14-2017, 08:59 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,310
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
I would look at tr or sed for that. It is easy in either. Try tr first as it is simpler.
 
1 members found this post helpful.
Old 08-14-2017, 09:20 AM   #4
rokyo
Member
 
Registered: Oct 2012
Distribution: Ubuntu Mate 18.04 (production), Arch rolling (tinkering)
Posts: 102

Original Poster
Rep: Reputation: Disabled
Thanks, tr worked perfectly with:

Code:
tr -cd [:alpha:] < test.txt > test_processes.txt
Took maybe 2 seconds on CLI, while doing this in LibreOffice made my computer run out of RAM and crash.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
remove line spaces and add new line entry for array sam.987 Linux - Newbie 2 06-25-2017 09:57 PM
how to remove a line from a txt file graziano1968 Linux - General 16 11-07-2009 05:17 PM
[SOLVED] vim remove line breaks ColInvictus Linux - Newbie 3 09-27-2009 08:10 PM
[SOLVED] Remove extra spaces in a line vikas027 Programming 11 10-11-2008 08:20 AM
remove all spaces from a line in C xeon123 Programming 12 10-23-2007 01:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration