Best way to swap filenames
I need to swap filenames of two files (file and file_1). I’m using the following code for it.
I need to swap filenames of two files (file and file_1). I’m using the following code for it.
How can I count the number of files (in a directory) containing a given string as input in bash/sh?
Alright, when I run certain commands the wrong way, (misspelled, etc.) The terminal outputs this: > instead of computername:workingfolder username$, and when I type enter it goes like this:
Many examples for trap use trap ... INT TERM EXIT for cleanup tasks. But is it really necessary to list all the three sigspecs?
I have played around with PS1 and PROMPT_COMMAND in bash to create a zsh-style right side prompt. I have a solution who almost works.
Once a friend of mine (who is an experienced Unix/Linux user) told me that setting root’s shell to something other than sh (i.e bash or zsh) might create problems, because some script might assume that the shell is sh and do something weird.
Considering this Q&A about the order of execution in the shell as it relates to redirection, and despite the fact that if a file doesn’t exist it gets created first so that cat example.txt | shuf > example.txt doesn’t complain that the file doesn’t exist – which just confirms the order from what I understand – then why is it that about once every thousand times on my system the shuffle works when I do this (backup contains 15 static values each on their line)
I’d like to output hello world over 20 characters.
Often times I find myself in need to have the output in a buffer with all the features (scrolling, searching, shortcuts, …) and I have grown accustomed to less.
I’ve got a script that scp’s a file from remote host back to local. Sometimes the file names contain spaces. scp does not like spaces in its file names. For some reason my attempts at handling the spaces have not resulted in the correct scp path.