- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting help
Operating System - HP-UX
1752808
Members
7022
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
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
тАО04-08-2009 06:00 AM
тАО04-08-2009 06:00 AM
Hi. I have a file which contains data in specific positions, its a CISAM file.
When I cat the file normally for example,
cat file | cut -c 265 returns
Y
Y
Y
N
However, when I
cat file | while read line
The "read line" section truncates the position of 265 and leaves only one space between the text fields.
For example cat file | head -1 shows
AIMPORT 001199910251416U094CLE 199911241809Q823EYX IMPORT AUTO ALLOCATION
GBP
00000000018000
Y A
But with the while read line , $line shows as
AIMPORT 001199910251416U094CLE 199911241809Q823EYX IMPORT AUTO ALLOCATION GBP 00
000000018000 Y A
I am not too sure how to use $IFS.
How can I get "read" to not remove the spaces !!?
When I cat the file normally for example,
cat file | cut -c 265 returns
Y
Y
Y
N
However, when I
cat file | while read line
The "read line" section truncates the position of 265 and leaves only one space between the text fields.
For example cat file | head -1 shows
AIMPORT 001199910251416U094CLE 199911241809Q823EYX IMPORT AUTO ALLOCATION
GBP
00000000018000
Y A
But with the while read line , $line shows as
AIMPORT 001199910251416U094CLE 199911241809Q823EYX IMPORT AUTO ALLOCATION GBP 00
000000018000 Y A
I am not too sure how to use $IFS.
How can I get "read" to not remove the spaces !!?
Argh ye land lovers !
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2009 06:11 AM
тАО04-08-2009 06:11 AM
Solution
Hi:
You need to use double quotes. Consider:
#!/usr/bin/sh
while read LINE
do
echo "${LINE}"
echo ${LINE}
done < file
...compare the output when you run this.
Note that 'cat file|whle read...' adds a needless process. Let the shell do the work as I show above.
Regards!
...JRF...
You need to use double quotes. Consider:
#!/usr/bin/sh
while read LINE
do
echo "${LINE}"
echo ${LINE}
done < file
...compare the output when you run this.
Note that 'cat file|whle read...' adds a needless process. Let the shell do the work as I show above.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2009 06:38 AM
тАО04-08-2009 06:38 AM
Re: Scripting help
Thanks James, answered my question !!
Argh ye land lovers !
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP