VI editor and tables


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers VI editor and tables
# 1  
Old 09-04-2008
VI editor and tables

I have a host table that looks similar like this:

Code:
# IP                        Name                      Comment
10.10.10.1         Lab1-1                   # Static for Lab1 subnet
10.10.10.2         Lab1-2                   # Static for Lab1 subnet
10.10.10.3         Lab1-3                   # Static for Lab1 subnet
10.10.10.4         Lab1-4                   # Static for Lab1 subnet
10.10.10.5         Lab1-5                   # Static for Lab1 subnet

Lets say I want to add another 200 records. Is there a macro or something I can use in VI to generate the desired table?

Up to now, I've been copying blocks at a time and then using a search/replace to edit this copied block. Obviously this is tedious.

Thanks
# 2  
Old 09-04-2008
A quick and dirty solution, adapt the line if you want to keep the indention if the length of the number increases.
An example how to add 10 lines:

Code:
awk -v number="10" '
END{
  split($1,a,".")
  n=a[4]
  for(i=1;i<=number;i++){
    print "10.10.10." ++n "         Lab1-" n "                   # Static for Lab1 subnet"
  }
}' file > new_file

# 3  
Old 09-04-2008
Thank you for the suggestion.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing two tables

I have defined a set of global variables at the beginning of my script as below: #ideal values export ITEM1=SUCCESS export ITEM2=FAILURE export ITEM3=UNAVAILABLE export ITEM5=FAILURE export ITEM6=SUCCESS now I have a shell script function which returns a value in below format. ITEM1... (1 Reply)
Discussion started by: ctrld
1 Replies

2. Shell Programming and Scripting

Selecting tables

Hi, Can anyone help me that, How to see the table fields in Oracle database through shell script(ksh). I have tried with the following: sqlplus -s $user/$passwd@$sid << SQL >> session.log select * from Testtab.sql I'm not able to see anything.. Thanks (4 Replies)
Discussion started by: zxcjggu708
4 Replies

3. UNIX for Dummies Questions & Answers

Mysqldump certain tables

Hi, I have to upload part of my database periodically when i make changes to product data etc. However I only want to upload certain tables. We suffer from bandwidth chock here, so i want to write a couple of separate scripts that upload parts of the database that changed. The database is large... (5 Replies)
Discussion started by: timgolding
5 Replies

4. IP Networking

IP tables - ip forward to another ip

Hi all, Now my need is: This should forward each client to 1.11 and 1.12 as per each request. I mean : First request should go to : http://192.168.1.10:8080/MySite Second request should go to : http://192.168.1.11:8081/MySite Third request should go to ... (1 Reply)
Discussion started by: linuxadmin
1 Replies

5. Solaris

Epic Editor was not able to obtain a license for your use. Feature Epic Editor :Licen

Epic Editor was not able to obtain a license for your use. Feature Epic Editor :License server is down (1 Reply)
Discussion started by: durgaprasadr13
1 Replies

6. Shell Programming and Scripting

set EDITOR=vi -> default editor not setting for cron tab

Hi All, I am running a script , working very fine on cmd prompt. The problem is that when I open do crontab -e even after setting editor to vi by set EDITOR=vi it does not open a vi editor , rather it do as below..... ///////////////////////////////////////////////////// $ set... (6 Replies)
Discussion started by: aarora_98
6 Replies

7. UNIX for Dummies Questions & Answers

Pasting text in VI editor from a different editor

Hi, I knw its a silly question, but am a newbie to 'vi' editor. I'm forced to use this, hence kindly help me with this question. How can i paste a chunk 'copied from' a different editor(gedit) in 'vi editor'? As i see, p & P options does work only within 'vi'. (10 Replies)
Discussion started by: harishmitty
10 Replies

8. Shell Programming and Scripting

Converting tables of row data into columns of tables

I am trying to transpose tables listed in the format into format. Any help would be greatly appreciated. Input: test_data_1 1 2 90% 4 3 91% 5 4 90% 6 5 90% 9 6 90% test_data_2 3 5 92% 5 4 92% 7 3 93% 9 2 92% 1 1 92% ... Output:... (7 Replies)
Discussion started by: justthisguy
7 Replies

9. UNIX for Dummies Questions & Answers

viewing tables

I have completely blanked out on this and I have done it a million times. I need to modify some tables in unix. What is the command for opening/viewing the tables? Thanks so much. :o (2 Replies)
Discussion started by: itldp
2 Replies
Login or Register to Ask a Question