Extracting a list of files and creating a new file containing this list <p>I am a researcher and my skill in Unix commands is limited. 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.</p> <p>Basically, the folder has filenames in the following format :</p> <pre><code>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 </code></pre> <p>and so on up until</p> <pre><code>1000_Apple_A_someword.txt 1000_Apple_B_someword.txt </code></pre> <p>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,</p> <pre><code>1_Apple=1_Apple_A_someword.txt 2_Apple=2_Apple_A_someword.txt 3_Apple=3_Apple_A_someword.txt </code></pre> <p>and so on...till</p> <pre><code>1000_Apple=1000_Apple_A_someword.txt </code></pre> <p>Could you tell me a one-line Unix command that does this ? Maybe using "awk" and "sed"</p>