A picture leading me straight into hell, and a coding question

1 Star2 Stars3 Stars4 Stars5 Stars (15 votes, average: 2.73 out of 5)
Loading...
By Oliver (AKA the Admin) on 11 comments
in Categories: Just Talking

A short non-hentai post, if you don’t mind ^^

First things first, linuxians please, could I ask you two minutes of your time ?
I really suck at bash, and I don’t manage to adapt a little bit a code line, here, look at this pastebin

If you could tell me how to get it done, I’d be grateful :)

Second things… I’ll be going into hell, but, god, that picture made me laugh hard.

yes, even of that, we can laugh

Subscribe
Notify of
guest

11 Comments
oldest
newest most voted
Inline Feedbacks
View all comments
一二三
一二三
9 years ago

Would the following not work?

find . -name '*.zip' -exec zip -rv {} notes and info from the uploader.txt ;

xnine
xnine
9 years ago
Reply to  一二三

Yeah, this would work. I tested here myself.
find . -name "*.zip" -exec zip -rv {} test_file ;
Just replace test_file with the desired name and you should be good to go =)

Oliver AKA The Admin
Admin
9 years ago
Reply to  xnine

(Thanks ! ^^)

Ah, only ending with ; and not ; ?

See what I wrote in response to OldBrokenHands below, I'm feeling so lost with linux scripts and bash, it's like their extreme concision is more confusing than long coding languages *_*

Oliver AKA The Admin
Admin
9 years ago
Reply to  一二三

I'm thanking everyone here, lol, but, well, 一二三 , thank you too ^^

一二三
一二三
9 years ago

No problem. If you want to learn more about (or quickly review) find, 'man find' is your friend (you can even search for terms by preceding them with a slash).

The -exec action expects a semicolon as its last argument, but the semicolon also occurs in bash to separate successive commands (think "echo hentai; echo rules!"), so the semicolon needs to be escaped using a backslash. (You could also escape it by enclosing it with quotes instead.) {} is the current result find is currently running the command specified in -exec on. As rell pointed out, to differentiate between multiple filenames and one that contains spaces, the name of the file you're adding to/updating in all archives should be enclosed by quotes. The expression you're searching for ('*.zip') needs quotes if you're using patterns that contain symbols such as * or ?, because without quotes, bash would expand them before find runs. (Globbing is the keyword if you want to learn more.) In all of these cases, double are required when using bash variables so that bash can substitute the values for the variable names (like $f), otherwise single would suffice (in which case $f would be taken literally). Alternatively, one could escape special characters such as spaces or * and ? using a backslash, but this will not work when using bash variables.

zaz
zaz
9 years ago

you should use quotes “{}” in case the files names have a space.

rell
rell
9 years ago

you dont need add quotes in {}, because it will be replaced by FIND not BASH

… -exec zip -rv {} file_to_add \;

or

… -exec zip -rv {} “file to add with space in name”

Oliver AKA The Admin
Admin
9 years ago
Reply to  rell

Thank you, Rell ! :)

If I may ask, the second one,
-exec zip -rv {} "file to add with space in name"

Doesn't it lack the final
;
in the end ?

oldbrokenhands
oldbrokenhands
9 years ago

Rell has the right answer. The second part of his/her comment, with the quotes.

Oliver AKA The Admin
Admin
9 years ago
Reply to  oldbrokenhands

Thanks for the confirmation, OldBrokenHands, although I'm troubled by the lack of a final ;

It's weird, huh, as time passes I'm growing more comfortable with php, and I even learned the basics of python for the fun. But comes bash and Linux, and I still fail to grasp the fundamentals, I'm supposed to have remembered over time what this {} ; will do, but, nah, it's like it's too concise, too simple-looking for me, I prefer when it takes more instructions with functions written clearly in loops and all T__T

oldbrokenhands
oldbrokenhands
9 years ago

Don't beat yourself up over it. bash is starting to show it's age when it comes to modern usability.

Beginning Linux users have been waiting for clear/concise documentation for commands since the dawn of Linux. What you have is guys who can write and execute commands, but lack the human communication skills and patience to make it understandable to all.

It's the primary thing that keeps the OS from being mainstream. Some folks like it that way, others pull hair.