Sponsored Content
Top Forums Shell Programming and Scripting Insert single quote on every word separated by comma Post 302949828 by rbatte1 on Thursday 16th of July 2015 11:36:49 AM
Old 07-16-2015
Does the above (reading the input file text_file) not work for you?

The value is stored in $my_var at the end of these few lines and you can use it as you please.

What is the eventual purpose? Perhaps there is a smarter way to achieve your overall aim that we can help with.



Robin
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

How to insert a single quote to each record

I have a file as: 1 New used 1 used New I need o/p as: '1' 'New' 'used' '1' 'used' 'New' (12 Replies)
Discussion started by: karumudi7
12 Replies

3. Shell Programming and Scripting

Need Help - comma inside double quote in comma separated csv,

Hello there, I have a comma separated csv , and all the text field is wrapped by double quote. Issue is some text field contain comma as well inside double quote. so it is difficult to process. Input in the csv file is , 1,234,"abc,12,gh","GH234TY",34 I need output like below,... (8 Replies)
Discussion started by: Uttam Maji
8 Replies

4. UNIX for Dummies Questions & Answers

[solved] Comma separated values to space separated

Hi, I have a large number of files which are written as csv (comma-separated values). Does anyone know of simple sed/awk command do achieve this? Thanks! ---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ---------- Guess I asked this too soon. Found the... (0 Replies)
Discussion started by: lost.identity
0 Replies

5. UNIX for Dummies Questions & Answers

Insert single quote and commas

Hi All, I have a set of data as below : XS012371378 Raj 23-09-12 SH128238948 Andrew 24-08-12 CH273712399 Walsh 12-10-12 JK7249923893 Nick 10-02-13 JP6383791389 Braslin 30-12-13 I want the first column to be extracted separately. I can get this using awk. awk '{print $1}' file_name ... (3 Replies)
Discussion started by: Nand Kishor
3 Replies

6. Shell Programming and Scripting

Make multiple lines into single quoted comma separated Linux

Hi, I want to change a file file1.txt: 1234 3456 2345 6789 3456 2333 4444 As, file2.txt in Linux: '1234','3456','2345','6789','3456','2333','4444' Could someone please help me. (Single liner sed, awk will be welcome!) (7 Replies)
Discussion started by: wiweq05
7 Replies

7. Shell Programming and Scripting

Convert column to quote and comma separated row

Hi, I have a list of tables in a file.txt C_CLAIM C_HLD C_PROVIDER I want the output to be 'C_CLAIM','C_HLD','C_PROVIDER' Currently I'm usin awk and getting output which is almost correct but still has minor defects awk -vORS="','" '{ print $1 }' file.txt The output of... (4 Replies)
Discussion started by: wahi80
4 Replies

8. 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

9. Shell Programming and Scripting

Insert a single quote in front of a line in vi editor

Hello Gurus, I wanted to put a single quote in every where starting with /oradata, and at the end with .dbf. For example I have one line as below: alter database rename datafile /oradata/test.dbf to /oradata_new/test.dbf I wanted as below alter database rename datafile '/oradata/test.dbf' to... (3 Replies)
Discussion started by: pokhraj_d
3 Replies

10. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies
Petal::Deprecated(3pm)					User Contributed Perl Documentation				    Petal::Deprecated(3pm)

NAME
Petal::Deprecated - Documents Petal's deprecated syntax. IMPORTANT NOTE
This is an article, not a module. From version 2.00 onwards Petal *requires* that you use well-formed XML. This is because Petal now uses MKDoc::XML::TreeBuilder rather than HTML::TreeBuilder and XML::Parser. In particular, this version of Petal *CAN* break backwards compatibility if you were using Petal's HTML mode will non well formed XHTML. If you still want to use broken XHTML, you can Petal 2.00 in conjunction with Petal::Parser::HTB which has been created for this purpose. INLINE VARIABLES SYNTAX
<!--? This is a template comment. It will not appear in the output --> <html xmlns:tal="http://purl.org/petal/1.0/"> <body> This is the variable 'my_var' : ${my_var}. </body> </html> And if "my_var" contained Hello World, Petal would have outputted: <html> <body> This is the variable 'my_var' : Hello World. </body> </html> Now let's say that "my_var" is a hash reference as follows: $VAR1 = { hello_world => 'Hello, World' } To output the same result, you would write: This is the variable 'my_var' : ${my_var/hello_world}. SETTING PETAL OPTIONS AS GLOBALS
If you want to use an option throughout your entire program and don't want to have to pass it to the constructor each time, you can set them globally. They will then act as defaults unless you override them in the constructor. $Petal::BASE_DIR (use base_dir option) $Petal::INPUT (use input option) $Petal::OUTPUT (use output option) $Petal::TAINT (use taint option) $Petal::ERROR_ON_UNDEF_VAR (use error_on_undef_var option) $Petal::DISK_CACHE (use disk_cache option) $Petal::MEMORY_CACHE (use memory_cache option) $Petal::MAX_INCLUDES (use max_includes option) $Petal::LANGUAGE (use default_language option) $Petal::DEBUG_DUMP (use debug_dump option) # $Petal::ENCODE_CHARSET (use encode_charset option) -- _DEPRECATED_ $Petal::DECODE_CHARSET (use decode_charset option) TAL DIRECTIVES ALIASES
On top of all that, for people who are lazy at typing the following aliases are provided (although I would recommend sticking to the defaults): * tal:define - tal:def, tal:set * tal:condition - tal:if * tal:repeat - tal:for, tal:loop, tal:foreach * tal:attributes - tal:att, tal:attr, tal:atts * tal:content - tal:inner * tal:replace - tal:outer TRAP: Don't forget that the default prefix is "petal:" NOT "tal:", until you set the petal namespace in your HTML or XML document as follows: <html xmlns:tal="http://purl.org/petal/1.0/"> XINCLUDES
Let's say that your base directory is "/templates", and you're editing "/templates/hello/index.html". From there you want to include "/templates/includes/header.html" general syntax You can use a subset of the XInclude syntax as follows: <body xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="/includes/header.html" /> </body> For backwards compatibility reasons, you can omit the first slash, i.e. <xi:include href="includes/header.html" /> relative paths If you'd rather use a path which is relative to the template itself rather than the base directory, you can do it but the path MUST start with a dot, i.e. <xi:include href="../includes/header.html" /> <xi:include href="./subdirectory/foo.xml" /> etc. limitations The "href" parameter does not support URIs, no other tag than "xi:include" is supported, and no other directive than the "href" parameter is supported at the moment. Also note that contrarily to the XInclude specification Petal DOES allow recursive includes up to $Petal::MAX_INCLUDES. This behavior is very useful when templating structures which fit well recursive processing such as trees, nested lists, etc. You can ONLY use the following Petal directives with Xinclude tags: * on-error * define * condition * repeat "replace", "content", "omit-tag" and "attributes" are NOT supported in conjunction with XIncludes. UGLY SYNTAX
For certain things which are not doable using TAL you can use what I call the UGLY SYNTAX. The UGLY SYNTAX is UGLY, but it can be handy in some cases. For example consider that you have a list of strings: $my_var = [ 'Foo', 'Bar', 'Baz' ]; $template->process (my_var => $my_var, buz => $buz); And you want to display: <title>Hello : Foo : Bar : Baz</title> Which is not doable with TAL without making the XHTML invalid. With the UGLY SYNTAX you can do: <title>Hello<?for name="string my_var"?> : <?var name="string"?><?end?></title> Of course you can freely mix the UGLY SYNTAX with other Petal syntaxes. So: <title><?for name="string my_var"?> $string <?end?></title> Mind you, if you've managed to read the doc this far I must confess that writing: <h1>$string</h1> instead of: <h1 tal:replace="string">Dummy</h1> is UGLY too. I would recommend to stick with TAL wherever you can. But let's not disgress too much. variables Abstract <?var name="EXPRESSION"?> Example <title><?var name="document/title"?></title> Why? Because if you don't have things which are replaced by real values in your template, it's probably a static page, not a template... :) if / else constructs Usual stuff: <?if name="user/is_birthay"?> Happy Birthday, $user/real_name! <?else?> What?! It's not your birthday? A very merry unbirthday to you! <?end?> You can use "condition" instead of "if", and indeed you can use modifiers: <?condition name="false:user/is_birthay"?> What?! It's not your birthday? A very merry unbirthday to you! <?else?> Happy Birthday, $user/real_name! <?end?> Not much else to say! loops Use either "for", "foreach", "loop" or "repeat". They're all the same thing, which one you use is a matter of taste. Again no surprise: <h1>Listing of user logins</h1> <ul> <?repeat name="user system/list_users"?> <li><?var name="user/login"?> : <?var name="user/real_name"?></li> <?end?> </ul> Variables are scoped inside loops so you don't risk to erase an existing "user" variable which would be outside the loop. The template engine also provides the following variables for you inside the loop: <?repeat name="foo bar"?> <?var name="repeat/index"?> - iteration number, starting at 0 <?var name="repeat/number"?> - iteration number, starting at 1 <?var name="repeat/start"?> - is it the first iteration? <?var name="repeat/end"?> - is it the last iteration? <?var name="repeat/inner"?> - is it not the first and not the last iteration? <?var name="repeat/even"?> - is the count even? <?var name="repeat/odd"?> - is the count odd? <?end?> Again these variables are scoped, you can safely nest loops, ifs etc... as much as you like and everything should be fine. Includes <?include file="include.xml"?> It will include the file 'include.xml', using the current @Petal::BASE_DIR directory list. If you want use XML::Parser to include files, you should make sure that the included files are valid XML themselves... FYI XML::Parser chokes on this: <p>foo</p> <p>bar</p> But this works: <div> <p>foo</p> <p>bar</p> </div> (Having only one top element is part of the XML spec). perl v5.12.4 2011-08-25 Petal::Deprecated(3pm)
All times are GMT -4. The time now is 10:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy