20,676 reputation
34577
bio website
location United States
age
visits member for 3 years, 4 months
seen 3 hours ago

Debian user, GNU/Linux enthusiast, FLOSS supporter, hobby developer.


Nov
11
comment For loop for curling on multiple pages with API's
We can't help you because we have no idea what site you are using or how it works.
Nov
10
comment Search 2nd line of files and print filenames to stdout
@chishaku Just use if ($0 ~ /search string/) print FILENAME; instead of print FILENAME ...;.
Nov
8
comment Trying to make aliases that open the last modified file
I'll just leave the standard caveat about Parsing ls output here.
Nov
6
comment How do I analyze report type of data in Bash?
You're going to need to be more specific about what your goal is. It sounds like you need a database, but you haven't actually said what you need to do.
Nov
6
comment For loop for curling on multiple pages with API's
According to the curl manual, you can do this using without a for loop, just curl: cd desktop/mysite && curl --remote-name-all "https://api.mysite.com/info?page=[1-100]"
Nov
6
comment For loop for curling on multiple pages with API's
Use page=$i instead of page=i.
Oct
28
comment How do I add ncmpcpp search results to the current playlist?
@mkaito Maybe your version has different default keys or you have a different key configuration. ncmpcpp keys can be rebound. You can look at the keys in the F1 / 1 menu.
Oct
27
comment Piping bash string manipulation
Considering our recent conversation about how tr / sed are faster than bash at string processing, and considering how you are using pipes to pass strings via standard I/O, I see literally zero point to doing those operations in bash as opposed to tr / sed. Why would one ever | { read x; echo $x... } as opposed to a | sed that does the same thing?
Oct
27
comment Piping bash string manipulation
@Miati Why would you think this extra read x; echo $x is any better for performance? The syntax does not look any shorter or cleaner. x=${x// /_}; x=${x^^} is a much more concise way to do the same thing as {read x; echo ${x.... As far as performance goes, @jimmij has pointed out that tr / sed would be faster than bash, fork count being equal. Using a pipe always results in an extra process so the argument of saving a fork no longer applies. Thus, if are using pipes, just use sed / tr etc. If you can do it in bash, do so and skip this read x; echo $x nonsense.
Oct
27
comment Piping bash string manipulation
@jimmij Fair enough. For 90% of use cases where bash performance matters, I suspect the strings will be small enough where the penalty of process creation outweighs the benefits of faster regex handling.
Oct
26
comment Piping bash string manipulation
@jimmij Are you claiming that bash's string manipulation code is so inefficient compared to sed or awk that it is more efficient to fork off an extra process to run the better code in sed / awk than it is to use bash's code? I find that to be unlikely - if bash can do something it should be faster than forking a process to do the same thing. As to the other point, if you have a string so big it won't even fit in a bash variable then the performance question is moot.
Oct
26
comment Piping bash string manipulation
@Ketan Sed and awk are separate processes, so they can never be fast as something that bash can do natively without launching a separate process. Normally this difference is hardly noticeable, but where performance matters in shell scripts is usually a certain loop or computation is being repeated a very large number of times, and spawning thousands of processes will be noticeably slower than doing a simple string manipulation in bash natively.
Oct
25
comment Why is a here-string command substitution considered as a single line?
@MainMa The main point is that whitespace inside expansions gets lost if you don't double-quote the expansion. You may want to read this: mywiki.wooledge.org/Quotes. The ./b.sh | ... example does not use any expansions so doesn't have the quoting problem. I could have sworn there was already a question like this but I can't find one at the moment.
Oct
25
comment Why is a here-string command substitution considered as a single line?
Try putting "" quotes around "`./b.sh`" and see what happens.
Oct
24
comment How do back-references match in sed?
@slm Many thanks!
Oct
23
comment Using find to search and report files that have one but not two keywords inside
@MarkPlotnick You could post that as an answer. Note that the -a is optional.
Oct
21
comment Transfer files between Windows and Linux machines?
You can use something like WinSCP or other Windows ssh / scp client to access the Linux machine after you set up an ssh server. Basic samba set-up is very simple as well. Perhaps you were looking at the wrong tutorials.
Oct
21
comment Is it possible to make a symbolic link of a file in other machine?
The only way would be to mount the remote directory somewhere locally.
Oct
20
comment Move to other end of paragraph in vim (not a visual block)
@TylerDurden There is no swap key. Just use {}.
Oct
17
comment Optional arguments after or before the mandatory arguments?
@MichaelMrozek The POSIX standard getopts actually expects all option arguments to come before non-option arguments ("operands"). The script itself has to do extra work to support interleaving the two. I do not know about getopt since it is less standard and there are multiple (GNU and not GNU) versions out there.