- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Need a little search script to find ^L and ^M
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
10-17-2002 10:36 AM
10-17-2002 10:36 AM
I need a little help again. Can anyone suggest a way to run through a directory and search the files to see if they have any carriage return / line feeds in them. We get them in some of our text files when when transfer them in binary mode from our unix boxes to our LAN. The dos2unix utility can strip them off if I can identify them 1st. Any suggestions? Thank you in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 10:50 AM
10-17-2002 10:50 AM
Re: Need a little search script to find ^L and ^M
Cheryl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 10:55 AM
10-17-2002 10:55 AM
Re: Need a little search script to find ^L and ^M
I created a file with vi:
# vi ^l^y^t (by hitting the control L, etc.)
this is a test
:wq!
# ll <--- does not show the file
# ll | cat -vet
total 1124$
-rw-rw-rw- 1 root sys 16 Oct 17 14:52 ^L^Y^T$ <-- here is my file
Here's what a "regular" file looks like:
-rw------- 1 root sys 297 May 13 09:18 .TTauthority$
The $ marks the end of the file name.
The cat -vet helps print those unseen characters.
Cheryl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 11:12 AM
10-17-2002 11:12 AM
Solutionfind . -type f -print | while read FNAME
do
awk '/.*\015/ { exit 99 }; /.*\014/ { exit 98 }' ${FNAME}
STAT=${?}
if [[ ${STAT} -eq 99 || ${STAT} -eq 98 ]]
then
echo "File ${FNAME} needs some work."
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 11:17 AM
10-17-2002 11:17 AM
Re: Need a little search script to find ^L and ^M
If I understand your question, you just want to find the files that have carriage return characters in them and run the dos2ux utility on them. Here is a little script I came up with to do it. To get the ^M character in the grep line, I had to hit Ctrl-X and then Ctrl-M. I also had to do it in sh as I couldn't get a ^M entered in ksh, but that is another problem. Take a look at this:
#!/bin/sh
# find_dos_files
for f in $(ls *.txt)
do
CR=$(grep -c '^M' $f)
if [[ CR -gt 0 ]]
then
echo "The $f file has CR/LF and needs to be converted."
mv $f $f.tmp
dos2ux $f.tmp >$f
rm $f.tmp
fi
done
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 11:18 AM
10-17-2002 11:18 AM
Re: Need a little search script to find ^L and ^M
: find all files down from the current folder that contain any characters from ^A to ^
# find . -type d | perl -nle'opendir D,$_;for$f(grep/[\001-\037],readdir D){$f=~s/([\001-\037])/sprintf"^%03o",ord$1/ge;print "$_/$f"}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2002 11:24 AM
10-17-2002 11:24 AM
Re: Need a little search script to find ^L and ^M
echo '^M' > x
find /dir -type f | xargs grep -lf x {}
To get the '^M' use ctrl-V ctrl-M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2002 06:18 AM
10-22-2002 06:18 AM