|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
sed command problem
hi all. pls help.
i am using the sed command to substitute several text patterns in a file. my problem is, i want to replace the pattern with a new line. i cant seem to make \n work. here's an example. the patterns to be replaced with a next line are "abc", "def" and "hij". input file: qwertyabcuiop asdfgdefhjkl hijzxcvbnm output file shoule be like this: qwerty uiop asdfg hjkl zxcvbnm thanks. |
|
#2
|
|||
|
|||
|
To my knowledge, \n doesn't work in sed. But you can spilt lines:
Code:
#!/bin/bash echo "This is a test sentence" | \ sed -n 's/This is\(.*\)/This is\ \1/p' => This is\(.*\) Searchpatern. => This is\ => \1 Output patern. The \ after is is there for the linebreak, the \1 prints all that was captured with the \(.*\). |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > sed command problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|