Help with deleting some parts from text file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with deleting some parts from text file
# 8  
Old 06-02-2012
Quote:
Originally Posted by jawsnnn
If you don't want to rely on properly formatted code, here is a script that keeps track of left and right parentheses counts to do this

Code:
#!/bin/ksh
count_prev=0
count=0
mask=false
while read line
do
  if [ `echo $line | grep -cw HOME` -eq 1 ]; then
    mask=true
    count_l=0
    count_r=0
    count=0
  fi  
  let count_l=count_l+`echo $line | grep -c '('`
  let count_r=count_r+`echo $line | grep -c ')'`
  count=$(expr $count_l - $count_r)
  if [ $mask == "false" ]; then
    echo $line
  elif [ $count_prev -eq 0 -a $count -eq 0 ]; then
    echo $line
    mask=false
  fi  
  count_prev=$count
done < in_file

wow, i will test this and come back. Thanx a lot Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove answers and explanation parts from a text file with lots of questions.?

Hi, I have a text file with thousands of questions in it. Each question (multiple lines) with multiple choice options, Answer and Explanation (optional). I need to delete Answer & explanation parts for all Questions and insert a blank line before net question. Each question starts with NO. I... (4 Replies)
Discussion started by: prvnrk
4 Replies

2. UNIX for Dummies Questions & Answers

Deleting Block of Text from a File

Hi I am looking for the way to delete the block of data for example original file line1 line2 line3 line4 line5 input file line2 line3 original file should contain line1 line4 line5 (3 Replies)
Discussion started by: rakeshkumar
3 Replies

3. UNIX for Dummies Questions & Answers

Deleting specific rows from a text file

How do I go about deleting specific rows from a text file (given row number)? (5 Replies)
Discussion started by: evelibertine
5 Replies

4. UNIX for Dummies Questions & Answers

Help with deleting characters from text file

I have a text file that looks like this: I want to delete the last character of first column in all rows so that my output looks like this: Thanks a lot! (1 Reply)
Discussion started by: evelibertine
1 Replies

5. UNIX for Dummies Questions & Answers

Deleting all instances of a certain character from a text file

In my command prompt I did: sed 's/\://' mytextfile > newtextfile But it only deleted the first instance of : in each line when some lines have multiple : appearing in each one. How can I delete all the : from the entire file? (1 Reply)
Discussion started by: guitarscn
1 Replies

6. Shell Programming and Scripting

How can i break a text file into parts that occur between a specific pattern

How can i break a text file into parts that occur between a specific pattern? I have text file having various xml many tags like which starts with the tag "<?xml version="1.0" encoding="utf-8"?>" . I have to break the whole file into several xmls by looking for the above pattern. All the... (9 Replies)
Discussion started by: abhinav192
9 Replies

7. Shell Programming and Scripting

deleting certain parts of a line in perl

I have a filr data.txt. Its contents are Available labels (* indicates activated, I indicates installed, R idicates running): abc-3.0.3 def-3.0.4 xyz-3.1.2-1.0 I want to delete " Available labels (* indicates activated, I indicates installed, R idicates running):" and... (3 Replies)
Discussion started by: lassimanji
3 Replies

8. UNIX for Dummies Questions & Answers

Deleting lines in text file

Hi everyone, I have text files that I want to delete lines from. I have searched through this forum for quite some time and found examples of both awk and sed. Unfortunately, I was not able to successfully do what I want. Well to some extent. I did manage to delete the first 15 lines from each... (5 Replies)
Discussion started by: hern14
5 Replies

9. Shell Programming and Scripting

Deleting text block in file

Need to delete a text block inside a file, that is marked with a start and an end pattern. Eg do not delete not delete <tag1> delete everything here here and here and here... <tag2> do not delete do not delete.... Believe sed is able to do this job but don't get it working. ... (1 Reply)
Discussion started by: andre123
1 Replies

10. Shell Programming and Scripting

Deleting text from a file

Hi, In my korn shell script, I want to delete some particular text from a certain file...How can this be done? Is the below right? ed $NAMES << EOF echo "" > /dev/null echo "${x} = " > /dev/null echo "name = " > /dev/null echo "adress = " > /dev/null w q EOF (1 Reply)
Discussion started by: n8575
1 Replies
Login or Register to Ask a Question
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)