To replace in vi mode


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To replace in vi mode
# 1  
Old 06-28-2014
To replace in vi mode

I have a string like below in a comma delimted file, which is of 7th position.
Code:
""1234""
""345""

I want to replace it globally such that the first and last double quotes should be removed for all string at the 7th postion.

Code:
:%s/""1234""/"1234"/g

.But where I can replace only this string since all the entries at that particular position varies
# 2  
Old 06-28-2014
What does "in vi mode" mean? Do you mean you are using vi to edit your file and you are currently in command mode?

Please post a few lines from your file before the changes you're trying to make, and show us what you want it to look like after the edits so we have sample data we can use to verify that we're doing what you want done!
  1. Are there any occurrences of two adjacent double-quotes in other fields?
  2. Do all lines have two pairs of double double-quotes in the 7th field?
  3. Are all of the characters between the double double-quotes in the 7th field numeric?
  4. Are there always four characters between the double double-quotes in field 7?
  5. Are there any other fields that might have four characters between pairs of double double-quotes?
# 3  
Old 06-28-2014
If the comma-separated fields do never contain commas (in quotes), you can skip the first 6 fields with
Code:
^\([^,]*,\)\{6\}

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies

2. HP-UX

From a C++ application how to find if a hpux host is in standard mode or trusted mode

is there a way for my C++ application to find out which mode the hpux OS is running in? standard mode or trusted mode. (3 Replies)
Discussion started by: einsteinBrain
3 Replies

3. Solaris

DNS service is in maintenance mode. How to bring it back to online mode?

:confused: when i tried to look the status of DNS-client, it is in maintenance mode..... Please tell me how to bring it back to online mode...PLEASE TELL ME STEP BY STEP.... PLEASE... :wall: (2 Replies)
Discussion started by: vamshigvk475
2 Replies

4. UNIX for Advanced & Expert Users

What is the difference between single line mode and multiline mode in Regular expressions?

Hi All, Can please let me know what is the difference between the single line mode and multi line mode in regular expresions? Thanks, Chidhambaram B (3 Replies)
Discussion started by: chidhu.anu
3 Replies

5. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

6. Shell Programming and Scripting

Debug mode

When I run a lengthy script in debug mode i need to capture all the steps which are executed. e.g ksh -x script.ksh + test -f /proc/mounts + /bin/ls -l /proc/21326/exe + is=ksh + test ksh = ksh + test -s /etc/ksh.kshrc + . /etc/ksh.kshrc + trap 1 2 3 + who am i + awk {print $1} +... (2 Replies)
Discussion started by: zooby
2 Replies

7. HP-UX

how to distinguish standard system mode or trust system mode

I think that if the directory /tcb exists, HP-UX is in trusted mode and the passwd data is somewhere in /tcb/files/auth. But that's all I remember. Also I think recent versions of HP-UX can have a /etc/shadow file. (0 Replies)
Discussion started by: Perderabo
0 Replies

8. SuSE

Convet Linux OS from text mode to graphic mode

Hi All, I used to have my suse linux(VM) server in graphic mode but not anymore since morning. I cant rolback since i loose somuch work. Any idea how to it back to normal. Thanks (6 Replies)
Discussion started by: s_linux
6 Replies

9. UNIX for Dummies Questions & Answers

solaris forth mode?

hi i have a headless ultra 10 server running obp 3.29 i connect to the sever via telnet and i was wondering what is the command inorder to get to the forth mode from a telnet session? is it even possible to get to the ok prompt from telnet or do i need a serial connection? many thanks (2 Replies)
Discussion started by: xNYx
2 Replies
Login or Register to Ask a Question