LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-03-2011, 03:57 PM   #1
Quest ion
Member
 
Registered: Oct 2011
Posts: 45

Rep: Reputation: Disabled
less memo.txt question


When I type in the command "cat memo.txt", it displays the contents of the file in double spaced fashion.

When I try to remove those spaces by entering in "less memo.txt" , it removed the spaces between the lines of text, but at the end of each line is this, "^K".

To remove the "^K" what I ended up doing is make a new file called memo.new and typed the whole paragraph in by hand so then when I use the "less memo.new" it has no "^K" in it.

Is there a better way to accomplish this?
 
Old 10-03-2011, 04:26 PM   #2
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
^K is a vertical tab character. It is (in my observation) rarely used in documents but you've obviously found one of them.

You should be able to see the character when 'cat'-ing the file if you use the -b option for cat.

Removing it with vi or vim is pretty simple:

Code:
vi -b memo.txt

:g/<ctrl>v<ctrl>k/s///g

<ctrl>v allows you to enter an escaped character (such as <ctrl>k)

Obviously, don't type the text "<ctrl>whatever" but press the ctrl key and the specified character.
The best answer is, of course, modify the editor (human or otherwise) that created the file to avoid vertical tabs.
 
1 members found this post helpful.
Old 10-03-2011, 04:39 PM   #3
Quest ion
Member
 
Registered: Oct 2011
Posts: 45

Original Poster
Rep: Reputation: Disabled
Thanks! that helped alot! How do I exit from that file now though, I have tried ctrl c and d but to no avail....
 
Old 10-03-2011, 04:41 PM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
In vim, you probably want ":wq" to write and quit. If you're using less, then just pressing "q" will quit.
 
Old 10-03-2011, 04:44 PM   #5
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
Quote:
Originally Posted by Quest ion View Post
Thanks! that helped alot! How do I exit from that file now though, I have tried ctrl c and d but to no avail....
You're welcome.

Use vi's standard write-and-quit key sequences to exit.
Press the colon key then wq.

If the file is read-only or has other permissions issues, you may need to extend the sequence by forcing a write first.
To do that, :w!, then :q
 
1 members found this post helpful.
Old 10-03-2011, 04:46 PM   #6
Quest ion
Member
 
Registered: Oct 2011
Posts: 45

Original Poster
Rep: Reputation: Disabled
Ah! Thanks!
 
  


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
cut first 10 lines of file master.txt and paste in ab1.txt and so on yogeshkumkar Programming 4 08-31-2011 07:23 AM
Copy the contents of a txt file to other txt files (with similar names) by cp command Aquarius_Girl Linux - Newbie 7 07-03-2010 12:54 AM
cat onelinefile.txt >> newfile.txt; cat twofile.txt >> newfile.txt keep newline? tmcguinness Programming 4 02-12-2009 06:38 AM
Simple question for i in `cat move.txt` Noto Programming 13 05-25-2008 06:32 PM
rpm --verify -a > rpmcheck.txt Question klickibunti Linux - Security 3 08-26-2002 12:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:23 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