06-05-2012
Simple, I think, VIM Insertion
Hey everyone, I recently had to learn how to use UNIX and VIM for an internship, and have run in to a little challenge today. I have lists of thousands of file names that represent CAS (Chemical Abstracts Service) numbers, but they are not formatted correctly. CAS numbers run in the form of xxxx-xx-x, where the last two sets are always 2 and 1 digits long, respectively, but the first set of digits varies in length. My file names are just strings of numbers at the moment. Currently I have been inserting the -'s manually, but I believe VIM can automate the process. To clarify; I have a long list of strings of numbers (in either a .txt or .csv format, whichever would be more helpful) and I would like to insert a - before the last and third to last character of every line. Can this be done with a relatively simple VI command, or would writing some sort of shell script be best? I have little to no experience with scripting, so any suggestions would be helpful. Thank you!
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi All,
We are running the HP-UX 11.11 and Linux AS 3.0. so, shall we need to make any changes for leap second i.e. insert the leap second on 1st Jan 2006 or does the system have some setup which would take care of this automatically.
Please advise.
Regards,
Inder (2 Replies)
Discussion started by: isingh786
2 Replies
2. Shell Programming and Scripting
hi
Is there any way to automatically insert a predefined header into a file?
It would include the file name, author name, date and a description, the description entered on the first line of vi.
Thanks for any help
Oliver (4 Replies)
Discussion started by: olimiles
4 Replies
3. UNIX for Dummies Questions & Answers
Hi, I was wondering if someone here could help me figure out what's wrong with this simple insertion sort shell script. This is the output I get when I try to run it:
"23 43 22 15 63 43 23 11 10 2
./insertion.sh: line 23: 23
43
22
15
63
43
23
11
10
2
And here's the script:
... (2 Replies)
Discussion started by: sogpop
2 Replies
4. Shell Programming and Scripting
A header record is to be inserted in the begining of a flat file without using extra file or new file. It should be inserted into same file. Advace thanks for all help... (7 Replies)
Discussion started by: shreekrishnagd
7 Replies
5. UNIX for Dummies Questions & Answers
I ran into this issue and thanks to various postings in various forums, was
able to figure out the solution but didn't see one posting that laid the
whole issue out cleanly. So thought the following might help others ...
------------------------------------------------------------------------... (2 Replies)
Discussion started by: oxysep
2 Replies
6. Shell Programming and Scripting
Hi All,
I want to insert a line just befor the lst line in a file. please can anyone advise.
Cheers,
Shazin (3 Replies)
Discussion started by: Shazin
3 Replies
7. Solaris
I downloaded vim.7.2 and compiled the vim source .
Added the vim binary path to PATH (Because iam not the root of the box)
when i load the file using vim it throws me an error
Error detected while processing /home2/e3003091/.vimrc:
line 2:
E185: Cannot find color scheme darkblue
line... (0 Replies)
Discussion started by: girija
0 Replies
8. Shell Programming and Scripting
I want to use bash to insert the variable $a into the cell A1 of a csv file mycsv.csv.
How do I insert a variable into a specific cell in a csv file? (1 Reply)
Discussion started by: locoroco
1 Replies
9. Shell Programming and Scripting
I have 800+ html files that need to have a javascript added to them in the head. I can do the looping, setting filenames as variables, etc. but I cannot figure out how to insert my javascript file into the html.
My javascript is in a file named jsinsert.txt
It basically has this format:... (4 Replies)
Discussion started by: Trapper
4 Replies
10. Programming
TD P { margin-bottom: 0in; }P { margin-bottom: 0.08in; }TT.cjk { font-family: "WenQuanYi Zen Hei Sharp",monospace; }A:link { } I am trying to run this program for Insertion Sort, But don't know that why I am getting following Error
#include<iostream>
int main(){
int i,j,key,n;... (4 Replies)
Discussion started by: liveproject101
4 Replies
LEARN ABOUT X11R4
vimtutor
VIMTUTOR(1) General Commands Manual VIMTUTOR(1)
NAME
vimtutor - the Vim tutor
SYNOPSIS
vimtutor [-g] [language]
DESCRIPTION
Vimtutor starts the Vim tutor. It copies the tutor file first, so that it can be modified without changing the original file.
The Vimtutor is useful for people that want to learn their first Vim commands.
The optional argument -g starts vimtutor with gvim rather than vim, if the GUI version of vim is available, or falls back to Vim if gvim is
not found.
The optional [language] argument is the two-letter name of a language, like "it" or "es". If the [language] argument is missing, the lan-
guage of the current locale will be used. If a tutor in this language is available, it will be used. Otherwise the English version will
be used.
Vim is always started in Vi compatible mode.
FILES
/usr/share/vim/vim80/tutor/tutor[.language]
The Vimtutor text file(s).
/usr/share/vim/vim80/tutor/tutor.vim
The Vim script used to copy the Vimtutor text file.
AUTHOR
The Vimtutor was originally written for Vi by Michael C. Pierce and Robert K. Ware, Colorado School of Mines using ideas supplied by
Charles Smith, Colorado State University. E-mail: bware@mines.colorado.edu.
It was modified for Vim by Bram Moolenaar. For the names of the translators see the tutor files.
SEE ALSO
vim(1)
2001 April 2 VIMTUTOR(1)