- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Adding and removing control characters from a docu...
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
Discussions
Discussions
Forums
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
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
тАО07-09-2009 09:21 AM
тАО07-09-2009 09:21 AM
What works currently:
if [[ $(head -c -n 1 ${OUTPUTFILE}) = $(head -c -n 1 ${FEEDFILE}) ]]
then
#remove form feed character from the beginning
mv ${OUTPUTFILE} ${TEMPFILE}
tail -c +2 ${TEMPFILE} > ${OUTPUTFILE}
rm ${TEMPFILE}
fi
if [[ $(tail -n 1 ${NEWOUT}) != $(head -c -n 1 ${FEEDFILE}) ]]
then
#add a form feed character to the end
mv ${NEWOUT} ${TEMPFILE}
cat ${TEMPFILE} ${FEEDFILE} > ${NEWOUT}
rm ${TEMPFILE}
fi
These methods remove all the ^M's, not just one:
sed 's/^L/^g' ${OUTPUTFILE} > ${TEMPFILE}
tr -d "\14" < ${INPUTFILE} > ${TEMPFILE}
perl -p -i -e 's/^L//g' ${INPUTFILE}
With awk I can remove the first form feed but I don't want to do that unless it's the first character of the file:
awk '/\014/&&f<1{sub("\014","");1' ${OUTPUTFILE} > ${TEMPFILE}
Ideas appreciated!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 09:40 AM
тАО07-09-2009 09:40 AM
Re: Adding and removing control characters from a document
If I understand your requirement, try this:
# perl -0777 -pi.old -e 's/^\014//;s/$/\014/' file
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 10:33 AM
тАО07-09-2009 10:33 AM
Re: Adding and removing control characters from a document
$ cat awk.scr
==============================
BEGIN {
ff="\014"
}
{
if (NR == 1)
{
sub(ff,"");
}
print $0;
}
END{
print ff;
}
=======================================
awk -f awk.scr
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 11:16 AM
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 06:39 AM
тАО07-15-2009 06:39 AM
Re: Adding and removing control characters from a document
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 06:51 AM
тАО07-15-2009 06:51 AM
Re: Adding and removing control characters from a document
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 06:53 AM
тАО07-15-2009 06:53 AM