Команда внутри другой команды - Bash

Note

I know how to run a simple command inside another command, but in my case is special.

My command contain ". (date "+%Y-%m-%d")

Goal

I need to display my log via 1 command

Steps

If I do this date "+%Y-%m-%d" I will get 2020-06-03

I want to pass that command into another command like this :

tail -f /Users/jdoe/Sites/laravel7/storage/logs/laravel-"date "+%Y-%m-%d"".log

I can't to get it working.

How do I do it ?

Expected

To run this command

tail -f /Users/jdoe/Sites/laravel7/storage/logs/laravel-2020-06-03.log
0
задан 12 June 2020 в 17:37

1 ответ

This is called command substitution

tail -f /Users/jdoe/Sites/laravel7/storage/logs/laravel-$(date "+%Y-%m-%d").log

An older deprecated syntax uses backticks

tail -f /Users/jdoe/Sites/laravel7/storage/logs/laravel-`date "+%Y-%m-%d"`.log
2
ответ дан 19 June 2020 в 21:31

Другие вопросы по тегам:

Похожие вопросы: