I am currently dealing with a folder containing about 1000 files and I have to extract some filenames from this folder and create another file (configuration file) containing these filenames.
Basically, the folder has filenames in the following format :
1_Apple_A_someword.txt 1_Apple_B_someword.txt 2_Apple_A_someword.txt 2_Apple_B_someword.txt 3_Apple_A_someword.txt 3_Apple_B_someword.txt
and so on up until
I just want to extract out all files which have "Apple_A" in them. Also, I want to create another file which has 'labels' (Unix variables) for each of these "Apple_A" files whose values are the names of the files. Also, the 'labels' are part of the filenames (everything up until the word "Apple") For example,
1_Apple=1_Apple_A_someword.txt 2_Apple=2_Apple_A_someword.txt 3_Apple=3_Apple_A_someword.txt
and so on...till
Could you tell me a one-line Unix command that does this ? Maybe using "awk" and "sed"