Solved

Linux: Using echo to copy file with whitespace removed

Posted on 2013-11-01
3
318 Views
Last Modified: 2013-11-01
I use this to copy the text content of ''xyz.txt" to "ttt.txt":
echo $(< xyz.txt) > ttt.txt

Open in new window


How can I copy it with all whitespace removed?  All spaces, newlines and tabs should be REMOVED in the "ttt.txt" version.
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 100 total points
ID: 39616478
All spaces, tabs and newlines? Really?

OK, so:

tr -d "[:space:]" < xyz.txt > ttt.txt
0
 
LVL 11

Accepted Solution

by:
MajorBigDeal earned 400 total points
ID: 39616483
cat xyz.txt | tr -d " \t\n\r" > ttt.txt
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39616599
Why do you think MajorBigDeal's solution is so much better than mine?

Please don't confuse "[:space:]" and "[:blank:]". The latter matches just spaces (!), but the former matches space, tab, vertical tab, line feed (newline),  form feed and carriage return.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question