Sponsored Content
Full Discussion: string concatenation
Top Forums UNIX for Dummies Questions & Answers string concatenation Post 302070330 by gauravgoel on Tuesday 4th of April 2006 05:47:45 AM
Old 04-04-2006
Quote:
Originally Posted by systemsb
Can you show me how to do using awk or sed

Yes all the lines are of the same pattern

try the following

Quote:
awk '$1=$1":"{print}' filename
Gaurav

Last edited by gauravgoel; 04-04-2006 at 06:55 AM.. Reason: typo
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help concatenation string and variable

Hello, in my script i have this lines of code in a while cycle: .. let j=i+1 t_prod_$i = `cat myfile.csv | grep world | cut -d ";" -f$j` let i+=1 ... So if i try an echo $t_prod_$i at the end of the cycle i cannot see the right value obtained by `cat myfile.csv | grep world |... (5 Replies)
Discussion started by: drain
5 Replies

2. Shell Programming and Scripting

String concatenation with spaces

Hi, I have a variable $ID=40 and I need to build a string like 40 40 40 40 40 40 so repeating ID 'n' times separated by spaces. Any help? Thanks Sarah (2 Replies)
Discussion started by: f_o_555
2 Replies

3. Shell Programming and Scripting

String Concatenation

Hi All, I need to concatenate the values in the array into a variable. Currently the code is : for (( i=1 ; i <= $minCount ; i++ )) do var="${var}""${sample_file}" done The output is : /tmp/1/tmp/2/tmp/3/tmp/4/tmp/5/tmp/6/tmp/7/tmp/8/tmp/9/tmp/10 I need a space between... (1 Reply)
Discussion started by: sh_kk
1 Replies

4. Shell Programming and Scripting

String/Variable Concatenation

Hello, Trying to concatenate the following using bourne shell: # !/bin/bash # this works in bash shell e.g. get the results I am expecting fnTmp=C$cindex.$station_0.$station_1.$station_3.$ts.tmp # # under !/bin/sh # the results are not the same Any assistance would be... (8 Replies)
Discussion started by: LAVco
8 Replies

5. Shell Programming and Scripting

String concatenation problems

#! /bin/csh set tt=12345_UMR_BH452_3_2.txt set rr=`echo $tt | cut -d_ -f1` set rr1=welcome set ff=$rr $rr1 echo $ff why $ff returned only 12345 and not 12345welcome? thanks (2 Replies)
Discussion started by: jdsignature88
2 Replies

6. Shell Programming and Scripting

String / Variable Concatenation

Hi all, I'm trying to build a variable name automatically through a for loop for a script I'm working on, basically I want to build the variables named: $JVM_HOME0 or $JVM_HOME1 so that I can loop through some file copy/deletes and a server restart once completed. With the code below, I get this... (3 Replies)
Discussion started by: hydroponx
3 Replies

7. Shell Programming and Scripting

String concatenation

Hi, I have two files. cat file.txt a b c d cat file1.txt j k l m I need the output as a:j (12 Replies)
Discussion started by: nareshkumar522
12 Replies

8. Shell Programming and Scripting

String concatenation problem

Hi there, I'm writing a basic script where I want to make a string of 2 numeric fields from a file, which I have done, but the behavior is rather confusing. I have a file of random values such as: 1 2 3 4 5 6 7 8 9 10 and my awk code is: BEGIN { FS = " " } { str = str $1 $2 } END {... (7 Replies)
Discussion started by: HMChadwick
7 Replies

9. Shell Programming and Scripting

Group by and string concatenation

Hi, I was trying to work on a file which had the following data format 1 hi 1 this 1 is 1 john 2 hello 3 test 3 case the expected output file is the below 1 hi, this, is, john 2 hello 3 test, case I tried using awk or while read, but I couldnt... (13 Replies)
Discussion started by: karthikbhuvana
13 Replies

10. Shell Programming and Scripting

Help with String concatenation

I have a script which is migrated from AIX to Linux & now while running it is no able to concatenate string values The string concatenation step under while loop is not displaying desired result Please find below the piece of code: while read EXT_FILE ; do EXT_FILE=$EXT_FILE.ext.sent echo... (7 Replies)
Discussion started by: PreetArul
7 Replies
Locale::Maketext::Fuzzy(3pm)				User Contributed Perl Documentation			      Locale::Maketext::Fuzzy(3pm)

NAME
Locale::Maketext::Fuzzy - Maketext from already interpolated strings SYNOPSIS
package MyApp::L10N; use base 'Locale::Maketext::Fuzzy'; # instead of Locale::Maketext package MyApp::L10N::de; use base 'MyApp::L10N'; our %Lexicon = ( # Exact match should always be preferred if possible "0 camels were released." => "Exact match", # Fuzzy match candidate "[quant,_1,camel was,camels were] released." => "[quant,_1,Kamel wurde,Kamele wurden] freigegeben.", # This could also match fuzzily, but is less preferred "[_2] released[_1]" => "[_1][_2] ist frei[_1]", ); package main; my $lh = MyApp::L10N->get_handle('de'); # All ->maketext calls below will become ->maketext_fuzzy instead $lh->override_maketext(1); # This prints "Exact match" print $lh->maketext('0 camels were released.'); # "1 Kamel wurde freigegeben." -- quant() gets 1 print $lh->maketext('1 camel was released.'); # "2 Kamele wurden freigegeben." -- quant() gets 2 print $lh->maketext('2 camels were released.'); # "3 Kamele wurden freigegeben." -- parameters are ignored print $lh->maketext('3 released.'); # "4 Kamele wurden freigegeben." -- normal usage print $lh->maketext('[*,_1,camel was,camels were] released.', 4); # "!Perl ist frei!" -- matches the broader one # Note that the sequence ([_2] before [_1]) is preserved print $lh->maketext('Perl released!'); DESCRIPTION
This module is a subclass of "Locale::Maketext", with additional support for localizing messages that already contains interpolated variables. This is most useful when the messages are returned by external sources -- for example, to match "dir: command not found" against "[_1]: command not found". Of course, this module is also useful if you're simply too lazy to use the $lh->maketext("[quant,_1,file,files] deleted.", $count); syntax, but wish to write $lh->maketext_fuzzy("$count files deleted"); instead, and have the correct plural form figured out automatically. If "maketext_fuzzy" seems too long to type for you, this module also provides a "override_maketext" method to turn all "maketext" calls into "maketext_fuzzy" calls. METHODS
$lh->maketext_fuzzy(key[, parameters...]); That method takes exactly the same arguments as the "maketext" method of "Locale::Maketext". If key is found in lexicons, it is applied in the same way as "maketext". Otherwise, it looks at all lexicon entries that could possibly yield key, by turning "[...]" sequences into "(.*?)" and match the resulting regular expression against key. Once it finds all candidate entries, the longest one replaces the key for the real "maketext" call. Variables matched by its bracket sequences ($1, $2...) are placed before parameters; the order of variables in the matched entry are correctly preserved. For example, if the matched entry in %Lexicon is "Test [_1]", this call: $fh->maketext_fuzzy("Test string", "param"); is equivalent to this: $fh->maketext("Test [_1]", "string", "param"); However, most of the time you won't need to supply parameters to a "maketext_fuzzy" call, since all parameters are already interpolated into the string. $lh->override_maketext([flag]); If flag is true, this accessor method turns "$lh->maketext" into an alias for "$lh->maketext_fuzzy", so all consecutive "maketext" calls in the $lh's packages are automatically fuzzy. A false flag restores the original behaviour. If the flag is not specified, returns the current status of override; the default is 0 (no overriding). Note that this call only modifies the symbol table of the language class that $lh belongs to, so other languages are not affected. If you want to override all language handles in a certain application, try this: MyApp::L10N->override_maketext(1); CAVEATS
o The "longer is better" heuristic to determine the best match is reasonably good, but could certainly be improved. o Currently, "[quant,_1,file] deleted" won't match "3 files deleted"; you'll have to write "[quant,_1,file,files] deleted" instead, or simply use "[_1] file deleted" as the lexicon key and put the correct plural form handling into the corresponding value. o When used in combination with "Locale::Maketext::Lexicon"'s "Tie" backend, all keys would be iterated over each time a fuzzy match is performed, and may cause serious speed penalty. Patches welcome. SEE ALSO
Locale::Maketext, Locale::Maketext::Lexicon HISTORY
This particular module was written to facilitate an auto-extraction layer for Slashcode's Template Toolkit provider, based on "HTML::Parser" and "Template::Parser". It would work like this: Input | <B>from the [% story.dept %] dept.</B> Output| <B>[%|loc( story.dept )%]from the [_1] dept.[%END%]</B> Now, this layer suffers from the same linguistic problems as an ordinary "Msgcat" or "Gettext" framework does -- what if we want to make ordinals from "[% story.dept %]" (i.e. "from the 3rd dept."), or expand the "dept." to "department" / "departments"? The same problem occurred in RT's web interface, where it had to localize messages returned by external modules, which may already contain interpolated variables, e.g. "Successfully deleted 7 ticket(s) in 'c: emp'.". Since I didn't have the time to refactor "DBI" and "DBI::SearchBuilder", I devised a "loc_match" method to pre-process their messages into one of the candidate strings, then applied the matched string to "maketext". Afterwards, I realized that instead of preparing a set of candidate strings, I could actually match against the original lexicon file (i.e. PO files via "Locale::Maketext::Lexicon"). This is how "Locale::Maketext::Fuzzy" was born. AUTHORS
Audrey Tang <cpan@audreyt.org> CC0 1.0 Universal To the extent possible under law, aaXXeXX has waived all copyright and related or neighboring rights to Locale-Maketext-Fuzzy. This work is published from Taiwan. <http://creativecommons.org/publicdomain/zero/1.0> perl v5.14.2 2011-12-11 Locale::Maketext::Fuzzy(3pm)
All times are GMT -4. The time now is 08:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy