Use Variable Date in Sed Command
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
I want to use sed
command as below:
$ sed -n '/MONTH_TODAY DATE_YEST/,/MONTH_TODAY DATE_TODAY/p'
/home/crmiib/TESTUSERLOG/XYZ/user.log
I can print logs using:
$ sed -n '/Jul 27/,/Jul 28/p' /home/crmiib/TESTUSERLOG/XYZ/user.log
But I want to view logs using variables instead of hard coded dates?
sed logs split data
add a comment |Â
up vote
3
down vote
favorite
I want to use sed
command as below:
$ sed -n '/MONTH_TODAY DATE_YEST/,/MONTH_TODAY DATE_TODAY/p'
/home/crmiib/TESTUSERLOG/XYZ/user.log
I can print logs using:
$ sed -n '/Jul 27/,/Jul 28/p' /home/crmiib/TESTUSERLOG/XYZ/user.log
But I want to view logs using variables instead of hard coded dates?
sed logs split data
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I want to use sed
command as below:
$ sed -n '/MONTH_TODAY DATE_YEST/,/MONTH_TODAY DATE_TODAY/p'
/home/crmiib/TESTUSERLOG/XYZ/user.log
I can print logs using:
$ sed -n '/Jul 27/,/Jul 28/p' /home/crmiib/TESTUSERLOG/XYZ/user.log
But I want to view logs using variables instead of hard coded dates?
sed logs split data
I want to use sed
command as below:
$ sed -n '/MONTH_TODAY DATE_YEST/,/MONTH_TODAY DATE_TODAY/p'
/home/crmiib/TESTUSERLOG/XYZ/user.log
I can print logs using:
$ sed -n '/Jul 27/,/Jul 28/p' /home/crmiib/TESTUSERLOG/XYZ/user.log
But I want to view logs using variables instead of hard coded dates?
sed logs split data
edited Jul 28 at 19:10
slmâ¦
232k65479649
232k65479649
asked Jul 28 at 18:28
Hamas Rizwan
404
404
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
Use double quotes so the shell evaluates the variables before sed
runs:
DATE_YEST="Jul 27"
DATE_TODAY="Jul 28"
sed -n "/$DATE_YEST/,/$DATE_TODAY/p" /home/crmiib/TESTUSERLOG/XYZ/user.log
Thanks Man.! :)
â Hamas Rizwan
Jul 28 at 18:59
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Use double quotes so the shell evaluates the variables before sed
runs:
DATE_YEST="Jul 27"
DATE_TODAY="Jul 28"
sed -n "/$DATE_YEST/,/$DATE_TODAY/p" /home/crmiib/TESTUSERLOG/XYZ/user.log
Thanks Man.! :)
â Hamas Rizwan
Jul 28 at 18:59
add a comment |Â
up vote
4
down vote
accepted
Use double quotes so the shell evaluates the variables before sed
runs:
DATE_YEST="Jul 27"
DATE_TODAY="Jul 28"
sed -n "/$DATE_YEST/,/$DATE_TODAY/p" /home/crmiib/TESTUSERLOG/XYZ/user.log
Thanks Man.! :)
â Hamas Rizwan
Jul 28 at 18:59
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Use double quotes so the shell evaluates the variables before sed
runs:
DATE_YEST="Jul 27"
DATE_TODAY="Jul 28"
sed -n "/$DATE_YEST/,/$DATE_TODAY/p" /home/crmiib/TESTUSERLOG/XYZ/user.log
Use double quotes so the shell evaluates the variables before sed
runs:
DATE_YEST="Jul 27"
DATE_TODAY="Jul 28"
sed -n "/$DATE_YEST/,/$DATE_TODAY/p" /home/crmiib/TESTUSERLOG/XYZ/user.log
edited Jul 28 at 18:41
answered Jul 28 at 18:38
JRFerguson
9,06532228
9,06532228
Thanks Man.! :)
â Hamas Rizwan
Jul 28 at 18:59
add a comment |Â
Thanks Man.! :)
â Hamas Rizwan
Jul 28 at 18:59
Thanks Man.! :)
â Hamas Rizwan
Jul 28 at 18:59
Thanks Man.! :)
â Hamas Rizwan
Jul 28 at 18:59
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459077%2fuse-variable-date-in-sed-command%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password