GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help in reading text file
Operating System - HP-UX
1859294
Members
2971
Online
110398
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
back
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
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
06-29-2010 06:49 AM
06-29-2010 06:49 AM
Hi all,
Consider a text file with the following format:
/filesystem1
/filesystem2
/filesystem3
/filesystem4
/filesystem5
Given the above file I'd need a shell script which read each line of the file, applies some format to every single line and then attach it to another file, somethingo like this:
FILESYSTEM "/filesystem1" server_hostname:"/filesystem1"
{
}
FILESYSTEM "/filesystem2" server_hostname:"/filesystem2"
{
}
FILESYSTEM "/filesystem3" server_hostname:"/filesystem3"
{
}
FILESYSTEM "/filesystem4" server_hostname:"/filesystem4"
{
}
FILESYSTEM "/filesystem5" server_hostname:"/filesystem5"
{
}
Each one of the above output must be added at the end of another text file.
I will really appreciate your support.
Consider a text file with the following format:
/filesystem1
/filesystem2
/filesystem3
/filesystem4
/filesystem5
Given the above file I'd need a shell script which read each line of the file, applies some format to every single line and then attach it to another file, somethingo like this:
FILESYSTEM "/filesystem1" server_hostname:"/filesystem1"
{
}
FILESYSTEM "/filesystem2" server_hostname:"/filesystem2"
{
}
FILESYSTEM "/filesystem3" server_hostname:"/filesystem3"
{
}
FILESYSTEM "/filesystem4" server_hostname:"/filesystem4"
{
}
FILESYSTEM "/filesystem5" server_hostname:"/filesystem5"
{
}
Each one of the above output must be added at the end of another text file.
I will really appreciate your support.
Solved! Go to Solution.
- Tags:
- scripting
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2010 06:55 AM
06-29-2010 06:55 AM
Solution
Hi:
# cat ./mycomposer
#!/usr/bin/sh
while read LINE
do
echo "FILESYSTEM \"${LINE}\" server_hostname:\"${LINE}\""
echo "{\n}"
done < myfile
...where 'myfile' looks like:
# cat ./myfile
/filesystem1
/filesystem2
/filesystem3
/filesystem4
/filesystem5
Regards!
...JRF...
# cat ./mycomposer
#!/usr/bin/sh
while read LINE
do
echo "FILESYSTEM \"${LINE}\" server_hostname:\"${LINE}\""
echo "{\n}"
done < myfile
...where 'myfile' looks like:
# cat ./myfile
/filesystem1
/filesystem2
/filesystem3
/filesystem4
/filesystem5
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2010 07:06 AM
06-29-2010 07:06 AM
Re: Need help in reading text file
Thank you for your support James!!!
It worked just fine.
It worked just fine.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP