|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
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"" |
| Sponsored Links | ||
|
|
|
|||
|
Code:
awk 'NR==2{print "Category:TheBlah\n"$0;next}1' file |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| insert line into file using variable | aimmanuel | Shell Programming and Scripting | 2 | 04-12-2009 12:30 PM |
| Return code of command assigned to variable | browndr | Shell Programming and Scripting | 2 | 08-05-2008 09:26 AM |
| How to insert carriage return before line feed? | huey ing | Shell Programming and Scripting | 2 | 08-05-2005 02:22 PM |
| Remove a carriage return at end of variable | flagship99 | UNIX for Dummies Questions & Answers | 5 | 11-17-2004 06:39 PM |
| Regex to pick up name from the following including carriage return at end of the line | Shakey21 | Shell Programming and Scripting | 3 | 07-18-2002 09:27 AM |