Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F840
FixNewLines.sh
Public
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
clarkson
May 31 2012, 9:35 AM
2012-05-31 09:35:07 (UTC+2)
Size
500 B
Referenced Files
None
Subscribers
None
FixNewLines.sh
View Options
#!/bin/sh
newline
=
'
'
for
f in h cpp cxx txx
do
filenames
=
`
find . -type f -name
"*.${f}"
`
number_of_files
=
`
find . -type f -name
"*.${f}"
| wc -l
`
for
g in
${
filenames
}
do
lastline
=
$(
tail -n 1
${
g
}
;
echo
x
)
;
lastline
=
${
lastline
%x
}
lastcharacter
=
"${lastline#"
${
lastline
%?
}
"}"
echo
"${lastcharacter}"
> /tmp/a.txt
echo
"${newline}"
> /tmp/b.txt
match
=
`
diff /tmp/a.txt /tmp/b.txt | wc -l
`
[
"${match}"
!
=
"0"
]
&&
echo
>>
${
g
}
done
done
rm /tmp/a.txt /tmp/b.txt
File Metadata
Details
Attached
Mime Type
application/x-shellscript
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
811
Default Alt Text
FixNewLines.sh (500 B)
Attached To
Mode
T12044: Fix no newline at end of file warning
Attached
Detach File
Event Timeline
clarkson
added a comment.
May 31 2012, 9:35 AM
2012-05-31 09:35:07 (UTC+2)
Comment Actions
Script to add a new line to files without new lines at the end.
Log In to Comment