bash script - get filename created by script using variables
Probably a horrible title for this thread, but here goes...
If I create a file via bash script like so: Code:
tar -C $BACKUP_DIR -czf backup_$HOST_$STAMP.tar.gz . Thank you. Andrew |
Why not define the variable name first, before the tar command?
Code:
filename=backup_$HOST_$STAMP.tar.gz |
Quote:
|
One of us is missing something :scratch: how about show us the chunk of code where this procedure takes place? And where the $STAMP gets defined...
|
Code:
#!/bin/bash then later, I want to echo the filename that was created. |
Code:
#!/bin/bash Sasha |
Perfect.
Question, was it necessary to rewrite the STAMP and HOST variables? Is there a problem with using the VAR=`command` syntax? |
using `backticks` instead of $(this) is deprecated. While either will work for simple operations, using backticks becomes confusing when there are longer commands or statements, or when you need to embed multiple instances.
I'm sure there's an "official" reason stated somewhere about why one is better than the other, but I don't know it verbatim :) though others may have more detail to provide on why to use $() instead of `` Cheers! Sasha |
Quote:
|
All times are GMT -5. The time now is 03:54 PM. |