Sponsored Content
Top Forums Shell Programming and Scripting Swap two characters in a string Post 303000585 by drl on Friday 14th of July 2017 04:05:15 PM
Old 07-14-2017
Hi.

This looks like it does what you wish:
Code:
$ cat z8; tr '_-' '-_' < z8
abc-def_hij-klm_nop-qrs_tuv-wxy_z
abc_def-hij_klm-nop_qrs-tuv_wxy-z

and
Code:
$ echo "$s" ; echo "$s" | tr '_-' '-_'
abc-def_hij-klm_nop-qrs_tuv-wxy_z
abc_def-hij_klm-nop_qrs-tuv_wxy-z

For a system like:
Code:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution        : Debian 8.8 (jessie) 
tr (GNU coreutils) 8.23

Best wishes ... cheers, drl
This User Gave Thanks to drl For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add string after another string with special characters

Hello everyone, I'm writing a script to add a string to an XML file, right after a specified string that only occurs once in the file. For testing purposes I created a file 'testfile' that looks like this: 1 2 3 4 5 6 6 7 8 9 And this is the script as far as I've managed: ... (2 Replies)
Discussion started by: heliode
2 Replies

2. UNIX for Advanced & Expert Users

split a string into 3 characters

Hi, I have a requirement like this. String=abcdefghijkl I need to split this string into a substrign each 3 characters and write output into a file. Output: abc def ghi jkl Can any one please help me how can i acheive this Thanks (3 Replies)
Discussion started by: ukatru
3 Replies

3. Shell Programming and Scripting

number of characters in a string

Hi there, I have some user input in a variable called $VAR, and i need to ensure that the string is 5 or less characters .... does anybody know how i can count the characters in the variables ? any help would be great, cheers (2 Replies)
Discussion started by: rethink
2 Replies

4. Shell Programming and Scripting

get certain characters in a string

Hi Everyone, I have a.txt 12341" <sip:191@vo.my>;asdf=q" 116aaaa<sip:00091@vo.my>;penguin would like to get the output 191 00091 Please advice. Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

5. HP-UX

Swap device file and swap sapce

Hi I have an integrity machine rx7620 and rx8640 running hp-ux 11.31. I'm planning to fine tune the system: - I would like to know when does the memory swap space spill over to the device swap space? - And how much % of memory swap utilization should be specified (swap space device... (6 Replies)
Discussion started by: lamoul
6 Replies

6. Programming

Swap different size string

how can I write a function to swap to different sized string? (2 Replies)
Discussion started by: rupeshkp728
2 Replies

7. Shell Programming and Scripting

remove characters from string based on occurrence of a string

Hello Folks.. I need your help .. here the example of my problem..i know its easy..i don't all the commands in unix to do this especiallly sed...here my string.. dwc2_dfg_ajja_dfhhj_vw_dec2_dfgh_dwq desired output is.. dwc2_dfg_ajja_dfhhj it's a simple task with tail... (5 Replies)
Discussion started by: victor369
5 Replies

8. Linux

string characters in UNIX

I need some help. when i use the following command, it deletes all lines containing WINNT& v2010 and WINNT& v2010.2 I just want it to delete lines containing WINNT & v2010 only. perl -n -i.bak -e 'print unless /WINNT/&&/v2010/' *.* Danish (2 Replies)
Discussion started by: sdanish110
2 Replies

9. Shell Programming and Scripting

Cut a string for last 8 characters

Hello All I have a file like this abc.tpt.ctl bdc.tpt.ctl cdw.tpt.ctl I have looped every line using the for Loop, now I want to take each line and cut the .tpt.ctl part of it and store it in a variable and use the variable in same loop. The part I am stuck at is how do I cut the last... (9 Replies)
Discussion started by: nnani
9 Replies

10. Shell Programming and Scripting

Outputting characters after a given string and reporting the characters in the row below --sed

I have this fastq file: @M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86 GGGGGGGGGGGGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCA +test-1 GGGGGGGGGGGGGGGGGCCGGGGGFF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8... (10 Replies)
Discussion started by: Xterra
10 Replies
LOCALE(3)								 1								 LOCALE(3)

The Locale class

INTRODUCTION
A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API. PHP locales are organized and identified the same way that the CLDR locales used by ICU (and many vendors of Unix-like operating systems, the Mac, Java, and so forth) use. Locales are identified using RFC 4646 language tags (which use hyphen, not underscore) in addition to the more traditional underscore- using identifiers. Unless otherwise noted the functions in this class are tolerant of both formats. Examples of identifiers include: oen-US (English, United States) ozh-Hant-TW (Chinese, Traditional Script, Taiwan) ofr-CA, fr-FR (French for Canada and France respectively) The Locale class (and related procedural functions) are used to interact with locale identifiers--to verify that an ID is well-formed, valid, etc. The extensions used by CLDR in UAX #35 (and inherited by ICU) are valid and used wherever they would be in ICU normally. Locales cannot be instantiated as objects. All of the functions/methods provided are static. The null or empty string obtains the "root" locale. The "root" locale is equivalent to "en_US_POSIX" in CLDR. Language tags (and thus locale identifiers) are case insensitive. There exists a canonicalization function to make case match the specification. CLASS SYNOPSIS
Locale Locale Methods o publicstatic string Locale::acceptFromHttp (string $header) o publicstatic string Locale::canonicalize (string $locale) o publicstatic string Locale::composeLocale (array $subtags) o publicstatic bool Locale::filterMatches (string $langtag, string $locale, [bool $canonicalize = false]) o publicstatic array Locale::getAllVariants (string $locale) o publicstatic string Locale::getDefault (void ) o publicstatic string Locale::getDisplayLanguage (string $locale, [string $in_locale]) o publicstatic string Locale::getDisplayName (string $locale, [string $in_locale]) o publicstatic string Locale::getDisplayRegion (string $locale, [string $in_locale]) o publicstatic string Locale::getDisplayScript (string $locale, [string $in_locale]) o publicstatic string Locale::getDisplayVariant (string $locale, [string $in_locale]) o publicstatic array Locale::getKeywords (string $locale) o publicstatic string Locale::getPrimaryLanguage (string $locale) o publicstatic string Locale::getRegion (string $locale) o publicstatic string Locale::getScript (string $locale) o publicstatic string Locale::lookup (array $langtag, string $locale, [bool $canonicalize = false], [string $default]) o publicstatic array Locale::parseLocale (string $locale) o publicstatic bool Locale::setDefault (string $locale) PREDEFINED CONSTANTS
o Locale::DEFAULT_LOCALE ( null) - Used as locale parameter with the methods of the various locale affected classes, such as Number- Formatter. This constant would make the methods to use default locale. These constants describe the choice of the locale for getLocalte method of different classes. o Locale::ACTUAL_LOCALE ( string) -This is locale the data actually comes from. o Locale::VALID_LOCALE ( string) -This is the most specific locale supported by ICU. These constants define how the Locales are parsed or composed. They should be used as keys in the argument array to locale_compose(3) and are returned from locale_parse(3) as keys of the returned associative array. o Locale::LANG_TAG ( string) -Language subtag o Locale::EXTLANG_TAG ( string) -Extended language subtag o Locale::SCRIPT_TAG ( string) -Script subtag o Locale::REGION_TAG ( string) -Region subtag o Locale::VARIANT_TAG ( string) -Variant subtag o Locale::GRANDFATHERED_LANG_TAG ( string) -Grandfathered Language subtag o Locale::PRIVATE_TAG ( string) -Private subtag SEE ALSO
oRFC 4646 - Tags for Identifying Languages oRFC 4647 - Matching of Language Tags oUnicode CLDR Project:Common Locale Data Repository oIANA Language Subtags Registry oICU User Guide - Locale oICU Locale api PHP Documentation Group LOCALE(3)
All times are GMT -4. The time now is 06:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy