Sponsored Content
Top Forums Shell Programming and Scripting How to separate based on delimiter? Post 302893286 by Subbeh on Tuesday 18th of March 2014 10:17:59 AM
Old 03-18-2014
Quote:
Originally Posted by in2nix4life
Code:
read -r variable1 variable2 variable3 <<< "$variable"

You'll need to set IFS to a comma in order to split the variable though:
Code:
IFS=, read variable1 variable2 variable3 <<< "$variable"

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cut a Variable into sub variables based on a delimiter

Hello All, I am novice on Shell Scripting. Any help on this is highly appreciated. I have a variable $VARIABLE="$some1|$some2|$some3" I need sub variables $SUBVAR1,$SUBVAR2,$SUBVAR3 which must be equal to $some1 , $some2 and $some3 respectively. It works fine with $SUBVAR1 =... (6 Replies)
Discussion started by: jingi1234
6 Replies

2. Shell Programming and Scripting

Separate based on file names

Hello experts, This might prove to be a stupid question to some of you, but I have tried to tackle it in different ways. Being new to shell scripting, I am requesting your help in coming up with an elegant solution. I am using Korn shell. We have a directory with file names with the pattern:... (2 Replies)
Discussion started by: prashk15
2 Replies

3. Shell Programming and Scripting

Substring based on delimiter, finding last delimiter

Hi, I have a string like ABC.123.XYZ-A1-B2-P1-C4. I want to delimit the string based on "-" and then get result as only two strings. One with string till last hyphen and other with value after last hyphen... For this case, it would be something like first string as "ABC.123.XYZ-A1-B2-P1" and... (6 Replies)
Discussion started by: gupt_ash
6 Replies

4. Shell Programming and Scripting

split record based on delimiter

Hi, My inputfile contains field separaer is ^. 12^inms^ 13^fakdks^ssk^s3 23^avsd^ 13^fakdks^ssk^a4 I wanted to print only 2 delimiter occurence i.e 12^inms^ 23^avsd^ (4 Replies)
Discussion started by: Jairaj
4 Replies

5. UNIX for Dummies Questions & Answers

Trimming a string based on delimiter.

Hi, I have a string say "whateverCluster". I need everthing apart from the string "Cluster" Input: whateverCluster Desired output: whatever (5 Replies)
Discussion started by: mohtashims
5 Replies

6. Shell Programming and Scripting

Separate string based on delimiter

Hi, for fd in $(grep "/tmp/" hello.properties)The grep gives me the below output: deploydir=/tmp/app1/dfol prodir= /tmp/hello/prop ...... Now i want to store /tmp/app1/dfol then /tmp/hello/prop in a variable so that i can check if those folders files exists or not. The delimiter would... (4 Replies)
Discussion started by: mohtashims
4 Replies

7. Shell Programming and Scripting

How to separate a statement based on some delimiter and store each field in a variable?

Hi, Variable1 = MKT1,MKT2,MKT3,MKT4 Now i want to store each of these value seperated by comma to a array and access each of the values. Also find out number of such values seperated by comma. Variable1 can have any number of values seperated by comma. Thanks :) (3 Replies)
Discussion started by: arghadeep adity
3 Replies

8. Shell Programming and Scripting

Separate output based on dates

Hi guys! First time poster on here, was wondering if someone could help with a problem which I'm facing. Is it possible to use awk or sed to separate the below output based on TRANSACTION_DATE? The output would then feed into DataStage. Contents of CSV file:... (5 Replies)
Discussion started by: Jimmy_the_tulip
5 Replies

9. UNIX for Dummies Questions & Answers

Splitting strings based on delimiter

i have a snippet from server log delimited by forward slash. /a/b/c/d/filename i need to cut until last delimiter. So desired output should look like: /a/b/c/d can you please help? Thanks in advance. (7 Replies)
Discussion started by: alpha_1
7 Replies

10. Programming

C++ separate code based on the few changes

Hi, I am working in Visual studio 2008 in which i have written the code in c++,qml,qt.Its a simulator application. I would like to create a simulator with certain changes. In order to do that i have modified the code with few changes based on the preprocessor condition. #define... (4 Replies)
Discussion started by: SA_Palani
4 Replies
Spoon::Base(3pm)					User Contributed Perl Documentation					  Spoon::Base(3pm)

NAME
Spoon::Base - Generic Spoon Base Class SYNOPSIS
use Spoon::Base '-Base'; DESCRIPTION
Base class for application plugins. Provides basic functionality to all modules inheriting from this class. SUBROUTINES
These subroutines are meant to be called bare, not as an object-method call. trace See Spoon::Trace::trace(). conf(name, default) Returns the configuration value for "name", if it can be found in the config ($self->hub->config). Returns $default, otherwise. METHODS
hub Return the application's hub object. See Spoon::Hub. init Inherited by all subclasses. Put your class initialization stuff here. assert(boolean) Die if the supplied argument is false. t([label]) Calls Spoon::Trace::mark(). See Spoon::Trace. clone Copies a class instance. The copy is only a shallow one. is_in_cgi Returns a boolean, indicating whether we were called from a CGI interface. is_in_test Returns a boolean, indicating whether we were called from a test suite. have_plugin(class_id) Tries to load a plugin. See Spoon::Hub::load_class(). plugin_directory Returns your plugin's directory. You can use this directory to store state. env_check(variable_name) Sanity check: ensure the specified variable exists in %ENV. If the variable is not found, dies with a useful error message. dumper_to_file(filepath, variable1 [, variable2...]) Uses Data::Dumper to save a dump of one or more variables to the specified file. has_utf8 Returns a boolean, indicating whether utf8 is available on this platform and version of perl. utf8_encode(string) Encodes the string in utf8, if utf8 is available. Otherwise, returns $string unmodified. See Encode::encode(). utf8_decode(string) Decodes the string from utf8, if utf8 is available. Otherwise, returns $string unmodified. See Encode::decode(). uri_escape(string) Escapes all invalid URI characters. See CGI::Util::escape(). uri_unescape(string) Unescapes all invalid URI characters. See CGI::Util::unescape(). html_escape(string) Escapes all reserved characters. The result is suitable for including verbatim in an HTML document. See CGI::escapeHTML(). html_unescape(string) Escapes all reserved characters. The result is suitable for including verbatim in an HTML document. See CGI::unescapeHTML(). base64_encode(string) Encodes the specified string into Base64. See MIME::Base64::encode_base64(). base64_encode(base64_data) Decodes the specified data from Base64. See MIME::Base64::decode_base64(). TODO
* Document what Spoon::Base->debug() does. AUTHOR
Brian Ingerson <INGY@cpan.org> COPYRIGHT
Copyright (c) 2004. Brian Ingerson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.12.4 2006-11-09 Spoon::Base(3pm)
All times are GMT -4. The time now is 01:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy