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
Find(3) 						User Contributed Perl Documentation						   Find(3)

NAME
Module::Find - Find and use installed modules in a (sub)category SYNOPSIS
use Module::Find; # use all modules in the Plugins/ directory @found = usesub Mysoft::Plugins; # use modules in all subdirectories @found = useall Mysoft::Plugins; # find all DBI::... modules @found = findsubmod DBI; # find anything in the CGI/ directory @found = findallmod CGI; # set your own search dirs (uses @INC otherwise) setmoduledirs(@INC, @plugindirs, $appdir); # not exported by default use Module::Find qw(ignoresymlinks followsymlinks); # ignore symlinks ignoresymlinks(); # follow symlinks (default) followsymlinks(); DESCRIPTION
Module::Find lets you find and use modules in categories. This can be very useful for auto-detecting driver or plugin modules. You can differentiate between looking in the category itself or in all subcategories. If you want Module::Find to search in a certain directory on your harddisk (such as the plugins directory of your software installation), make sure you modify @INC before you call the Module::Find functions. FUNCTIONS
"setmoduledirs(@directories)" Sets the directories to be searched for modules. If not set, Module::Find will use @INC. If you use this function, @INC will not be included automatically, so add it if you want it. Set to undef to revert to default behaviour. "@found = findsubmod Module::Category" Returns modules found in the Module/Category subdirectories of your perl installation. E.g. "findsubmod CGI" will return "CGI::Session", but not "CGI::Session::File" . "@found = findallmod Module::Category" Returns modules found in the Module/Category subdirectories of your perl installation. E.g. "findallmod CGI" will return "CGI::Session" and also "CGI::Session::File" . "@found = usesub Module::Category" Uses and returns modules found in the Module/Category subdirectories of your perl installation. E.g. "usesub CGI" will return "CGI::Session", but not "CGI::Session::File" . "@found = useall Module::Category" Uses and returns modules found in the Module/Category subdirectories of your perl installation. E.g. "useall CGI" will return "CGI::Session" and also "CGI::Session::File" . "ignoresymlinks()" Do not follow symlinks. This function is not exported by default. "followsymlinks()" Follow symlinks (default behaviour). This function is not exported by default. HISTORY
0.01, 2004-04-22 Original version; created by h2xs 1.22 0.02, 2004-05-25 Added test modules that were left out in the first version. Thanks to Stuart Johnston for alerting me to this. 0.03, 2004-06-18 Fixed a bug (non-localized $_) by declaring a loop variable in use functions. Thanks to Stuart Johnston for alerting me to this and providing a fix. Fixed non-platform compatibility by using File::Spec. Thanks to brian d foy. Added setmoduledirs and updated tests. Idea shamelessly stolen from ...errm... inspired by brian d foy. 0.04, 2005-05-20 Added POD tests. 0.05, 2005-11-30 Fixed issue with bugfix in PathTools-3.14. 0.06, 2008-01-26 Module::Find now won't report duplicate modules several times anymore (thanks to Uwe Voelker for the report and the patch) 0.07, 2009-09-08 Fixed RT#38302: Module::Find now follows symlinks by default (can be disabled). 0.08, 2009-09-08 Fixed RT#49511: Removed Mac OS X extended attributes from distribution 0.09, 2010-02-26 Fixed RT#38302: Fixed META.yml generation (thanks very much to cpanservice for the help). 0.10, 2010-02-26 Fixed RT#55010: Removed Unicode BOM from Find.pm. 0.11, 2012-05-22 Fixed RT#74251: defined(@array) is deprecated under Perl 5.15.7. DEVELOPMENT NOTES
Please report any bugs using the CPAN RT system. The development repository for this module is hosted on GitHub: <http://github.com/crenz/Module-Find/>. SEE ALSO
perl AUTHOR
Christian Renz, <crenz@web42.com> COPYRIGHT AND LICENSE
Copyright 2004-2012 by Christian Renz <crenz@web42.com>. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2012-05-21 Find(3)
All times are GMT -4. The time now is 10:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy