LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 568 Comments 0 NullTerminator is offline
Old

editing a text file

Posted 03-26-2012 at 08:58 AM by arn2025
Tags awk, text files

i want to edit this text file and remove the column with the arts and also edit the separator & so that they become columns.
old text

ANNE 2453 3564 M@M.U 1 O&C&TY
JUDE 3453 2345 n@m.u 1 W&Y&TY
wend 3442 3773 h@y.u 1 O&C&TY
fill 3266 7473 g@m.u 1 W&T&TY
feat 3455 5544 1 W&C&TY
carl 3435 6723 1 Y&C&TY
wade 3442 7843 1 L&C&TY
jenw 7863 9028 1 P&C&TY
matt...
LQ Newbie
Posted in Uncategorized
Views 509 Comments 0 arn2025 is offline
Old

How to kill lines before and after a pattern

Posted 12-21-2011 at 05:45 PM by Telengard (Here are some things which I hope will be helpful.)
Updated 12-21-2011 at 06:27 PM by Telengard
Tags awk

PHP Code:
#! /usr/bin/awk -f

# Deletes n lines before pattern and m lines after.
# Intended to be portable.
# It is your own responsibility to evaluate the fitness of this program.

BEGIN {
    
# set the following initializers as you please
    # FS=" "
    # OFS=" "
    
n=5
    m
=3
}

/
line 11/ { # insert your desired regex "pattern" between the slashes
    
pattern_line=FNR 
...
Member
Posted in programming
Views 759 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 1790 Comments 2 JimRobinson is offline

  



All times are GMT -5. The time now is 03:10 PM.

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