I’m new in bash scripting and I’m trying to create a bash script which can create multiple file with content (around 10000 lines [no matters what text]) but with user input. I made a script which create files (see below) but how can I fill each file with 10000 lines? Thank you in advance! Answer Replace your touch command with
Tag: scripting
Execute a command on all the files within a directory
I am trying to write a bash script that could automate a programme on all the files present in a directory. The files that are in my directory are in the .nii or .nii.gz format. The command that I have to write is InputFile is the name of the file that has to be processed by the programme, and OutputFile
How to put a value after certain pattern in a Linux file
I run a script which stores a value in a variable like this: Now I have a file called env-list which has an entry like this: I want to redirect the output of first command to paste after = sign in env-list file, so that my env-file holds the secret value from first command: secret=value. I am struggling a lot
Is it possible to extract the contents of a tar file to two directories at the same time with a single command?
What I was curious about is whether I can use a version of the command tar -xvf fileName.tar to accomplish this. Answer I recommend to use this script.
how to write Bash script for getting Public ip address in a way that when one command failed then it have to execute another command
i want to write a bash script in a way that if one command gets failed then it will have to execute another command. For example:- “curl www.ifconfig.me” if this command gets failed then another command “curl http://icanhazip.com” to get execute and should show the output. Answer If you want the HTTP code, try this: Then: After that, you could
How to quickly rename my files on macOS or linux from CLI?
Here’re my source files. I need to figure it out a way to rename all the files to remove the first 36 characters up to _file or replacing as something else. I am expecting all the files are as below. Thanks in advance! Answer You can use rename like this: If you are on macOS, you can install rename with
Ubuntu shell script – Scanning the drive for archives: ERROR: No more files
I have installed the package p7zip-full for ubuntu and I am running the following shell script named 7z and placed within the same directory as the dataset zipped files The dataset folder looks as in the image and I get the error below although this certain file exists within my directory. How can I resolve the issue? I use Ubuntu
I am unable to type cast string to integer in csh
I want to fetch out ‘-0.5’ from the file example.txt and add 1 to it. Although I am able to fetch out ‘-0.5’. but I am unable to add 1 to it, maybe because -0.5 is considered as a string and not a integer. Code: Obtained Result: Expected Result: How do I type cast -0.5 to integer? Answer csh doesn’t
How can I iterate over some file names returned from ls command?
Hello I am trying to write a simple bash script, the problem I am having is that I want to iterate through the 4th,5th,6th and the 7th files returned from the ls command and then to check if these files have write or read permissions and if they do so, to do a simple copy of these files to another
how can i echo a line containing single quotes?
I want to echo a line containing single quotes but when I am echoing it, the output comes out without the quotes inside that line. I am using this echo rule_files: [ ‘${path.config}/folder/*.py’ ] and the output is rule_files: [ ${path.config}/folder/*.py ] I want the output to include the single quotes around the path. Answer You have to escape the