Commit 25848b6c authored by Vincent Tam's avatar Vincent Tam

Post drafts

parent f8db76ee
Pipeline #41135400 passed with stages
in 41 seconds
---
title: "2018 12 23 Detect Missing Eof"
date: 2018-12-23T12:10:06+01:00
draft: true
---
for file in `git ls-files`; do grep -Iq . $file && if ! newline_at_eof $file; then; else echo $file && tail -c10 $file && echo '\n'; fi; done
---
title: "Find Files for Rename"
date: 2018-12-23T11:57:58+01:00
type: post
categories:
- technical support
tags:
- Linux
draft: true
---
### Background
Three years ago, I wrote [*Used More Bash Utilities*][old] for batch renaming
files. One of my [Facebook] friends has pointed out that it fails for file names containing whitespace.
### Problem
Recently, I would like to remove the extension name `.sh` of all shell scripts
in `~/bin`, so that `which {script}` will work *without* `.sh`.
### Method
A `for` loop over `$(ls)` is a basic solution, but `find` is _more correct_ since it's possible that a file name contains a space character.
```sh
find ~/bin -maxdepth 1 -name "*.sh" -type f -print0 |\
while read -d $'\0' file; do
mv $file ${file%.*}
done
```
[old]: https://vincenttam.github.io/blog/2015/08/22/used-more-bash-utilities/
[Facebook]: https://facebook.com
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment