- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- loop to add line to file list
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 11:04 PM
01-31-2005 11:04 PM
loop to add line to file list
2 instrument.sql
4 parameter(data).sql
1 programs.sql
when i try to add a blank line to the end of these file with
for i in `ls *`;do echo "" >> $i; done
i get the following files;
2
2 instrument.sql
4
4 parameter(data).sql
1
1 programs.sql
Can anyone tell me how to do this correctly??
Thanks in advance - Declan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 11:17 PM
01-31-2005 11:17 PM
Re: loop to add line to file list
works for me!
Created file a.lis:
1
2
then ran your command and got:
1
2
So the line was added!
I assume the numbers in front of the filenames come from ll?
Can you do a ls -b ?
(Hidden files/control characters ????)
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 11:28 PM
01-31-2005 11:28 PM
Re: loop to add line to file list
Have you blank in file names?
Try:
for i in `ls`
do
echo "" >> "$i"
done
Rgds
JMB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 11:31 PM
01-31-2005 11:31 PM
Re: loop to add line to file list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 12:20 AM
02-01-2005 12:20 AM
Re: loop to add line to file list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 12:38 AM
02-01-2005 12:38 AM
Re: loop to add line to file list
were was the problem then?
In the for loop or the filenames?
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 12:41 AM
02-01-2005 12:41 AM
Re: loop to add line to file list
ls * | while read i; do echo "" >> "$i"; done
not sure this wouldn't work for original loop though
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 02:28 AM
02-01-2005 02:28 AM
Re: loop to add line to file list
2, instrument.sql, 4, parameter(data).sql, 1, programs.sql
i.e. 6 arguments, when in fact you wanted only 3 arguments "2 instrument.sql", "4 parameter(data).sql" and "1 programs.sql"
apart from stating the obvious (i.e. don't use spaces in file names), the while/read construct sees each argument from the ls as a separate line, rather than as separate strings separated by whitespace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 02:33 AM
02-01-2005 02:33 AM
Re: loop to add line to file list
Cheers