I am trying to write a bash script which takes a file as a command line argument and appends the name of that file, the number of lines and the last modified date to the file. I am confused over how to access that file from within the bash script and how the command line arguments behave within the script.
Here's my script so far:
#!/bin/bash
filename = $1
linecount = $(wc -l $1)
lastmod = $(date -r $1)
echo "$filename $linecount $lastmod" >> $1
I think I'm doing something wrong with the $1
references. Generally confused about how to manipulate a command line argument that is a file.