I'm facing a small issue here. I'm doing :
cd $(find . -type d | grep "${4:0:4}.*${4:4:2}.*${4:6:2}")
$4 is a data entered from the user. However, if the user doesn't respect the format to enter, it will do : cd
Then, my $?
will be 0 and not 1, and it will cd
to my home.
I'd like to introduce this in my error case to (by error case, I mean : if $? = 1
).
How can I do that ?
pwd
result after thecd
?