Sponsored Content
Top Forums Shell Programming and Scripting Insert a line including Variable & Carriage Return / sed command as Variable Post 302317706 by lowmaster on Tuesday 19th of May 2009 05:07:29 PM
Old 05-19-2009
Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line

something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong:

sed "2i\\${n}Category:$cat\n"

Sample:

Titel Blahh Blahh abllk sdhsd sjdhf
Blahh Blah Blahh
Blahh

Should look like this afterwards;

Titel Blahh Blahh abllk sdhsd sjdhf
Category:The Blahh
Blahh Blah Blahh
Blahh

2. Question: how should the syntax be, if the sed command itself should be a variable, like:

insertcat="sed "2i\\${n}Category:$cat\n""
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regex to pick up name from the following including carriage return at end of the line

has anyone got any suggestions how i would pick up the string as part of a substitution inclusive of the carriage return. ie i want to pick up <<NAME>> from the PS output but the <<; seems to be on the line before the NAME. Any ideas are appreciated! ... (3 Replies)
Discussion started by: Shakey21
3 Replies

2. UNIX for Dummies Questions & Answers

Remove a carriage return at end of variable

Is there a command in unix to remove a carriage return character(^M) at the end of a variable value? (5 Replies)
Discussion started by: flagship99
5 Replies

3. Shell Programming and Scripting

How to insert carriage return before line feed?

I am doing some edi where translations had to be run on unix. Generally when I run the translations on windows, the output file has both carriage returns and line feed where as when ran on unix will have only line feed. I need to insert carriage return before the line feed. Is there some tool... (2 Replies)
Discussion started by: huey ing
2 Replies

4. Shell Programming and Scripting

strip carriage return & append next line

Hello everyone, I am trying to search a file for lines that start with 'ip:' and have a carriage return after(ip:$). I then want to remove the carriage return from that line and append the next line in the file to the line containing 'ip'. I tried doing this with SED, but had no luck. Any... (3 Replies)
Discussion started by: vada010
3 Replies

5. Shell Programming and Scripting

sqlplus returns leading carriage return into a variable

I am trying to generate some scripts to help manage an Oracle database. When I check the value returned from Oracle it has a leading carriage return in the variable. Is there a way to prevent this? Is there a way to easily strip out the carriage return. See code and output below. ... (7 Replies)
Discussion started by: Panzer993
7 Replies

6. Shell Programming and Scripting

A variable is including the Carriage Return char...

Hi all, I'm reading a file with this layout: First_Col Second_Col The Second_Col has values as 1000, -1, 10, 43... While reading the file I'm getting the second column value with awk command, but it is including the CR control char. do item_saved=`echo $b | awk '{print... (4 Replies)
Discussion started by: mrreds
4 Replies

7. Shell Programming and Scripting

Why sed command deletes last line in a file if no carriage return?

Hi I am using sed command to make SCORE=somevalue to SCORE=blank in a file. Please see the attached lastline.txt file. After executing the below command on the file, it removes the last line. cat lastline.txt | sed 's/SCORE=.*$/SCORE=/g' > newfile.txt Why does sed command remove the... (3 Replies)
Discussion started by: ashok.k
3 Replies

8. Shell Programming and Scripting

Insert carriage return on the 10th char position of each line

Hi experts, Need your help on how to insert carriage return after the 10th char position of each line in a file and then add two blank spaces after the carriage return. Example: >cat test.txt testingline dummystring samplesample teststringline Expected output should be.. ... (2 Replies)
Discussion started by: brichigo
2 Replies

9. Shell Programming and Scripting

Remove carriage return from the variable

Hi, I try to handle very large numbers with a bash script. I run ssh command in a remote server and store the output in a local variable. But this output contains a return carriage at the end. So I try to remove it by tr But I can't figure out the right notation with printf. So my problem... (6 Replies)
Discussion started by: Meacham12
6 Replies

10. UNIX for Beginners Questions & Answers

Carriage return with cat variable

Hi, I wish to know how to works the carriage return with cat.. As a picture often speaks better than words, my code below : #te=`cat text.txt` (I tried this, but the same..) te=$(cat text.txt) echo $te My file text.txt below: BLABLABLABLABLALBLA BLABLABLABLABLALBLA ... (9 Replies)
Discussion started by: Arnaudh78
9 Replies
NL_LANGINFO(3)								 1							    NL_LANGINFO(3)

nl_langinfo - Query language and locale information

SYNOPSIS
string nl_langinfo (int $item) DESCRIPTION
nl_langinfo(3) is used to access individual elements of the locale categories. Unlike localeconv(3), which returns all of the elements, nl_langinfo(3) allows you to select any specific element. PARAMETERS
o $item -$item may be an integer value of the element or the constant name of the element. The following is a list of constant names for $item that may be used and their description. Some of these constants may not be defined or hold no value for certain locales. nl_langinfo Constants +-------------------------------+---------------------------------------------------+ | Constant | | | | | | | Description | | | | +-------------------------------+---------------------------------------------------+ | | | | LC_TIME Category Constants | | | | | | | | | ABDAY_(1-7) | | | | | | | Abbreviated name of n-th day of the week. | | | | | | | | DAY_(1-7) | | | | | | | Name of the n-th day of the week (DAY_1 = Sun- | | | day). | | | | | | | | ABMON_(1-12) | | | | | | | Abbreviated name of the n-th month of the year. | | | | | | | | MON_(1-12) | | | | | | | Name of the n-th month of the year. | | | | | | | | AM_STR | | | | | | | String for Ante meridian. | | | | | | | | PM_STR | | | | | | | String for Post meridian. | | | | | | | | D_T_FMT | | | | | | | String that can be used as the format string for | | | strftime(3) to represent time and date. | | | | | | | | D_FMT | | | | | | | String that can be used as the format string for | | | strftime(3) to represent date. | | | | | | | | T_FMT | | | | | | | String that can be used as the format string for | | | strftime(3) to represent time. | | | | | | | | T_FMT_AMPM | | | | | | | String that can be used as the format string for | | | strftime(3) to represent time in 12-hour format | | | with ante/post meridian. | | | | | | | | ERA | | | | | | | Alternate era. | | | | | | | | ERA_YEAR | | | | | | | Year in alternate era format. | | | | | | | | ERA_D_T_FMT | | | | | | | Date and time in alternate era format (string can | | | be used in strftime(3)). | | | | | | | | ERA_D_FMT | | | | | | | Date in alternate era format (string can be used | | | in strftime(3)). | | | | | | | | ERA_T_FMT | | | | | | | Time in alternate era format (string can be used | | | in strftime(3)). | | | | | | | |LC_MONETARY Category Constants | | | | | | | | | INT_CURR_SYMBOL | | | | | | | International currency symbol. | | | | | | | | CURRENCY_SYMBOL | | | | | | | Local currency symbol. | | | | | | | | CRNCYSTR | | | | | | | Same value as CURRENCY_SYMBOL. | | | | | | | | MON_DECIMAL_POINT | | | | | | | Decimal point character. | | | | | | | | MON_THOUSANDS_SEP | | | | | | | Thousands separator (groups of three digits). | | | | | | | | MON_GROUPING | | | | | | | Like "grouping" element. | | | | | | | | POSITIVE_SIGN | | | | | | | Sign for positive values. | | | | | | | | NEGATIVE_SIGN | | | | | | | Sign for negative values. | | | | | | | | INT_FRAC_DIGITS | | | | | | | International fractional digits. | | | | | | | | FRAC_DIGITS | | | | | | | Local fractional digits. | | | | | | | | P_CS_PRECEDES | | | | | | | Returns 1 if CURRENCY_SYMBOL precedes a positive | | | value. | | | | | | | | P_SEP_BY_SPACE | | | | | | | Returns 1 if a space separates CURRENCY_SYMBOL | | | from a positive value. | | | | | | | | N_CS_PRECEDES | | | | | | | Returns 1 if CURRENCY_SYMBOL precedes a negative | | | value. | | | | | | | | N_SEP_BY_SPACE | | | | | | | Returns 1 if a space separates CURRENCY_SYMBOL | | | from a negative value. | | | | | | | | P_SIGN_POSN | | | | | | | | | | | | | o Returns 0 if parentheses | | | surround the quantity and | | | CURRENCY_SYMBOL. | | | | | | o Returns 1 if the sign | | | string precedes the quantity | | | and | | | CURRENCY_SYMBOL. | | | | | | o Returns 2 if the sign | | | string follows the quantity | | | and | | | CURRENCY_SYMBOL. | | | | | | o Returns 3 if the sign | | | string immediately precedes | | | the | | | CURRENCY_SYMBOL. | | | | | | o Returns 4 if the sign | | | string immediately follows | | | the | | | CURRENCY_SYMBOL. | | | | | | | | N_SIGN_POSN | | | | | | | | |LC_NUMERIC Category Constants | | | | | | | | | DECIMAL_POINT | | | | | | | Decimal point character. | | | | | | | | RADIXCHAR | | | | | | | Same value as DECIMAL_POINT. | | | | | | | | THOUSANDS_SEP | | | | | | | Separator character for thousands (groups of | | | three digits). | | | | | | | | THOUSEP | | | | | | | Same value as THOUSANDS_SEP. | | | | | | | | GROUPING | | | | | | | | | | T{ | | | | | | LC_MESSAGES Category Constants | | | | | | | | YESEXPR | | | | | | | Regex string for matching "yes" input. | | | | | | | | NOEXPR | | | | | | | Regex string for matching "no" input. | | | | | | | | YESSTR | | | | | | | Output string for "yes". | | | | | | | | NOSTR | | | | | | | Output string for "no". | | | | | | | | LC_CTYPE Category Constants | | | | | | | | | CODESET | | | | | | | Return a string with the name of the character | | | encoding. | | | | +-------------------------------+---------------------------------------------------+ RETURN VALUES
Returns the element as a string, or FALSE if $item is not valid. NOTES
Note This function is not implemented on Windows platforms. SEE ALSO
setlocale(3), localeconv(3). PHP Documentation Group NL_LANGINFO(3)
All times are GMT -4. The time now is 03:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy