asked    Beryl     2018-10-22       bash       114 view        1 Answer

[SOLVED] syntax error on bash rm -rf !; unexpected token

This command is working perfectly when you just type it into console and run;

rm -rf !(folder1|file_name|log.txt|*.sh|*.conf)

However, when I run it from a bash script, it gives me the following error;

./ line 1: syntax error near unexpected token `('
./ line 1: `rm -rf !(folder1|file_name|log.txt|*.sh|*.conf)'

  1 Answer  

        answered    Lesley     2018-10-22      

It's the extended glob matching syntax. You need to enable it with shopt -s extglob before the rm command.

Your Answer

 2018-10-22         Jeffrey

Return the rows(Ids) which satisfies and has both the values in IN condition

I have a below table with sample data called Recipes which acts as a junction table between other 2 tables.Query - select recipeId, IngredientId from Recipes where IngredientId in (1,31) order by recipeIdWhen i execute above SQL statement it gives below Output. which is fine.What changes i have to make in the query to get below highlighted Output.Now why 6,7 & 21?As RecipeIds 6, 7 & 21 are the only Ids which has both IngrdientIds [i.e. 1,31] You can use group by clause :select RecipeIds from table twhere IngrdientIds in (1, 31)group by RecipeIds having count(dis...
 sql                     1 answers                     63 view
 2018-10-22         Enoch

SQL Relationship to Secondary Table Without Adding Duplicate Column

There are Cities, Job Types, and Tasks. Cities can have multiple Job Types. Tasks are created for a City that can have multiple Job Types. Cities can have Many Tasks. But when adding the Job Types for the Tasks assigned to a City, must make sure the City has that Job Type. How to create Relationship/Constraint when Adding/Updating Task_JobTypes to make sure the City associated with the Task has that Job Type allowed in City_JobTypes? The constraint in Task_JobTypes "FK_Task_JobTypes_JobTypes" need to be referencing that instead of just JobTypes.Cities - Id,Name JobType...
 sql                     2 answers                     60 view
 2018-10-22         Noah

SQL - using calculated dates in WHERE clause

I have a table with future values where I only want the last full week. Meaning af want to find the last Sunday and have a WHERE clause where date is between 'last Sunday - 7' and 'last Sunday'. Meaning I have transactions until '31-10-2018' and want the period between '2018-10-28' and '2018-10-22' (both days included). But every week new data will be added continuously so very soon I have data until '2018-11-30' and so on.I have tried a query like:SELECT *FROM PlannedCountsWHERE [Date] BETWEEN DATEADD(d,-6,MAX([Date])) and MAX([Date])Note: I'm aware that this will only giv...
 sql                     2 answers                     61 view