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
REFER(1) General Commands Manual REFER(1)
NAME
refer, lookbib - find and insert literature references in documents
SYNOPSIS
refer [ option ] ...
lookbib [ file ] ...
DESCRIPTION
Lookbib accepts keywords from the standard input and searches a bibliographic data base for references that contain those keywords anywhere
in title, author, journal name, etc. Matching references are printed on the standard output. Blank lines are taken as delimiters between
queries.
Refer is a preprocessor for nroff or troff(1) that finds and formats references. The input files (standard input default) are copied to
the standard output, except for lines between .[ and .] command lines, which are assumed to contain keywords as for lookbib, and are
replaced by information from the bibliographic data base. The user may avoid the search, override fields from it, or add new fields. The
reference data, from whatever source, are assigned to a set of troff strings. Macro packages such as ms(7) print the finished reference
text from these strings. A flag is placed in the text at the point of reference; by default the references are indicated by numbers.
The following options are available:
-ar Reverse the first r author names (Jones, J. A. instead of J. A. Jones). If r is omitted all author names are reversed.
-b Bare mode: do not put any flags in text (neither numbers nor labels).
-cstring
Capitalize (with CAPS SMALL CAPS) the fields whose key-letters are in string.
-e Instead of leaving the references where encountered, accumulate them until a sequence of the form
.[
$LIST$
.]
is encountered, and then write out all references collected so far. Collapse references to the same source.
-kx Instead of numbering references, use labels as specified in a reference data line beginning %x; by default x is L.
-lm,n Instead of numbering references, use labels made from the senior author's last name and the year of publication. Only the first m
letters of the last name and the last n digits of the date are used. If either m or ,n is omitted the entire name or date respec-
tively is used.
-p Take the next argument as a file of references to be searched. The default file is searched last.
-n Do not search the default file.
-skeys
Sort references by fields whose key-letters are in the keys string; permute reference numbers in text accordingly. Implies -e. The
key-letters in keys may be followed by a number to indicate how many such fields are used, with + taken as a very large number. The
default is AD which sorts on the senior author and then date; to sort, for example, on all authors and then title use -sA+T.
To use your own references, put them in the format described in pubindex(1) They can be searched more rapidly by running pubindex(1) on
them before using refer; failure to index results in a linear search.
When refer is used with eqn, neqn or tbl, refer should be first, to minimize the volume of data passed through pipes.
FILES
/usr/dict/papers directory of default publication lists and indexes
/usr/lib/refer directory of programs
SEE ALSO
REFER(1)