Reputation: 2551
I'm trying to achieve something like below.
I have a file called file_number
and another file called serial_number
which is containing a number inside it. Let's say 1.
Now, I want to append this number 1 from the serial_number
file to the name of the my existing file called file_number
. So, i want it to become file_number_1
How to do this in Unix??
Upvotes: 1
Views: 52
Reputation: 548
I think you're asking to do this:
mv "file_number" "file_number_$(cat serial_number)"
Example demonstration:
[email protected]:~ $ touch file_number
[email protected]:~ $ echo 1 > serial_number
[email protected]:~ $ cat serial_number
1
[email protected]:~ $ ls -l
total 8
-rw-r--r-- 1 nicolaw staff 0 25 Oct 14:07 file_number
-rw-r--r-- 1 nicolaw staff 2 25 Oct 14:07 serial_number
[email protected]:~ $ mv "file_number" "file_number_$(< serial_number)"
[email protected]:~ $ ls -l
total 8
-rw-r--r-- 1 nicolaw staff 0 25 Oct 14:07 file_number_1
-rw-r--r-- 1 nicolaw staff 2 25 Oct 14:07 serial_number
[email protected]:~ $
Upvotes: 3