My shell script looks like this: It’s checked into cvs in a shell folder, Jenkins is configured to execute it on a Linux machine via a job with ‘Execute Shell’ build step: But Jenkins is wrapping the whole sudo line in single quotes which results in my log files not been deleted (although the Jenkins job passes successfully): Any ideas
Tag: shell
deletion of file after 7 days
I have to delete multiple files after 7 days regularly. And the deletion dates and location are different for each file.Yes, I can apply a cronjob for each folder separately but tat will involve many cronjobs (atleast 15). In order to avoid this, I want to create a script which will go to each folder and delete the data. For
Difference on bash and ash parentheses
I was trying to use a diff command for comparing directory listings which works fine in bash: However, on the ash (embedded device where no other shell is available) I get Is there any difference regarding reading input operator < or parentheses ( )? Answer Don’t confuse the angle bracket in <( … ) with the one in redirections like
Variable passed through environment not available in script
I’m trying to write an if/elif/else statement where if a variable equals “Full” it will cat a file and if the same variable equals “Quick” it will read a different, smaller file. The variable is being set outside of the script and is being exported by export var1=Quick I have When I try to run the script by calling ./test,
How cut characters from string and put it at the end- In shell
I want to be able to do the following: And get output like: I know the command sed is able to do this but I need some guidance. Thanks! Answer In sed you can do: Which outputs 3002_3322 3.2.1.log HELLO. Explanation The first word is captured by ([^[:blank:]]*) The () means I want to capture this group to use later.
Using makefile, LD_PRELOAD to executable file
I have two files, “abc.c” and “run” and I want to make a executable binary file which perform below two intstructions I tried to use makefile in linux, but failed. Can I use makefile to make executable binary file ? Answer Ideally, makefile should be used for compilation. For automating the shell commands, you can use a shell script. Maybe,
Counting all .class files
I want to count all .class file in my project directory. I am working on ubuntu. I can list all the class file like this – It lists a lot of .class files. But I want to know the count of these .class files. Is there any way to do this in linux. Thanks. Answer Use wc -l. wc stands
How to abort if command fails in Unix shell?
I’m not very great with shell scripting and still couldn’t find a solution to this. I want to run a command gulp tslint and if it returns errors, abort the script. So far I tried gulp tslint || exit 1 with no success. I think it somehow is returning true, even though it has errors when i run it on
Validating file records shell script
I have a file with content as follows and want to validate the content as 1.I have entries of rec$NUM and this field should be repeated 7 times only. for example I have rec1.any_attribute this rec1 should come only 7 times in whole file. 2.I need validating script for this. If records for rec$NUM are less than 7 or Greater
how to auto complete files names on bash script?
I have a bash shell script that cd to directory according to a variable. After that I press Tab and files don’t appear like in terminal. Ex: on read code ups, the files don’t appear when I press tab. Answer The read command requires the -e flag in order to use the readline library to edit the command line (including