Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to use sed to look for the particular pattren and convert? Post 302865031 by vikatakavi on Thursday 17th of October 2013 01:42:26 PM
Old 10-17-2013
How to use sed to look for the particular pattren and convert?

Hi ,

How do i use sed on a tsv file and look for the date format mm/dd/yyyy and convert it to yyyy-mm-dd. There are around 15 colums in that file and two colums need to be converted. i tried using this but didnt work.Can some one tweek it.

Code:
 sed -e "s_\(..\)\-\(..\)\-\(..\)_\3-\1-\2_" My file.tsv

Example : 10/23/2013 to 2013-10-23
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to convert grep to sed??

Hi, I am hing problem in grep.. So I need convert following code to sed based one.. grep -ie "error|exception" $LOG_DIR/Node$i\Log.txt >> $LOG_ERR_REP thats is I want to serach error and exception (ignore case) and write to other file . how to do? (5 Replies)
Discussion started by: redlotus72
5 Replies

2. Shell Programming and Scripting

Search for a Pattren in the files.

Hi Guys, Can you please helpme with this: I would like to read all the files in a directory and need to search for a pattern, Can we use the grep at folder level. Thanks in advance. :) Sat. (2 Replies)
Discussion started by: sbasetty
2 Replies

3. Shell Programming and Scripting

Problem with pattren Matching

I have a set of programs and there coressponding MAPSETs i tried grep on the all the programs and got the following out put from this i want to extract only the Program Name and Mapset name {i.e. the word in (' ') after MAPSET } There or some cases where u have no ( after MAPSET that need... (7 Replies)
Discussion started by: pbsrinivas
7 Replies

4. Shell Programming and Scripting

negate * with in pattren matching...

Hi Every one I have a file in the following manner... AAAAAA*PERFORM WRITEQ BBDFDD*PERFOMF WRITEQ FFFF *PERFOMF WRITEQ i want to find the lines which donot have * in 7th position.. I have tried this but some problem i think... grep '......*WRITEQ' INpFIle... any 6 chars not... (7 Replies)
Discussion started by: pbsrinivas
7 Replies

5. Shell Programming and Scripting

find and replace pattren in file

Hi, I have the input file having data as follow: file1.txt 001 aaa_1:abcd 002 bbb_2:abcd I want output as, 001xabcd 002xabcd Here iam trying to replace "{1 space}{alphanumeric string with underscore}{:}" with characrter "x". I tried to achieve this using sed;but Iam not getting this... (5 Replies)
Discussion started by: gopalss
5 Replies

6. Shell Programming and Scripting

Convert sed to perl

Can anyone convert this from sed to perl: sed -n '/\var\/log/p' /etc/syslog.conf I think Ive looked at this to much....urgh.. Thanks Ben (5 Replies)
Discussion started by: bigben1220
5 Replies

7. UNIX for Dummies Questions & Answers

Get the previous word from the search pattren

Hi, How do i find the previous worlds from the searched pattrens? Input:- Create or replace procedure some tesx. search work is procedure(case insencitive). output:- Create or replace (8 Replies)
Discussion started by: manasa_vs
8 Replies

8. Shell Programming and Scripting

Convert string using sed

I have a couple structure definitions in my input code. For example: struct node { int val; struct node *next; }; or typedef struct { int numer; int denom; } Rational; I used the following line to convert them into one line and copy it twice. sed '/struct*{/{:l... (3 Replies)
Discussion started by: James Denton
3 Replies

9. Shell Programming and Scripting

Replace a string on specific lines which match a pattren

Hi Experts, I have a file which contains a pattern multiple times i.e. matchthispattren. If a line is matched with this pattern. I want a number in 1234567890 to 123456789 in that line. (Basically remove the last digit from that number. Please help. Thanks, Varun (1 Reply)
Discussion started by: varun22486
1 Replies

10. Shell Programming and Scripting

Remove lines with Pattren Matching

Hi , I need to remove the lines that matches the pattern TABLEEXCLUDE *.AQ$_*_F ; * is wildcard, it can be any word. For example, I have following file: TABLEEXCLUDE THOT.AQ$_PT_ADDR_CLEANUP_QTAB2_F ; TABLEEXCLUDE THOT.AQ$_MICRO_SERVICE_QT_F ; TEST TABLEEXCLUDE... (1 Reply)
Discussion started by: rcc50886
1 Replies
SWISS::TextFunc(3pm)					User Contributed Perl Documentation				      SWISS::TextFunc(3pm)

NAME
SWISS::TextFunc DESCRIPTION
This module is designed to be a repository of functions that are repeatedly used during parsing and formatting of SWISS-PROT/TREMBL lines. If more than two line types need to do aproximately the same thing then it is probably in here. All functions expect to be called as package->function(param list) listFromText Takes a piece of text, a seperator regex and a seperator that may appear at the end. Returns an array of items that were seperated in the text by that seperator. Takes care of null items (looses them for you). textFromList Takes an array of items, a separator, a terminating string, and a line width. Returns an array of strings, each ending with the separator or the terminator with a width less than or equal to the width specified. Seems to do the wrong thing for references - not sure why. Don't use it for that. wrapText Takes a string and a length. Returns an array of strings which are shorter or equal in length to length, spliting the string on white space. wrapOn ($firstLinePrefix, $linePrefix, $colums, $text[, @separators]) Wraps $text into lines with at most $colums colums. Prepends the prefixes to the lines. @separators is a list of expressions on which to wrap. The expression itself is part of the upper line. If no @separators are provided, the $text is wrapped at whitespace except in EC/TC numbers or at dashes that separate words. First tries to wrap on the first item of @separators, then the next etc. If no wrap on any element of @separators or whitespaces is possible, wraps into lines of exactly length $colums. A special case is that the first item of @separators may be a reference to an array. This is used internally for wrapping FT VARIANT- like lines. Example: wrapOn('DE ', 'DE ', 40, '14-3-3 PROTEIN BETA/ALPHA (PROTEIN KINASE C INHIBITOR PROTEIN-1)', 's+') returns ['14-3-3 PROTEIN BETA/ALPHA (PROTEIN ', 'KINASE C INHIBITOR PROTEIN-1)'] wrapOn('DE ', 'DE ', 40, '14-3-3 PROTEIN BETA/ALPHA (PROTEIN KINASE C INHIBITOR PROTEIN-1)', ' (?=()', 's+') returns ['14-3-3 PROTEIN BETA/ALPHA ', '(PROTEIN KINASE C INHIBITOR PROTEIN-1)'] cleanLine Remove the leading line Identifier and three blanks and trailing spaces from an SP line. joinWith ($text, $with, $noAddAfter, @list) Concatenates $text and @list into one string. Adds $with between the original elements, unless the postfix of the current string is $noAddAfter. This is used to avoid inserting blanks after hyphens during concatenation. So unpleasant strings like 'CALMODULIN- DEPENDENT' are avoided. Unfortunately a correct reassembly of strings like 'CARBON-DIOXIDE' is not done. insertLineGroup ($textRef, $text, $pattern) Inserts text block $text into the text referred to by $textRef. $text will replace the text block in $textRef matched by $pattern. uniqueList (@list) Returns a list in which all duplicates from @list have been removed. currentSpDate returns the current date in SWISS-PROT format toMixedCase($text, @regexps) Convert a text to mixed case, according to one or more regular expressions. In scalar context, returns the new text; in array context, also returns the regexp with which the change was performed, or undef on failure. See corresponding item in SWISS::GN for more details. perl v5.10.1 2006-08-31 SWISS::TextFunc(3pm)
All times are GMT -4. The time now is 12:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy