Sponsored Content
Top Forums Shell Programming and Scripting remove chunks of text from file Post 302340885 by staze on Tuesday 4th of August 2009 03:10:13 PM
Old 08-04-2009
okay, whatever.

figured I might learn some regex in the process, but I'll just do it the PHP way and be done with it.

Thanks, I suppose.

---------- Post updated at 12:10 PM ---------- Previous update was at 11:40 AM ----------

How about this then...

Can anyone think of a more streamlined version of this (mainly the multiple pipes to sed):

Code:
#!/bin/sh

INPUT=';ApplePasswordServer;0x49e8c2c668dbcb0200004a090000342a,1024 35 142348687369980182134507175767473848406728018835938950439244504199810591467084867869429532763785664902803450035110236201552277202539905523086333992178101548673534094938083763850217881171960226316582341046758647121979394968026644558722582733133246430363127883800192071325741645982074225105651514207812440564579 root@ldap.example.com:123.456.789.111'

OUT1=`echo "$INPUT" | sed 's/ApplePasswordServer/Kerberosv5/' | sed 's/\,/;username@REALM.EXAMPLE.COM;REALM.EXAMPLE.COM;/'`

echo $OUT1

Otherwise, this'll work.

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove specified text from file

I am trying to write a script that kills old sessions, I've posted here over the past few days and the script is just about perfect except I want to be given the option to exclude specified PIDs from being killed. this is the entire script: if then rm /tmp/idlepids fi if then rm... (2 Replies)
Discussion started by: raidzero
2 Replies

2. Shell Programming and Scripting

Remove filename is text file

Hello, I got files full path in a text file like that /main/k/kdelibs/kdelibs4c2a_3.5.10.dfsg.1-2ubuntu7_i386.deb /main/k/kdelibs-experimental/libknotificationitem-dev_4.3.2-0ubuntu1_i386.deb /main/k/kdemultimedia/dragonplayer_4.3.2-0ubuntu1_i386.deb... (13 Replies)
Discussion started by: davidkhan
13 Replies

3. Shell Programming and Scripting

Split file into chunks of low & high byte

Hi guys, i have a question about spliting a binary file into 2 chunks. First chunk with all high bytes and the second one with all low bytes. What unix tools can i use? And how can this be performed? I looked in manpages of split and dd but this does not help. Thanks (2 Replies)
Discussion started by: basta
2 Replies

4. Shell Programming and Scripting

Parsing chunks of text and finding data

Hi, I need a script that parses and greps data out of a textfile. I have a text file that has this structure: File1 host1.localdomain text random text Found errors this text is random (41123) --- random random at.5165 ---- random random at.5165 ---- random random at.5165 ----... (2 Replies)
Discussion started by: erick_tuk
2 Replies

5. UNIX for Dummies Questions & Answers

Awk: Print out overlapping chunks of file - rows 0-20,10-30,20-40 etc.

First time poster, but the forum has saved my bacon more times than... Lots. Anyway, I have a text file, and wanted to use Awk (or any other sensible program) to print out overlapping sections, or arbitrary length. To describe by example, for file 1 2 3 4 5 etc... I want the out put... (3 Replies)
Discussion started by: matfald
3 Replies

6. Shell Programming and Scripting

awk for splitting file in constant chunks

Hi gurus, I wanted to split main file in 20 files with 2500 lines in each file. My main file conatins total 2500*20 lines. Following awk I made, but it is breaking with error. awk '{ for (i = 1; i <= 20; i++) { starts=2500*$i-1; ends=2500*$i; NR>=starts && NR<=ends {f=My$i".txt"; print >> f;... (10 Replies)
Discussion started by: mukesh.lalwani
10 Replies

7. Shell Programming and Scripting

Reverse sort on delimited chunks within a file

Hello, I have a large file in which data of names is sorted according to their homographs. The database has the following structure:Each set of homographs with their corresponding equivalents in Devanagari is separated out from the next set by a hard return. An example will make this... (12 Replies)
Discussion started by: gimley
12 Replies

8. Shell Programming and Scripting

Splitting a file into chunks of 1TB

Hi I have a file with different filesystems with there sizes. I need to split them in chucks of 1TB. The file looks like vf_MTLHQNASF07_Wkgp2 187428400 10601AW1 vf_MTLHQNASF07_Wkgp2 479504596 10604AW1 vf_MTLHQNASF07_Wkgp2 19940 10605AID vf_MTLHQNASF07_Wkgp2 1242622044... (4 Replies)
Discussion started by: bombcan
4 Replies

9. Shell Programming and Scripting

Deleting duplicated chunks in a file using awk/sed

Hi all, I'd always appreciate all helps from this site. I would like to delete duplicated chunks of strings on the same row(?). One chunk is comprised of four lines such as: path name starting point ending point voltage number I would like to delete duplicated chunks on the same... (5 Replies)
Discussion started by: jypark22
5 Replies

10. Shell Programming and Scripting

How to remove the text between all curly brackets from text file?

Hello experts, I have a text file with lot of curly brackets (both opening { & closing } ). I need to delete them alongwith the text between opening & closing brackets' pair. For ex: Input:- 59. Rh1 Qe4 {(Qf5-e4 Qd8-g8+ Kg6-f5 Qg8-h7+ Kf5-e5 Qh7-e7+ Ke5-f5 Qe7-d7+ Qe4-e6 Qd7-h7+ Qe6-g6... (6 Replies)
Discussion started by: prvnrk
6 Replies
Text::WikiFormat::Blocks(3pm)				User Contributed Perl Documentation			     Text::WikiFormat::Blocks(3pm)

NAME
Text::WikiFormat::Blocks - blocktypes for Text::WikiFormat SYNOPSIS
None. Use Text::WikiFormat as the public interface, unless you want to create your own block type. DESCRIPTION
This module merely creates subclasses of Text::WikiFormat::Block, which is the interesting code. A block is a collection of related lines, such as a code block (text to display verbatim in a monospaced font), a header, an unordered list, an ordered list, and a paragraph (text to display in a proportional font). Every block extends "Text::WikiFormat::Block". METHODS
The following methods exist: o "new( %args )" Creates and returns a new block. The valid arguments are: o "text" The text of the line found in the block. o "args" The arguments captured by the block-identifying regular expression. o "level" The level of indentation for the block (usually only useful for list blocks). o "tags" The tags in effect for the current type of wiki formatting. o "opts" The options in effect for the current type of wiki formatting. Use the accessors of the same names to retrieve the values of the attributes. o "add_text( @lines_of_text )" Adds a list of lines of text to the current text for the block. This is very useful when you encounter a block and want to merge it with the previous block of the same type o "add_args( @arguments )" Adds further arguments to the block; useful when merging blocks. o "formatted_text()" Returns text formatted appropriately for this block. Blocks don't have to have formatters, but they may. o "formatter( $line_of_text )" Formats the $line using "Text::WikiFormat::format_line()". You can add your own formatter here; this is worth overriding. o "merge( $next_block )" Merges the current block with $next_block (the next block encountered) if they're of the same type and are at the same level. This adds the text and args of $next_block to the current block. It's your responsibility to remove $next_block from whatever your code iterates over. o "nests()" Returns true if this block should nest (as in lists and unordered lists) for the active wiki formatting. o "nest( $next_block )" Nests $next_block under this block if the both nest and if $next_block has a level greater than the current block. This actually adds $next_block as a text item within the current block. Beware. AUTHOR
chromatic, "chromatic at wgz dot org" BUGS
No known bugs. COPYRIGHT
Copyright (c) 2006, chromatic. Some rights reserved. This module is free software; you can use, redistribute, and modify it under the same terms as Perl 5.8.x. perl v5.10.1 2011-02-12 Text::WikiFormat::Blocks(3pm)
All times are GMT -4. The time now is 07:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy