Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 11th, 2008, 01:20 PM
Ziptnf's Avatar
Ziptnf Ziptnf is offline
Haphazardly programming
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Louisville, KY
Posts: 195 Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 15 h 57 m 59 sec
Reputation Power: 26
Send a message via AIM to Ziptnf Send a message via MSN to Ziptnf Send a message via Yahoo to Ziptnf
Cool Need help writing a bash script

Suppose I had a reference text file where each line was a path to a file. I need to be able to edit these files one at a time.

I have sort of an idea on how to do it, but not much code. Can anyone help me?

Code:
#!/bin/bash
read -p <one file at a time> LIMIT

for ((N=1; N<$LIMIT+1; N++)); do

vi ${N}

done

Reply With Quote
  #2  
Old January 11th, 2008, 01:27 PM
Matt1776's Avatar
Matt1776 Matt1776 is offline
Recovering Intellectual
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Orange County, CA
Posts: 922 Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 4 h 14 m 15 sec
Reputation Power: 347
Send a message via ICQ to Matt1776 Send a message via AIM to Matt1776 Send a message via MSN to Matt1776 Send a message via Yahoo to Matt1776 Send a message via Skype to Matt1776
Quote:
Originally Posted by Ziptnf
Suppose I had a reference text file where each line was a path to a file. I need to be able to edit these files one at a time.

I have sort of an idea on how to do it, but not much code. Can anyone help me?

Code:
#!/bin/bash
read -p <one file at a time> LIMIT

for ((N=1; N<$LIMIT+1; N++)); do

vi ${N}

done


in vi you can edit files like this by default. just cat the reference file and pipe it through xargs vi:
Code:
cat <file_with_paths> | xargs vi
__________________
Bugs that go away by themselves come back by themselves
Never take life seriously, Nobody gets out alive anyway.

Reply With Quote
  #3  
Old January 11th, 2008, 01:43 PM
Ziptnf's Avatar
Ziptnf Ziptnf is offline
Haphazardly programming
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Louisville, KY
Posts: 195 Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 15 h 57 m 59 sec
Reputation Power: 26
Send a message via AIM to Ziptnf Send a message via MSN to Ziptnf Send a message via Yahoo to Ziptnf
Quote:
Originally Posted by Matt1776
in vi you can edit files like this by default. just cat the reference file and pipe it through xargs vi:
Code:
cat <file_with_paths> | xargs vi

This is almost exactly what I'm looking for.

The problem is, once I'm done editing a file, and I save it (using x in the vi command), it goes back to the terminal, and the spacing is all screwed up. How do I move to the next file?

EDIT: I went to the manual for VI and found it. The command is :n
Comments on this post
Matt1776 agrees: You got it man. ;0)

Last edited by Ziptnf : January 11th, 2008 at 01:55 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Need help writing a bash script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway