Skip to content
Advertisement

Tag: unix

Sort on specific part of filename in shell script

I have a list of files which I want to delete except 2 of the most recent ones. The files are named as “filename_dd_mm” for example “filename_19_05”. If I do It sorts them according to the day. What I want is to sort them by month first and then the day. Can someone please guide me to do this. P.S.

Modify config files with sed in bash

I am trying to set net.ipv4.ip_forward to 1 in /etc/sysctl.conf.The following works fine but it sure missing some edge cases For e.g if the sysctl.conf contain any one of the following it won’t match #net.ipv4.ip_forward=1 ##net.ipv4.ip_forward=1. Is there a more reliable way to modify settings in config files ? Answer You can use the -r switch to enable Extended Regular

How do I force install an application in Linux with input option I?

I am trying install an application in single command. The application gives the following options Actions: <I> start installation to hard disk <H> help <Q> quit My option is <I>. So, how do I enter this <I> in single command? sudo ./install-tl this is my command Answer Since texlive is an interactive perl script you can’t give an option I

How to change date format in linux/unix text file

I have sample.txt file in my linux system.all the data that is present in my file are in the following date format I want to convert all this date format in my sample.txt file to YYYY-MM-DD Format. Answer It’s quite simple with date -d, e.g. Input File Example Use/Output

Compute base64 encoded hash from a given hash?

I created a file and input some random string into it. Now if I use openssl to compute base64 hash [sha256], I run this: which returns me KHN0ZGluKT0gMzJjYjA1MTgzNDNhZmY2N2FlMmY5YzUwNDcwNGRiNGE5Njc5MzIyZWVlNTBmMjBiNTMzNjZlYTBiMDY2MWNlZgo= Now I process this hash stepwise, as, which gives me (stdin)= 32cb0518343aff67ae2f9c504704db4a9679322eee50f20b53366ea0b0661cef Let this hash be X. Then I do this, I get a different result. Why is that? My reason for

Complex rsync filtering (includes and excludes)

I got directories and files that look like this I only want to copy the 20170409_*/schedule, 20170410_*/schedule, 20170411_*/schedule folders and contents. This mostly works: However this also copies the following: How do I omit the files and the dateTimeFolders I haven’t included and only get the dateTimeFolder’s schedule folder that I have included? Answer If I understand the situation correctly,

Advertisement