A copy of all installed debian packages on your system will be put back together, with all changes in configuration files you made and placed in the current directory. Make sure you have enough disk space (say 2-3 GB). Break any time with Ctrl+C. Show Sample Output
apt install toilet toilet-fonts # replace 'tput setaf 1' with 'tput setaf 9' to change color
One liner is based on this article: https://www.computerhope.com/issues/ch001307.htm Show Sample Output
This way you don't need to replace first line of a bash foo.sh script #!/bin/bash with #!/bin/bash -x to obtain the same effect
Last listed files presumably have higher precedency then files listed first, i.e. configuration files in the personal .config directory will be listed last and their config parameters will be more authoritative then default config parameters defined in /etc directory which are usually listed above them. If you replace ".conf" with ".ini" in the command, initial files will be listed instead of config files. If you do not like to list multiple access to the same config file, pipe to "uniq" or "uniq -c" to prefix lines by the number of occurrences Show Sample Output
Will delete empty directories and sub-directories (hideen too = whose names are starting with dot .). Used 'rm' command instead of 'rmdir' to give the possibility of asking for confirmation before deleting i.e. it is not wise do delete all empty directories in /etc folder. Replace dot in 'find .' with any for other starting directory instead of current. in 'rm -i -R' 'i' stands for ask before delete and 'R' for delete folder recursively or folder itself if it is empty
I can think of using this command after compiling an downloaded source from anywhere as an easy way to find all executable products.
We usually issue the
find
command (without arguments) to list the full paths of all directories and sub-directories and files in the entire current tree.
Similar command is
tree -aicfnF
( Or
ls -lat|lolcat -a
if you like it in technicolor - apt install lolcat if needed )
Use flag "--" to stop switch parsing Show Sample Output
Copy this function to command line, press 'Enter' 'f'' 'Enter' to execute (sentence on the left written only for newbies). Hint 'e|x|v|1..9' in front of displayed last modified file name means: "Press 'e' for edit,'x' for execute,'v' for view or a digit-key '1..9' to touch one file from the recent files list to be last modified" and suggested (hidden files are listed too, else remove 'a' from 'ls -tarp' statement if not intended).
If you find this function useful you can then rename it if needed and append or include into your ~/.bashrc config script. With the command
. ~/.bashrc
the function then can be made immediately available.
In the body of the function modifications can be made, i.e. replaced joe editor command or added new option into case statement, for example 'o) exo-open $h;;' command for opening file with default application - or something else (here could not be added since the function would exceed 255 chars).
To cancel execution of function started is no need to press Ctrl-C - if the mind changed and want to leave simple Enter-press is enough. Once defined, this function can with
typeset -f f
command be displayed in easy readable form
Show Sample Output
include in the list human readable hidden files too:
file .* *|grep 'ASCII text'|sort -rk2
more reliable command:
ls|xargs file|grep 'ASCII text'|sort -rk2
and include hidden files:
ls -a|xargs file|grep 'ASCII text'|sort -rk2
Number of days back: change/append arbitrary amount of '\|'$[$(date +%Y%j)-x] expressions or specify any n-th day before today for a single day (you have to replace x with 3, 4, 5, whatever ... above I replaced it with 1 and 2 to get listing for yesterday and day before yesterday and 0 for today was not necessary, so left out).
Q: How to narrow to *.pdf , *.png, *.jpg, *.txt, *.doc, *.sh or any type of files only?
A: Pipe to grep at the end of command.
Even shorter:
cd && day=3;for a in $(seq $day -1 0);do tree -aicfnF --timefmt %Y%j-%d-%b-%y|grep $[$(date +%Y%j)-$a];done
Here it's only needed to change amount of variable day to list period of days back - here is set to three days back (the seq command is adjusted for listing the oldest stuff first).
Show Sample Output
Credits go to Flatcap https://www.commandlinefu.com/commands/by/flatcap
Even shorter:
seq -s '*' 120|tr -d '[0-9]'
You can append these commands to the bottom of the history file to access them easier with the Up key:
sort ~/.bash_history|uniq -c|sort -n|tail -n 10|tr -s " "|cut -d' ' -f3- >> ~/.bash_history
Only the first appearance of a repeated command in the history will be kept. Otherwise, if you prefer to keep last occurrence of a repeated command then maybe you can achieve that by including reverse input/output i.e with 'tac' command in expression above.
To see statistics of removed repeated commands:
diff --suppress-common-lines -y ~/.bash_history.bak ~/.bash_history|uniq -c|sort -n|tr -s " "|sed '/^ 1/d'|grep '<'
tput setaf 1 && tput rev && seq -ws "___|" 81|fold -69|tr "0-9" "_" && tput sgr0
# (brick wall)
(example above is the 'ls' command with reduced output speed)
Display recursive file list (newest file displayed at the end) and be free to access last file in the list simply by pressing arrow_up_key i.e. open it with joe editor.
BTW IMHO the list of files with newest files at the end is often more informative.
Put this 'lsa' function somewhere in your .bashrc and issue
. ~/.bashrc
or
source ~/.bashrc
to have access to the 'lsa' command immediately.
.
(the function appends command "joe last_file_in_the_list" at the end of command history)
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: