You can also watch this video at YouTube (but with ads).
Mac Terminal Commands and Apps To Work With Text Files
Comments: 3 Responses to “Mac Terminal Commands and Apps To Work With Text Files”
Comments Closed.
You can also watch this video at YouTube (but with ads).
Thank you-most of this was new to me. Do you know a command to append a text file’s name into itself? Ideally this would be on the same row as the existing text, rather than in a new row as with conCATenate. One of my students has a 100 tiny text files that are systematically named and include only 2 numbers. She needs to end up with a single text file that includes the name of each file on the same line as its 2 numbers (so this would open in Numbers as a 3 column sheet with 100 row).
Jasper: A simple shell script would output this.
for i in *; do cat "$i"; echo "\t$i"; done ;
This will output it to the Terminal. You can then copy and paste into a text file or directly into Numbers.
Thanks Gary, I couldn't get that to work but I found/adapted this:
grep "" *.txt > agnes.txt
This looks inside any .txt-extension files ('file1.txt..') and adds their name and their contents (incrementing pairs of numbers) to a new text file called 'agnes.txt'.
file1.txt:1, 2
file2.txt:3, 4
file3.txt:5, 6