- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Adding and removing control characters from a ...
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
Forums
Discussions
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
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