LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices

Old

sed awk tr etc

Posted 01-15-2013 at 06:33 AM by NullTerminator
Updated 01-18-2013 at 06:54 AM by NullTerminator (add sed cmd for non prinitng char)

A couple sample to strip unreadable characters from a binary file
Code:
# Translate junk characters into newlines while squeezing
C:\Temp>tr -sc '[\011\012\015\040-\176]' \n < blob_of_data.txt

# Translate and discard single character lines
C:\Temp>tr -sc '[\011\012\015\040-\176]' \n < blob_of_data.txt | awk "length($0) > 1"
# replace a bad character in a file
0xa0 is a 'non breaking space' that appears often when...
LQ Newbie
Posted in Uncategorized
Views 563 Comments 0 NullTerminator is offline
Old

Pure-text de-truncator script, a work in progress

Posted 09-30-2012 at 01:28 PM by the dsc (linux-related notes)
Updated 09-30-2012 at 01:32 PM by the dsc
Tags epub, pdf, sed, truncated

Sometimes I want to quote some PDF on pure text, luckily enough it would have actual text rather than being an non-OCRed image, but often there's still the problem that the text on the PDF is truncated/formatted in a fake/dumb way, with actual "new lines" to break the page, which may not make the text completely unreadable when pasted in a text editor, but it's reasonably annoying, and may require quite some time to fix manually.

I'm trying to create a script or one-liner...
Member
Posted in Uncategorized
Views 491 Comments 0 the dsc is offline
Old

Selecting fields from a line using "sed"

Posted 12-25-2011 at 12:51 AM by Telengard (Here are some things which I hope will be helpful.)
Updated 12-26-2011 at 10:24 PM by Telengard
Tags sed

Yeah, sed ...

No matter how well I think I know sed, it still manages to bite me more often than serve me. Everything I do know about sed, manuals aside, I learned from other programs like ed, vi, and even awk. What I'm getting to is this: my sed-fu is weak, so don't take anything I say about it at face value. Do your own research and learn better for yourself (which you ought to do regardless).

About portability

I'll be using the --posix option with GNU sed...
Member
Views 3157 Comments 0 Telengard is offline
Old

Joining records using sed or awk

Posted 07-01-2009 at 07:34 AM by JimRobinson
Tags awk, line join, sed

I have a very large file, 9 million records, and there are sections in the file where I need to join records. How can I get for example line number 100,000 and join to it lines 100,001-100,050 using sed or awk? The joins need to happen multiple times throughout the file. I can get the line number for the first and last line I need in my join but am having difficulty figuring out how to reformat the file with the lines joined and the file saved with the one end-resulting line.

Any...
LQ Newbie
Posted in Uncategorized
Views 1788 Comments 2 JimRobinson is offline

  



All times are GMT -5. The time now is 04:52 AM.

Main Menu

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration