How do you run multiple commands in Linux terminal but only run the next command if the previous command succeeded?
Experience Level: Junior
Tags: Linux
Answer
You can use && separator for this case. && makes sure that the next command will only run when the previous command was successful.
Example:
clear && pwd && ls
Related Linux job interview questions
How do you move to the beginning of the line in Linux terminal?
Linux JuniorHow do you search in commands that you executed in past in Linux terminal?
Linux JuniorHow do you run multiple commands at once in Linux terminal?
Linux JuniorHow do you go back to home directory in Linux?
Linux JuniorHow do you switch back to the last working directory in Linux?
Linux Junior