Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-30-2011, 02:28 PM   #1
Registered: May 2010
Posts: 354

Rep: Reputation: 34
A problem with tabs


I've written a c program which uses tab characters in the output. Output goes to stdout.

When I run it at the terminal command line - output is tabbbed.

If I direct output to a file (./program > book.txt) , and use "more" to display the file, output is tabbed.

If I send the file to my HP 1020 printer, output is not tabbed. I get a space at the location of each tab character.

If I try to open the file with gedit, gedit refuses to open it and says that it has not been able to detect the character encoding. I try all the obvious choices and it rejects them all.

If I try to open it with notepad, notepad opens it and shows the output as tabbed.

If I display it with od, I see the hex 09 characters in the file.

1) what is happening and why?

2) as I recall there is a utility that lets me change the attributres of a file. I imagine I can correct the encoding, but I dont remember what utility.

3) is there sometihng that i need to do as regards compiler settings to get the file marked correctly?
Old 04-30-2011, 04:54 PM   #2
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
The expand utility will convert tabs to spaces. That may solve the problem with your printer. How Gedit interprets your file encoding depends on what else it contains. Perhaps a better editor will work around the problem. Have you tried opening it in Vim?
1 members found this post helpful.
Old 04-30-2011, 07:44 PM   #3
Registered: May 2010
Posts: 354

Original Poster
Rep: Reputation: 34
thanks - expand replaced the tab characters with spaces
Old 05-05-2011, 02:30 PM   #4
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
FWIW, pr is more complex & therefore more flexible; & of course harder to use.

W/ the right options it can convert spaces back to tabs. Piped into itself (w/ the right options) it can convert n spaces to tabs, & then the tabs to m spaces.

It does not have:
-t, --tabs=LIST
use comma separated list of explicit tab positions

Post 4500, 1.88 ppd

Last edited by archtoad6; 05-05-2011 at 03:00 PM. Reason: add post count


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
can vim have tabs attached to viewports instead of viewports attached to tabs? frznchckn Linux - Software 0 11-17-2010 08:15 PM
Vim problem with tabs and session nicostcado Linux - Software 1 12-14-2008 11:03 AM
Firefox - Tabs Problem Irajas Linux - Software 5 05-14-2007 03:29 PM tabs Smokey Linux - Software 0 11-09-2004 01:52 AM
Emacs problem with tabs Nylex Linux - Software 2 09-03-2004 04:28 AM > Forums > Linux Forums > Linux - Newbie

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

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