Thursday, May 2, 2024
41
rated 0 times [  41] [ 0]  / answers: 1 / hits: 83755  / 2 Years ago, tue, november 8, 2022, 5:02:57

I have the following commands.



cd import
zcat urls1.sql.gz | mysql -u root -p urls
cd /var/www/project1/
nano 1.php


As of now I'm executing it one by one.



Is there a way to combine those commands in one line?


More From » command-line

 Answers
5

Yes, separate with a semi-colon like so:



dir; ls -l


Most lanugauges/shells use the semi-colon to signify the end of a command and to start new while evaluating from left to right.



Or as @RobieBasak recommends, use && instead of ; to guard against coding accidents.



dir && ls -l

[#29868] Thursday, November 10, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ttarum

Total Points: 417
Total Questions: 101
Total Answers: 115

Location: Maldives
Member since Wed, Nov 4, 2020
4 Years ago
ttarum questions
Sat, Aug 20, 22, 12:42, 2 Years ago
Wed, Sep 28, 22, 18:07, 2 Years ago
Mon, Feb 7, 22, 20:23, 2 Years ago
;