I want to preserve the timestamp of the files I’m editing in a for loop The issue is I need to get a formatted date string from the file so that I can do touch -r to revert the files date back once the loop has completed. stat is not giving the me the format I need. Required Format: YYMMDDhhmm
Tag: shell
How do I replace all lines after line XX in one file with content from another file?
I’m on Debian 8.2. Here’s test.sh so far. I want lines 26 onwards of fileA’s content to replace everything in fileB from line 26 onward — so I end up with the first 25 lines of the output are from lines 1-25 of the original fileB and the remainder is lines 26 onwards of fileA. How do I do this?
Iterating over lines in a file with “for” in shell never matching target
i wrote a shell script as you can see followed. The script reads all line which in .dat file and writes screen matching words according to specified parameter but if/else block doesn’t properly.Both block if and else fired same time. sh file dat file terminal result Answer The original code didn’t ever look inside of a file until after running
How to get a single output file with N lines from N multiline files?
I am looking for some effective way to concatenate multiple multiline files into one file – here is an example for three input files: 1.txt: 2.txt: 3.txt: output.txt: (Replacing each linebreak with single whitespace). Which way can you recommend? Answer Using BASH for loop: If you want to strip one ending space before each line break then use:
Shell bash script does not run R
I have an R script that I can run with and it successfully returns the results to a.txt. I am attempting to write a new shell script that plan to run daily, and have made the following script, called morning I run this with the following commands I can get this to work sort of, but end up with the
Newbie-ish error: cp: omitting directory
Pulling my hair as I’m stuck with a basic error without understanding why: We’re in a “test” directory, in which I created one “del” subdirectory. The “test” directory contains a variety of files of various types. The result is a series of lines (same number as the number of files present in the directory from where the command is ran)
Issue finding the process id from shell scipt
mySample.sh The above command is printing and killing the temporary process that was created for grep Even though i do not have any process running with Abcd, This is printing pid Any ways to ignore it, iam actually ignoring it using grep -v, still… Any Issue in fetching the process id.? Basic command line output is below,After running a process
bash does not get root permissions with setuid program
I have the following home-grown implementation of su: To allow for proper execution, the permissions and ownership information are set accordingly: When I invoke a shell, such as /bin/sh, I am able to modify root-owned files and directories: However, /bin/bash doesn’t seem to get root permissions: Answer Shells reset the euid to the uid for security reasons. So if you
set line-increment in nl command to a float number
I want to use nl command to do numbering for lines. Is it possible to set line-increment in nl command to a float number. I know that we cant use -i switch to set line-increment like this: but it doesn’t work for float numbers like: I want the output to be like this Answer Could use awk instead With padding
How can I run a python script on many files to get many output files?
I am new at programming and I have written a script to extract text from a vcf file. I am using a Linux virtual machine and running Ubuntu. I have run this script through the command line by changing my directory to the file with the vcf file in and then entering python script.py. My script knows which file to