Sponsored Content
Top Forums Shell Programming and Scripting Remove 3rd and onwards occurances of a character Post 302435714 by Shivdatta on Thursday 8th of July 2010 07:19:07 AM
Old 07-08-2010
Yes I am on solaris.
I tried your command,it does not give error but the o/p is different than what
i am expecting.It is removing all the occurances of "@".Seems it is not able to interpret "4" alongwith "g".

Code:
$/usr/xpg4/bin/sed 's/@/ /4g' test.dat
fdgfgddfg sfsdfdsf dfdfd  vfdfsdfd
sfsdfs sdfd gfhfgh  ddffg sdf
srfgtfsdfs sdfertrd eergfhfgh  ddffg sdf
wttrtrt sdfd sdfdf  sdfdfds



---------- Post updated at 02:29 PM ---------- Previous update was at 02:25 PM ----------

Yes I am on solaris.
I tried your command,it does not give error but the o/p is different than what
i am expecting.It is removing all the occurances of "@".Seems it is not able to interpret "4" alongwith "g".

Code:
$/usr/xpg4/bin/sed 's/@/ /4g' test.dat
fdgfgddfg sfsdfdsf dfdfd  vfdfsdfd
sfsdfs sdfd gfhfgh  ddffg sdf
srfgtfsdfs sdfertrd eergfhfgh  ddffg sdf
wttrtrt sdfd sdfdf  sdfdfds



---------- Post updated at 04:49 PM ---------- Previous update was at 02:29 PM ----------

The perl command works fine but when i try to create a perl file with contents
Code:
#!/usr/local/bin/perl
perl \-pe "$c=0; s/(\t)/ ++$c<=23 ? $1 : ""/eg" "src.dat" > "dest.dat"

it gives me an error.

Do i need to change anything in the perl file

Last edited by Franklin52; 07-08-2010 at 08:21 AM.. Reason: corrected code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to change every 3rd character

hey champs, i have a files, whose contents are as follows, abcdefghijk lmnopqrstuv .............. .............. i want to replace every other 3rd character to some specified character. let here in this file i want to replace each 3rd character to z. abzdezghzjk lmzopzrszuv... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

2. Shell Programming and Scripting

Count occurances of a character in a file

I want to find the number of occurences of a character in a file. How do i do it. Eg: $cat file1.txt Welcome to World of Unix. $ If i want to find the occurences of 'o' then I should be getting 3. Thanks. (6 Replies)
Discussion started by: Shivdatta
6 Replies

3. Shell Programming and Scripting

Merging lines based on occurances of a particular character in a file

Hi, Is there any way to merge two lines based on specific occurance of a character in a file. I am having a flat file which contains multiple records. Each row in the file should contain specified number of delimiter. For a particular row , if the delimiter count is not matched with... (2 Replies)
Discussion started by: mohan_tuty
2 Replies

4. UNIX for Advanced & Expert Users

if 4th and 5th character of sting -ge 45 then add 1 to 3rd character

I want to know how to, given a string like W87151WR71C, if the 4th and 5th character (in this case 15) are greater than 45, then to add 1 to the 3rd character (in this case 7) and assign the revised string the variable name MODSTRING. Thanks in advance. This is ultimately to grab info from... (6 Replies)
Discussion started by: glev2005
6 Replies

5. Shell Programming and Scripting

Replace multiple occurances of same character with a single character.

Hi all, Greetings, I have the following scenario, The contents of main file are like : Unix|||||forum|||||||||||||||is||||||the||best so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it And i need the output in the following form: Unix=forum=is=the=best so=be=on=it ... (3 Replies)
Discussion started by: dipanchandra
3 Replies

6. Shell Programming and Scripting

Remove 3rd character from the end of a random-length string

Hi, I hope someone can share there scripting fu on my problem, I would like to delete the 3rd character from a random length of string starting from the end Example Output Hope you can help me.. Thanks in advance.. (3 Replies)
Discussion started by: jao_madn
3 Replies

7. Shell Programming and Scripting

Replace first 3 occurances of a character in a file for each line

Hi all, I am very new to unix - ksh. I want to replace some characters in a file with some other, but only for first three occurances for each line. For eg: the first 3 occurances character ']' has to be replaced with ',' in each line. Please help. thanks Sreejith (1 Reply)
Discussion started by: rsreejithmenon
1 Replies

8. Shell Programming and Scripting

[Solved] Replace character in 3rd column and leave 1rst and last

Hello to all, I have the following text where columns are separated by spaces. I want to have the 3rd column separating 3 strings with 2 "_" in the format below: LeftSring_CentralString_RightString So, in 3rd column I want to replace all "_" with "-", except the first and last "_" The... (5 Replies)
Discussion started by: Ophiuchus
5 Replies

9. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies
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)
All times are GMT -4. The time now is 05:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy