Sponsored Content
Top Forums Shell Programming and Scripting Need to split string on single quote as delimiter Post 303038169 by Corona688 on Tuesday 27th of August 2019 11:32:57 AM
Old 08-27-2019
Another way that doesn't need externals, arrays, loops, or backticks:

Code:
INPUT="string'delimited'with'quotes"
OLDIFS="$IFS" ; IFS="'"
printf "%s\n" $INPUT
IFS="$OLDIFS"

This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

split string with multibyte delimiter

Hi, I need to split a string, either using awk or cut or basic unix commands (no programming) , with a multibyte charectar as a delimeter. Ex: abcd-efgh-ijkl split by -efgh- to get two segments abcd & ijkl Is it possible? Thanks A.H.S (1 Reply)
Discussion started by: azmathshaikh
1 Replies

2. Shell Programming and Scripting

Multiple characters including single quote in delimiter

Hello, I need to replace the comma to something else between the single quote: 1aaa,bbb,'cc,cc','ddd',1 2aaa,bbb,'ccc','d,d',0 to 1aaa,bbb,'cc<comma>cc','ddd',1 2aaa,bbb,'ccc','d<comma>d',0 Can someone help? Thanks. (2 Replies)
Discussion started by: bgirl
2 Replies

3. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

4. UNIX for Dummies Questions & Answers

find single quote in a string and replace it

Hi, I have variable inside shell script - from_item. from_item = 40.1'1/16 i have to first find out whether FROM_ITEM contains single quote('). If yes, then that need to be replace with two quotes (''). How to do it inside shell script? Please note that inside shell script........ (4 Replies)
Discussion started by: yogichavan
4 Replies

5. Shell Programming and Scripting

How to split a string with no delimiter

Hi; I want to write a shell script that will split a string with no delimiter. Basically the script will read a line from a file. For example the line it read from the file contains: 99234523 These values are never the same but the length will always be 8. How do i split this... (8 Replies)
Discussion started by: saint34
8 Replies

6. Shell Programming and Scripting

Replace single quote with two single quotes in perl

Hi I want to replace single quote with two single quotes in a perl string. If the string is <It's Simpson's book> It should become <It''s Simpson''s book> (3 Replies)
Discussion started by: DushyantG
3 Replies

7. Shell Programming and Scripting

double quote as the delimiter

I'm trying to extract a column from a csv file with either cut or awk but some of the fields contain comma with them: "Field1","Field2, additional info","Field3",...,"Field17",... If I want to extract column 3 and use comma as the delimiter, I'll actually get the additional info bit but not... (4 Replies)
Discussion started by: ivpz
4 Replies

8. Shell Programming and Scripting

Replace double quotes with a single quote within a double quoted string

Hi Froum. I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is. I have the following data: Before: ... (32 Replies)
Discussion started by: pchang
32 Replies

9. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

10. UNIX for Beginners Questions & Answers

Enclose String in single quote

I have a comma separated file which contains data like; File header: ID_WVR,SAK_WVR_SVC,DSC_WVR_WVC,SAK_PROCEDURE,CODES,CDE_PROC_MOD ,CDE_PROC_MOD_2 ,CDE_PROC_MOD_3 File Detail: AMR,5100,Total Services,305,D0120,,, AMR,5101,Periodic Services,40702,H2011,U1,, AMR,5112,Day... (4 Replies)
Discussion started by: jnrohit2k
4 Replies
Device::Cdio::ISO9660::IFS(3pm) 			User Contributed Perl Documentation			   Device::Cdio::ISO9660::IFS(3pm)

NAME
Device::Cdio::ISO9660::IFS - Class for ISO 9660 Filesystem image reading SYNOPSIS
This encapsulates ISO 9660 Filesystem Image handling. The class is often used in conjunction with Device::Cdio::ISO9660. use Device::Cdio::ISO9660; use Device::Cdio::ISO9660::IFS; $iso = Device::Cdio::ISO9660::IFS->new(-source=>'copying.iso'); $id = $iso->get_application_id(); @file_stats = $iso->readdir($path); foreach my $href (@file_stats) { printf "%s [LSN %6d] %8d %s%s ", $href->{is_dir} ? "d" : "-", $href->{LSN}, $href->{size}, $path, Device::Cdio::ISO9660::name_translate($href->{filename}); } DESCRIPTION
This is an Object-Oriented interface to the GNU CD Input and Control library ("libcdio") which is written in C. This class handles ISO 9660 aspects of an ISO 9600 image. An ISO-9660 image is distinct from a CD in a CD-ROM which has ISO-9660 tracks; the latter contains other CD-like information (e.g. tracks, information or assocated with the CD). An ISO-9660 filesystem image on the other hand doesn't and is generally file in some file system, sometimes with the file extension ".iso"; perhaps it can be burned into a CD with a suitable tool, perhaps is can be "mounted" as a filesystem on some OS's. CALLING ROUTINES Routines accept named parameters as well as positional parameters. For named parameters, each argument name is preceded by a dash. For example: Device::Cdio::ISO9660::IFS->new(-source=>'MYISO.ISO') Each argument name is preceded by a dash. Neither case nor order matters in the argument list. -driver_id, -Driver_ID, and -DRIVER_ID are all acceptable. In fact, only the first argument needs to begin with a dash. If a dash is present in the first argument, we assume dashes for the subsequent parameters. In the documentation below and elsewhere in this package the parameter name that can be used in this style of call is given in the parameter list. For example, for "open" the documentation below reads: open(source, iso_mask=$pyiso9660::EXTENSION_NONE)->bool So the parameters are "source", and "is_mask". The iso_mask parameter is not required and if not specified a value of $perliso9660:EXTENSION_NON will be used. The older, more traditional style of positional parameters is also supported. So the "have_driver example from above can also be written: Cdio::open($s, $i) Finally, since no parameter name can be confused with an integer, negative values will not get confused as a named parameter. METHODS
new new(source, iso_mask)->$iso9660_object Create a new ISO 9660 object. Source or iso_mask is optional. If source is given, open() is called using that and the optional iso_mask parameter; iso_mask is used only if source is specified. If source is given but opening fails, undef is returned. If source is not given, an object is always returned. close close()->bool Close previously opened ISO 9660 image and free resources associated with ISO9660. Call this when done using using an ISO 9660 image. find_lsn find_lsn(lsn)->$stat_href Find the filesystem entry that contains LSN and return file stat information about it. "undef" is returned on error. get_application_id get_application_id()->$id Get the application ID stored in the Primary Volume Descriptor. undef is returned if there is some problem. get_preparer_id get_preparer_id()->$id Get the preparer ID stored in the Primary Volume Descriptor. undef is returned if there is some problem. get_publisher_id get_publisher_id()->$id Get the publisher ID stored in the Primary Volume Descriptor. undef is returned if there is some problem. get_root_lsn get_root_lsn()->$lsn Get the Root LSN stored in the Primary Volume Descriptor. undef is returned if there is some problem. get_system_id get_system_id()->$id Get the Volume ID stored in the Primary Volume Descriptor. undef is returned if there is some problem. get_volume_id get_volume_id()->$id Get the Volume ID stored in the Primary Volume Descriptor. undef is returned if there is some problem. get_volumeset_id get_volume_id()->$id Get the Volume ID stored in the Primary Volume Descriptor. undef is returned if there is some problem. open open(source, iso_mask=$perliso9660::EXTENSION_NONE)->bool Open an ISO 9660 image for reading. Subsequent operations will read from this ISO 9660 image. This should be called before using any other routine except possibly new. It is implicitly called when a new is done specifying a source. If device object was previously opened it is closed first. See also open_fuzzy. open_fuzzy open_fuzzy(source, iso_mask=$perliso9660::EXTENSION_NONE, fuzz=20)->bool Open an ISO 9660 image for reading. Subsequent operations will read from this ISO 9660 image. Some tolerence allowed for positioning the ISO9660 image. We scan for $perliso9660::STANDARD_ID and use that to set the eventual offset to adjust by (as long as that is <= $fuzz). This should be called before using any other routine except possibly new (which must be called first. It is implicitly called when a new is done specifying a source. See also open. read_fuzzy_superblock read_fuzzy_superblock(iso_mask=$perliso9660::EXTENSION_NONE, fuzz=20)->bool Read the Super block of an ISO 9660 image but determine framesize and datastart and a possible additional offset. Generally here we are not reading an ISO 9660 image but a CD-Image which contains an ISO 9660 filesystem. readdir readdir(dirname)->@iso_stat Read path (a directory) and return a list of iso9660 stat references Each item of @iso_stat is a hash reference which contains LSN the Logical sector number (an integer) size the total size of the file in bytes sec_size the number of sectors allocated filename the file name of the statbuf entry XA if the file has XA attributes; 0 if not is_dir 1 if a directory; 0 if a not; FIXME: If you look at iso9660.h you'll see more fields, such as for Rock-Ridge specific fields or XA specific fields. Eventually these will be added. Volunteers? read_pvd read_pvd()->pvd Read the Super block of an ISO 9660 image. This is the Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume Descriptor if (Joliet) extensions are acceptable. read_superblock read_superblock(iso_mask=$perliso9660::EXTENSION_NONE)->bool Read the Super block of an ISO 9660 image. This is the Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume Descriptor if (Joliet) extensions are acceptable. seek_read seek_read(start, size=1)->(size, str) Seek to a position and then read n bytes. Size read is returned. stat stat(path, translate=0)->\%stat Return file status for path name psz_path. "undef" is returned on error. If translate is 1, version numbers in the ISO 9660 name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names are lowercased. Each item of @iso_stat is a hash reference which contains LSN the Logical sector number (an integer) size the total size of the file in bytes sec_size the number of sectors allocated filename the file name of the statbuf entry XA if the file has XA attributes; 0 if not is_dir 1 if a directory; 0 if a not. SEE ALSO
See also Device::Cdio for module information, Device::Cdio::ISO9660::FS and Device::Cdio::Device for device objects and Device::Cdio::Track for track objects. perliso9660 is the lower-level interface to "libiso9660", the ISO 9660 library of <http://www.gnu.org/software/libcdio>. <http://www.gnu.org/software/libcdio/doxygen/iso9660_8h.html> is documentation via doxygen of "libiso9660". doxygen. AUTHORS
Rocky Bernstein "<rocky at cpan.org>". COPYRIGHT
Copyright (C) 2006, 2007, 2008 Rocky Bernstein <rocky@cpan.org> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. perl v5.14.2 2012-06-22 Device::Cdio::ISO9660::IFS(3pm)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy