I’ve disabled bash history. Or rather, I made that file immutable. I did that bc I never needed the file and on top of that something (IDK what) was constantly filling it with repeated commands that I have used until the file becomes a few hundred megabytes. And since I use aliases (currently ~280 aliases with ~200 bash scripts), I don’t need bash history, so I disabled the file. If I need a repeat of a command, I simply repeat the alias.
The magical braces sounds interesting and I might start using it. Not sure if it will work in a for loop with several commands inside the loop, but it’s worth to try, even if just to see what will happen. :)
Here’s another trick you obviously don’t know: the for loop is much more readable and understandable (by anyone reading it after you) if you replace the “i” with an actual word, depending on the context, like this:
for name in *.flac; do newname=$(echo"$name" | rev | cut -f 2- -d '.' | rev) ffmpeg -i "$name" -vn -ar 44100 -ac 2 -ab 1411k -f wav "$newname".wav; done
This way, any other person who reads your code will be able to better understand the loop, or if they’re like me - will understand in principle what the loop does. Back when I was trying to learn programming, the so called programmers (teachers) were unable to explain where the hell that i comes from and so I was unable to understand how the loop works. I can’t use a function which I don’t understand how it works and/or what it does. It might sound stupid but that’s how my brain works. But once I decided to experiment on my own and instead of “i” I wrote “name” like shown above. And suddenly the for loop became crystal clear about what it does and how it works. An AI helped for the “newname=” contents in the brackets, the rest was me.
The “touch” file looks more useful for a loop where multiple files with different timestamps must be created. For a single use this is a lot harder to remember than
command > /path/to/filename.txt
Finally, I’d appreciate a shortcut to stop the execution of a command because sometimes Ctrl+C works, but sometimes it doesn’t and instead Ctrl+Z works in its place. If there’s a univeral shortcut to cancel the execution of any command, that would be way more useful, IMO.
If I need a repeat of a command, I simply repeat the alias.
This only makes sense if you make an alias for every command you ever use…which sounds like a lot of pointless labor. I don’t use bash history anymore, though, because I use fish, and it can autofill your commands without having to do a search through history. Much easier.
Here’s another trick you obviously don’t know
You presume too much. I didn’t create this comic. I’ve heard the debate around pros and cons of metasyntactic variables, and I think there are good points on both sides. Typically, when I want to use an example, I try to use a specific case, because it makes it more memorable, but I’ve actually had somebody get more confused by that, so I guess you can’t make everybody happy.
My question is: Are you confused by algebra? Like, when you see “2 + X = 5”, do you say “I can’t solve this! WTF is X??? What does it mean?”
The “touch” file looks more useful for a loop where multiple files with different timestamps must be created. For a single use this is a lot harder to remember than command > /path/to/filename.txt
I’m not sure what you’re saying here. Do you know what touch does? Also, no, it isn’t easier to look up the timestamp and manually type it in, even if it’s just one file. This was really about using $(), not touch, anyway.
Finally, I’d appreciate a shortcut to stop the execution of a command because sometimes Ctrl+C works, but sometimes it doesn’t and instead Ctrl+Z works in its place. If there’s a univeral shortcut to cancel the execution of any command, that would be way more useful, IMO.
This is one of the quirks of Unix and Unix-like systems. I was reading something about this recently. I think that it has to do with how programs are written and how they interact with the shell. CTRL-C is used by the shell, but some programs use CTRL-Z instead. So, I think that some programs override the shell or something like that?
I’ve disabled bash history. Or rather, I made that file immutable. I did that bc I never needed the file and on top of that something (IDK what) was constantly filling it with repeated commands that I have used until the file becomes a few hundred megabytes. And since I use aliases (currently ~280 aliases with ~200 bash scripts), I don’t need bash history, so I disabled the file. If I need a repeat of a command, I simply repeat the alias.
The magical braces sounds interesting and I might start using it. Not sure if it will work in a for loop with several commands inside the loop, but it’s worth to try, even if just to see what will happen. :)
Here’s another trick you obviously don’t know: the for loop is much more readable and understandable (by anyone reading it after you) if you replace the “i” with an actual word, depending on the context, like this:
for name in *.flac; do newname=$(echo "$name" | rev | cut -f 2- -d '.' | rev) ffmpeg -i "$name" -vn -ar 44100 -ac 2 -ab 1411k -f wav "$newname".wav; doneThis way, any other person who reads your code will be able to better understand the loop, or if they’re like me - will understand in principle what the loop does. Back when I was trying to learn programming, the so called programmers (teachers) were unable to explain where the hell that i comes from and so I was unable to understand how the loop works. I can’t use a function which I don’t understand how it works and/or what it does. It might sound stupid but that’s how my brain works. But once I decided to experiment on my own and instead of “i” I wrote “name” like shown above. And suddenly the for loop became crystal clear about what it does and how it works. An AI helped for the “newname=” contents in the brackets, the rest was me.
The “touch” file looks more useful for a loop where multiple files with different timestamps must be created. For a single use this is a lot harder to remember than
command > /path/to/filename.txtFinally, I’d appreciate a shortcut to stop the execution of a command because sometimes Ctrl+C works, but sometimes it doesn’t and instead Ctrl+Z works in its place. If there’s a univeral shortcut to cancel the execution of any command, that would be way more useful, IMO.
This only makes sense if you make an alias for every command you ever use…which sounds like a lot of pointless labor. I don’t use bash history anymore, though, because I use fish, and it can autofill your commands without having to do a search through history. Much easier.
You presume too much. I didn’t create this comic. I’ve heard the debate around pros and cons of metasyntactic variables, and I think there are good points on both sides. Typically, when I want to use an example, I try to use a specific case, because it makes it more memorable, but I’ve actually had somebody get more confused by that, so I guess you can’t make everybody happy.
My question is: Are you confused by algebra? Like, when you see “2 + X = 5”, do you say “I can’t solve this! WTF is X??? What does it mean?”
I’m not sure what you’re saying here. Do you know what
touchdoes? Also, no, it isn’t easier to look up the timestamp and manually type it in, even if it’s just one file. This was really about using$(), nottouch, anyway.This is one of the quirks of Unix and Unix-like systems. I was reading something about this recently. I think that it has to do with how programs are written and how they interact with the shell. CTRL-C is used by the shell, but some programs use CTRL-Z instead. So, I think that some programs override the shell or something like that?