Solaris 5.8, ksh
I need to open everyone's favorite editor, vi
of course, with a command that will place me on a search string at the time of invocation:
Given this data file:
user1 pts/1 Aug 29 13:22 (10.12.214.101)
user2 pts/2 Aug 29 09:56 (10.12.212.132)
user3 pts/3 Aug 29 12:39 (10.12.212.132)
user4 pts/6 Aug 29 13:29 (10.12.212.117)
user5 pts/5 Aug 28 08:13 (10.12.212.132)
user6 pts/4 Aug 29 13:14 (10.12.212.96)
I want to open vi
, with the cursor positioned on the first occurrence of "132" (last number in the second line).
Having a look at the man vi
page in the invocation options section:
+command | -c command
Begin editing by executing the specified editor com-
mand (usually a search or positioning command).
I launch vi
like this: $ vi +/132 filename.dat
, expecting to end up positioned on the "1" of the first "132". Instead, I end up at the very first column of the row that contains the pattern. So, it seems that the "specified editor command" is not necessarily the same command as you would expect after vi
has opened the file (where typing /132 indeed places me on the "132".
Putting double or single quotes around the "132" does not make a difference.
Any ideas? Is there a list of what commands are available when starting vi
like this? I cannot seem to find a list.
Thank you,
Gary