Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replacing multiple special chars with single char Post 302821123 by smile689 on Friday 14th of June 2013 05:43:24 AM
Old 06-14-2013
Replacing multiple special chars with single char

Hi
I've a string . And i need to replace set of characters with a single character
Means .. or . or ... and so on should be replaced with single % character
Irrespective of number of dots in between the characters , those should be replaced with single %
All the above strings should be replaced with like below
For ex
Code:
abc..cd
bcd...ad
ac.rfd
Should be replaces with 
abc%cd
bcd%ad
ac%rfd

Please help in achieving this,
Thank You
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Special Char in Multiple Files

We develop a file in windows and move to unix box as a part of deployment. When we do this, we get ctrl-M(^M) character added to the file. So we need to remove ctrl-M(^M) character from all the files from deployment folder and all subfolders folder. Currently we move to individual folders and... (5 Replies)
Discussion started by: thinakarmani
5 Replies

2. Shell Programming and Scripting

treating special chars

Hi, I need some advise on treating non printable chars over ascii value 126 Case 1 : On some fields in the text , I need to retiain then 'as-is' and load to a database.I understand it also depends on database codepage. but i just wanna know how do i ensure it do not change while loading... (1 Reply)
Discussion started by: braindrain
1 Replies

3. Shell Programming and Scripting

replacing multiple lines with single line

Can any one give me the idea on replacing multiple blank lines with a single blank line? Please conside it for a file having more than 100 number of characters. Regards, Siba (3 Replies)
Discussion started by: siba.s.nayak
3 Replies

4. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies

5. Shell Programming and Scripting

Single/Multiple Line with Special characters - Find & Replace in Unix Script

Hi, I am creating a script to do a find and replace single/multiple lines in a file with any number of lines. I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE print $FIND gives Hi How r $u Rahul() Note:... (0 Replies)
Discussion started by: r_sarnayak
0 Replies

6. Shell Programming and Scripting

Replace char between chars - help needed

Hello, I have a csv file with "^" as text delimiters and "|" as field delimiters. It's converted from a xls file. One record looks like this: ^Tablete Internet^|Archos|501838|^Tableta Internet ARCHOS 80 G9 ...| ... (more lines) ... "501|838"^|330.00|USD|sl|12|0|Link|^router wireless 150... (10 Replies)
Discussion started by: go0ogl3
10 Replies

7. Shell Programming and Scripting

All strings within two special chars

I have a file with multiple lines. From each line I want to get all strings that starts with '+' and ends with '/'. Then I want the strings to be separated by ' + ' Example input: +$A$/NOUN+At/NSUFF_FEM_PL+K/CASE_INDEF_ACC Sample output: $A$ + At + K (20 Replies)
Discussion started by: Viernes
20 Replies

8. Shell Programming and Scripting

Replacing a single line with multiple lines in a file

Hi Am confused with the usage of "sed" command I want to replace a single line with multiple lines of a file.. eg., A file has Hi, How are you? I need to replace as Am fine What are You doing? I used the script as string1="Hi, How are you?" echo "$string1 is the value"... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies

9. Shell Programming and Scripting

Replacing Multiple spaces with a single space but excluding few regular expressions

Hi All. Attached are two files. I ran a query and have the output as in the file with name "FILEWITHFOURRECORDS.txt " I didn't want all the spaces between the columns so I squeezed the spaces with the "tr" command and also added a carriage return at the end of every line. But in two... (3 Replies)
Discussion started by: sparks
3 Replies

10. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies
STRFTIME(3)						     Library Functions Manual						       STRFTIME(3)

NAME
strftime - format date and time SYNOPSIS
#include <sys/types.h> #include <time.h> #include <string.h> size_t strftime(buf, maxsize, format, timeptr) char *buf; size_t maxsize; char *format; struct tm *timeptr; DESCRIPTION
The strftime() function formats the information from timeptr into the buffer buf according to the string pointed to by format. The format string consists of zero or more conversion specifications and ordinary characters. All ordinary characters are copied directly into the buffer. A conversion specification consists of a percent sign ``%'' and one other character. No more than maxsize characters will be placed into the array. If the total number of resulting characters, including the terminating null character, is not more than maxsize, strftime() returns the number of characters in the array, not counting the terminating null. Other- wise, zero is returned. Each conversion specification is replaced by the characters as follows which are then copied into the buffer. %A is replaced by the full weekday name. %a is replaced by the abbreviated weekday name, where the abbreviation is the first three characters. %B is replaced by the full month name. %b or %h is replaced by the abbreviated month name, where the abbreviation is the first three characters. %C is equivalent to ``%a %b %e %H:%M:%S %Y'' (the format produced by asctime(3)). %c is equivalent to ``%m/%d/%y''. %D is replaced by the date in the format ``mm/dd/yy''. %d is replaced by the day of the month as a decimal number (01-31). %e is replaced by the day of month as a decimal number (1-31); single digits are preceded by a blank. %H is replaced by the hour (24-hour clock) as a decimal number (00-23). %I is replaced by the hour (12-hour clock) as a decimal number (01-12). %j is replaced by the day of the year as a decimal number (001-366). %k is replaced by the hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a blank. %l is replaced by the hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a blank. %M is replaced by the minute as a decimal number (00-59). %m is replaced by the month as a decimal number (01-12). %n is replaced by a newline. %p is replaced by either ``AM'' or ``PM'' as appropriate. %R is equivalent to ``%H:%M'' %r is equivalent to ``%I:%M:%S %p'' . %t is replaced by a tab. %S is replaced by the second as a decimal number (00-60). %T or %X is equivalent to "%H:%M:%S" . %U is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number (00-53). %W is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (00-53). %w is replaced by the weekday (Sunday as the first day of the week) as a decimal number (0-6). %x is equivalent to ``%m/%d/%y %H:%M:%S'' . %Y is replaced by the year with century as a decimal number. %y is replaced by the year without century as a decimal number (00-99). %Z is replaced by the time zone name. %% is replaced by `%' . SEE ALSO
date(1), ctime(3), printf(1), printf(3) STANDARDS
The strftime() function conforms to ANSI X C3.159-1989(``ANSI C''). BUGS
There is no conversion specification for the phase of the moon. 4.2 Berkeley Distribution April 1, 1995 STRFTIME(3)
All times are GMT -4. The time now is 10:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy