LinuxQuestions.org
Register a domain and help support LQ
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 09-12-2012, 08:55 AM   #1
bashari
LQ Newbie
 
Registered: Sep 2012
Posts: 3

Rep: Reputation: Disabled
How to remove ^L control characters from text files?


Hi All,

When i try to edit the file i m getting this symbol : ^L

its related to clear the screen and redraw so its not letting me to grep any pattern .

1. I want to remove this Symbol : ^L

Thanks in advance.

Regards
Basha G
 
Old 09-12-2012, 09:29 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Hi and welcome to LinuxQuestions!

Ctrl-L is a hidden control character that stats for Form Feed or New Paper sheet. You can find it in the ASCII table at position 12, or better:
Code:
Dec  Hex  Oct  Char  Description
12   C    014  FF    NP Form Feed, new page
You can reproduce it in a terminal using this sequence of keystrokes
Code:
Ctrl-V Ctrl-L
where the first Ctrl-V summons the shell to display a control character. To remove it from a text file, you can either use this sequence of keystrokes or his octal/hex/decimal code taken from the ASCII table.

For example using sed you can do something like this (by typing Ctrl-V and Ctrl-L):
Code:
sed 's/^L//' file
or by means of the octal code:
Code:
sed 's/\o14//' file
Take in mind that to actually change the content of a file using sed, you have to use the -i option. Without -i the output is sent to the terminal (standard output) which is useful for testing the command until it gives the desired result. Hope this helps.
 
1 members found this post helpful.
Old 09-12-2012, 12:36 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
To be more specific, ^L is the caret notation for that non-printing ascii character.

tr is usually the most efficient solution for simple character removal jobs, although you have to work through at temporary file to do it.

Code:
tr -d '\014' <infile.txt >outfile.txt
 
  


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
Need to remove the first three characters in the name of a ton of files... ooagentbender Linux - Newbie 17 10-04-2013 03:02 PM
Supressing control characters in GTK+ based GUI's text area display iamck25 Linux - Newbie 0 06-13-2012 04:54 PM
Rename all files in dir to remove first nine characters zappadragon Linux - Newbie 4 11-13-2011 07:00 AM
Viewing control characters in a text file dmorse Linux - General 2 01-07-2007 12:10 AM
Clearing control characters from a text file LinuxLala Linux - General 1 04-07-2006 07:45 AM


All times are GMT -5. The time now is 08:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration