LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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: 19,774

Rep: Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572Reputation: 3572
"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: 5,661
Blog Entries: 3

Rep: Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 03:55 PM.

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