Sponsored Content
Top Forums Shell Programming and Scripting sed - Removing all characters from token to end of line Post 302786995 by jcdole on Thursday 28th of March 2013 01:42:45 PM
Old 03-28-2013
Quote:
Originally Posted by Corona688
Think awk may be more appropriate, you can use its token splitting features to extract exactly what you want. Tell it that " splits columns and the token will always be the second column, i.e. $2.

FS is the special variable for column separator, so I'm just printing quote, token, quote.

Code:
awk -F"\"" '{ print FS $2 FS }' inputfile > outputfile

Great

But I Known very few with sed and nothing with awk.

Thank you for helping.

---------- Post updated at 18:42 ---------- Previous update was at 18:40 ----------

Quote:
Originally Posted by mirni
I agree that awk solution is more readable, but just for the heck of it, here is sed command that should do the trick:
Code:
sed 's/.*\("[^"]*"\).*/\1/'

Great

Thank you for helping.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing characters from end of $string

I am writing a script to search PCL output and append more PCL data to the end accordingly. I need to remove the last 88 bytes from the string. I have searched for a few hours now and am coming up with nothing. I can't use head or tail because the PCL output is all on one line. awk crashes on... (3 Replies)
Discussion started by: craig2k
3 Replies

2. Shell Programming and Scripting

Get the 1st 99 characters and add new line feed at the end of the line

I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed). AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC MY * A02 RESALE 6990788000 Y... (3 Replies)
Discussion started by: udelalv
3 Replies

3. UNIX for Dummies Questions & Answers

Removing end of line using SED

Hello Friends, How can I remove the last two values of this line using sed John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638:9/3/90:45900 The result should look like this: John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638 (3 Replies)
Discussion started by: humkhn
3 Replies

4. Shell Programming and Scripting

sed removing until end of line

All: Can somebody help me out with a sed command, which removes the the first occurance of ')' until the end of the line If I have the following input ... (5 Replies)
Discussion started by: BeefStu
5 Replies

5. Shell Programming and Scripting

Removing characters from end of line (length unknown)

Hi I have a file which contains wrong XML, There are some garbage characters at the end of line that I want to get rid of. Example: <request type="product" ><attributes><pair><name>q</name><value><!]></value></pair><pair><name>start</name><value>1</value></pair></attributes></request>�J ... (7 Replies)
Discussion started by: dirtyd0ggy
7 Replies

6. UNIX for Dummies Questions & Answers

Removing characters from end of string

Hello, I have records like below that I want to remove any five characters from the end of the string before the double quotes unless it is only an asterik. 3919,5020 ,04/17/2012,0000000000006601.43,,0000000000000000.00,, 132, 251219,"*" 1668,0125 ... (2 Replies)
Discussion started by: jyoung
2 Replies

7. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

8. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

9. Shell Programming and Scripting

sed - How to insert line before the first blank line following a token

Hello. I have a config file (/etc/my_config_file) which may content : # # port for HTTP (descriptions, SOAP, media transfer) traffic port=8200 # network interfaces to serve, comma delimited network_interface=eth0 # set this to the directory you want scanned. # * if have multiple... (6 Replies)
Discussion started by: jcdole
6 Replies

10. Shell Programming and Scripting

sed removing extra character from end

Hi, Searching through forum I found "sed 's/*$//'" can be used to remove trailing whitespaces and tabs from file. The command works fine but I see minor issue as below. Can you please suggest if I am doing something wrong here. $ cat a.txt upg_prod_test upg_prod_new $ cat a.txt |sed... (11 Replies)
Discussion started by: bhupinder08
11 Replies
DateTime::Locale::to(3) 				User Contributed Perl Documentation				   DateTime::Locale::to(3)

NAME
DateTime::Locale::to SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'to' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Tonga. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) MXnite Tusite Pulelulu TuXapulelulu Falaite Tokonaki SXpate Abbreviated (format) MXn Tus Pul TuXa Fal Tok SXp Narrow (format) M T P T F T S Wide (stand-alone) MXnite Tusite Pulelulu TuXapulelulu Falaite Tokonaki SXpate Abbreviated (stand-alone) MXn Tus Pul TuXa Fal Tok SXp Narrow (stand-alone) M T P T F T S Months Wide (format) SXnuali FXpueli MaXasi XEpeleli MX Sune Siulai XAokosi SXpitema XOkatopa NXvema Tisema Abbreviated (format) SXn FXp MaXa XEpe MX Sun Siu XAok SXp XOka NXv Tis Narrow (format) S F M E M S S A S O N T Wide (stand-alone) SXnuali FXpueli MaXasi XEpeleli MX Sune Siulai XAokosi SXpitema XOkatopa NXvema Tisema Abbreviated (stand-alone) SXn FXp MaXa XEpe MX Sun Siu XAok SXp XOka NXv Tis Narrow (stand-alone) S F M E M S S A S O N T Quarters Wide (format) kuata Xuluaki kuata ua kuata tolu kuata fX Abbreviated (format) K1 K2 K3 K4 Narrow (format) 1 2 3 4 Wide (stand-alone) kuata 1 kuata 2 kuata 3 kuata 4 Abbreviated (stand-alone) K1 K2 K3 K4 Narrow (stand-alone) 1 2 3 4 Eras Wide ki muXa taXu Xo SXsX Abbreviated KM TS Narrow KXMX TXSX Date Formats Full 2008-02-05T18:30:30 = Tusite 5 FXpueli 2008 1995-12-22T09:05:02 = Falaite 22 Tisema 1995 -0010-09-15T04:44:23 = Tokonaki 15 SXpitema -10 Long 2008-02-05T18:30:30 = 5 FXpueli 2008 1995-12-22T09:05:02 = 22 Tisema 1995 -0010-09-15T04:44:23 = 15 SXpitema -10 Medium 2008-02-05T18:30:30 = 5 FXp 2008 1995-12-22T09:05:02 = 22 Tis 1995 -0010-09-15T04:44:23 = 15 SXp -10 Short 2008-02-05T18:30:30 = 05-02-2008 1995-12-22T09:05:02 = 22-12-1995 -0010-09-15T04:44:23 = 15-09--010 Default 2008-02-05T18:30:30 = 5 FXp 2008 1995-12-22T09:05:02 = 22 Tis 1995 -0010-09-15T04:44:23 = 15 SXp -10 Time Formats Full 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = Tusite 5 FXpueli 2008 18:30:30 UTC 1995-12-22T09:05:02 = Falaite 22 Tisema 1995 09:05:02 UTC -0010-09-15T04:44:23 = Tokonaki 15 SXpitema -10 04:44:23 UTC Long 2008-02-05T18:30:30 = 5 FXpueli 2008 18:30:30 UTC 1995-12-22T09:05:02 = 22 Tisema 1995 09:05:02 UTC -0010-09-15T04:44:23 = 15 SXpitema -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = 5 FXp 2008 18:30:30 1995-12-22T09:05:02 = 22 Tis 1995 09:05:02 -0010-09-15T04:44:23 = 15 SXp -10 04:44:23 Short 2008-02-05T18:30:30 = 05-02-2008 18:30 1995-12-22T09:05:02 = 22-12-1995 09:05 -0010-09-15T04:44:23 = 15-09--010 04:44 Default 2008-02-05T18:30:30 = 5 FXp 2008 18:30:30 1995-12-22T09:05:02 = 22 Tis 1995 09:05:02 -0010-09-15T04:44:23 = 15 SXp -10 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Tus 1995-12-22T09:05:02 = 22 Fal -0010-09-15T04:44:23 = 15 Tok Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 EA 1995-12-22T09:05:02 = 9:05 HH -0010-09-15T04:44:23 = 4:44 HH Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 EA 1995-12-22T09:05:02 = 9:05:02 HH -0010-09-15T04:44:23 = 4:44:23 HH M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (d-M) 2008-02-05T18:30:30 = 5-2 1995-12-22T09:05:02 = 22-12 -0010-09-15T04:44:23 = 15-9 MEd (E d-M) 2008-02-05T18:30:30 = Tus 5-2 1995-12-22T09:05:02 = Fal 22-12 -0010-09-15T04:44:23 = Tok 15-9 MMM (LLL) 2008-02-05T18:30:30 = FXp 1995-12-22T09:05:02 = Tis -0010-09-15T04:44:23 = SXp MMMd (d MMM) 2008-02-05T18:30:30 = 5 FXp 1995-12-22T09:05:02 = 22 Tis -0010-09-15T04:44:23 = 15 SXp MMMEd (E d MMM) 2008-02-05T18:30:30 = Tus 5 FXp 1995-12-22T09:05:02 = Fal 22 Tis -0010-09-15T04:44:23 = Tok 15 SXp MMMMd (d MMMM) 2008-02-05T18:30:30 = 5 FXpueli 1995-12-22T09:05:02 = 22 Tisema -0010-09-15T04:44:23 = 15 SXpitema MMMMEd (E d MMMM) 2008-02-05T18:30:30 = Tus 5 FXpueli 1995-12-22T09:05:02 = Fal 22 Tisema -0010-09-15T04:44:23 = Tok 15 SXpitema ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (M-yyyy) 2008-02-05T18:30:30 = 2-2008 1995-12-22T09:05:02 = 12-1995 -0010-09-15T04:44:23 = 9--010 yMEd (EEE d-M-yyyy) 2008-02-05T18:30:30 = Tus 5-2-2008 1995-12-22T09:05:02 = Fal 22-12-1995 -0010-09-15T04:44:23 = Tok 15-9--010 yMMM (MMM y) 2008-02-05T18:30:30 = FXp 2008 1995-12-22T09:05:02 = Tis 1995 -0010-09-15T04:44:23 = SXp -10 yMMMEd (EEE d MMM y) 2008-02-05T18:30:30 = Tus 5 FXp 2008 1995-12-22T09:05:02 = Fal 22 Tis 1995 -0010-09-15T04:44:23 = Tok 15 SXp -10 yMMMM (MMMM y) 2008-02-05T18:30:30 = FXpueli 2008 1995-12-22T09:05:02 = Tisema 1995 -0010-09-15T04:44:23 = SXpitema -10 yQ (yyyy Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -010 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 K1 1995-12-22T09:05:02 = 1995 K4 -0010-09-15T04:44:23 = -10 K3 yyMM (MM-yy) 2008-02-05T18:30:30 = 02-08 1995-12-22T09:05:02 = 12-95 -0010-09-15T04:44:23 = 09--10 yyMMM (MMM yy) 2008-02-05T18:30:30 = FXp 08 1995-12-22T09:05:02 = Tis 95 -0010-09-15T04:44:23 = SXp -10 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week MXnite SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.18.2 2017-10-06 DateTime::Locale::to(3)
All times are GMT -4. The time now is 02:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy