How to change file names in Shell Script?

Solution 1:

A few things to note:

  1. the syntax for command substitution is $( command ) not ($ command )

  2. the syntax for printing the second field in awk is print $2 not print=$2

  3. you need to pass the name of the file as an argument to awk ex. awk 'NR==1 {print $2}' "$f"

Also note that the new file will be created relative to the current directory, rather than the subdirectory sequences (there's not enough detail in your question to know whether that's the intended outcome or not).