Skip to content
Advertisement

Tag: bash

Bash script to delete all but N files when sorted alphabetically

It’s hard to explain in the title. I have a bash script that runs daily to backup one folder into a zip file. The zip files are named worldYYYYMMDD.zip with YYYYMMDD being the date of backup. What I want to do is delete all but the 5 most recent backups. Sorting the files alphabetically will list the oldest ones first,

extracting unique values between 2 sets/files

Working in linux/shell env, how can I accomplish the following: text file 1 contains: text file 2 contains: I need to extract the entries in file 2 which are not in file 1. So ‘6’ and ‘7’ in this example. How do I do this from the command line? many thanks! Answer Explanation of how the code works: If we’re

How can I show the wget progress bar only? [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 Exchange site, you can leave a comment to explain where the question

Using sed to get an env var from /proc/*/environ weirdness with x00

I’m trying to grovel through some other processes environment to get a specific env var. So I’ve been trying a sed command like: sed -n “s/x00ENV_VAR_NAME=([^x00]*)x00/1/p” /proc/pid/environ But I’m getting as output the full environ file. If I replace the 1 with just a static string, I get that string plus the entire environ file: sed -n “s/x00ENV_VAR_NAME=([^x00]*)x00/BLAHBLAH/p” /proc/pid/environ I

Advertisement