As the title says, I just started with linux mint and am falling in love with bash scripts 😍 Actually I'm not sure if it's considered a script, but I want to delete the last 2 files in all subfolders in a folder. So far I've (after great effort) got the terminal to list the files, but I want to delete them. Here is how I get them listed:
for f in *; do ls $f | tail -n 2; done
All their names come satisfyingly up in the terminal. Now what? I tried adding | xargs rm but that didn't delete them. I also tried something with find command but that didn't work either. Some folders have 3 items, so I want to delete #2 and 3. Some folders have 15 items so I want to delete #14 and 15. Folders are arranged by name, so it's always the last 2 that I want to delete.
It's frustrating to be sooooo clooooose, but also very fun. Any help is appreciated!
EDIT: Thanks for the awesome help guys! The next part of this is to move all the .html files into one folder (named "done"), prepending their name with an integer. So far I got:
n=1; for f in *; do find ./"$f" -type f | sort | xargs mv done/"$n$f"; n=$((n+1)); done
but that is... not really doing anything. The closest I have gotten so far is some error like
mv: Missing destination file operand
Any help is again appreciated!
Yes, I see your point. Very true about "moving to the right".
"People need to vote, and they need to vote effectively. If you’ve got ranked choice, great, vote for the candidates that represent your views the best. If you have a first past the post system, then you need to vote for the least worst candidate that can actually win, even if they don’t align with your morals or ethics."
This I think is one thing what Progressives in America have been working on, without the help of the Democrats (also healthcare, labour protection etc.). Then when the election comes, Democrats are surprised they did not get more votes and did not motivate people to the polls. Then they blame Progressives, who they have been ignoring, for not voting for them even though Republicans have a worse guy. So, Democrats don't serve the poeple and are sad when they don't get votes, is that right? Also, Democrats only listen to campaign advice from donors, even though donors are not a majority of the base... and then surprised when they get less votes? It just seems absurd to blame anyone but the Party. It is plain and simple bad politicking. Even blaming Trump supporters makes more sense, but they might actually fight back.