What I usually type: what I want to type (for example. mnemonic = “all”): or I was just thinking there could be a shortcut like in the style of find . -iname “blah” or rgrep instead of grep -r Even though, like the grep example, it only saves a couple of characters, they are shifted characters not as easy to
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.
Unix: List files with specific ending and show their size and date
I want to use ls -larth but I want to see only files that end with .dmp find . -name ‘*.dmp’ gives me the results of files, but I cannot see their dates and size. If possible, I would like to have them sorted by date. Thanks in advance. Regards, Danijel Answer
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
Convert multiple SFTP command lines to a single line command line
How do I convert this EOF into a one line sftp command-line? Answer Your question has nothing to do with SFTP/sftp. It’s just a generic shell question. So use any method that a shell allows, for example
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
Is there any faster way to grep the pattern or to increase the speed of while loop?
this loop is taking time because lacks of entry in main_file. Answer Your current approach is very inefficient – the whole loop could be done in a single grep, with the -f option. -F treats lines in file as strings, not patterns -x looks for exact matching line (if that is what you want) -f file reads the lines from
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,