recording keystrokes in vi


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers recording keystrokes in vi
# 1  
Old 12-07-2005
recording keystrokes in vi

What is the syntax for recording command in vi. If I want to repeat a command over and over.

My file is
12/01/05,,adsmte,9,0,0
12/02/05,,adsmte,12,0,0
12/03/05,,adsmte,10,0,0
12/04/05,,adsmte,11,0,0
12/05/05,,adsmte,10,0,0
12/06/05,,adsmte,10,0,0
12/01/05,,tsmpc1,57,1,2
12/02/05,,tsmpc1,83,4,2
12/03/05,,tsmpc1,89,6,2
12/04/05,,tsmpc1,31,1,0
12/05/05,,tsmpc1,35,1,0
12/06/05,,tsmpc1,52,5,2
12/01/05,,tsmpc2,86,2,2
12/02/05,,tsmpc2,94,5,1

and I want to insert Thu,Fri,Sat,Sun in between ,, without having to type that one at a time on each line.
I this is something I have done before but can't recall how.
# 2  
Old 12-07-2005
awk should do it...

If your input file is 'test' you can do it without vi'ing it - which has to be easier. Try this:

awk -F',' '{ print $1",Thu,Fri,Sat,Sun,"$3","$4","$5","$6 }' test > test1

where test1 is an output file - which looks like this:

12/01/05,Thu,Fri,Sat,Sun,tsmpc2,86,2,2
12/02/05,Thu,Fri,Sat,Sun,tsmpc2,94,5,1

HTH,
# 3  
Old 12-07-2005
Thanks for the reply but what I am trying to achieve is
12/01/05,Thu,adsmte,9,0,0
12/02/05,Fri,adsmte,12,0,0
12/03/05,Sat,adsmte,10,0,0
12/04/05,Sun,adsmte,11,0,0
12/05/05,Mon,adsmte,10,0,0
12/06/05,Tue,adsmte,10,0,0
12/01/05,Thu,tsmpc1,57,1,2
12/02/05,Fri,tsmpc1,83,4,2
12/03/05,Sat,tsmpc1,89,6,2
12/04/05,Sun,tsmpc1,31,1,0
12/05/05,Mon,tsmpc1,35,1,0
12/06/05,Tue,tsmpc1,52,5,2
12/01/05,Thu,tsmpc2,86,2,2
# 4  
Old 12-07-2005
sed 's=12/01/05,,=12/01/05,Tue,=;s=12/02/05,,=12/02/05,Wed,=' <input >output
# 5  
Old 12-08-2005
That way works Perderabo but I'm really trying to recall how to record repetitive keystrokes in vi.
# 6  
Old 12-08-2005
There's several ways do that in vi...maybe you were using map
:map ; o123^V^M^V^[

^V = control V
^M = cntrol M
^[ = escape

Now ; will add a line with just 123.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting recording using egrep

Hello, Need help using egrep file format: test.gz Date, time, , number 1, number 2, counter... 20130618,912154, ,009912345678,911111111111,10000, , ,abc 20130618,982148, ,009101373810,034028791952294,8999, , ,gh Want to extract number1 OR number2 records in files based on a two or... (8 Replies)
Discussion started by: vegasluxor
8 Replies

2. UNIX for Advanced & Expert Users

Recording stats for Comcast

The last few weeks I've had a problem with Comcast in San Francisco (anyone else sharing the same issue ? Please share !) During the late afternoon throughout early morning hours I see a high amount of dropped packets and increased latency when pinging my favorite destinations, like 8.8.8.8. ... (1 Reply)
Discussion started by: SandmanCL
1 Replies

3. Shell Programming and Scripting

Record and re-use keystrokes

We have a FORTRAN program that creates a report for our client. The client makes a number of selections as to what will appear on the report. However, the client has to repeat this everytime the report is run. I am trying to find a way to record what they've selected (their keystrokes) in UNIX and... (22 Replies)
Discussion started by: KathyB148
22 Replies

4. UNIX for Advanced & Expert Users

Sending keystrokes to another process

The third-party ERP system used by our company has no idle-out facility and we sometimes have issues because users simply walk away from their computers and leave sessions logged in for hours or even go home without logging out. (We are in a factory environment so it is hard to raise the care... (7 Replies)
Discussion started by: Wayne Ivory
7 Replies

5. Programming

How do you detect keystrokes in canonical mode?

I'm writing a command shell, and I want to be able to detect when the user presses an arrow key (otherwise it just prints [[A, [[B, etc.). I know it's relatively easy (although somewhat more time-consuming) to detect keystrokes in noncanonical mode, but I've noticed that the bash shell detects... (4 Replies)
Discussion started by: Ultrix
4 Replies

6. OS X (Apple)

Any mac software for recording keystrokes

I'm trying to find a good keylogger that doesn't come with any viruses. It happens to me several times that my browser crashes when I am in article writing or some other thing, very annoying. Thus, I need a keylogger to keep all my keystroke recorded. I 'v tried some, like the Aobo Mac Keylogger,... (1 Reply)
Discussion started by: Bluerosen
1 Replies

7. Shell Programming and Scripting

Queueing keystrokes

Hello, I have a ksh which can be run interactively with read etc waiting for input and so forth. Do you have an idea how can I invoke the ksh and supply a sequence of keystrokes that will feed the executable flow so that it will automatically run as if someone actually walked through one prompt... (7 Replies)
Discussion started by: gio001
7 Replies

8. UNIX for Dummies Questions & Answers

Looking for an X11 Utility - Send Keystrokes to Multiple Clients

A long time ago, I frequently used a small X11 utility that allows you to manage multiple systems at the same time. It worked by opening a small window that had a button you used to "Add" X Clients to it. These would be xterms on different systems for example. You would then type inside that... (5 Replies)
Discussion started by: Alon.Albert
5 Replies

9. Shell Programming and Scripting

tool to emulate keystrokes out to a ps/2 device?

hey all, i am trying to connect my mac to my sony DVD changer so that i can control one aspect of it with any kind of shell script or program. the DVD player allows you to plug in a PS/2 keyboard to navigate it's on screen menu. what i want to do is use my mac to navigate my own menus, then... (0 Replies)
Discussion started by: drzoomn
0 Replies
Login or Register to Ask a Question