3 ms·
Instead to create a script in Python to convert numbers in integers, you can use awk: "python3 parse.py" becomes "awk '{printf "%d\n", $0}'"
by inp 8y ago
Instead to create a script in Python to convert numbers in integers, you can use awk: "python3 parse.py" becomes "awk '{printf "%d\n", $0}'"
- darrenf 8y agoWhy even use awk rather than the shell's (well, bash's) builtin printf? $ printf '%d\n' "0005" 5
- inp 8y agoYou can apply the awk command on a pipe, and so it is applies on each line of the file/stream.
- darrenf 8y agoRight - though that's solvable with xargs: $ echo "0005" | xargs printf '%d\n' 5 That said, my suggestion doesn't work anyway since the leading 0 marks it as octal, d'oh (as mentioned elsewhere in the thread).
- jfk13 8y agoThat might not always do what a naïve user expects: $ printf '%d\n' "0025" 21
- deleted 8y ago[deleted]
- tyingq 8y agoNot sure I understand why it needs to even know there's numbers in the filename. The problem seems to boil down to: "Find all files with the pattern '[something]_data.csv' and report if '[something]_A.csv' doesn't exist" Unless I'm missing something, all the sorting and sequence generation isn't adding anything.