Last active
May 20, 2020 06:24
-
-
Save jschnasse/c320af2187e46c4aad1a8c19407fdd0c to your computer and use it in GitHub Desktop.
Convert `ls -l` to csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
_space_="\ *"; | |
type="."; | |
perm="[^\ ]*"; | |
hlinks=$perm; | |
user=$perm; | |
group=$perm; | |
size=$perm; | |
modified=".{12}"; | |
name=".*"; | |
REGEX="^($type)" | |
REGEX=${REGEX}"($perm)" | |
REGEX=${REGEX}"$_space_" | |
REGEX=${REGEX}"($hlinks)" | |
REGEX=${REGEX}"$_space_" | |
REGEX=${REGEX}"($user)" | |
REGEX=${REGEX}"$_space_" | |
REGEX=${REGEX}"($group)" | |
REGEX=${REGEX}"$_space_" | |
REGEX=${REGEX}"($size)" | |
REGEX=${REGEX}"$_space_" | |
REGEX=${REGEX}"($modified)" | |
REGEX=${REGEX}"$_space_($name)" | |
ls -l $@ | \ | |
sed -r -e s/"$REGEX"/'"\1","\2","\3","\4","\5","\6","\7","\8"'/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment