i've looked at most of the options and haven't seen capability of it accepting any input file .
the only input that i've used is the path to a charset :
-f /path/to/charset.lst charset-name
in my case: /usr/share/crunch/ where charset-name is one of :
hex-lower = [0123456789abcdef]
hex-upper = [0123456789ABCDEF]
etc etc
From looking at the man pages for crunch - I think you may be right! Which means my script suggestion is probably the best way to go for this particular problem.
@None-yet
Here's a quick and dirty python3 script written in a few minutes during my lunch break, that attempts to read the entire input file and generates the required output file.....
NOTE: At the very last minute I noticed what you posted about special characters at the end of the sequence. So I've added code that generates a sequence of special characters and appends one of each of those to the end of each year/name combo too.
e.g.
{year}{name}{special char}
Python:
#!/usr/bin/env python3
def getSpecialCharsInRange(start, end):
ret=""
for x in range(start,end+1):
ret+=chr(x)
return ret
def main():
try:
inputFile = open("name-list", "r")
except:
print("ERROR - Input file not found!")
exit(1)
try:
outputFile = open("output-file", "w")
except:
print("ERROR - Unable to create output file")
exit(1)
# Generate a set of printable special characters
# assuming UTF-8 as per:
# https://www.utf8-chartable.de/
specialchars=""
specialchars += getSpecialCharsInRange(33,47)
specialchars += getSpecialCharsInRange(58,64)
specialchars += getSpecialCharsInRange(91,96)
specialchars += getSpecialCharsInRange(123,126)
specialchars += getSpecialCharsInRange(160,255)
nameList = inputFile.readlines()
inputFile.close()
for name in nameList:
if name and name.strip():
name = name.replace('\n','').replace('\r','')
for num in range(2000, 2099+1):
outputFile.write(str(num)+name+"\n")
for special in specialchars:
outputFile.write(str(num)+name+special+"\n")
if __name__ == "__main__":
main()
Save that as whatever you like and make it executable using
chmod +x {filename}
Where {filename} is whatever you called it.
I called it joinYearsAndNames (without the .py extension).
The script uses a shebang - so the shell will automatically invoke the python3 interpreter when the script is ran. Omitting the .py extension makes it seem like a normal terminal command. Especially if you put it somewhere in your path. I have a personal bin/ directory set up in my home directory which has been added to $PATH. Then you don't have to prefix the script name with
./
when you run it!! Otherwise, if it is off your path, run it using
./joinYearsAndNames
- or whatever you called it!
As long as you have a file called "input-file" which contains some names - (or you have replaced "input-file" in the script with a path to a file containing a list of names) - then the script will iterate through the names, generate a sequence of numbers and output each number and the current name to the output file "output-file".
And for each year/name combo, it also writes out each one with one of each printable special character at the end.
Again - substitute "output-file" with a path/file-name to suit your needs.
By default the program expects the input and output files to be in the current directory.
I decided to use python rather than shell script, because python performs well and I think it might be faster and more robust than shellscript for this particular application.
I didn't have time to make the script more generic
e.g.
To allow it to accept arguments to define the input and output files. So it simply uses hard-coded paths to the input and output files.
But I have used pythons try/except mechanism to catch problems with the code which opens the input and output files. So it should be fairly robust.
Also, the script reads the entire name-list into memory.
If the name-list is extremely large - you might want to consider reading the input file line by line, or in blocks.
But I'll leave you to make any modifications.
FYI - On my work PC - with your list of 12 names, it generates all of the possible combinations in 0.27 seconds, yielding a 2.1Mb output file containing 154800 lines.