- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: read looses leading spaces
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
02-11-2005 02:03 AM
02-11-2005 02:03 AM
Regrads,
John.
while read -r f1
do
newtest=`echo $f1 |cut -c1`JF
if [ $newtest = "^LJF" ]
then
mv jf1.txt jf2.txt
cat jf2.txt | ux2dos | uuencode jf.txt | mail fngj@ptipc-144
rm jf2.txt
f1=`echo $f1 |cut -c2-70`
fi
echo "$f1" >> jf1.txt
done < APB003RR.txt_FE_0126_150409
cat jf1.txt | ux2dos | uuencode jf.txt | mail fngj@paipc-144
rm jf1.txt
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2005 02:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2005 02:13 AM
02-11-2005 02:13 AM
Re: read looses leading spaces
$>read a && echo $a
[some spaces]az
az
$>export IFS=\
>
$>read a && echo $a
[some spaces]az
[some spaces]az
example looks bad cause ITRC forum removes leading spaces :/
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2005 02:15 AM
02-11-2005 02:15 AM
Re: read looses leading spaces
Thank you.
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2005 02:16 AM
02-11-2005 02:16 AM
Re: read looses leading spaces
Try this loop:
INFILE=myfile
exec 4<${INFILE}
f1=$(line <&4)
STAT=${?}
while [[ ${STAT} -eq 0 ]]
do
echo "\"${f1}\""
f1=$(line <&4)
STAT=${?}
done
I think you will find that your spaces are now preserved.
Man line for details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2005 07:47 PM
02-13-2005 07:47 PM
Re: read looses leading spaces
It also seems to strip some of the control characters in the file e.g. ^L for new page.
Is 4 a buffer number? can exec be used to read and process several files?
Regards,
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2005 02:23 AM
02-14-2005 02:23 AM
Re: read looses leading spaces
exec 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2005 02:50 AM
02-14-2005 02:50 AM
Re: read looses leading spaces
Thanks,
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2005 03:47 AM
02-14-2005 03:47 AM
Re: read looses leading spaces
INFILE=myfile
exec 4<${INFILE}
f1=$(line <&4)
STAT=${?}
while [[ ${STAT} -eq 0 ]]
do
echo "\"${f1}\""
f1=$(line <&4)
STAT=${?}
done
if [[ -n "${f1}" ]]
then
echo "\"${f1}\"\c"
fi
Note that \c is added to the echo so that no NL is added to this last output.
You are probably more familiar with file descriptors then you know. For example, error messages should be directed to stderr rather than stdout so to do that:
echo "Bad Error" >&2
In this case there is no need for an exec because stderr is already associated with file descriptor 2.