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: bash
How can i execute comm Linux command in Python
I want to extract lines from File1 which are not present in File2 File1 File2 so the output should be: One possible command in bash is: And it works perfectly well in bash, but I don’t know how correctly to implement in Python. I’ve tried with And is not working. Any hint? Answer If you must use a…
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 th…
How can i save automatically the SSH_CLIENT at login?
i want to save the user’s IP when he connects to it’s home folder, this is because i’m a user in a server where my team has a folder where our public_html is located, but we use the same account, so i just want to register who connected. So i want to make a script that triggers when a connec…
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…
How do I restart wlan0 with the static ip instead of a dynamic ip? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …
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 endi…
Paste header line in multiple tsv (tab separated) files
I have multiple .tsv files named as choochoo1.tsv, choochoo2.tsv, … choochoo(nth).tsv files. I also have a main.tsv file. I want to extract the header line in main.tsv and paste over all choochoo(nth).tsv files. Please note that there are other .tsv files in the directory that I don’t want to chan…
How to call user/group IDs in Linux bash scripts
I have this bash script. I run it with the following command: sudo ./install.sh Calling the user core as 500 and root as 0 not working. I’ve got the following error: The reason why I want to use user or group numbers, because I want to make it multiplatform (would be nice if it can choose between 500 or…
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