vi Search for text, Replace with <CR> or control character.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers vi Search for text, Replace with <CR> or control character.
Prev   Next
# 1  
Old 05-20-2009
vi Search for text, Replace with <CR> or control character.

Greetings,

Using vi, how can I change the following text:
-I/myviews/nexus_7400rel/vobs/nexus/platforms/97400/include -I/myviews/nexus_7400rel/vobs/nexus/modules/i2c/7400/include -I/myviews/nexus_7400rel/vobs/nexus/modules/surface/7400/include

Into this:
/myviews/nexus_7400rel/vobs/nexus/platforms/97400/include
/myviews/nexus_7400rel/vobs/nexus/modules/i2c/7400/include
/myviews/nexus_7400rel/vobs/nexus/modules/surface/7400/include

The first text is a contiguous string with spaces and "-I" separating the lines of include paths (yes, this is from a "C" makefile output).

I want to search for all the occurances of " -I", and replace with a carriage return (or linefeed) using vi. This is for vi on a Linux system.

The search portion is easy: :g/ -I/s// (what goes here?)/g

It's the "what goes here?" part that I need help with.

Any answers or alternative solutions would be greatly appreciated.

Omega949
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Search for a pattern and replace a space at specific position with a Character in File

In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123. So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
3 Replies

2. Shell Programming and Scripting

Search a character and replace it with multiple lines

This is for AIX 6.1, I've a flat file and the format is like this DECLARE some statements; BEGIN some statements; END; I've to search BEGIN and replace it with the following 4 lines BEGIN For x in 1..1 LOOP BEGIN Similarly I've to search END and replace it with the... (7 Replies)
Discussion started by: Mukul Sharma
7 Replies

3. UNIX for Dummies Questions & Answers

Search for a particular word and replace the first character

Hi Unix gurus, I've a dna sequence in a file format known as fasta format (sequence header starts with > and ignored), an example shown below: >sequence_1 CGTATTCTCCGAATACC ATACG >sequence_2 CAGATTTTCAAATACCCCC In a file like this I want to do the following three search and replace. The... (4 Replies)
Discussion started by: Fahmida
4 Replies

4. Shell Programming and Scripting

Replace Control M (^M) character with new line

Hi All, We are getting an external file in abc.csv format. When opened in excel spread sheet, it is opening alright. But when opened in notepad, I see the contents in a single line. Ftp'd the file in binary mode to AIX UNIX host. When opened, I see Control M (^M) characters in place of New Line... (16 Replies)
Discussion started by: njny
16 Replies

5. Shell Programming and Scripting

Regex:search/replace but not for escaped character

Hi Input: - -- --- ---- aa-bb-cc aa--bb--cc aa---bb---cc aa----bb----cc Output: . - -. -- aa.bb.cc (7 Replies)
Discussion started by: chitech
7 Replies

6. Shell Programming and Scripting

Search and replace text

Hello, I am trying to search and replace but I don't know how to do it. My simple knowlegde in search and replace using sed is not helping me at all. File: its a cause value #22: dfg ggg Cause value #1: aasfa fasdf asfa value #22: affg gggg Basically i want to replace the... (6 Replies)
Discussion started by: balan1983a
6 Replies

7. Shell Programming and Scripting

Replace any control character in the string

Need to replace any control character in the string in perl ---------- Post updated at 04:22 PM ---------- Previous update was at 03:50 PM ---------- Any help !!! Thanks in advance (2 Replies)
Discussion started by: hansini
2 Replies

8. Shell Programming and Scripting

Need to search and replace based on character count

Hi, I wanted to add a newline character after every 100 characters in a file using a awk or shell without reading each line of the file. I want to run a command on the complete file. This does based on a string but i want to add a new line after every 100 characters ir-respective of the... (3 Replies)
Discussion started by: vijaykrc
3 Replies

9. UNIX for Dummies Questions & Answers

search and replace a specific text in text file?

I have a text file with following content (3 lines) filename : output.txt first line:12/12/2008 second line:12/12/2008 third line:Y I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before. I tried using cat output.txt... (4 Replies)
Discussion started by: santosham
4 Replies

10. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies
Login or Register to Ask a Question
SMP_CONF_GENERAL(8)						     SMP_UTILS						       SMP_CONF_GENERAL(8)

NAME
smp_conf_general - invoke CONFIGURE GENERAL SMP function SYNOPSIS
smp_conf_general [--connect=CO] [--expected=EX] [--help] [--hex] [--inactivity=IN] [--interface=PARAMS] [--nexus=NE] [--raw] [--sa=SAS_ADDR] [--verbose] [--version] SMP_DEVICE[,N] DESCRIPTION
Sends a SAS Management Protocol (SMP) CONFIGURE GENERAL request function to a SMP target. The SMP target is identified by the SMP_DEVICE and the --sa=SAS_ADDR. Depending on the interface, the SAS_ADDR may be deduced from the SMP_DEVICE. With one interface there is one SMP_DEVICE per machine so the SMP_DEVICE,N syntax is needed to differentiate between HBAs if there are multiple present. OPTIONS
Mandatory arguments to long options are mandatory for short options as well. -c, --connect=CO sets the "update STP maximum connect time limit" flag and the corresponding "STP maximum connect time limit" field to CO. Unit of CO is 100 microseconds. A CO of zero is taken to mean no maximum connection time limit. -E, --expected=EX set the 'expected expander change count' field in the SMP request. The value EX is from 0 to 65535 inclusive with 0 being the default value. When EX is greater than zero then if the value doesn't match the expander change count of the SMP target (i.e. the expander) when the request arrives then the target ignores the request and sets a function result of "invalid expander change count" in the response. -h, --help output the usage message then exit. -H, --hex output the response in hexadecimal. -i, --inactivity=IN sets the "update STP bus inactivity time limit" flag and the corresponding "STP bus inactivity time limit" field to IN. Unit of IN is 100 microseconds. A IN of zero is taken to mean no bus inactivity time limit. -I, --interface=PARAMS interface specific parameters. In this case "interface" refers to the path through the operating system to the SMP initiator. See the smp_utils man page for more information. -n, --nexus=NE sets the "update STP SMP I_T nexus loss time" flag and the corresponding "STP SMP I_T nexus loss time" field to NE. Unit of NE is one millisecond. A NE of zero is taken to mean a vendor specific amount of time; a NE of 65535 means the port shall never recognize an I_T nexus loss. -r, --raw send the response to stdout in binary. All error messages are sent to stderr. -s, --sa=SAS_ADDR specifies the SAS address of the SMP target device. Typically this is an expander. This option may not be needed if the SMP_DEVICE has the target's SAS address within it. The SAS_ADDR is in decimal but most SAS addresses are shown in hexadecimal. To give a number in hexadecimal either prefix it with '0x' or put a trailing 'h' on it. -v, --verbose increase the verbosity of the output. Can be used multiple times -V, --version print the version string and then exit. CONFORMING TO
The SMP CONFIGURE GENERAL function was introduced in SAS-2 . AUTHORS
Written by Douglas Gilbert. REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>. COPYRIGHT
Copyright (C) 2006-2008 Douglas Gilbert This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
smp_utils, smp_rep_general(smp_utils) smp_utils-0.93 January 2008 SMP_CONF_GENERAL(8)