http://stackoverflow.com/a/78274409
score: 1
upvote count: 1
type: Answer
has body: You could use a tool that understands CSV, such as xsv: $ xsv fmt -t ';' --quote-always <<< '"001","User,Super","04/04/2024"' "001";"User,Super";"04/04/2024"
downvote count: 0
answers question: http://stackoverflow.com/q/78274285

http://stackoverflow.com/a/78242834
type: Answer
answers question: http://stackoverflow.com/q/78240671
score: 0
has body: As you can see from the trace which you have posted, commandOutput does not hold the string true, but the string "true", so you have to test for this: $commandOutput == '"true"'

http://stackoverflow.com/comment/137824887
type: Comment
score: 0
type: QuestionComment
has text: Why are you running `sh` if you actually want `bash` or `zsh`? Why not use a `#!` line and make the script executable?
comment on: http://stackoverflow.com/q/78178090

http://stackoverflow.com/comment/137866405
has text: Truncating and wrapping are 2 quite different things. You currently have 2 answers, one for each concept - a `sed-only` solution that truncates each line (as your original text said you wanted) and a `fold+sed` solution that wraps each line (as the example you provided shows you wanted). For the benefit of others with a similar question in future, please [edit] your question to just clearly tell us and show us the 1 thing you wanted, truncation or wrapping, and then accept the answer that does that thing so we can delete the other answer or at least comment it's for a different problem.
comment on: http://stackoverflow.com/q/78196374
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137972149
type: Comment
comment on: http://stackoverflow.com/q/78261314
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137936528
score: 0
has text: "If the place they download packages from is on security tools' radar as a source of malicious code" - Is there any way to find that ?
type: QuestionComment
comment on: http://stackoverflow.com/q/78239018
type: Comment

alpha-transparency
tag name: alpha-transparency
tags question: http://stackoverflow.com/q/78261118
type: Tag

bash
tags question: http://stackoverflow.com/q/78202378
tags question: http://stackoverflow.com/q/78253800
tags question: http://stackoverflow.com/q/78226551
tags question: http://stackoverflow.com/q/78195172
tags question: http://stackoverflow.com/q/78204675
tags question: http://stackoverflow.com/q/78235101
tags question: http://stackoverflow.com/q/78169456
tags question: http://stackoverflow.com/q/78156372
tags question: http://stackoverflow.com/q/78276574
tags question: http://stackoverflow.com/q/78175689
tags question: http://stackoverflow.com/q/78192206
tags question: http://stackoverflow.com/q/78202789
tags question: http://stackoverflow.com/q/78197884
tags question: http://stackoverflow.com/q/78195964
tags question: http://stackoverflow.com/q/78171914
tags question: http://stackoverflow.com/q/78298936
tags question: http://stackoverflow.com/q/78190505
tags question: http://stackoverflow.com/q/78233301
tags question: http://stackoverflow.com/q/78158123
tags question: http://stackoverflow.com/q/78204849
tags question: http://stackoverflow.com/q/78239018
tags question: http://stackoverflow.com/q/78186259
tags question: http://stackoverflow.com/q/78216460
tags question: http://stackoverflow.com/q/78194442
tags question: http://stackoverflow.com/q/78186846
tags question: http://stackoverflow.com/q/78161552
tags question: http://stackoverflow.com/q/78165163
tags question: http://stackoverflow.com/q/78213645
tags question: http://stackoverflow.com/q/78146721
tags question: http://stackoverflow.com/q/78154096
tags question: http://stackoverflow.com/q/78210154
tags question: http://stackoverflow.com/q/78216881
tags question: http://stackoverflow.com/q/78225038
tags question: http://stackoverflow.com/q/78276987
tags question: http://stackoverflow.com/q/78212759
tag name: bash
tags question: http://stackoverflow.com/q/78232246
tags question: http://stackoverflow.com/q/78180816
tags question: http://stackoverflow.com/q/78148102
tags question: http://stackoverflow.com/q/78155628
tags question: http://stackoverflow.com/q/78302587
tags question: http://stackoverflow.com/q/78284934
tags question: http://stackoverflow.com/q/78240309
tags question: http://stackoverflow.com/q/78181239
tags question: http://stackoverflow.com/q/78261314
tags question: http://stackoverflow.com/q/78254419
tags question: http://stackoverflow.com/q/78192103
tags question: http://stackoverflow.com/q/78250385
tags question: http://stackoverflow.com/q/78228111
tags question: http://stackoverflow.com/q/78260874
tags question: http://stackoverflow.com/q/78166538
tags question: http://stackoverflow.com/q/78290808
tags question: http://stackoverflow.com/q/78286060
tags question: http://stackoverflow.com/q/78228875
tags question: http://stackoverflow.com/q/78199979
tags question: http://stackoverflow.com/q/78273096
tags question: http://stackoverflow.com/q/78152355
tags question: http://stackoverflow.com/q/78200978
tags question: http://stackoverflow.com/q/78287441
tags question: http://stackoverflow.com/q/78306525
tags question: http://stackoverflow.com/q/78158852
tags question: http://stackoverflow.com/q/78240155
tags question: http://stackoverflow.com/q/78285382
tags question: http://stackoverflow.com/q/78228745
tags question: http://stackoverflow.com/q/78278018
tags question: http://stackoverflow.com/q/78149866
tags question: http://stackoverflow.com/q/78211761
tags question: http://stackoverflow.com/q/78292693
tags question: http://stackoverflow.com/q/78276793
tags question: http://stackoverflow.com/q/78298036
tags question: http://stackoverflow.com/q/78208234
tags question: http://stackoverflow.com/q/78158725
tags question: http://stackoverflow.com/q/78261247
tags question: http://stackoverflow.com/q/78246449
tags question: http://stackoverflow.com/q/78261786
tags question: http://stackoverflow.com/q/78207181
tags question: http://stackoverflow.com/q/78167734
tags question: http://stackoverflow.com/q/78183685
tags question: http://stackoverflow.com/q/78298728
tags question: http://stackoverflow.com/q/78173589

http://stackoverflow.com/q/78194991
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137855913
has body: Linux version: Linux <server_alias> 3.10.0-1160.76.1.el7.x86_64 #1 SMP Tue Jul 26 14:15:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux I have the following function : killProc () { local PROCNAME="$1" echo "$(date) | Attempting to shutdown $PROCNAME ... " if -z $(findproc "$PROCNAME") ; then echo "Process not running ..." else #search for PID based on process name local PROCESS_ID=$( ps -ef -u ${USER} | grep "${APPNAME}" | grep -v grep | grep "procname ${PROCNAME}" | awk '{print $2}') #only if this search returns a result do we kill the process if "$PROCESS_ID" ; then set -x kill -9 "$PROCESS_ID" #check that process has been killed temp_exit=$? if [ $temp_exit -eq 0 ]; then while kill -0 ${PROCESS_ID} 2>/dev/null; do echo "$(date) | Waiting for process to stop running ... " sleep 2 done echo "Done" else echo "Failed" fi set +x else echo "Missing" fi fi } Function is meant to kill a process using it's procname The output from ps is something like this: <USER> 7456 0.3 0.0 77112 9268 pts/0 S 16:29 0:00 <path> -proctype dis -procname procname1 <params> -p 10000 For most procs, it all works well, but for some I get an error Wed Mar 20 16:20:13 UTC 2024 | Attempting to shutdown procname1 ... + kill -9 6603 + temp_exit=0 + '[' 0 -eq 0 ']' + kill -0 6603 ++ date + echo 'Wed Mar 20 16:20:13 UTC 2024 | Waiting for process to stop running ... ' Wed Mar 20 16:20:13 UTC 2024 | Waiting for process to stop running ... + sleep 2 <path>/bin/killProcs.sh: line 26: 6603 Killed taskset -c 39,40 <path> <params> -procname procname1 -p 10001 < /dev/null > ${LOG}/dis_test_nont_$(date +%s).log 2>&1 + kill -0 6603 + echo Done Done That bit after the sleep 2. I wouldn't expect that to show up. Line 26 is the entire function. I tried using kill -9 "$PROCESS_ID" 2> /dev/null but no success. I tried removing all the code in the function and sometimes I get it, sometimes I don't. Any suggestions ? UPDATE: I have a few other processes which are killed by this same function and they don't ha…
has comment: http://stackoverflow.com/comment/137855839
has title: Error message when killing process in bash
has comment: http://stackoverflow.com/comment/137855300
has comment: http://stackoverflow.com/comment/137855180
tagged with: kill
has comment: http://stackoverflow.com/comment/137855163
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137855418
score: 0
tagged with: linux
has comment: http://stackoverflow.com/comment/137855849
tagged with: bash

http://stackoverflow.com/q/78226499
favorite count: 0
has answer: http://stackoverflow.com/a/78227374
has comment: http://stackoverflow.com/comment/137911518
downvote count: 1
has body: when i try to kill the script by ctrl-z or ctrl-c they are interpreted like input and not commands. I'm using linux (fedora 37) on a virtual box machine terminal: [me@meVPC ~]$ ./time_logger 9698 ^C ^C ^Z the script: ` #!/bin/bash log_file="time_log.txt" signal_script="script_logger" # Start the signal script bash $signal_script & # Function to send signals send_signal() { signal=$1 pkill -RTMIN+$signal -f $signal_script } # Signal handling trap 'send_signal 2' SIGINT # Signal for script stop trap 'send_signal 3' SIGTSTP # Signal for script pause trap 'send_signal 4' SIGCONT #signal for script continue send_signal 1 #sending signal that script started echo $$ #showing PID of this process while true do current_time=$(date +"%Y-%m-%d %H:%M:%S") echo "$current_time" >> $log_file sleep 60 done` i tried killing it from another bash terminal window, strangely it works half the times.
has comment: http://stackoverflow.com/comment/137911702
has comment: http://stackoverflow.com/comment/137911643
tagged with: linux
tagged with: bash
has comment: http://stackoverflow.com/comment/137911766
has comment: http://stackoverflow.com/comment/137912820
tagged with: signals
upvote count: 1
has comment: http://stackoverflow.com/comment/137911847
score: 0
type: Question
tagged with: hotkeys
type: UnansweredQuestion
answer count: 1
has title: (Bash, terminal) why do killing script hotkeys don't work (e.g. ctrl-c, ctrl-z)

http://stackoverflow.com/q/78167734
accepted answer: http://stackoverflow.com/a/78167873
possible better answer: http://stackoverflow.com/a/78167906
tagged with: awk
tagged with: uniq
has body: I have an array of value,location pairs arr=(test,meta my,amazon test,amazon this,meta test,google my,google hello,microsoft) I want to print the duplicate values, the number/count of them, along with the location. For example: 3 test: meta, amazon, google 2 my: amazon, google 1 this: meta 1 hello: microsoft Here test appears 3 times, in meta, amazon, and google So far, this code will print the item and location printf '%s\n' "${arr[@]}" | awk -F"," '!_[$1]++' test,meta my,amazon this,meta hello,microsoft This will print the count, but it's taking in the value,location as one value printf '%s\n' "${arr[@]}" | sort | uniq -c | sort -r 1 my,amazon 1 my,google 1 this,meta 1 test,meta 1 test,google 1 test,amazon 1 hello,microsoft
tagged with: arrays
type: AnsweredQuestion
has title: Find duplicates in array, print count with pair
type: Question
answer count: 4
upvote count: 2
has answer: http://stackoverflow.com/a/78167873
score: 1
tagged with: bash
has answer: http://stackoverflow.com/a/78172085
has answer: http://stackoverflow.com/a/78167823
has answer: http://stackoverflow.com/a/78167906
favorite count: 0
downvote count: 1

http://stackoverflow.com/comment/137956222
score: 1
comment on: http://stackoverflow.com/q/78252063
type: QuestionComment
type: Comment
has text: Hello, can you check whether it reads the env file with console.log?

http://stackoverflow.com/q/78214961
accepted answer: http://stackoverflow.com/a/78215334
favorite count: 0
has title: How to assign variables to each of the values in a row in an associated array
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/78215334
tagged with: bash
type: AnsweredQuestion
downvote count: 1
possible better answer: http://stackoverflow.com/a/78215529
has comment: http://stackoverflow.com/comment/137891197
type: Question
has body: The script will ask for a color scheme when executed. Color schemes are organized in a file in this way: $ cat schemes sch-001=red blue white sch-002=green yellow black An associated array is clearly called for here. Further, depending on the scheme, each of the colors should be used in another (nested) script or command. In a script it should look like this. #!/usr/bin/env bash ... (The initial part of the script) ... declare -A assscheme mapfile -O 1 -t inscheme < schemes #I prefer keys starting with 1 for val in "${inscheme[@]}"; do key=${val%%=*} value=${val#*=} assscheme[$key]=$value done echo "${!assscheme[@]}" echo "${assscheme[@]}" read -p " Select color scheme: " color #Let's say I've selected sch-001 echo "$color" if "$key" == "$color" ; then # I can't think of anything further yet. # And then I need something like this. magick ......... -fill "$red" ........... ......................................... script1 .......... -b "$blue" ........... ......................................... script2 .......... -o "$white" .......... fi ... (Continue the script) ... How can I organize it this way? Or is there another way?
has answer: http://stackoverflow.com/a/78215529
upvote count: 1

http://stackoverflow.com/a/78216128
upvote count: 2
has comment: http://stackoverflow.com/comment/137893442
downvote count: 0
has comment: http://stackoverflow.com/comment/137893376
type: Answer
has comment: http://stackoverflow.com/comment/137893414
answers question: http://stackoverflow.com/q/78215669
score: 2
has comment: http://stackoverflow.com/comment/137893210
has comment: http://stackoverflow.com/comment/137893198
has body: Consider writing a wrapper script that combines stdout and stderr, and running your scripts behind that wrapper when you're using a tool like Textadept that reads those streams separately and then recombines them. For example, if you create a script, saved in a location on your PATH under the name on-stdout with the following contents: #!/bin/sh exec 2&gt;&amp;1 # make FD 2 (stderr) point to what's currently on FD 1 (stdout) exec &quot;$@&quot; # replace ourselves with the script named by our arguments ...you could, instead of having Textadept run ./yourscript arg1 arg2, tell it to run on-stdout ./yourscript arg1 arg2. This would make the stderr handle received by yourscript be a copy of the stdout handle; because both descriptors point to the same handle, the operating system will then guarantee that write order is preserved.
accepted answer of: http://stackoverflow.com/q/78215669
has comment: http://stackoverflow.com/comment/137893368
type: AcceptedAnswer

http://stackoverflow.com/comment/137810705
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78169487
has text: @Alexis, did you put that _in the script_ (where it wouldn't help at all) or _in the dotfiles of your interactive shell_ (where it would)? The idea of defining a shell function is to _replace_ the script with the function so you aren't invoking a subprocess in the first place.

http://stackoverflow.com/q/78261314
has comment: http://stackoverflow.com/comment/137972148
tagged with: bash
has comment: http://stackoverflow.com/comment/137972170
has title: How to compare string variables containing spaces and special characters in a Bash script?
has body: Below is a simple script where I compare two string variables $rev and $prev #!/bin/sh rev=`/usr/local/bin/svn info | grep "Revision"` echo $rev prev=`cat rev.txt` if[ "$rev" = "$prev" ]; then echo "Are equal" else echo "Differ => run" fi Both the rev and prev variable will contain strings of the form "Revision: nnn" where n's are digits. I was assuming that by encasing both $prev and $rev in quotes they would be interpreted as strings and compared however the output is: ./test.sh Revision: 130 ./test.sh: line 9: if\[ Revision: 130 = Revision: 130 \]: command not found ./test.sh: line 10: syntax error near unexpected token `then' ./test.sh: line 10: `then' I'm guessing that its the colon character in the strings that is causing the problem but I'm not sure. What syntax do I use to ensure that $prev and $rev are compared as raw strings ? Or is there something else that is causing the error ? Thanks, As above, no really, as above.
has comment: http://stackoverflow.com/comment/137972667
has comment: http://stackoverflow.com/comment/137981966
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137971970
duplicate of: http://stackoverflow.com/q/9581064
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/5725296
linked to: http://stackoverflow.com/q/9581064
linked to: http://stackoverflow.com/q/29378566
has comment: http://stackoverflow.com/comment/137972149

http://stackoverflow.com/a/78195138
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/78194906
upvote count: 1
has body: How would I do that? I suggest taking look at printf as you want just text as-is inside string simple %s will suffice for your needs, let command output be LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- <12.81g swap rhel -wi-ao---- 1.60g lv_hana_backups vg_hana_backups -wi-ao---- <10.00g lv_hana_data vg_hana_data -wi-ao---- <10.00g lv_hana_log vg_hana_log -wi-ao---- <10.00g lv_hana_shared vg_hana_shared -wi-ao---- <10.00g then command | awk 'NR>3{printf("/dev/%s/%s\n",$2,$1)}' output is /dev/vg_hana_backups/lv_hana_backups /dev/vg_hana_data/lv_hana_data /dev/vg_hana_log/lv_hana_log /dev/vg_hana_shared/lv_hana_shared Explanation: for lines after 3rd line use formatting print with 2 placeholders (%s) to output desired text. Keep in mind to use \n as printf does not add it automatically as opposed to print. (tested in GNU Awk 5.1.0)
type: Answer

http://stackoverflow.com/comment/137858196
score: 0
type: QuestionComment
has text: For the sake of piece of mind i changed it to IFS="$sMABz_IFS" but it didn't solve the actual issue i described on this post, that read is removing the new lines (i.e. \n)
comment on: http://stackoverflow.com/q/78196593
type: Comment

http://stackoverflow.com/comment/137935183
comment on: http://stackoverflow.com/q/78239545
has text: `sh` is not bash. There's no guaranteed support for arrays in anything you start with `sh`. (`sh` also doesn't guarantee support for the abomination that is `function funcname() {`, which merges the incompatible legacy ksh syntax `function funcname {` and the modern POSIX sh syntax `funcname() {` in a way that's incompatible with **both** legacy ksh and POSIX sh).
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78164653
upvote count: 0
downvote count: 1
score: -1
type: Answer
has body: In node you can make use of fs library to create folder and write files into it. for example like this, const fs = require('fs'); const html = `custom starter html script as per your requirement`; const css = `custom script as per your requirement`; const js = `custom script as per your requirement`; const folderName = process.argv[2]; function createFiles() { try{ if(folderName) { fs.mkdirSync(`${folderName}`); //creates the folder name with the argument you have provided. fs.writeFileSync(`${folderName}\\index.html`,html); // writes to the folder you have created with the custom file contents. } }catch(e){ console.log(`Error: ${e}`); } } if(folderName){ createFiles(); }else{ console.log("Please enter the folder name"); }
answers question: http://stackoverflow.com/q/78164579

http://stackoverflow.com/comment/137858522
score: 0
has text: `man cron` will show you how to increase the log level. And try the redirection I posted yesterday. No logs == badly configured cron, never started. Logs == look at that it did and figure out the issue. You might need to add `-x` to your script's first line.
type: QuestionComment
comment on: http://stackoverflow.com/q/78183354
type: Comment

http://stackoverflow.com/a/78233068
answers question: http://stackoverflow.com/q/78232634
score: 1
type: Answer
upvote count: 1
has body: Not an answer but a workaround: case $file in *cars-bad-cats/* | *cars-dogs/* ) ;; *cars-*/src/bin/out/* ) matching_files=${matching_files:+$matching_files,}$file esac
downvote count: 0

http://stackoverflow.com/a/78211120
accepted answer of: http://stackoverflow.com/q/78203871
answers question: http://stackoverflow.com/q/78203871
type: AcceptedAnswer
upvote count: 1
downvote count: 0
score: 1
type: Answer
has body: Perhaps not the simplest solution, but (sh -c ./example &amp; wait) should work. After example replaces itself with the parent sh process, this process will then immediately end, and the grand parent won't be bothered.

http://stackoverflow.com/q/78166538
has comment: http://stackoverflow.com/comment/137805749
has comment: http://stackoverflow.com/comment/137804714
score: 0
has comment: http://stackoverflow.com/comment/137804681
type: Question
tagged with: linux
accepted answer: http://stackoverflow.com/a/78166564
upvote count: 1
answer count: 1
has body: I have a directory with a couple of files. I want to gunzip one of them. Why does ls . | grep "$filter" | gunzip return an error gzip: stdin: not in gzip format while find . -maxdepth=1 -type f -name "*${filter}*" | while read file; do gunzip "$file"; done works just fine?
favorite count: 0
has comment: http://stackoverflow.com/comment/137804709
downvote count: 1
has answer: http://stackoverflow.com/a/78166564
tagged with: bash
type: AnsweredQuestion
has title: How to gunzip matching files from a directory?

http://stackoverflow.com/a/78227637
upvote count: 2
downvote count: 0
type: Answer
score: 2
has body: The $output is a string, not an array. To declare a bash array, you need the following syntax: output=(one two) It then provides the expected result. service_list_json=$(jq -c -n '$ARGS.positional' --args "${output[@]}") echo "$service_list_json" Output: ["one","two"]
answers question: http://stackoverflow.com/q/78227591
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78227591

http://stackoverflow.com/q/78252038
tagged with: dongle
score: 4
type: Question
downvote count: 0
answer count: 1
has body: !! EDIT: a solution can be found at the bottom of the question !! I am using a Huawei E3372 4G USB dongle on Win8.1. This dongle's settings can be accessed via browser by typing 192.168.8.1 and the user can enable a 4G connection by manually clicking the "Enable mobile data" button. This is the script I am trying to use to "Enable mobile data" connection, knowing I'm doing something wrong only on line 4: #!/bin/bash curl -s -X GET "http://192.168.8.1/api/webserver/token" > token.xml TOKEN=$(grep -v '<?xml version="1.0" encoding="UTF-8"?> ' -v ' ' token.xml) curl "http://192.168.8.1/api/dialup/mobile-dataswitch" -H "Host: 192.168.8.1" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:68.0) Gecko/20100101 Goanna/4.8 Firefox/68.0 PaleMoon/29.0.1" -H "Accept: */*" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8;" -H "_ResponseSource: Broswer" -H "__RequestVerificationToken: $TOKEN" -H "X-Requested-With: XMLHttpRequest" -H "Referer: http://192.168.8.1/html/content.html" -H "Cookie: SessionID=AgVjkIjBxOC0xPbys3nne7rA4I8GXNzUkZCcSOGPR8P3xss8XOuqRbdb0EgHidXhQXZ903xf0nk0F8J81ISqHpZ7kYvZaSW5wHWDqJ9w90pXj90cPwCm7F01fFcmp0gv" -H "Connection: keep-alive" --data-raw "<?xml version=""1.0"" encoding=""UTF-8""?> 1 " date exec $SHELL Upon executing the first curl command, the xml file's content would look like this: <?xml version="1.0" encoding="UTF-8"?> ZsxY7Q9G90jh4FqUiAjxD9XmqLWf0rYg4RUNf6FoVzeTIlPPms0Ov1RERFFRY77o Just for test purposes, if I manually insert the token in the bash script, it works like a charm: #!/bin/bash curl "http://192.168.8.1/api/dialup/mobile-dataswitch" -H "Host: 192.168.8.1" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:68.0) Gecko/20100101 Goanna/4.8 Firefox/68.0 PaleMoon/29.0.1" -H "Accept: */*" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8;" -H "_ResponseSource: Broswer" -H "__RequestVerificationToken: ZsxY7Q9G90jh4…
has comment: http://stackoverflow.com/comment/137956473
has answer: http://stackoverflow.com/a/78252087
has title: How to "Enable mobile data" on a Huawei E3372 4G USB dongle using a bash script in Windows
accepted answer: http://stackoverflow.com/a/78252087
tagged with: 4g
tagged with: usb
tagged with: curl
tagged with: bash
upvote count: 4
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137956363

http://stackoverflow.com/q/78212116
tagged with: dataset
has answer: http://stackoverflow.com/a/78214709
accepted answer: http://stackoverflow.com/a/78212599
has answer: http://stackoverflow.com/a/78212459
tagged with: awk
answer count: 3
has comment: http://stackoverflow.com/comment/137886052
possible better answer: http://stackoverflow.com/a/78212459
tagged with: for-loop
score: 1
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137885750
has body: ok so I am currently in the process of making a very basic bash script to search a jsonl file of mario maker levels with their id's, and then converting the found id's into the actual in game id's using a python script given to me (the database and explanation is in this reddit thread, im searching the courses.jsonl file https://www.reddit.com/r/MarioMaker/comments/wlkwp9/easily_searchable_database_of_super_mario_maker_1/) with my current code, im able to search, seperate just the id's, then convert 1 id to the correct in game id. however, i am not sure how i would be able to convert all the id's found in the search separately. would it just be a for loop, or would i have to do something more complex? here is the code, any help would be appreciated, as most of my bash knowledge is very basic #!/bin/sh id=$(grep $1 /file/path/courses.jsonl | awk -F ',' '{print $1}' | awk -F ':' '{print $2}') python3 /file/path/mmid.py $id edit: here is the current mmid.py file, its basically the initial one i was given with the small change of just adding the id to an argument on runtime instead of asking for input after running import struct import hashlib import hmac import sys idno = int(sys.argv[1]) key = hashlib.md5(b"9f2b4678").digest() data = struct.pack("<Q", idno) checksum = hmac.HMAC(key, data, 'md5').digest() checksum = checksum[3:1:-1].hex().upper() idstring = str.upper(hex(idno))[2:] for y in range(8 - len(idstring)): idstring = '0' + str(idstring) code = str(checksum) + '0000' + str(idstring) print(code) edit 2: i was asked for an example of the courses.jsonl file, so here is one entry. they all look like this, the important thing im grabbing here is the id, which is the first part {"id":69558108,"retrieval_date":"2021-06-05T08:04:59.154776Z","url":"https://d2sno3mhmk1ekx.cloudfront.net/10.WUP_AMAJ_datastore/ds/1/data/00069558108-00001?Expires=1625472299&Signature=BqxLU18d~4rV4FeHNN-Sm2dbKqKyLhS5qX2liHPqr3MN9Y0Fgt5GCYCXrseFt-tinj4LVjrtMIWZW4G1ijj4FSHQyXN9OoW3PfyZbSuatl9…
has comment: http://stackoverflow.com/comment/137886087
has title: How to get a list of numbers out of an awk output in bash
has answer: http://stackoverflow.com/a/78212599
downvote count: 0
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137885696

http://stackoverflow.com/comment/138052307
has text: `$createPath` ends with a carriage return.
score: 0
comment on: http://stackoverflow.com/q/78306525
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137891585
type: Comment
score: 1
has text: Can you please provide a link to an online sandbox (https://repl.it/ or the like) where you repro the problem with only the code given here? I can't make it happen.
type: QuestionComment
comment on: http://stackoverflow.com/q/78215669

http://stackoverflow.com/comment/137816866
type: QuestionComment
type: Comment
has text: `while read -r dec; do printf -v oct '%03o' "$dec"; printf "\\$oct"; done <decimals.txt`
score: 0
comment on: http://stackoverflow.com/q/78173269

http://stackoverflow.com/comment/137824678
type: Comment
has text: There's no need for the temp file. Use `-` as the filename in `aws s3 cp` and it will write to stdout, then you can pipe to the command that counts lines.
comment on: http://stackoverflow.com/q/78177875
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137843014
type: AnswerComment
comment on: http://stackoverflow.com/a/78188142
has text: Don't waste your time with crapware like this.
score: 0
type: Comment

http://stackoverflow.com/comment/137993621
comment on: http://stackoverflow.com/q/78272291
type: QuestionComment
has text: Please add the expected output and always make sure to post the expected and actual output **from the sample input**. Don't post output you got or expect to get from some input we can't see as that just makes it harder for us to help you as then we won't have something we can copy/paste to test with.
type: Comment
score: 0

http://stackoverflow.com/comment/137822745
has text: @markp-fuso I thought I did that in the OP, but I will try to update with some more examples.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78176143
type: QuestionComment

http://stackoverflow.com/comment/137769823
score: 3
type: QuestionComment
comment on: http://stackoverflow.com/q/78146724
type: Comment
has text: Does `test02.py` import `test01.py`? There's nothing wrong with your shell code; to confirm the loop only executes `python3` twice, try adding something like `echo "Running test0$i.py"` as the first line of the loop

http://stackoverflow.com/comment/137783512
score: 0
type: QuestionComment
has text: Are you editing a binary? Consider carefully whether this is an [X/Y Problem](http://xyproblem.info/).
comment on: http://stackoverflow.com/q/78151708
type: Comment

http://stackoverflow.com/comment/137801254
type: Comment
comment on: http://stackoverflow.com/q/78155690
has text: This question is pretty broad. Here at SO, we generally want tightly focused, narrowly scoped questions.
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138027638
type: QuestionComment
has text: This ... `$(dirname "$(readlink -f "$0")")` ... is a risky way to try to determine the script's installation directory. It likely will not work as intended if the script is looked up in the path instead of directly by its name.
type: Comment
comment on: http://stackoverflow.com/q/78292693
score: 0

http://stackoverflow.com/comment/137823348
score: 0
has text: Try figuring it out with small steps like `for wav in **/*.wav; do echo $wav; done`.
comment on: http://stackoverflow.com/a/78173029
type: Comment
type: AnswerComment

date
tag name: date
tags question: http://stackoverflow.com/q/78200396
type: Tag
tags question: http://stackoverflow.com/q/78566886
tags question: http://stackoverflow.com/q/78596837
tags question: http://stackoverflow.com/q/78803876
tags question: http://stackoverflow.com/q/78761018
tags question: http://stackoverflow.com/q/78994210
tags question: http://stackoverflow.com/q/79074586
tags question: http://stackoverflow.com/q/79380617
tags question: http://stackoverflow.com/q/79377185
tags question: http://stackoverflow.com/q/79317281
tags question: http://stackoverflow.com/q/79545027
tags question: http://stackoverflow.com/q/79517529

http://stackoverflow.com/comment/137815968
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78160193
score: 1
has text: In `ksh`, there's actually a small difference between functions declared with the `function` keyword and those without. No such difference exists in `bash`; it supports `function` simply to facilitate executing existing `ksh` scripts without having to edit them. When writing code specifically for `bash`, there is no reason to use `function`.

http://stackoverflow.com/q/78177875
has comment: http://stackoverflow.com/comment/137827383
tagged with: awk
has comment: http://stackoverflow.com/comment/137828994
has comment: http://stackoverflow.com/comment/137830112
has comment: http://stackoverflow.com/comment/137830151
has comment: http://stackoverflow.com/comment/137824678
tagged with: bash
has comment: http://stackoverflow.com/comment/137828977
has comment: http://stackoverflow.com/comment/137830122
has title: Counting no of records from the files using Bash script
has comment: http://stackoverflow.com/comment/137824659
has comment: http://stackoverflow.com/comment/137825264
has comment: http://stackoverflow.com/comment/137827456
type: Question
answer count: 0
has body: I have written this script to count the no of records that are present in the files on the AWS s3 location. #!/bin/bash export bucket="$1" export prefix="$2" export threads="$3" copy_and_count(){ temp_file=$(mktemp) aws s3 cp "s3://$bucket/$1" "$temp_file" line_count=$(sed -n '$=' "$temp_file") echo $line_count rm "$temp_file" } main(){ objects=$(aws s3 ls "s3://$bucket/$prefix" --recursive | awk '{print $4}') echo "$objects" | xargs -n 1 -P "$threads" -I {} bash -c 'copy_and_count "{}"' | awk '{s+=$1} END {print s}' > total_count.txt } export -f copy_and_count main This script works for smaller data sets like 4 or 5 files having 10000 records in the file, but when I am running the same script for a larger data set like 5000 files having the same records in each file then I am not getting the correct count Here is the command that I am using to run the file bash script.sh bucket-name object-prefix 10 Here I am using dummy values for the bucket-name and object-prefix and 10 is the number of parallel threads that I am invoking So I am not sure why this is happening, whether it is due to parallel threads or something else is going on here.
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137827432
upvote count: 1
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/137827449
score: 0

http://stackoverflow.com/q/78147838
answer count: 2
score: 0
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137771894
tagged with: grep
has comment: http://stackoverflow.com/comment/137773256
has answer: http://stackoverflow.com/a/78147860
tagged with: bash
has answer: http://stackoverflow.com/a/78147865
has body: I have a simple question here. I have a file and want to check if it is gzipped or not. I've had cases where people rename files without .gz so I'm using file $name instead of looking for ".gz" in the filename. The output of file $filname gives a long string: zip1.gz: gzip compressed data, was "zip1", from Unix, last modified: Fri Jan 26 11:01:59 2024. I have two commands that appear to both work. if file $filename | grep -q gzip ; then if $(file $filename) == *"gzip"* ; then Which way is preferred? I also don't know why the first method works. file $filename outputs a string, correct? Then that string is piped to the input of grep. I thought grep accepts a file as an input, not a string.
has comment: http://stackoverflow.com/comment/137772892
has title: Bash: checking gzip using == or "| grep"

http://stackoverflow.com/comment/137886410
type: AnswerComment
comment on: http://stackoverflow.com/a/78211596
has text: I don't currently have Linux and I don't have the `ip` command, but that's irrelevant - if you edit your question to show the output that YOU get from those commands then we can help you. I know what the commands you are using do, and I've shown what I believe to be the awk equivalent of each command pipeline, but if it's not producing the output you expect then maybe I got something wrong but I won't know til I see the text you're trying to parse. By seeing the output I can probably suggest a more robust way of parsing it too as matching a regexp across the whole of each line is fragile.
type: Comment
score: 0

http://stackoverflow.com/a/78221751
accepted answer of: http://stackoverflow.com/q/78221728
type: AcceptedAnswer
upvote count: 3
downvote count: 0
score: 3
has body: You need to put the command in quotes. Otherwise, the command ends as soon as you type the newline. Also, the variables will be expanded in the original shell, not when the for loop iterates. watch --interval 30 'for x in a b c do echo &quot;$x has $(ls file_${x} 2&gt;/dev/null | wc -l)&quot; done' I also recommend you stop using the archaic backticks for command substitution, use modern $(command).
answers question: http://stackoverflow.com/q/78221728
type: Answer

http://stackoverflow.com/comment/137939265
type: QuestionComment
comment on: http://stackoverflow.com/q/78241761
type: Comment
score: 0
has text: @jhnc Perhaps you can share an example output of an equery command targettng a package and another `qdepends -Q` command targetting the same package but with contrasting outputs.

http://stackoverflow.com/comment/137972148
has text: BTW, `echo $rev` [isn't reliable; don't use it.](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else) If you want to debug, xtrace (`bash -x yourscript` or `set -x` within the script to turn on tracing) is your friend.
type: Comment
comment on: http://stackoverflow.com/q/78261314
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137871417
comment on: http://stackoverflow.com/q/78203871
type: QuestionComment
type: Comment
score: 0
has text: Are you sure `./example` exits with zero?

http://stackoverflow.com/a/78208750
accepted answer of: http://stackoverflow.com/q/78208548
type: Answer
upvote count: 2
downvote count: 0
has body: Just as the error says, Docker is unable to find entrypoint.sh at the path ./entrypoint.sh when trying to start your container. The most likely cause is that the entrypoint.sh script is not where Docker expects it to be when the ENTRYPOINT instruction is executed. So ensure it’s in the same directory as your Dockerfile and included in your Docker image. Try making the following changes to your Dockerfile: WORKDIR /usr/src/app # Copy the entrypoint script into the container at /usr/src/app COPY entrypoint.sh /usr/src/app/ RUN chmod +x /usr/src/app/entrypoint.sh ENTRYPOINT ["sh", "./entrypoint.sh"] Make sure to rebuild your Docker image with docker-compose build after making these changes, before running docker-compose up -d again.
score: 2
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78208548

http://stackoverflow.com/a/78228153
upvote count: 8
has body: Put the & on the command you want to put in the background. In this context, that might be your whole loop: #!/usr/bin/env bash # ^^^^- ensures that array support is available hValues=( 1 10 100 ) # best practice is to iterate over array elements, not... kValues=( 0.01 0.1 ) # ...words in strings! { # perform conditional redirections akin to what nohup would do [ -t 0 ] && exec </dev/null # stdin [ -t 1 ] && exec >myprogram.log # stdout [ -t 2 ] && exec 2>&1 # stderr for hVal in "${hValues[@]}"; do for kVal in "${kValues[@]}"; do python program.py "$hVal" "$kVal" done done } & Notice how the & was moved to be after the done -- that way we background the entire loop, not a single command within it, so the backgrounded process -- running that loop -- invokes only one copy of the Python interpreter at a time. The redirections (</dev/null, >myprogram.log, and 2>&1) are equivalent to how nohup would redirect stdout and stderr to nohup.out if they weren't already going to a file (or other non-TTY destination) to ensure that they aren't attached to a TTY; adjust the name myprogram.log to your preference.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78228111
downvote count: 0
answers question: http://stackoverflow.com/q/78228111
type: Answer
score: 8

http://stackoverflow.com/comment/137863028
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78199319
has text: @jhnc Thanks <3 Was in a hurry and wanted to have this finished before rushing out
score: 0

http://stackoverflow.com/a/78281278
has comment: http://stackoverflow.com/comment/138013068
has comment: http://stackoverflow.com/comment/138007431
has comment: http://stackoverflow.com/comment/138007448
has body: Yes, to output a backslash you would type \\. The code could then look something like: EDIT2 #!/bin/bash bash_var='dir\t\010\out' awk -v awk_var=&quot;${bash_var//\\/\\\\}&quot; 'BEGIN{ print awk_var }'
has comment: http://stackoverflow.com/comment/138019733
upvote count: 2
score: 1
has comment: http://stackoverflow.com/comment/138018386
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78281234

http://stackoverflow.com/comment/137957074
score: 0
comment on: http://stackoverflow.com/q/78252458
type: QuestionComment
type: Comment
has text: That makes a lot of sense. One question though, I stumble some of the pitfalls of `set -e` as well, mainly when storing the text/option of a whiptail input into a variable. Would you recommend handling manually possible errors with if statements as a replacement of `set -e`?

http://stackoverflow.com/a/78297369
type: Answer
has comment: http://stackoverflow.com/comment/138035471
has comment: http://stackoverflow.com/comment/138035823
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/78297320
type: AcceptedAnswer
upvote count: 1
has comment: http://stackoverflow.com/comment/138035720
answers question: http://stackoverflow.com/q/78297320
has body: That's crazy. The simple and obvious syntax is string=' foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working bar ' If you need variable interpolation inside the quoted string, use double quotes instead of single. Then, you will have to backslash-escape any literal double quotes, backslashes, dollar signs, or backticks (`). You can also use different quotes next to each other: string=' foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working '"$var1"' bar ' This contains a long single-quoted string which contains literal backslashes and double quotes immediately adjacent to the double-quoted string "$var1" immediately adjacent to another single-quoted string with newlines and bar in it. The shell will join these into a single string after quote removal. The acute reason your attempt isn't working is that the shell will, by definition, trim final newlines from command substitutions.
has comment: http://stackoverflow.com/comment/138035487

http://stackoverflow.com/comment/137855569
comment on: http://stackoverflow.com/q/78195172
score: 0
has text: Sorry, I've fixed that. It exists, but I cleaned up my code after pasting it here, and must have accidentally removed it.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137835682
comment on: http://stackoverflow.com/a/78183686
score: 0
type: Comment
has text: `ksh93` didn't error out on this, but when I tried `cat <> /dev/pty/1 >&0` (another window's pty address) (WSL doesn't seem to have `rz` available, so I tried `cat`) it would only echo input on the terminal where the input had been typed. (Not clear what problem you are trying to solve with your O.P. (?) ).
type: AnswerComment

http://stackoverflow.com/a/78193154
has body: Most of the time you don't need to use whole string as pattern, look for a sub-pattern to ease your quest, like this for example: $ url='https://stackoverflow.com/questions/78192804/replace-string-with-link-in-bash' $ echo '[Report 1](**Please put link here**)' | sed "s|\*.*\*|$url|" [Report 1](https://stackoverflow.com/questions/78192804/replace-string-with-link-in-bash)
answers question: http://stackoverflow.com/q/78192804
downvote count: 0
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/comment/137902351
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78221337
has text: `.[0] == .[1]` just produces a string (`true` or `false`). This does not affect the exit code. You might want to use jq's `--exit-status` (or `-e`) option.
score: 1

mpi
type: Tag
tags question: http://stackoverflow.com/q/78260874
tag name: mpi

http://stackoverflow.com/a/78251741
has body: I'm not at a proper machine to test this on, but I think it's simpler if you use a two-stage approach. First, generate each of the images with its label, then pipe all those into a second montage command to lay them all out together. In simple terms, that will look like this: for f in *.jpg; do # Generate a single, labelled image on stdout in MIFF format magick "$f" ... MIFF:- done | magick montage MIFF:- ... result.jpg I use MIFF as the intermediate format because it can preserve and propagate any bit-depth, any transparency and all meta-data. So, your actual command will look more like this: for f in $(ls -rt *.jpg) ; do # Take first 8 characters, no need to invoke external process like "cut" label="${f:0:8}" magick "$f" -label "$label" -font Arial -pointsize 16 \ -auto-orient -resize 200x200 -background black \ -fill grey MIFF:- done | magick montage -background black MIFF:- -geometry +2+2 -tile 8x result.jpg Remember not to put any debug code inside the for loop that writes on stdout because it will get sent to the final montage command and confuse it. So, if you want debug statements inside the for loop, use stderr like this: >&2 echo DEBUG: Processing file $f Note that you may want to add -extent 200x200 to the command inside the for loop to ensure smaller, or different aspect-ratio images are padded up to a full 200x200. If, during the debug stage, you want to see the individual images that are getting sent through the pipe, you can write them to the filesystem as well by changing the magick command in the for loop to write an extra copy: for ... ; do magick "$f" ... -write "DEBUG-${label}.jpg" MIFF:- done | magick montage MIFF:- ...
type: AcceptedAnswer
upvote count: 3
type: Answer
accepted answer of: http://stackoverflow.com/q/78251624
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/78251624

http://stackoverflow.com/comment/137810615
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78166645
has text: Don't forget the quotes

http://stackoverflow.com/a/78276099
score: 1
downvote count: 0
has body: I would exploit GNU AWK for this task following way key="KEY" value="- & -" echo "AAA $key AAA" | awk --assign FS="$key" --assign OFS="$value" '{$1=$1;print}' gives output AAA - & - AAA Explanation: I inform GNU AWK that field separator is key and output field separator is value, then for each line I trigger rebuild ($1=$1) and print result. Keep in mind you still need to be watchful against characters of special meaning inside key. Disclaimer: this code replaces all key occurrences with value, which is different than sub which you have use. If you want to know more about FS or OFS then read 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR (tested in GNU Awk 5.1.0)
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/78274893

amazon-ec2
tag name: amazon-ec2
tags question: http://stackoverflow.com/q/78177847
tags question: http://stackoverflow.com/q/78156372
type: Tag
tags question: http://stackoverflow.com/q/78584835
tags question: http://stackoverflow.com/q/78570866
tags question: http://stackoverflow.com/q/78464573
tags question: http://stackoverflow.com/q/79043844
tags question: http://stackoverflow.com/q/78941355
tags question: http://stackoverflow.com/q/79170269
tags question: http://stackoverflow.com/q/79225717
tags question: http://stackoverflow.com/q/79383675
tags question: http://stackoverflow.com/q/79269635

http://stackoverflow.com/q/78146600
tagged with: ubuntu
tagged with: bash
favorite count: 0
upvote count: 0
has answer: http://stackoverflow.com/a/78147680
tagged with: alias
has body: Context: I am trying to compile JModelica Ubuntu (running on WSL - Windows Subsystem for Linux) and facing a challenge with Python version conflicts. The compilation process requires Python 2, but by default, python on my system refers to a Python version managed by pyenv, specifically located at /mnt/c/Users/&lt;userName&gt;/.pyenv/pyenv-win/shims/python. This setup leads to errors during the JModelica compilation process, such as: make[2]: Entering directory '/mnt/c/dev/JModelica/build' ... python setup.py install --with_openmp=True ... /mnt/c/Users/&lt;userName&gt;/.pyenv/pyenv-win/bin/pyenv: 3: cygpath: not found /mnt/c/Users/&lt;userName&gt;/.pyenv/pyenv-win/bin/pyenv: 3: exec: cmd: not found make[2]: *** [Makefile:1020: build-python-packages] Error 127 ... The compilation fails because it attempts to use the Python version managed by pyenv, which seems incompatible with the expected environment. Running which python confirms that python points to the pyenv shim: /mnt/c/Users/&lt;userName&gt;/.pyenv/pyenv-win/shims/python. Question: I have installed Python 2 using sudo apt install python2, and which python2 correctly points to /usr/bin/python2. However, I am unsure how to alias python to /usr/bin/python2 across the system or specifically for the JModelica compilation process, bypassing pyenv. I have tried temporarily aliasing python to python2 in my current shell session alias python=/usr/bin/python2 and adjusting the PATH environment variable so that /usr/bin takes precedence over the pyenv shims directory export PATH=/usr/bin:$PATH but neither approach resolves the issue during the JModelica build process. Could someone guide me on how to force the Ubuntu operating system to recognize /usr/bin/python2 as the default python interpreter, especially for compiling JModelica, or how to adjust the build process to use the correct Python version?
has title: How to Alias `python` to Python 2 (`/usr/bin/python2`) on WSL Ubuntu?
type: Question
score: -10
type: UnansweredQuestion
tagged with: environment-variables
answer count: 1
tagged with: windows-subsystem-for-linux
downvote count: 10
has comment: http://stackoverflow.com/comment/137776516

http://stackoverflow.com/q/78216881
type: Question
possible better answer: http://stackoverflow.com/a/78217506
has comment: http://stackoverflow.com/comment/137912334
score: 2
has comment: http://stackoverflow.com/comment/137894047
has answer: http://stackoverflow.com/a/78217506
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/137912318
tagged with: bash
has comment: http://stackoverflow.com/comment/137895076
has title: Bash: How to assign the value of an environment variable to a local variable?
accepted answer: http://stackoverflow.com/a/78217017
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137895094
has body: I'm sure that I'm missing something basic but I can't figure it out. This is a simple test/learning script to assign the value of one variable BITBUCKET_TAG to the local variable varr. In this case, I've defined BITBUCKET_TAG explicitly, but ultimately it will be an environment variable. Here is a sequence of various command syntax attempts that I've tried (based on a bunch of SO and other internet searches) along with the return values (if any). BITBUCKET_TAG=2.2.2 $ if $BITBUxCKET_TAG ; then varr=$BITBUCKET_TAG; else varr="Nothing to see here"; echo $varr; fi Nothing to see here $ if $BITBUCKET_TAG ; then varr="$BITBUCKET_TAG"; else varr="Nothing to see here"; echo $varr; fi $ if $BITBUCKET_TAG ; then varr="${BITBUCKET_TAG}"; else varr="Nothing to see here"; echo $varr; fi $ if $BITBUCKET_TAG ; then varr="$!BITBUCKET_TAG"; else varr="Nothing to see here"; echo $varr; fi $ if $BITBUCKET_TAG ; then varr="${!BITBUCKET_TAG}"; else varr="Nothing to see here"; echo $varr; fi bash: 2.2.2: bad substitution $ if $BITBUCKET_TAG ; then varr=${!BITBUCKET_TAG}; else varr="Nothing to see here"; echo $varr; fi bash: 2.2.2: bad substitution Obviously, the last two are the closest to working the way that I want, but I don't know what is causing the bad substitution error. Any suggestions are appreciated. Thanks
has comment: http://stackoverflow.com/comment/137893904
answer count: 2
has answer: http://stackoverflow.com/a/78217017
has comment: http://stackoverflow.com/comment/137898148

http://stackoverflow.com/comment/137937344
has text: A line like `eval $myJson | jq '.data'` demonstrates a fundamental misunderstanding of the purpose of quotes. A string like `.data` does not need to be quoted. Variables generally should be quoted. Ignoring the issue of using `eval` at all, this would be better written `eval "$myJson" | jq .data` (Although there is no harm quote .data and writing `jq ".data"` or `jq '.data'`, it is not necessary.)
score: 2
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78240671

http://stackoverflow.com/comment/137919068
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78228875
has text: If you don't want to fiddle with IFS to inhibit word splitting, you could use `readarray` to put the output of `find` into an array, and then loop over the array. Note that this would still not work, if you have filenames with embedded newline characters (which could indeed occur with music files).
score: 0

http://stackoverflow.com/q/78171914
linked to: http://stackoverflow.com/q/6697753
tagged with: mariadb
duplicate of: http://stackoverflow.com/q/22697688
has answer: http://stackoverflow.com/a/78171975
score: 0
type: Question
duplicate of: http://stackoverflow.com/q/6697753
linked to: http://stackoverflow.com/q/4937792
linked to: http://stackoverflow.com/q/13548118
linked to: http://stackoverflow.com/q/8055694
tagged with: bash
has body: This line: use test; SELECT `xyflagged`.`Article number`, `xyflagged`.`Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; However, this works: "use test; SELECT * INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; I've looked at several solutions on SO, such as this and this and several more about escaping strings. Obviously, it has something to do with the space in the column name (I don't have control over that). So I tried various combinations: use test; SELECT `xyflagged`.`Article number`, `xyflagged`.`Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; use test; SELECT `Article number`, `Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; use test; SELECT [xyflagged].[Article number], [xyflagged].[Flag] INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; as suggested by the various answers and the brackets especially appear to have worked for some but not for me. I've tried it like this: mysql -u me -paaaaaaaaaaaaaaa -e "use test; SELECT `xyflagged`.`Article number`, `xyflagged`.`Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged"; and also like this: mysql -u me -paaaaaaaaaaaaaaa << EOF use test; SELECT `xyflagged`.`Article number`, `xyflagged`.`Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; EOF The error is always: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' INTO outfile 'Test1618' fields terminated by ...' at line 1 Maybe it is something basic or obvious, but I think I've tried every combination and I can't make it work. T…
answer count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78171975
linked to: http://stackoverflow.com/q/61024113
has title: MariaDB working in phpmyadmin but not in bash

http://stackoverflow.com/comment/137806093
score: 5
comment on: http://stackoverflow.com/q/78167188
has text: `/etc` ≠ `/usr/local/etc`! Furthermore, performing `chmod` on system files is generally a recipe for a bad time.
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78232840
has comment: http://stackoverflow.com/comment/137925043
has comment: http://stackoverflow.com/comment/137925173
has comment: http://stackoverflow.com/comment/137925049
has body: You need to run shopt -s expand_aliases to enable alias support, which is turned off by default in noninteractive shells. (Historically, aliases were part of the optional interactive extensions in the User Portability Utilities annex to the POSIX sh standard; it's only as of the Issue 7 revision to the POSIX standard that they're part of the proper base featureset). &gt;&gt;&gt; subprocess.run(['bash', '-c', 'alias foo=true;' ... 'command -v foo']).returncode 1 &gt;&gt;&gt; subprocess.run(['bash', '-c', 'alias foo=true;' ... 'shopt -s expand_aliases; command -v foo']).returncode alias foo='true' 0 If you want to actually run that alias, however, it needs to be defined (and alias expansion needs to be enabled) before parse time. To make simple statements be parsed individually, make sure they aren't part of a group or other compound statement, and separate them with newlines rather than ;s or &amp;s. &gt;&gt;&gt; subprocess.run(['bash', '-c', '\n'.join(['alias foo=true', 'foo'])], ... env=(os.environ | {'BASHOPTS': 'expand_aliases'})) CompletedProcess(args=['bash', '-c', 'alias foo=true\nfoo'], returncode=0)
type: Answer
score: 4
answers question: http://stackoverflow.com/q/78232787
has comment: http://stackoverflow.com/comment/137923046
upvote count: 4
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78232787
has comment: http://stackoverflow.com/comment/137922684
has comment: http://stackoverflow.com/comment/137923151
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137925064
has comment: http://stackoverflow.com/comment/137923108
has comment: http://stackoverflow.com/comment/137922739

http://stackoverflow.com/q/78193259
has answer: http://stackoverflow.com/a/78194762
favorite count: 0
has title: Dinamic Table in Bash (Shell)
score: -7
answer count: 2
tagged with: bash
type: Question
type: UnansweredQuestion
has body: I have a problem, there are a series of commands that generate me data that are stored in the variables $nombreioc, $valorioc and $recursoioc, these are printed in the following table: +------------+-----------+---------------------+ | Type | Value | Adicional Resources | +------------+-----------+---------------------+ | $nombreioc | $valorioc | $recursoioc | +------------+-----------+---------------------+ The problem is that the variables have different numbers of characters and the whole table must be adapted to the length of the variable at that moment. All that I want to do in shellscript, linux I have tried to use \t with echo, but it does not work
has answer: http://stackoverflow.com/a/78193436
tagged with: sh
downvote count: 7
upvote count: 0
tagged with: shell
tagged with: linux
has comment: http://stackoverflow.com/comment/137852018

http://stackoverflow.com/comment/137864291
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78188212
has text: @Rubberducky ah, sorry, I didn't notice that you're talking about ***the values*** assigned to the variables; I've re-run the chatGPT code as well as my code ... both sets of code generate the correct assignments ... I'm not seeing all 4 variables set to the same string of `2345`; at this point I have to assume there's something different in your system ... different set of data, different script ... ????

http://stackoverflow.com/q/78203871
has comment: http://stackoverflow.com/comment/137880530
has comment: http://stackoverflow.com/comment/137871417
has comment: http://stackoverflow.com/comment/137871454
has answer: http://stackoverflow.com/a/78211120
has comment: http://stackoverflow.com/comment/137872987
has comment: http://stackoverflow.com/comment/137871518
type: Question
tagged with: shell
accepted answer: http://stackoverflow.com/a/78211120
has comment: http://stackoverflow.com/comment/137871678
has title: How to continue script execution after a command replaces itself with a new shell process?
tagged with: ruby
has comment: http://stackoverflow.com/comment/137873017
score: 1
has comment: http://stackoverflow.com/comment/137880529
has comment: http://stackoverflow.com/comment/137871748
answer count: 1
has comment: http://stackoverflow.com/comment/137871822
has body: I have an executable ruby script as follows: example: #!/usr/bin/env ruby at_exit do # Replace the currently running Ruby process with a new instance of the parent shell exec(`ps -p #{Process.ppid} -o comm=`.chomp) end It works fine when running as a command, but due to it replacing itself with a new shell instance, it does not work in scripting, as no commands after it are executed. How do I modify my shell script such that execution continues? (I am running the shell scripts like so: bash test.sh) Some examples of what I would like to achieve: test.sh: #!/usr/bin/bash ./example && echo "How do i get here" test1.sh: #!/usr/bin/bash VAR=foo $VAR ./example <argument> test2.sh: #!/usr/bin/bash cd ~ && git clone https://github.com/gfxstrand/pycook yes | ./example test3.sh: #!/usr/bin/bash ./example || echo "How do i get here" Note that I cannot change the behavior of the ruby script-- it must replace itself with a new instance of the parent shell at exit. (The exception to this is a solution replacing the parent process of the ruby script with a new instance of the parent shell, which would also suffice)
has comment: http://stackoverflow.com/comment/137880492
has comment: http://stackoverflow.com/comment/137871238
has comment: http://stackoverflow.com/comment/137880540
tagged with: linux
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137871773
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/137871353
type: AnsweredQuestion

http://stackoverflow.com/comment/137949635
comment on: http://stackoverflow.com/a/78245181
type: Comment
type: AnswerComment
score: 0
has text: @CNDominic, correct. This code will *only* cache the `main.py` code. If files that are imported by `main.py` are changed between runs then the cached `main.py` code will import the updated files. This goes beyond the scope of your question (which requires only a single file to be cached) so you may want to ask a new question.

http://stackoverflow.com/tag/r
tag name: r
type: Tag
tags question: http://stackoverflow.com/q/78147406
tags question: http://stackoverflow.com/q/78167188
tags question: http://stackoverflow.com/q/78450649
tags question: http://stackoverflow.com/q/79347783

http://stackoverflow.com/comment/137973125
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78261786
has text: Are you looking to just clear the screen? https://stackoverflow.com/questions/2084508/clear-the-terminal-in-python

http://stackoverflow.com/comment/137833362
type: QuestionComment
comment on: http://stackoverflow.com/q/78175689
type: Comment
score: 0
has text: You need a semi-colon before closing brace: `{ ... ;} `! But for only one command, this is useless.

http://stackoverflow.com/comment/137871518
type: Comment
has text: OK, now I get it. After `bash ./test.sh` if I press Ctrl+D it does print `How do i get here`. If you want the rest of the script to run inside the interactive shell `./example` replaces itself with I don't think that's possible.
comment on: http://stackoverflow.com/q/78203871
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137856898
type: QuestionComment
has text: Is it not possible to use npm/yarn/etc to add the dependencies via script?
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78195387

http://stackoverflow.com/comment/137831420
type: QuestionComment
has text: Understand the difference between these shells. If your script was written for `zsh`, run it with `zsh drinkwater.sh` (or better yet set its [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) to point to Zsh, `chmod +x` it, and simply run it by writing the path to the script). Understand that `zsh` is required to run scripts which contain Zsh syntax, Bash for Bash syntax, and `sh` for portable scripts which only contain POSIX shell syntax.
comment on: http://stackoverflow.com/q/78178090
type: Comment
score: 0

http://stackoverflow.com/comment/137772687
type: AnswerComment
comment on: http://stackoverflow.com/a/78148123
has text: Revision 2, explicitly specifying bash syntax highlighting, still was incorrectly highlighted in my (Chromium-based) browser. (direct link: https://stackoverflow.com/revisions/78148123/2)
score: 0
type: Comment

http://stackoverflow.com/q/78240671
has body: I've a script that does something like this: set -x myJson="echo '{\"data\":\"true\"}'" commandOutput=$(eval $myJson | jq '.data') echo $commandOutput while : do if $commandOutput == "true" then break fi sleep 1 done echo "Done" However, my string comparison never works. The only way I managed this to work was putting '"true"' in the string comparison. It seems that is something related to the eval. Since I've set the x flag here is the output of this script: + myJson='echo '\''{"data":"true"}'\''' ++ eval echo ''\''{"data":"true"}'\''' +++ echo '{"data":"true"}' ++ jq .data + commandOutput='"true"' + echo '"true"' "true" + : + "true" == \t\r\u\e + sleep 1 + : + "true" == \t\r\u\e + sleep 1 + : + "true" == \t\r\u\e + sleep 1 It seems that the string at the right side is being always scaped, if this is the case why is this happening?
tagged with: bash
has title: Why my string comparison isn't working in bash?
has comment: http://stackoverflow.com/comment/137936562
tagged with: string
has answer: http://stackoverflow.com/a/78266239
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137936614
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137937344
tagged with: jq
has comment: http://stackoverflow.com/comment/137936491
has comment: http://stackoverflow.com/comment/137936435
answer count: 2
tagged with: string-comparison
has comment: http://stackoverflow.com/comment/137936420
has answer: http://stackoverflow.com/a/78242834

http://stackoverflow.com/comment/137879267
comment on: http://stackoverflow.com/q/78208234
type: Comment
type: QuestionComment
score: 0
has text: See this https://docs.github.com/en/actions/learn-github-actions/variables#using-contexts-to-access-variable-values

http://stackoverflow.com/comment/137923619
type: Comment
has text: If it's using JSON escaping rules, it's best to use something that knows how to parse that JSON properly (like `jq` as @Brian61354270 suggested) rather than hack something that only handles certain characters.
comment on: http://stackoverflow.com/q/78233301
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137855942
comment on: http://stackoverflow.com/q/78194973
type: Comment
has text: not getting any errors but doesnt seem to be adding the routes when doing that
score: 0
type: QuestionComment

autoconf
tag name: autoconf
tags question: http://stackoverflow.com/q/78274675
type: Tag
tags question: http://stackoverflow.com/q/78276793

http://stackoverflow.com/comment/137937992
comment on: http://stackoverflow.com/q/78241462
type: QuestionComment
type: Comment
score: 1
has text: `write text` needs its argument in quotes.

http://stackoverflow.com/comment/137908423
has text: Alright well thanks for trying!
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78224990
type: Comment

http://stackoverflow.com/q/78208234
has title: Github Actions - What am I doing wrong with this conditional step?
downvote count: 2
tagged with: bash
favorite count: 0
upvote count: 0
tagged with: github-actions
has comment: http://stackoverflow.com/comment/137879238
type: Question
has body: I'm creating an action for a Selenium grid instance, it's only supposed to exit if $READY comes back false, $READY is true and we're still getting a failed job! - name: Get Selenium Grid status variables run: | echo "READY=$(cURL 'http://localhost:4444/status' | jq '.value.ready')" >> $GITHUB_ENV NODE_COUNT=$(cURL 'http://localhost:4444/status' | jq '.value.nodes' | jq 'length') - name: (DEBUG) Print variables env: ENV_CONTEXT: ${{ toJson(env) }} STEP_CONTEXT: ${{ toJson(steps) }} run: | echo "$READY" # true echo "${{env.READY}}" # true cURL http://localhost:4444/status - name: Confirm Grid is up if: ${{ env.READY }} == true run: echo "Selenium Grid is Ready" - name: Exit if Grid is down if: ${{ env.READY }} != true run: echo "Selenium Grid wasn't ready, ending action" && exit 1 Any help is appreciated Also the runner is Macmini if that's relevant
type: UnansweredQuestion
answer count: 1
score: -2
has comment: http://stackoverflow.com/comment/137879267
has answer: http://stackoverflow.com/a/78208742

http://stackoverflow.com/comment/137822398
type: QuestionComment
type: Comment
has text: yes file.txt is supposed to be numbers.txt
comment on: http://stackoverflow.com/q/78176347
score: 0

http://stackoverflow.com/a/78176634
has comment: http://stackoverflow.com/comment/137822166
answers question: http://stackoverflow.com/q/78176347
has body: change the awk line to awk '$1&gt;=200 &amp;&amp; (NF&gt;7) &amp;&amp; substr($8,2,length($8)-2)+0&lt;=400' numbers.txt use substr to extract the number from the paranthesized expression and the added number of fields check will avoid false matches when there is no 8th field.
score: 0
type: Answer

sh
tags question: http://stackoverflow.com/q/78298936
tags question: http://stackoverflow.com/q/78156679
tags question: http://stackoverflow.com/q/78215669
type: Tag
tag name: sh
tags question: http://stackoverflow.com/q/78255091
tags question: http://stackoverflow.com/q/78238193
tags question: http://stackoverflow.com/q/78195172
tags question: http://stackoverflow.com/q/78177405
tags question: http://stackoverflow.com/q/78192103
tags question: http://stackoverflow.com/q/78193259
tags question: http://stackoverflow.com/q/78173269
tags question: http://stackoverflow.com/q/78300019
tags question: http://stackoverflow.com/q/78253800
tags question: http://stackoverflow.com/q/78389511
tags question: http://stackoverflow.com/q/78422837
tags question: http://stackoverflow.com/q/78428782
tags question: http://stackoverflow.com/q/78433528
tags question: http://stackoverflow.com/q/78353017
tags question: http://stackoverflow.com/q/78513408
tags question: http://stackoverflow.com/q/78472033
tags question: http://stackoverflow.com/q/78535188
tags question: http://stackoverflow.com/q/78451463
tags question: http://stackoverflow.com/q/78506003
tags question: http://stackoverflow.com/q/78573688
tags question: http://stackoverflow.com/q/78511517
tags question: http://stackoverflow.com/q/78559360
tags question: http://stackoverflow.com/q/78494598
tags question: http://stackoverflow.com/q/78497806
tags question: http://stackoverflow.com/q/78675262
tags question: http://stackoverflow.com/q/78677918
tags question: http://stackoverflow.com/q/78783704
tags question: http://stackoverflow.com/q/78889365
tags question: http://stackoverflow.com/q/78849261
tags question: http://stackoverflow.com/q/78896851
tags question: http://stackoverflow.com/q/78885332
tags question: http://stackoverflow.com/q/78888424
tags question: http://stackoverflow.com/q/78842937
tags question: http://stackoverflow.com/q/78883050
tags question: http://stackoverflow.com/q/78790696
tags question: http://stackoverflow.com/q/78971884
tags question: http://stackoverflow.com/q/78988601
tags question: http://stackoverflow.com/q/78983888
tags question: http://stackoverflow.com/q/78966986
tags question: http://stackoverflow.com/q/79014876
tags question: http://stackoverflow.com/q/79015678
tags question: http://stackoverflow.com/q/79160239
tags question: http://stackoverflow.com/q/79244484
tags question: http://stackoverflow.com/q/79099208
tags question: http://stackoverflow.com/q/79147830
tags question: http://stackoverflow.com/q/79317898
tags question: http://stackoverflow.com/q/79301901
tags question: http://stackoverflow.com/q/79266920
tags question: http://stackoverflow.com/q/79359311
tags question: http://stackoverflow.com/q/79407186
tags question: http://stackoverflow.com/q/79292132
tags question: http://stackoverflow.com/q/79434995
tags question: http://stackoverflow.com/q/79496365
tags question: http://stackoverflow.com/q/79536203
tags question: http://stackoverflow.com/q/79521172
tags question: http://stackoverflow.com/q/79466700
tags question: http://stackoverflow.com/q/79535541

http://stackoverflow.com/a/78174063
score: 0
answers question: http://stackoverflow.com/q/78173269
type: Answer
has body: perl -ne'print( chr( $_ ) )' perl -ne'print chr' perl -pe'$_ = chr' Specifying file to process to Perl one-liner

http://stackoverflow.com/q/78286124
has body: i have a table, say 1.csv, having a name and presence/absence at the 1st, 2nd, 3rd, 4th days, like.. name,1st,2nd,3rd,4th Alice,1,1,0,0 bob,0,1,1,1 Clara,1,0,1,0 To reduce the number of columns, I replaced these four-flag attribute to hex numbered attribute (say 2.csv), like name,hex alice,c bob,7 clara,a I have another table the column contents are horizontally spread with only a single row (say, 3.csv) like alice,c,bob,7,clara,a I would like to extract the number of persons who attended, e.g., the third day. I prefer doing this task with MS Excel. How to implement it? Thanks in advance, I think the following Excel built-in functions can do the task, =DEC2BIN(HEX2DEC(B2), 4) =MID(DEC2BIN(HEX2DEC(B2), 4), 3, 1) =COUNTIF(C2:C4, "1") I prefer doing this task also with awk/bash if it works. Please advice!
score: -1
accepted answer: http://stackoverflow.com/a/78287633
downvote count: 2
tagged with: bash
has comment: http://stackoverflow.com/comment/138018661
has comment: http://stackoverflow.com/comment/138016277
has comment: http://stackoverflow.com/comment/138016409
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138018170
tagged with: awk
has comment: http://stackoverflow.com/comment/138016059
has title: How to account the number of persons satisfying some condition in a CSV
type: Question
has answer: http://stackoverflow.com/a/78286685
has comment: http://stackoverflow.com/comment/138016160
has answer: http://stackoverflow.com/a/78286286
favorite count: 0
has comment: http://stackoverflow.com/comment/138018066
answer count: 3
upvote count: 1
has comment: http://stackoverflow.com/comment/138016112
possible better answer: http://stackoverflow.com/a/78286286
linked to: http://stackoverflow.com/q/4614775
has comment: http://stackoverflow.com/comment/138016043
tagged with: excel
has answer: http://stackoverflow.com/a/78287633

http://stackoverflow.com/comment/137871773
type: QuestionComment
has text: `example` is, as the name suggests, a simplified example. My real-world use case has a ruby script which has the same exit behavior as `example`, but is an actual program. I wish to run this program in a script, and run additional commands after it.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78203871

http://stackoverflow.com/comment/137971970
type: QuestionComment
has text: it's `if [` not `if[`. Check your script with shellcheck.
type: Comment
comment on: http://stackoverflow.com/q/78261314
score: 1

http://stackoverflow.com/q/78286060
upvote count: 2
tagged with: linux
accepted answer: http://stackoverflow.com/a/78287570
tagged with: bash
has comment: http://stackoverflow.com/comment/138017090
has comment: http://stackoverflow.com/comment/138016393
has title: Adding a column to the right of a table with an unknown number of columns
favorite count: 0
has comment: http://stackoverflow.com/comment/138016117
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138017084
linked to: http://stackoverflow.com/q/45420535
tagged with: awk
downvote count: 2
score: 0
type: Question
has body: I have a two tables (one is 1.csv, the other is 2.csv). The first one consists of names and scores like... name,score Alice,6 Bob,1 Joe,2 John,7 Michel,9 The other one has a table with not constant number of columns (sometime only one column, sometime two, sometimes three..) like... Alice, Bob, Michel, Joe,John I would like to add a new score column just right to the name field to allot his/her scores. So, the desired results are, Alice,6,Bob,1 Michel,9 Joe,2,John,7 How to implement this? I prefer an awk/bash script to do this task. Thanks in advance, I tried to run the following script, #!/bin/bash declare -A scores while IFS=',' read -r name score do scores["$name"]=$score done < 1.csv while IFS=',' read -r -a names do for name in "${names[@]}" do name=$(echo "$name" | xargs) echo -n "$name,${scores[$name]}," done echo done < 2.csv I was expecting a result like, Alice,6,Bob,1 Michel,9 Joe,2,John,7 It seemed OK in this MWE case, but for bigger tables, it does no longer works. How should I improve?
has comment: http://stackoverflow.com/comment/138118569
answer count: 1
has comment: http://stackoverflow.com/comment/138016118
has answer: http://stackoverflow.com/a/78287570
tagged with: datatable

http://stackoverflow.com/q/78232634
upvote count: 3
has answer: http://stackoverflow.com/a/78233068
has comment: http://stackoverflow.com/comment/137922806
has title: Bash script: Matching extended glob pattern to a string array
tagged with: bash
favorite count: 0
type: AnsweredQuestion
answer count: 2
accepted answer: http://stackoverflow.com/a/78234934
downvote count: 0
has comment: http://stackoverflow.com/comment/137922881
type: Question
has comment: http://stackoverflow.com/comment/137922775
possible better answer: http://stackoverflow.com/a/78233068
has body: Hello Amazing People, I have been trying to achieve a goal of matching an extended glob pattern to a string array (file paths) and getting the list of file which matches to the pattern. Below is the code which works for one ext glob pattern but not for the other similar ext glob pattern. This is the pattern which doesn't work. pattern="**cars-+(!(bad-cats|dogs))/src/bin/out/**" Here is the shell code: #!/bin/bash # Enable extended globbing shopt -s extglob # pattern="**cars-!(bad-cats)/src/bin/out/**" # this extended glob pattern works pattern="**cars-+(!(bad-cats|dogs))/src/bin/out/**" # this extended glob pattern doesn't work and also goes in a very long loop cos of cars-ok-kk/src/main/out/start.txt files="cars-white-pens/src/bin/out/file.txt,cars-ok-kk/src/main/out/start.txt,cars-grey-dogs/src/bin/out/bottle.txt,cars-bad-cats/src/bin/out/computer.txt,cars-whales/src/bin/mouse.txt,cars-dogs/src/bin/out/mouse.txt" IFS=',' read -r -a files_array <<< "$files" matching_files="" for file in "${files_array[@]}"; do if $file == $pattern ; then if [ -z "$matching_files" ]; then matching_files="$file" else matching_files="$matching_files,$file" fi fi done echo "Match: $matching_files" PS: We can change the ext glob pattern too if needed for the code to work but I want the pattern to be ext glob pattern only with support of exclusion of one or more directories as shown in the pattern. Thanks in advance. The commented ext glob pattern pattern="**cars-!(bad-cats)/src/bin/**" works fine with the shell script but the other one doesn't. When I run it, it takes some time (not sure why) and then prints below: Match: cars-white-pens/src/bin/out/file.txt,cars-grey-dogs/src/bin/out/bottle.txt,cars-bad-cats/src/bin/out/computer.txt,cars-dogs/src/bin/out/mouse.txt It removed src/main/out and src/bin/mouse.txt but failed to remove cars-bad-cats and cars-dogs file strings. I expect output as Match: cars-white-pens/src/bin/out/file.txt,cars-grey-dogs/src/bin/out/bottle.txt since src/…
has answer: http://stackoverflow.com/a/78234934
score: 3
tagged with: extglob

http://stackoverflow.com/q/78224942
has comment: http://stackoverflow.com/comment/137908845
has comment: http://stackoverflow.com/comment/137908821
score: 0
type: Question
has title: Why is my bash script showing [2: command not found?
tagged with: shell
has comment: http://stackoverflow.com/comment/137910515
has comment: http://stackoverflow.com/comment/137908642
has answer: http://stackoverflow.com/a/78225000
linked to: http://stackoverflow.com/q/5725296
linked to: http://stackoverflow.com/q/9581064
accepted answer: http://stackoverflow.com/a/78225000
tagged with: scripting
has body: So here is my small bash script: #!/bin/sh echo "arg 0=" $0 echo "arg 1=" $1 echo "arg 2=" $2 if [$# -eq 1]; then cal $1 elif [$# -eq 2]; then cal $1 $2 else echo Incorrect amount of arguments used fi Once I start by executing the script using ./calscript.sh 5 2020 Then I get the following error arg 0= calscript.sh arg 1= 5 arg 2= 2020 calscript.sh: line 6: [2: not found calscript.sh: line 8: [2: not found Incorrect amount of arguments used Can anyone tell me what I am doing wrong? I was expecting to be shown the calendar tools may 2020 on the terminal.
linked to: http://stackoverflow.com/q/4277665
tagged with: bash
duplicate of: http://stackoverflow.com/q/9581064
answer count: 1
type: AnsweredQuestion
duplicate of: http://stackoverflow.com/q/4277665

http://stackoverflow.com/a/78266042
type: Answer
accepted answer of: http://stackoverflow.com/q/78261175
has body: Now what I'd really like to do is for in over all the variables starting DATABASE-URL- and pass that URL to my migration script. I've tried a few things but I can't seem to find my variables in the environment. Unlike a normal variable, secret variables are not automatically decrypted into environment variables for scripts. You cannot directly get them from environment(doc here). Checked on my side, it's able to get the secret variables name with Azure CLI, task below: - bash: | # Get all variables from the variable group variables=$(az pipelines variable-group variable list --group-id 11 --output json) # Get the "DATABASE-URL-" started variables name vars=$(echo "$variables" | jq -r 'to_entries[] | select(.key | startswith("DATABASE-URL-")) | .key') echo "$vars" for var in $vars do echo "checking: $var" # output the variable name #echo $($var) # it doesn't work #echo "${!var}" # it doesn't work done displayName: 'Get Secret Variables values' env: AZURE_DEVOPS_EXT_PAT: $(System.AccessToken) However, with the variable name in script, you cannot get the variable value. For example,$($var) and ${!var} doesn't work, even remove hyphen - in the variable name to simplify the variable name. I'm afraid it's not supported to dynamically get the expected secret variable values in DevOps.
type: AcceptedAnswer
upvote count: 1
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78261175

http://stackoverflow.com/comment/137943248
has text: You can find the complete description of git's pathspec syntax [in the docs](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec). Git itself only support fairly simple glob patterns. You can of course always use a different tool (e.g. shell globs, `find`, `fzf`, etc) to find the files and run `git add` on them.
comment on: http://stackoverflow.com/q/78244513
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137888075
type: QuestionComment
comment on: http://stackoverflow.com/q/78213645
type: Comment
score: 0
has text: Type `help [` in the shell, it will tell you what this is. Indirectly, you can use that to find out how the whole thing works.

http://stackoverflow.com/a/78277044
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78276360
score: -1
upvote count: 0
has body: This pure Bash solution might be of interest: while read -r line; do t=${line//[[:space:]]/}; lines[${#t}]+="$line"$'\n'; done <file.txt; printf '%s' "${lines[@]}" It is only practical for small input files (maybe up to 10 thousand lines). Pure Bash code is too slow for processing large amounts of data line-by-line. It depends on the fact that Bash arrays are sparse (so any index can be assigned without assigning anything to lower indices) and that the contents of Bash arrays are expanded in order by index values. This avoids the need for doing explicit sorting in the code. The code will drop the last line of the input file if it does not have a terminating newline. This is easy to fix, but the code is just a curiosity so I didn't bother. See the My text files are broken! They lack their final newlines! section of BashFAQ/001 (How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?) if you are interested.

unix
tags question: http://stackoverflow.com/q/78146721
tags question: http://stackoverflow.com/q/78146724
tags question: http://stackoverflow.com/q/78185284
type: Tag
tag name: unix
tags question: http://stackoverflow.com/q/78287441
tags question: http://stackoverflow.com/q/78178702
tags question: http://stackoverflow.com/q/78222483
tags question: http://stackoverflow.com/q/78178090
tags question: http://stackoverflow.com/q/78245937
tags question: http://stackoverflow.com/q/78373722
tags question: http://stackoverflow.com/q/78441743
tags question: http://stackoverflow.com/q/78353017
tags question: http://stackoverflow.com/q/78346345
tags question: http://stackoverflow.com/q/78424828
tags question: http://stackoverflow.com/q/78526961
tags question: http://stackoverflow.com/q/78581887
tags question: http://stackoverflow.com/q/78472033
tags question: http://stackoverflow.com/q/78494598
tags question: http://stackoverflow.com/q/78479235
tags question: http://stackoverflow.com/q/78538302
tags question: http://stackoverflow.com/q/78464004
tags question: http://stackoverflow.com/q/78654909
tags question: http://stackoverflow.com/q/78722674
tags question: http://stackoverflow.com/q/78597052
tags question: http://stackoverflow.com/q/78639369
tags question: http://stackoverflow.com/q/78739884
tags question: http://stackoverflow.com/q/78642423
tags question: http://stackoverflow.com/q/78646725
tags question: http://stackoverflow.com/q/78670080
tags question: http://stackoverflow.com/q/78707474
tags question: http://stackoverflow.com/q/78746139
tags question: http://stackoverflow.com/q/78869446
tags question: http://stackoverflow.com/q/78896851
tags question: http://stackoverflow.com/q/78872704
tags question: http://stackoverflow.com/q/78927409
tags question: http://stackoverflow.com/q/79014876
tags question: http://stackoverflow.com/q/79025069
tags question: http://stackoverflow.com/q/79068201
tags question: http://stackoverflow.com/q/78968615
tags question: http://stackoverflow.com/q/79159487
tags question: http://stackoverflow.com/q/79128348
tags question: http://stackoverflow.com/q/79241790
tags question: http://stackoverflow.com/q/79228416
tags question: http://stackoverflow.com/q/79110072
tags question: http://stackoverflow.com/q/79315975
tags question: http://stackoverflow.com/q/79397922

http://stackoverflow.com/a/78291593
score: 0
type: Answer
has body: Use timestamps: $ date +%s -d23:00 1712606400 $ date +%s -d01:00 1712527200 $ date -d@1712527200 Mon Apr 8 01:00:00 MSK 2024 $ date -d@1712606400 Mon Apr 8 23:00:00 MSK 2024 In your case: prodStartTime=$(date +%s -d23:00) prodEndTime=$(date +%s -d01:00) currentTime=$(date +%s)
answers question: http://stackoverflow.com/q/78290808

http://stackoverflow.com/comment/137826210
type: QuestionComment
type: Comment
has text: Ah, you need the command **and** the command output to be both stored in your file? Then try redirecting STDOUT to STDIN like this : `set -o xtrace; ls -l /directory/to/check/exists >> validation.log 2>&1`
comment on: http://stackoverflow.com/q/78178702
score: 0

http://stackoverflow.com/q/78283701
favorite count: 0
has answer: http://stackoverflow.com/a/78286984
has comment: http://stackoverflow.com/comment/138012955
score: 0
has comment: http://stackoverflow.com/comment/138012186
type: Question
has title: How to print echo command's output and a function's output side by side in same line?
tagged with: shell
downvote count: 1
type: UnansweredQuestion
has body: I am trying to output a diamond shape with the following bash script. #!/bin/bash read -p "Please write a number: " number # Printing asterisks according to input: for i in $(seq 1 "$number") do stars+="*" done # Another way: # stars=$(printf "%*s" "$number" "*") # Function 1 space=$(( number - 1 )) function pyramid1 { for (( i=1; i<=$number; i++ )) do for (( k=$space; k>=0; k-- )) do echo -n " " done for (( j=1; j<=i; j++ )) do echo -n "*" done space=$(( space - 1 )) echo done } # pyramid1 # output1=$(pyramid1) # pyramid3=$(echo "$output1" | rev) # echo "$pyramid3" function pyramid4 { for (( i=$number; i>0; i-- )) do echo "$stars" until=$(( $i-1 )) stars="${stars:0:i-1}" done } output=$(pyramid4) pyramid2=$(echo "$output" | tac) output1=$(pyramid1) pyramid3=$(echo "$output1" | tac) #pyramid1 #echo "$pyramid2" #echo "$pyramid3" #pyramid4 #echo "$pyramid2" > temp2 #echo "$pyramid3" > temp3 printf '%s|%s\n' "$(pyramid1)" "$pyramid2" printf '%s|%s\n' "$pyramid3" "$(pyramid4)" As a beginner, I was able to create each 4 parts. However I was not able to print each two parts side by side in the same line. I would really appreciate your help. Thank you in advance! Here is the output I am getting lastly
has comment: http://stackoverflow.com/comment/138012200
has comment: http://stackoverflow.com/comment/138013602
tagged with: printf
has comment: http://stackoverflow.com/comment/138012420
has comment: http://stackoverflow.com/comment/138012831
tagged with: bash
has comment: http://stackoverflow.com/comment/138012402
has comment: http://stackoverflow.com/comment/138013359
has comment: http://stackoverflow.com/comment/138013342
upvote count: 1
has comment: http://stackoverflow.com/comment/138013126
answer count: 1

http://stackoverflow.com/q/78147701
has answer: http://stackoverflow.com/a/78148060
tagged with: awk
tagged with: sed
has title: Map custom and arbitrary functions with sed or awk
accepted answer: http://stackoverflow.com/a/78148060
has answer: http://stackoverflow.com/a/78148473
type: Question
possible better answer: http://stackoverflow.com/a/78148473
has comment: http://stackoverflow.com/comment/137771999
has comment: http://stackoverflow.com/comment/137773177
has comment: http://stackoverflow.com/comment/137771689
score: 1
tagged with: command-line
linked to: http://stackoverflow.com/q/15285534
answer count: 2
linked to: http://stackoverflow.com/q/9625663
has comment: http://stackoverflow.com/comment/137771660
tagged with: linux
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137771678
has comment: http://stackoverflow.com/comment/137771832
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has body: I'm trying to use commands sed or awk, together with arbitrary functions (or commands) defined, for example, as Bash scripts. For example, the following Bash script prepend_largest_prime.sh accepts a string as its first argument, and outputs the larger prime number below N, where N is the length of the string: #!/bin/bash is_prime() { # Returns 1 if a number is prime, 0 if not i=2 if [ $1 -lt 2 ] then return 0 fi max=`echo "sqrt($1)" | bc` while [ $i -le $max ] do if [ `expr $1 % $i` -eq 0 ] then return 0 fi i=`expr $i + 1` done return 1 } largest_prime_under() { counter=$1 is_prime $counter counter_primeQ=$? if $counter_primeQ = 1 ; then echo $counter exit 1 fi counter=$[ $counter - 1 ] while $counter -gt 0 ; do is_prime $counter counter_primeQ=$? if $counter_primeQ = 1 ; then echo "$counter" exit 1 fi counter=$[ $counter - 1 ] done } string_length() { str="$1" n=${#str} echo "$n" } string_length_num=$(string_length "$1") largest_prime_under_string=$(largest_prime_under $string_length_num) echo $largest_prime_under_string $1 An example call of this script could be: $ ./prepend_largest_prime.sh 'The quick brown fox jumps over the lazy dog.' 43 The quick brown fox jumps over the lazy dog. Here the passed string has 44 characters, and the larger prime number below 44 is 43. This is all I have managed to do. It still doesn't work and seems too complicated for the task at hand: cat input_file.txt The majestic mountains towered over the quaint little beautiful village below. The serene garden is colorful. The old oak trees stood tall, their branches reaching towards the sky. $ sed "s|.*|\"\$(\./prepend_largest_prime.sh '&')\"|" input_file.txt "$(./prepend_largest_prime.sh 'The majestic mountains towered over the quaint little beautiful village below.')" "$(./prepend_largest_prime.sh 'The serene garden is colorful.')" "$(./prepend_largest_prime.sh 'The old oak trees stood tall, their branches reaching towards the sky.')" For this example, the output of the…
has comment: http://stackoverflow.com/comment/137771740

http://stackoverflow.com/comment/137946768
comment on: http://stackoverflow.com/q/78246449
type: Comment
has text: You are talking about bash prompt customization (in terms of what to search for)
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137842661
type: Comment
type: AnswerComment
has text: I came up with a workaround for my specific use-case. The "value space" of `first_line` is not fully exhausted (i.e. I only expect producer to return positive integers) and I can encode the failure into the value captured in `first_line` (i.e. by echoing a negative integer from `producer`). Not ideal and not generally applicable, but will work for me.
score: 0
comment on: http://stackoverflow.com/a/78177452

http://stackoverflow.com/q/78211450
tagged with: shell
answer count: 1
type: AnsweredQuestion
has body: I have this simple bash script that responds to SIGUSR{1,2}, while running a GUI program in the background: #!/usr/bin/env bash trap 'echo trapping && sleep inf' USR1 USR2 echo $$ gnome-calculator &>/dev/null & sleep inf (feel free to replace gnome-calculator with any other GUI programs) I then ran kill -USR1 with the PID that the script printed, and the script correctly echoed "trapping" in response. But unfortunately, gnome-calculator was killed in the process. Is there a way to make it so that the signal does not get propagated to its child processes? It looks like that you can do something like trap '' USR1 USR2, but I want to actually do something in response to the signal.
has title: bash - Don't propagate signal to child processes
has answer: http://stackoverflow.com/a/78211545
tagged with: bash
type: Question
accepted answer: http://stackoverflow.com/a/78211545
has comment: http://stackoverflow.com/comment/137887921
score: 0

http://stackoverflow.com/comment/137885696
type: Comment
has text: Are you allowed to alter `mmid.py` or it must remain as-is AT ANY PRICE?
score: 1
comment on: http://stackoverflow.com/q/78212116
type: QuestionComment

http://stackoverflow.com/comment/138000826
type: AnswerComment
has text: thank u @Barmar for the last, can instead of + operator can u limit it min to max number
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78277043

http://stackoverflow.com/q/78294007
score: 0
type: Question
type: UnansweredQuestion
tagged with: terminal
has comment: http://stackoverflow.com/comment/138029682
tagged with: github-codespaces
answer count: 0
has body: This is a small QoL thing but I have a postCreateCommand.sh script that installs bash-completion so my git autocomplete works. It works well but the default bash terminal that Codespaces presents me with does not work with autocomplete. I have to open a new terminal to use autocomplete. Is there anyway to get this first terminal I am presented with to make use of bash-completion? postCreateCommand.sh #!/bin/bash # Check if running as root if $EUID -ne 0 ; then echo "This script must be run as root" exit 1 fi # Install npm packages npm install npm audit fix # Update apt package manager and install bash-completion apt update apt install -y bash-completion devcontainer.json "postCreateCommand": "sudo bash .devcontainer/postCreateCommand.sh"
tagged with: bash
has title: Refresh default bash terminal when Codespace container starts
has comment: http://stackoverflow.com/comment/138029771

http://stackoverflow.com/q/78300019
answer count: 0
has comment: http://stackoverflow.com/comment/138040962
linked to: http://stackoverflow.com/q/37649080
upvote count: 1
tagged with: sh
linked to: http://stackoverflow.com/q/2853803
score: 0
type: Question
tagged with: shell
has title: how to find out which script sets variable during bash startup
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/2853803
favorite count: 0
downvote count: 1
has body: When I log on to a certain machine, I get greeted with -bash: TMOUT: readonly variable That means that somewhere in the depths of .bash_profile after untold levels of scripts sourcing other scripts, someone is setting TMOUT at least twice. How do I find those two places?
has comment: http://stackoverflow.com/comment/138040739
tagged with: bash

http://stackoverflow.com/comment/137810248
comment on: http://stackoverflow.com/a/78169487
type: AnswerComment
has text: I have changed the buggy code as suggested, but even if I change the source command to `sh ${PWD}/.venv/bin/activate` it doesn't activate the environment. Any other suggestion, please?
score: 0
type: Comment

parsing
tag name: parsing
tags question: http://stackoverflow.com/q/78223744
type: Tag
tags question: http://stackoverflow.com/q/78176143
tags question: http://stackoverflow.com/q/78438262
tags question: http://stackoverflow.com/q/78674730
tags question: http://stackoverflow.com/q/78867172
tags question: http://stackoverflow.com/q/79041382
tags question: http://stackoverflow.com/q/79221915
tags question: http://stackoverflow.com/q/79115246

http://stackoverflow.com/comment/137972170
type: QuestionComment
comment on: http://stackoverflow.com/q/78261314
type: Comment
has text: Also note that `sh` and `bash` are not the same thing, so the "bash" tag is not appropriate. See [Difference between sh and Bash](https://stackoverflow.com/q/5725296/4154375).
score: 1

http://stackoverflow.com/comment/137882081
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78210154
has text: You have to NOT pass this secrets as *arguments*! Use another way, like *STDIN*, avoid ENVIRONMENT variables too!!

http://stackoverflow.com/comment/138126818
comment on: http://stackoverflow.com/a/78301430
type: Comment
type: AnswerComment
has text: Many thanks, that solves it! Do you happen to have documentation on the formatting of "plot ... using"? I aim to tweak plotstyles but the documentation of specifics is spread across many manuals and examples. For instance, I want to modify the frequency of x-ticks using time syntax, but the docs don't apply to the 'plot ... using' syntax. Thanks!
score: 0

http://stackoverflow.com/comment/138040962
score: 1
has text: thank you for that link ... I would not have derived that incantation ... turns out it was in `/etc/profile` :)
comment on: http://stackoverflow.com/q/78300019
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137847159
type: QuestionComment
type: Comment
has text: steamlining the `awk` script ... combine `commandSQL` and `querySQL` into a single static variable (defined before the `while(1)` loop) with a single placeholder `%s`; then replace the current `if (DIN==1)` block with `if (DIN==1) system(sprintf(command_query_SQL,++TICKCOUNT))`; every statement in the `awk` script does take up some small slice of time (though not as heavy a cost as the `system()` call) so eliminating unnecessary statements should add a small improvement
comment on: http://stackoverflow.com/q/78190193
score: 0

http://stackoverflow.com/q/78239545
has comment: http://stackoverflow.com/comment/137935079
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137935183
has comment: http://stackoverflow.com/comment/137935205
has comment: http://stackoverflow.com/comment/137934308
score: 0
has title: Pass in positional arguments to Bash function
tagged with: bash
has comment: http://stackoverflow.com/comment/137934312
has body: I have a simple bash script: #!/bin/bash function main() { declare -a ARGS=( --cell=&quot;&quot; ) echo &quot;${ARGS[@]}&quot; } main &quot;$@&quot; I want to be able to modify the cell flag through a command line prompt, and I thought the following would work: sh launch_training.sh -- --cell=test However, this doesn't seem to override it in the function itself. Am I formatting my command line prompt incorrectly?
has comment: http://stackoverflow.com/comment/137934714
has comment: http://stackoverflow.com/comment/137934599
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137935047

http://stackoverflow.com/comment/137865880
type: AnswerComment
comment on: http://stackoverflow.com/a/78196477
score: 0
has text: OMG!!! You're so right! It was left over from when I was experimenting! I feel so stupid now! So sorry about this fuss!
type: Comment

http://stackoverflow.com/comment/137871238
comment on: http://stackoverflow.com/q/78203871
score: 0
type: QuestionComment
type: Comment
has text: The new shell is running in the same child process as the original ruby script. It will continue with the original script when you exit from the new shell.

http://stackoverflow.com/comment/137908071
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78224799
type: Comment
has text: @DevSolar Thank you. I'll leave the entire code block up for now and edit when I've cut it down. I personally thought sharing the entire code would be more helpful than not. Just the first function and if statement should suffice for testing.

http://stackoverflow.com/a/78150663
has comment: http://stackoverflow.com/comment/137777563
has comment: http://stackoverflow.com/comment/137777346
type: Answer
has body: Like this: { sleep 1; echo y; sleep 1; } | bash ./script.sh I use: more from util-linux 2.37.2
answers question: http://stackoverflow.com/q/78150653
has comment: http://stackoverflow.com/comment/137777373
has comment: http://stackoverflow.com/comment/137777392
has comment: http://stackoverflow.com/comment/137777378
score: 0

http://stackoverflow.com/q/78194973
has comment: http://stackoverflow.com/comment/137855431
has comment: http://stackoverflow.com/comment/137855498
has comment: http://stackoverflow.com/comment/137855952
has comment: http://stackoverflow.com/comment/137855917
has title: Bash Loop Variable from print
has comment: http://stackoverflow.com/comment/137855911
has comment: http://stackoverflow.com/comment/137856875
duplicate of: http://stackoverflow.com/q/11426529
has comment: http://stackoverflow.com/comment/137855198
has comment: http://stackoverflow.com/comment/137855964
has comment: http://stackoverflow.com/comment/137855835
has body: Update - kind of got it working with the following but getting Cannot find device "eth0 eth1" so its trying to add both as a variable and not a single line #!/bin/bash gateway=$(ip route | awk '/default / {print $3}'y) broadcast=$(ip route | awk 'NR==2 {print $1}') interface=$(basename -a /sys/class/net/* | awk '/eth/{print $1}') for x in $interface do ip rule add from "$broadcast" table vrack ip route add "$broadcast" dev "$interface" table vrack ip route add default via "$gateway" dev "$interface" table vrack ip route add "$broadcast" dev "$interface" table vrack done systemctl restart NetworkManager.service
has comment: http://stackoverflow.com/comment/137855150
has comment: http://stackoverflow.com/comment/137855818
linked to: http://stackoverflow.com/q/4651437
has comment: http://stackoverflow.com/comment/137855149
has comment: http://stackoverflow.com/comment/137855633
has comment: http://stackoverflow.com/comment/137855885
has comment: http://stackoverflow.com/comment/137855948
has comment: http://stackoverflow.com/comment/137856886
has comment: http://stackoverflow.com/comment/137856092
linked to: http://stackoverflow.com/q/16553089
has comment: http://stackoverflow.com/comment/137855909
has comment: http://stackoverflow.com/comment/137856169
has comment: http://stackoverflow.com/comment/137855942
score: 0
has comment: http://stackoverflow.com/comment/137855854
type: Question
has comment: http://stackoverflow.com/comment/137855863
answer count: 0
has comment: http://stackoverflow.com/comment/137856460
has comment: http://stackoverflow.com/comment/137856160
has comment: http://stackoverflow.com/comment/137855922
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137855169
has comment: http://stackoverflow.com/comment/137855971
has comment: http://stackoverflow.com/comment/137855232
has comment: http://stackoverflow.com/comment/137855782
has comment: http://stackoverflow.com/comment/137855876
has comment: http://stackoverflow.com/comment/137855900
has comment: http://stackoverflow.com/comment/137856864
has comment: http://stackoverflow.com/comment/137856064
has comment: http://stackoverflow.com/comment/137855363
has comment: http://stackoverflow.com/comment/137855158
has comment: http://stackoverflow.com/comment/137857614
has comment: http://stackoverflow.com/comment/137856330
has comment: http://stackoverflow.com/comment/137855925
tagged with: bash

http://stackoverflow.com/a/78266070
score: 0
has body: To convert all values of an array, you need to map its elements: .DailyForecasts | map(.Day.RainProbability) map(f) is equivalent to [.[]|f], so the above can be rewritten to the equivalent: [.DailyForecasts.[].Day.RainProbability] Output: [ 2, 1, 7, 6, 9 ] Similarly for your second query: .DailyForecasts | map(.AirAndPollen[1].Value) or [.DailyForecasts.[].AirAndPollen[1].Value] Output: [ 12, 12, 13, 29, 69 ] Note that your code is very sensitive to the order of the elements in the array. It looks like you are interested in the "Grass" value (the second element in the array, .[1]), so I would suggest to filter for this element specifically: .DailyForecasts | map(.AirAndPollen.[] | select(.Name=="Grass").Value)
type: Answer
answers question: http://stackoverflow.com/q/78253195

http://stackoverflow.com/comment/138013068
type: AnswerComment
comment on: http://stackoverflow.com/a/78281278
score: 0
has text: According to the POSIX specification of `awk`, you'll also need to replace the raw `LF`s with `\n` when passing them through `-v`. Here's what I get when I don't do it on UNIX: ```awk -v v=$'\n' 'BEGIN{print v}'``` ```awk: file "(null)": line 1: Newline in string```
type: Comment

http://stackoverflow.com/comment/137918939
type: QuestionComment
type: Comment
has text: Also see [Bash Pitfalls #14 (echo $foo)](https://mywiki.wooledge.org/BashPitfalls#echo_.24foo).
score: 0
comment on: http://stackoverflow.com/q/78229406

http://stackoverflow.com/q/78215669
has comment: http://stackoverflow.com/comment/137891563
has comment: http://stackoverflow.com/comment/137891624
has comment: http://stackoverflow.com/comment/137891609
tagged with: bash
has comment: http://stackoverflow.com/comment/137892382
has comment: http://stackoverflow.com/comment/137898450
has comment: http://stackoverflow.com/comment/137891864
has comment: http://stackoverflow.com/comment/137891617
type: Question
has comment: http://stackoverflow.com/comment/137891576
has comment: http://stackoverflow.com/comment/137891567
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78216128
has comment: http://stackoverflow.com/comment/137891816
has comment: http://stackoverflow.com/comment/137891768
tagged with: sh
has comment: http://stackoverflow.com/comment/137891642
has comment: http://stackoverflow.com/comment/137892953
has title: How to ensure proper order of single command outputs in a Linux shell (dash, bash) script run by Textadept F5?
score: 0
tagged with: shell
has comment: http://stackoverflow.com/comment/137891585
has answer: http://stackoverflow.com/a/78216128
has comment: http://stackoverflow.com/comment/137892105
has comment: http://stackoverflow.com/comment/137901411
linked to: http://stackoverflow.com/q/45760692
has body: The described behavior occurs when I am running the code from Textadept text editor F5 (run code) feature (bash "%f") looking at the output in the output buffer. I can't reproduce it when running the script from the Terminal shell ... (thanks to Charles Duffy for pointing it out in the comments). My current work around is to use sleep, but the amount of time is deliberately chosen and the approach may randomly fail no matter which value is used in sleep. Any idea how to assure the right order, so that the outcome of the output() function always for sure appears between -- 1 -- and -- 2 -- ? output() { echo stdout; echo stderr >&2; } echo ' --1-- ' output 3>&2 1>&2 2>&3 #sleep 0.001 # still causes the outcome of output be printed after echo '--2--' sleep 0.01 # causes outcome of output be printed after echo '--1--' echo ' --2-- ' Output to achieve: --1-- stdout stderr --2-- Output without sleep or with too small sleep value: --1-- --2-- stdout stderr
answer count: 1
has comment: http://stackoverflow.com/comment/137891635

http://stackoverflow.com/q/78178153
type: AnsweredQuestion
tagged with: pipestatus
accepted answer: http://stackoverflow.com/a/78178190
type: Question
has answer: http://stackoverflow.com/a/78178190
has title: PIPESTATUS variable does not return all the exit codes after running a pipeline
score: 1
has body: I am using the PIPESTATUS variable to access all the exit codes of the pipeline: echo "hello" | wc -w. Now since the commands run with success, the PIPESTATUS array returns me 0 0 when I access using echo ${PIPESTATUS[*]} immediately after running the pipeline either in script or terminal. However, when I try to print them separately by using the following codes: echo "${PIPESTATUS[0]}" # it prints the output 0 echo "${PIPESTATUS[1]}" # doesn't print anything, blank terminal The whole code is: #!/bin/bash echo "hello" | wc -w echo "${PIPESTATUS[0]}" echo "${PIPESTATUS[1]}" how to solve this? And why it's not possible to access elements in such a way. It's an array so it should be possible. Does the PIPESTATUS have anything to do with being volatile or something?
tagged with: arrays
downvote count: 0
tagged with: bash
upvote count: 1
answer count: 1
favorite count: 0

http://stackoverflow.com/q/78285382
duplicate of: http://stackoverflow.com/q/3009192
has comment: http://stackoverflow.com/comment/138014689
has body: I've encountered an unusual file, but I'm unable to comprehend its contents. What could be the reason behind this? -----weird_sh.sh----- #!/bin/echo 11 22 echo 33 $./weird_sh.sh aa 11 22 ./weird_sh.sh aa
linked to: http://stackoverflow.com/q/3009192
has title: A weird shell script file
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138014767
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138014677
score: 0
tagged with: shell
tagged with: linux
tagged with: bash
has comment: http://stackoverflow.com/comment/138014672

http://stackoverflow.com/q/78225038
has comment: http://stackoverflow.com/comment/137908800
has title: changing argument #0 to a shell script not working
tagged with: shell
has answer: http://stackoverflow.com/a/78225379
has comment: http://stackoverflow.com/comment/137908632
possible better answer: http://stackoverflow.com/a/78225379
has comment: http://stackoverflow.com/comment/137908655
accepted answer: http://stackoverflow.com/a/78225303
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137909886
score: 2
upvote count: 2
answer count: 2
has body: I am trying to replace parameter $0/argv[0]. If I compile this c code: #include <stdio.h> int main(int argc, char** argv) { printf("# %s #\n", argv[0]); } and then run it with exec -a fake ./run, I get the output # fake # I then tried with the following shell script: #!/bin/bash echo "# $0 #" but when I run exec -a fake ./test.sh I get # /home/user/test.sh # Why is argument 0 being reset somewhere in the shell script case? For reference, here is the relevant part of exec --help exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...] Replace the shell with the given command. Execute COMMAND, replacing this shell with the specified program. ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified, any redirections take effect in the current shell. Options: -a name pass NAME as the zeroth argument to COMMAND -c execute COMMAND with an empty environment -l place a dash in the zeroth argument to COMMAND
tagged with: linux
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137908699
type: Question
has answer: http://stackoverflow.com/a/78225303

http://stackoverflow.com/comment/137814071
has text: your last command makes no sense, as he want to make a csv file
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78171975

http://stackoverflow.com/comment/137855925
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
has text: The `readarray` command is an equivalent to `interfaces=$(...)` that creates `interfaces` as an array instead of a string. (So it's an alternative to the `for interface in /sys/class/net/*` approach -- use one or the other, not both).
type: Comment
score: 0

regex
tags question: http://stackoverflow.com/q/78278018
tags question: http://stackoverflow.com/q/78244513
tags question: http://stackoverflow.com/q/78213645
tags question: http://stackoverflow.com/q/78196837
tags question: http://stackoverflow.com/q/78276987
tags question: http://stackoverflow.com/q/78200217
tag name: regex
tags question: http://stackoverflow.com/q/78185284
tags question: http://stackoverflow.com/q/78186846
tags question: http://stackoverflow.com/q/78188914
type: Tag
tags question: http://stackoverflow.com/q/78411166
tags question: http://stackoverflow.com/q/78356050
tags question: http://stackoverflow.com/q/78586078
tags question: http://stackoverflow.com/q/78654364
tags question: http://stackoverflow.com/q/78680643
tags question: http://stackoverflow.com/q/78678033
tags question: http://stackoverflow.com/q/78708056
tags question: http://stackoverflow.com/q/78839799
tags question: http://stackoverflow.com/q/78775219
tags question: http://stackoverflow.com/q/78838067
tags question: http://stackoverflow.com/q/78919663
tags question: http://stackoverflow.com/q/79028575
tags question: http://stackoverflow.com/q/78956815
tags question: http://stackoverflow.com/q/78903740
tags question: http://stackoverflow.com/q/78917452
tags question: http://stackoverflow.com/q/79160173
tags question: http://stackoverflow.com/q/79153672
tags question: http://stackoverflow.com/q/79266869
tags question: http://stackoverflow.com/q/79292132
tags question: http://stackoverflow.com/q/79301106
tags question: http://stackoverflow.com/q/79417958
tags question: http://stackoverflow.com/q/79277709
tags question: http://stackoverflow.com/q/79261398
tags question: http://stackoverflow.com/q/79537639
tags question: http://stackoverflow.com/q/79537202
tags question: http://stackoverflow.com/q/79542463

http://stackoverflow.com/comment/138005725
type: AnswerComment
comment on: http://stackoverflow.com/a/78280230
has text: Thank you Mark for your clear explanation. Your help is much appreciated!
type: Comment
score: 0

http://stackoverflow.com/comment/137865701
type: Comment
has text: What did you intend when you wrote "writes into the it" in the title?
score: 0
comment on: http://stackoverflow.com/q/78200978
type: QuestionComment

http://stackoverflow.com/q/78211473
possible better answer: http://stackoverflow.com/a/78211681
has comment: http://stackoverflow.com/comment/137886319
tagged with: function
upvote count: 0
downvote count: 5
accepted answer: http://stackoverflow.com/a/78211596
favorite count: 0
linked to: http://stackoverflow.com/q/2013547
type: AnsweredQuestion
has body: I am trying to see if my public IPv6 have anything in it, if not then output the text Unknown in a variable (for storage). Then have the variable shown later in a text eg: echo "Public IPv6: "$PIP6 (variable that to save). I know that I don't have a public IPv6 (it is slow to come in my country), so I would expect it to say Unknown. But it is empty. What seems to be the problem? test.sh #!/bin/bash OS="$(uname)" InternalIP="" LIP="ip addr show" LIP6="ip -6 addr show scope global" IPv6="" PIPv6="" case $OS in *)InternalIP=$($LIP | grep 'inet'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NF>0{print $2}');; esac case $OS in *)IPv6=$($LIP | grep 'inet6' | grep -v '128' | awk '{print $2}');; esac case $OS in *)PIPv6=$($LIP6 | grep 'inet6' | grep -v '128' | awk '{print $2}');; esac if [ -z $PIPv6 ]; then echo $PIPv6 else echo "Unknown" fi length=$InternalIP echo $InternalIP | awk '{print substr($0, 1, length($0)-3)}' echo $IPv6 | awk '{print substr($0, 1, length($0)-3)}' echo "Public IPv6: "$PIPv6 I tried different if styles. tried with echo "Unknown instead of result and then it showed up as Unknown, but I want it to save to a variable, not showing up at the beginning of the output: Unknown 1xx.xxx.xxx.xxx xxxx::xxxx:xxxx:xxxx:xxx Public IPv6: Now when I run the file: publicip.sh #!/bin/bash LIB="ip address show" # Show Network Information PIB6="ip -6 adress show scope global" # Public IPv6 IPv4="$($LIB | awk '/inet/ && !/127/ && !/128/ && !/64/{print $2}')" IPv6="$($LIB | awk '/inet6/ && !/128/{print $2}')" PIPv4="$(dig +short myip.opendns.com @resolver1.opendns.com)" PIPv6="$($PIP6 | awk '/inet6/ && !/128/{print $2}')" if [ -z "$PIPv6" ]; then PIPv6="unknown" fi echo "Local IPv4: $IPv4" | awk '{print substr($0,1,length($0)-3)}' echo "Local IPv6: $IPv6" | awk '{print substr($0,1,length($0)-3)}' echo "Public IPv4: $PIPv4" echo "Public IPv6: $PIPv6" Output: Local IPv4: xxx.xxx.xxx.xxx Local IPv6: xxxx::xxxx:xxxx:xxxx:xxx Public IPv4: xxx.xxx.xxx.xxx Public IPv6: Unknown Just…
has comment: http://stackoverflow.com/comment/137884688
answer count: 2
tagged with: linux
duplicate of: http://stackoverflow.com/q/2013547
tagged with: bash
type: Question
has title: Bash: Trying to get public IPv6 through a function
score: -5
has answer: http://stackoverflow.com/a/78211681
has comment: http://stackoverflow.com/comment/137884892
has comment: http://stackoverflow.com/comment/137884876
has answer: http://stackoverflow.com/a/78211596

http://stackoverflow.com/a/78243565
answers question: http://stackoverflow.com/q/78241899
has comment: http://stackoverflow.com/comment/137947725
downvote count: 0
type: AcceptedAnswer
score: 2
has body: One way you could go about it is by extracting the prefixes first (DI1, DI2, WT1) and then doing a double iteration. For example this Bash script would produce the output you want: prefixes=() for name in "${file_ref[@]}"; do prefixes+=("${name%.*}") done for prefix in "${prefixes[@]}"; do echo -n "$prefix.fasta with " for fq in "${files_fq[@]}"; do if $fq == $prefix* ; then echo -n "$fq " fi done echo # add a newline done
upvote count: 2
accepted answer of: http://stackoverflow.com/q/78241899
type: Answer

http://stackoverflow.com/comment/137780673
comment on: http://stackoverflow.com/q/78146724
type: Comment
has text: @GirishManjunath then you went to the wrong web site or didn't copy/paste the script from your question into it or didn't bother to correct your shebang and then see what other issues shellcheck would then find as you have 2 `cd`s there without `|| exit` that shellcheck would have told you about and it'd probably also tell you about the unquoted variable. You didn't insult my sensibilities by posting a question on a forum but you did waste everyone's time by posting a question that didn't contain a script you wanted help to debug and not doing what the [tag:bash] tag you used tells you to do.
type: QuestionComment
score: 1

http://stackoverflow.com/q/78194866
tagged with: bash
has title: How to print the 1st line of a command’s output to screen, then sort the rest on col 6 and print that to screen?
score: 0
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137855046
linked to: http://stackoverflow.com/q/14562423
tagged with: command-line
has comment: http://stackoverflow.com/comment/137854913
duplicate of: http://stackoverflow.com/q/14562423
answer count: 0
tagged with: linux
tagged with: sorting
has body: Using the Linux command line, I would like to: — print the first line (from a command’s output) to screen — then sort the rest of the output by column 6, and print that to the screen too I’m sure there are sed and awk solutions, but I’d like to do it with the minimum complexity /{so I can remember it and probably use it again!/} The sort I’ve done, for example: df -h | sort -k 6 returns something like /dev/sda9 100G 33G 6.0G 23% / tmpfs 6.3G 3.4M 6.2G 1% /dev/shm /dev/sda2 10G 3G 6.0G 80% /home Filesystem Size Used Avail Use% Mounted on This sorts the header line into the output. Thanks for your kind assistance. I tried the sort using -k 6 to sort on 6th column, but didn’t know how to both not include the header line in the sort, for ex: df -h | tail -n +2 | sort -k 6 that works, but doesn’t display the header at all.

http://stackoverflow.com/a/78147860
has comment: http://stackoverflow.com/comment/137775625
has body: What I would do: if file -i "$file" | grep -q 'application/gzip'; then [...] else echo >&2 "$file is not a gzip file" fi or mytype=$(file -i "$file") case "$mytype" in *application/gzip*) [...] ;; *) echo >&2 "$file is not a gzip file" ;; esac Both solutions don't need bash, you even can use posix sh with them.
type: Answer
score: 2
answers question: http://stackoverflow.com/q/78147838
upvote count: 2
downvote count: 0

http://stackoverflow.com/comment/137945865
has text: All parts of a pipeline run in parallel. This means `>foo` empties the file _while the pipeline is being set up_. None of this is in any way terminal-specific -- a shell not connected to a terminal behaves the same way.
type: Comment
comment on: http://stackoverflow.com/q/78245937
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138003085
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78278695
score: 0
has text: Thanks, but this does not work for me. I get: $ m() { ( echo "$( history 1 | head -n 1 | cut -c 26- | cut -d\| -f 1 )" ; cat ) | xclip -i ; } $ ls | m Clipboard: m() { ( echo "$( history 1 | head -n 1 | cut -c 26- | cut -d\| -f 1 )" ; cat ) | xclip -i ; }

http://stackoverflow.com/q/78302587
score: 1
tagged with: bash
answer count: 1
has body: I have an initializing sql script for PostgreSQL database. In the script, instead of hardcoding the name of the user, I wish to use the variable stored in my shell file. However I am not able to do it. this is the shell file: export DB_HOST="xxx" DB_PORT="xxx" DB_USER="xxx" DB_NAME="xxx" psql -U $DB_USER -d $DB_NAME -v user1=$DB_USER -f initialize_postgres.sql and i want to use it in the sql script which looks like the following: GRANT SELECT, INSERT, DELETE, UPDATE ON ALL TABLES IN SCHEMA public TO :'user1'; GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public to :'user1'; CREATE FUNCTION save_property (IN prop varchar(50), IN val varchar(500)) RETURNS void AS $$ UPDATE properties SET "value"=val WHERE id=prop; INSERT INTO properties (id, value) SELECT prop, val WHERE NOT EXISTS (SELECT 1 FROM properties WHERE id=prop); $$ LANGUAGE sql; GRANT EXECUTE ON FUNCTION public.save_property(varchar(50),varchar(500)) TO :'user1'; this is the error that is shown to me when I run the pipeline:
upvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78302726
tagged with: variables
accepted answer: http://stackoverflow.com/a/78302726
has comment: http://stackoverflow.com/comment/138045651
tagged with: shell
type: AnsweredQuestion
tagged with: sql
tagged with: postgresql
linked to: http://stackoverflow.com/q/35274597
has comment: http://stackoverflow.com/comment/138045900
type: Question
has title: Using Shell script variable in SQL Script
downvote count: 0

http://stackoverflow.com/q/78173269
duplicate of: http://stackoverflow.com/q/13889659
possible better answer: http://stackoverflow.com/a/78174063
favorite count: 0
tagged with: sh
linked to: http://stackoverflow.com/q/13889659
has answer: http://stackoverflow.com/a/78174063
has title: Convert a file of decimal numbers to the ASCII equivalent
linked to: http://stackoverflow.com/q/41742890
duplicate of: http://stackoverflow.com/q/890262
type: AnsweredQuestion
downvote count: 1
tagged with: printf
has answer: http://stackoverflow.com/a/78173289
tagged with: od
linked to: http://stackoverflow.com/q/890262
answer count: 2
score: -1
tagged with: linux
accepted answer: http://stackoverflow.com/a/78173289
has comment: http://stackoverflow.com/comment/137816866
tagged with: bash
type: Question
has body: I can convert a text file to a list of ASCII decimals like this: $ echo "hello" | od -An -td1 -v -w1 104 101 108 108 111 10 What is the inverse operation? How can I convert the file of decimals back to text? I want to use only common Unix command-line tools. I've been looking at printf but haven't figured out how to make it work.
upvote count: 0
has comment: http://stackoverflow.com/comment/137818635

http://stackoverflow.com/q/78223744
upvote count: 1
has title: How to Handle Left Associativity for Logical Operators in a Recursive Descent Parser?
has comment: http://stackoverflow.com/comment/137908243
has comment: http://stackoverflow.com/comment/137906491
type: Question
linked to: http://stackoverflow.com/q/42610626
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137912270
score: 1
answer count: 1
favorite count: 0
tagged with: algorithm
has comment: http://stackoverflow.com/comment/137906661
has answer: http://stackoverflow.com/a/78227877
tagged with: parsing
tagged with: bash
has comment: http://stackoverflow.com/comment/137906530
tagged with: recursive-descent
has comment: http://stackoverflow.com/comment/137912264
has body: I'm implementing a recursive descent parser for a mini-shell program based on bash, where typically, right recursion is applied. However, for logical operators &amp;&amp; and ||, this approach doesn't seem convenient for execution. For instance, when parsing a command sequence such as cmd1 &amp;&amp; cmd2 || cmd3, the right recursive parser would generate a tree like this: &amp;&amp; / \ cmd1 || / \ cmd2 cmd3 However, for the execution to follow the bash logic correctly, it's more suitable to have left associativity for &amp;&amp; and || operators, resulting in a tree like this: || / \ &amp;&amp; cmd3 / \ cmd1 cmd2 Given this scenario, what would be the recommended approach to modify the parser to handle left associativity specifically for &amp;&amp; and || operators while maintaining right associativity for others? Would it involve a change in the parsing algorithm or a post-processing step after parsing? Or there is a way to execute the tree with right associativity according to bash?

http://stackoverflow.com/q/78175689
has comment: http://stackoverflow.com/comment/137820566
score: 0
linked to: http://stackoverflow.com/q/4651437
tagged with: scripting
has comment: http://stackoverflow.com/comment/137831411
has comment: http://stackoverflow.com/comment/137820484
tagged with: stderr
tagged with: bash
has comment: http://stackoverflow.com/comment/137833362
type: Question
has body: I'm trying to add a prefix to all output of the following command: sudo apt update && sudo apt -y upgrade I've been scouring the internet and it seem there are 2 outputs to handle. STDOUT, and STDERR. I've found the following: sudo apt update && sudo apt -y upgrade > >(sed "s/^/[prefix1]/") 2> >(sed "s/^/[prefix2]/" >&2) Which seems to redirect stdout and stderr and append the [prefix1] and [prefix2], however, there are still some output lines which do not have a prefix, and I'm wondering what I'm missing? The output looks like this: Hit:1 http://ca.archive.ubuntu.com/ubuntu mantic InRelease Hit:2 http://ca.archive.ubuntu.com/ubuntu mantic-updates InRelease Hit:3 http://ca.archive.ubuntu.com/ubuntu mantic-backports InRelease Hit:4 http://security.ubuntu.com/ubuntu mantic-security InRelease Hit:5 https://apt.postgresql.org/pub/repos/apt mantic-pgdg InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. [prefix2] [prefix2]WARNING: apt does not have a stable CLI interface. Use with caution in scripts. [prefix2] [prefix1]Reading package lists... [prefix1]Building dependency tree... [prefix1]Reading state information... [prefix1]Calculating upgrade... [prefix1]0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. How can I prefix the lines which start with HIT:, Reading, Building?
tagged with: stdout
duplicate of: http://stackoverflow.com/q/4651437
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/876239
has comment: http://stackoverflow.com/comment/137820473
has title: Adding a prefix to all output lines of "apt-update && apt-upgrade in BASH?
answer count: 0
tagged with: prefix

http://stackoverflow.com/q/78169456
answer count: 1
duplicate of: http://stackoverflow.com/q/20391943
tagged with: python
has title: Can't activate Python environment after creating it in bash
duplicate of: http://stackoverflow.com/q/13122137
has body: I have the following script myenv.sh: #!bin/bash echo &quot;####### Install automated template ########&quot; python3 -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install ipykernel pandas seaborn scikit-learn echo &quot;######## Done ########&quot; So I run the script, and it creates the environment but doesn't stay activated. Perhaps it is exiting. So I tried this: #!bin/bash echo &quot;####### Install automated template ########&quot; python3 -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install ipykernel pandas seaborn scikit-learn source ${PWD}/.venv/bin/activate echo &quot;######## Done ########&quot; But nothing happens. Please, could you point out what I am doing wrong?
tagged with: bash
has comment: http://stackoverflow.com/comment/137809942
has comment: http://stackoverflow.com/comment/137810266
has answer: http://stackoverflow.com/a/78169487
linked to: http://stackoverflow.com/q/45591428
has comment: http://stackoverflow.com/comment/137810650
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137810264
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/13122137

http://stackoverflow.com/comment/138039637
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78299332
has text: You script is already processing command line arguments. Why do you need a bash script as wrapper?
type: QuestionComment

http://stackoverflow.com/comment/138027999
score: 0
has text: Thank you for the answer! I will try this a bit later. Is it really possible to execute docker commands in the container? I'm not able no do this natively
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78292830

http://stackoverflow.com/comment/137833593
comment on: http://stackoverflow.com/q/78182867
type: QuestionComment
type: Comment
score: 1
has text: Most likely `malloc` allocates memory from the heap, calling something like `brk` or `sbrk` to expand the process's memory if necessary, but `free` only makes the memory available for allocation by the same process without returning it to the OS.

http://stackoverflow.com/comment/137813223
comment on: http://stackoverflow.com/q/78166553
has text: Can you show how `RELEASE_TAG` gets used ?
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137843194
has text: @WalterA That also only did the first level of subdirectories. So it has to do with the executable
comment on: http://stackoverflow.com/a/78173029
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138002255
type: Comment
has text: Maybe it is not possible, but since it opens a new bash, the private stuff is for the new window.
comment on: http://stackoverflow.com/q/78260557
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137852743
score: 0
comment on: http://stackoverflow.com/a/78187835
type: Comment
type: AnswerComment
has text: Time In Lieu? >;op

http://stackoverflow.com/a/78278298
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78278159
has comment: http://stackoverflow.com/comment/138002511
has body: Put the following alias into .bashrc: alias myclip='xclip -i -selection clipboard' Then open a new terminal and issue the following example command: ls | myclip That's all!

http://stackoverflow.com/comment/137875119
type: AnswerComment
score: 0
has text: But you are using bash that is not used in POSIX mode @user88888888
comment on: http://stackoverflow.com/a/78203898
type: Comment

http://stackoverflow.com/comment/137856403
type: Comment
has text: well. goalposts just got moved at lunch. this is no longer an issue because they've decided to go ModbusRTU instead. FFS. welcome to my life. at least i learned a TON from all your help and i'm very, very grateful. salty, (not at you guys) but grateful.
comment on: http://stackoverflow.com/q/78190193
type: QuestionComment
score: 2

http://stackoverflow.com/comment/138017990
has text: `ls` detects that its stdout is not connected to a terminal and produces output reusable by other utilities. This kind of questions are better suited at [unix.se].
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78287441
type: QuestionComment

http://stackoverflow.com/q/78158123
has comment: http://stackoverflow.com/comment/137791561
has comment: http://stackoverflow.com/comment/137790796
score: 0
has answer: http://stackoverflow.com/a/78163768
linked to: http://stackoverflow.com/q/66013532
tagged with: bash
has answer: http://stackoverflow.com/a/78158324
has body: I'm using find to generate a list of old backups, compressed tars, into a file, then reading that file into while loop. I out put the list to a log and screen, both looking correct. echo $x works fine; /vol4/backups/forms_02_24_2024.tar.gz But "rm $x" doesn't work, because it's receiving changed line below; rm: cannot remove '(arr+=(/vol4/backups/forms_02_24_2024.tar.gz))' :No such file or directory arr() while read line; do x="(arr+=("$line"))" echo $x rm $x done < ./old_backups.txt Tried using cut and sed to modify the line, but I still didn't get what rm needed, which is simply the path to each old file. But rm is still no getting the correct file names.
has title: bash unable to delete files in array loop
has comment: http://stackoverflow.com/comment/137807717
has comment: http://stackoverflow.com/comment/137790134
type: Question
has answer: http://stackoverflow.com/a/78158163
tagged with: arrays
has comment: http://stackoverflow.com/comment/137790515
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137790784
answer count: 3

http://stackoverflow.com/q/78254632
duplicate of: http://stackoverflow.com/q/806906
has comment: http://stackoverflow.com/comment/137963719
score: 0
type: Question
type: UnansweredQuestion
has body: I am trying to solve a riddle in bash in an exercise that given 3 arguments, the third being optional, check that argument is a real number, but I can't use regular expressions, grep, awk... How can I check if I can't use a regular expression? I also thought of using -gt and -le but it only works with integers. I saw a post here similar to this but it doestn work with float or negative without regular expression Thank you very much. if [ $# -ge 3 ] && [[ $3 != *[!0-9]* ]]; then echo "Error: optional third argument is not a valid frequency" exit 1 fi
has comment: http://stackoverflow.com/comment/137969773
has answer: http://stackoverflow.com/a/78254812
answer count: 2
linked to: http://stackoverflow.com/q/806906
has answer: http://stackoverflow.com/a/78255939
has title: Check if var is a real number (include float and negative) without regular expresions in Bash
tagged with: bash
has comment: http://stackoverflow.com/comment/137962784

http://stackoverflow.com/a/78279975
answers question: http://stackoverflow.com/q/78278159
type: Answer
score: 0
has body: clipsmth() { (echo &quot;\$ $@&quot;; $@;) | xclip -sel clipboard; } and call it like clipsmth ls -l if that you wanted

http://stackoverflow.com/comment/137866172
score: 0
comment on: http://stackoverflow.com/q/78200978
type: QuestionComment
has text: Usually [I'd avoid `echo`](https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo), and there are some extra flags you want to pass to `read` (so in code I was writing it might look more like`IFS= read -p "Enter your text: " -r user_input && printf '%s\n' "$user_input" >input.txt` -- on the read command, the `-r` stops backslashes in your text from being eaten, and the `IFS=` stops leading and trailing whitespace from being stripped)
type: Comment

http://stackoverflow.com/comment/137940191
type: Comment
has text: @konsolebox hopefully that's useful to the OP. I don't actually use gentoo normally, just installed a container for debugging the awk code
comment on: http://stackoverflow.com/q/78241761
score: 1
type: QuestionComment

http://stackoverflow.com/q/78204675
tagged with: shell
has body: I have this script: $WORKSPACE/bt-helper/navigate_to_project.sh #!/bin/bash this_dir="${0%/*}" echo -e "Script dir: $this_dir" echo -e "Argument 0: $0" echo -e "Argument 1: $1" source "$this_dir"/commons.sh project="$1" validate_project_name "$project" || return 1 project_name="${project//-/_}" # Replace dashes with underscores project_upper=$(echo "$project_name" | awk '{print toupper($0)}') path_var="BT_${project_upper}_PATH" path="${!path_var}" if | ! -d "$path" ; then echo -e print_error "Path for ${PROJECT_COLOR}$project${NC} not found or invalid." echo -e return 1 fi print_info "Navigating to: ${PROJECT_COLOR}$project${NC}" cd "$path" || return 1 print_ok "Current location: ${PROJECT_COLOR}$project${NC}" echo -e and it works fine here: $WORKSPACE/bt-helper/mvn_clean_install.sh #!/bin/bash this_dir="${0%/*}" source "$this_dir"/commons.sh mvn_clean_install() { local project="$1" validate_project_name "$project" || return 1 echo -e print_info "Performing clean install (with tests) on: ${PROJECT_COLOR}$project${NC}" . "$this_dir"/navigate_to_project.sh "$project" && mvn clean install echo -e print_ok "Clean install (with tests) complete for: ${PROJECT_COLOR}$project${NC}" } if "$1" == "all" ; then for project in "${ALL_PROJECTS[@]}"; do mvn_clean_install "$project" done return 0 fi mvn_clean_install "$@" But it doesn't work in my .bashrc This is the output of the debugging echo I added in the script: $ cd-bt some-project Script dir: /usr/bin Argument 0: /usr/bin/bash Argument 1: some-project bash: /usr/bin/commons.sh: No such file or directory bash: validate_project_name: command not found I expected argument 0 to be the true value of $WORKSPACE/bt-helper. Can someone help me understand what is going on? I use Git Bash for Windows. Neither of those cases work, I combined them all in one code block, but I wrote them separately, this does not represent my .bashrc ~/.bashrc cd-bt() { . "$WORKSPACE"/bt-helper/navigate_to_project.sh "$@" } alias c…
linked to: http://stackoverflow.com/q/59895
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137876192
tagged with: git-for-windows
duplicate of: http://stackoverflow.com/q/59895
score: 0
answer count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137872715
has title: How to execute a script with "source" from .bashrc?
has comment: http://stackoverflow.com/comment/137872564
type: Question

http://stackoverflow.com/comment/137955108
comment on: http://stackoverflow.com/q/78244372
has text: You are right, I should clone each code base for each set of experiments, thank you for the good suggestion!
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138004642
has text: @OneCricketeer Thanks the expression worked after escaping the +. I did not know that it need to be escaped.
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78278018

http://stackoverflow.com/comment/137778942
score: 0
has text: What's wrong with `sed -i 's/MaxRagDollCount" "[0-9]"/MaxRagDollCount" "9"/g' file.vpk`?
comment on: http://stackoverflow.com/q/78151708
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137787952
score: 0
type: QuestionComment
type: Comment
has text: (Separately, `.sh` extensions should be used for shell _libraries_, and only POSIX-compliant shell libraries at that, not executable scripts; see [commandname extensions considered harmful](https://www.talisman.org/~erlkonig/documents/commandname-extensions-considered-harmful/) re: rationale)
comment on: http://stackoverflow.com/q/78156916

http://stackoverflow.com/q/78213645
has comment: http://stackoverflow.com/comment/137888261
tagged with: conditional-statements
duplicate of: http://stackoverflow.com/q/806906
tagged with: if-statement
has comment: http://stackoverflow.com/comment/137888107
has comment: http://stackoverflow.com/comment/137888087
tagged with: regex
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137888166
has comment: http://stackoverflow.com/comment/137888081
has comment: http://stackoverflow.com/comment/137888138
type: UnansweredQuestion
has title: How to check for real numbers in bash script programming
tagged with: real-number
linked to: http://stackoverflow.com/q/806906
has comment: http://stackoverflow.com/comment/137888079
has comment: http://stackoverflow.com/comment/137888075
tagged with: bash
has body: I am learning Bash script and I need to write a conditional statement which make sure that my input string is a real number. if [ is not a real number ]; then echo "not a real number" I have found something like this: if [ ! "$num" =~ ^-?[0-9]*(.[0-9]+)?$ ] It works but I cannot understand what it is. I paste this thing to GG to research but I cannot find anything explaining about this one clearly enough. My question is: What is this and how does it work? Is there any different way to solve my problem?

http://stackoverflow.com/comment/137771462
type: AnswerComment
score: 0
has text: I do not understand "external". compgen is a builtin bash command. If you have bash, you have compgen. You can run `xargs bash -c 'compgen -G "$@"' -- < MANIFEST` . There is also python.
comment on: http://stackoverflow.com/a/78146818
type: Comment

http://stackoverflow.com/comment/137826042
type: Comment
comment on: http://stackoverflow.com/q/78178090
score: 0
type: QuestionComment
has text: `vared` is a zsh-only command; it's not available in either bash or generic sh-style shells. Use an explicit zsh shebang in the script (either `#!/bin/zsh` or `#!/usr/bin/env zsh`), and don't override that by specifying an interpreter when you run it (i.e. run it with just `Water-Reminder/drinkwater.sh`). See [this answer](https://stackoverflow.com/questions/76122906/bash-syntax-error-bad-for-loop-variable/76122947#76122947) (though it's about bash, not zsh).

http://stackoverflow.com/q/78176347
upvote count: 0
has comment: http://stackoverflow.com/comment/137822063
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137821770
has comment: http://stackoverflow.com/comment/137822184
has comment: http://stackoverflow.com/comment/137822539
has comment: http://stackoverflow.com/comment/137822527
downvote count: 1
has comment: http://stackoverflow.com/comment/137821873
has title: Using awk how do i find numbers in a file between 200 and 400?
score: -1
answer count: 2
has comment: http://stackoverflow.com/comment/137821763
tagged with: bash
has comment: http://stackoverflow.com/comment/137822481
has comment: http://stackoverflow.com/comment/137822398
has comment: http://stackoverflow.com/comment/137822050
has comment: http://stackoverflow.com/comment/137821750
has body: I have a file that reads something like: 500 text1 text1 text1 text1 text1 text1 (200) 200 text2 text2 text2 text2 text2 text2 350 text3 text3 text3 text3 text3 text3 400 text4 text4 text4 text4 text4 text4 (300) if [ -f file.txt ] then echo "Input your number:" read number if [ $number -ge 200 ] && [ $number -le 400 ] then echo "The number that matched the file are:" awk $1 >= 200 && $8 <= 400 {print} numbers.txt else echo "Number must be between 200 and 400." fi Trying to extract numbers between 200 and 400 and then print the whole line and I just keep getting the while file as output instead
tagged with: file
favorite count: 0
tagged with: sum
has comment: http://stackoverflow.com/comment/137822150
has comment: http://stackoverflow.com/comment/137822467
tagged with: awk
tagged with: range
has answer: http://stackoverflow.com/a/78176634
has comment: http://stackoverflow.com/comment/137821824
type: Question
has comment: http://stackoverflow.com/comment/137822230
has answer: http://stackoverflow.com/a/78176886

http://stackoverflow.com/a/78148473
score: 3
upvote count: 3
downvote count: 0
has body: I have rewritten your is_prime and largest_prime_under functions. #!/bin/bash is_prime() { local n="$1" if (( n==2 )) || (( n==3 )); then return 0 # 0 is 'true' in Unix sh convention.. fi if (( n<1 )) || (( n % 2==0 )) || (( n % 3==0 )); then return 1 # 1 is 'false' in Unix sh convention.. fi for (( i=5; i*i<=n; i+=6 )); do if (( n % i==0)) || (( n % (i+2)==0 )); then return 1 fi done return 0 } largest_prime_under() { local x=$1 if [[ ! "$x" =~ ^([0-9]|[1-9][0-9]+)$ ]]; then echo 'Input must be a natural number (0,1,2,3,...)' return 1 fi if (( x<2 )); then echo 'Input must be greater than 2' return 1 fi while (( x>=2 )); do if is_prime "$x"; then echo "$x is largest prime less than or equal to $1" return 0 fi (( x-- )) done } There is an explanation of the is_prime method HERE and a deep dive on various methods for calculating primes HERE. Know that this is not at all an optimal or general solution. With larger values of integers, the gap between primes grows. With larger gaps, the function largest_prime_under may be calling is_prime and recalculating the same composite numbers millions of times. A more efficient solution would cache all primes up to and including a given number and return the last number. With Bash, however, large arrays are not efficient at random access (ie, array[n] is not necessarily O(1) and introduces another level of problems. You would need to use a higher level language and implement something like Sieve of Eratosthenes.) As a practical matter, I was able to use these functions (on an M3 Mac) and receive accurate values from these functions as follows : values up to 10^12 with results in milliseconds; values up to 10^15 with results in seconds; values up to 10^17 with results in minutes. With larger values, it is unusably slow. It is likely worse than quadratic complexity but useable on modern hardware up to roughly 10^12.
answers question: http://stackoverflow.com/q/78147701
type: Answer

http://stackoverflow.com/comment/137858173
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/78196593
type: Comment
has text: The thing is, _literal single quotes don't work as quotes at all_. You aren't quoting a value when you put `\'` before and after it -- instead, you're prepending and appending the `'` character to the _content_ of the value being assigned. It would need to just be `'` _without_ the backslash to work as a quote. (Because you have _double_ quotes inside, your value is quoted, but the single quotes are just prepending and appending literal values to that double-quoted string).

http://stackoverflow.com/comment/137913419
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591
type: Comment
has text: @yshavit sorry, i had copied something wrong over
score: 0

http://stackoverflow.com/q/78252063
has answer: http://stackoverflow.com/a/78253546
favorite count: 0
downvote count: 1
type: AnsweredQuestion
has title: API key 401 error in .env.development file
score: -1
accepted answer: http://stackoverflow.com/a/78253546
possible better answer: http://stackoverflow.com/a/78277187
type: Question
tagged with: javascript
has comment: http://stackoverflow.com/comment/137958999
has body: I created an .env.development file in order to store my api key and other environment variables. I got an issue that when i use my api key defined in .env.development file and retrieved with the help of dotenvx dependencies, the website failed to load resources with a status of 401. However, if i used my api key directly without the need of retrieving from the .env.development file, the website fetched normally without any trouble. My api key works fine so dont need to worry about that. Note: I also want to mention that the API key I obtained is from TMDB, an external API. Other environment variables that i defined are working fine in the backend with dotenvx package. .env.development: API_KEY="my_api_key" api-config.js: const apiKey = process.env.API_KEY; const apiUrl = "my_api_url"; const apiKeyParams = `my_api_params`; error: I have tried manually with cli bash: $ dotenvx run -- npm run start and i have tried preload with npx: "scripts": { "start": "npx dotenvx run --env-file=.env.development -- react-scripts start" } it all injected environment variables successfully but it still doesnt work.
has answer: http://stackoverflow.com/a/78277187
tagged with: environment-variables
has comment: http://stackoverflow.com/comment/137958934
answer count: 2
tagged with: command-line-interface
upvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137956222

http://stackoverflow.com/a/78278389
answers question: http://stackoverflow.com/q/78276360
type: Answer
score: 0
has body: Disclaimer this solution assumes lines in file.txt are unique, if this does not hold ignore this answer entirely. I would harness GNU AWK for this task following way, let file.txt content be a b c abcde ab cd ef abcdefg a a b then awk 'BEGIN{FPAT="[^[:space:]]";PROCINFO["sorted_in"]="@val_num_asc"}{arr[$0]=NF}END{for(i in arr){print arr[i],i}}' file.txt gives output 1 a 2 a b 3 a b c 6 ab cd ef 5 abcde 7 abcdefg Explanation: I inform GNU AWK that non-white-space character constitute field and to traverse array with ascending values as numbers. When processing lines I store number of fields (that is number of non-white-space characters) in array arr under key being said line. When that is done I traverse that array in desired output and output stored number followed by line. (tested in GNU Awk 5.1.0)

http://stackoverflow.com/q/78200217
score: 0
duplicate of: http://stackoverflow.com/q/407523
has body: Testing for a simple script but I can't get this variable to cooperate with me. I've tried so many things, single quotes and doubles. New=$(df -h) sed -ie "200s|^.*$|"${NEW}"|g" "file.txt" I'm trying to replace whatever is on line 200 of file.txt with the output of df -h pretty much. Need help, if this has been asked before, sorry my brain is toasted and I'm not smart enough to comprehend. most of the time i get an "unterminated `s'" error when I run the script. I'm thinking it's got something to do with the "{}" brackets around the variable and it being misread as something else in regex.
has comment: http://stackoverflow.com/comment/137867634
has answer: http://stackoverflow.com/a/78200333
has comment: http://stackoverflow.com/comment/137872587
tagged with: bash
has answer: http://stackoverflow.com/a/78201892
type: UnansweredQuestion
upvote count: 1
has title: How to use a variable command in a sed expression
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/137867661
tagged with: sed
tagged with: variables
tagged with: regex
type: Question
linked to: http://stackoverflow.com/q/407523
linked to: http://stackoverflow.com/q/29613304
has answer: http://stackoverflow.com/a/78201829
answer count: 3

http://stackoverflow.com/comment/137852542
type: AnswerComment
comment on: http://stackoverflow.com/a/78193436
has text: It doesn't matter where the input to `column` comes from, I'm just using a couple of `echo`s as an example to produce some output to show how the `column | awk` works. I'm assuming you know how to do the part that produces whatever output you already get and can just replace `my example echos | column` with `whatever your existing code does | column`
score: 3
type: Comment

http://stackoverflow.com/q/78241899
tagged with: bash
type: Question
accepted answer: http://stackoverflow.com/a/78243565
has comment: http://stackoverflow.com/comment/137939402
has comment: http://stackoverflow.com/comment/137941158
has title: Iterate over items in one array and groups of items in second array
has comment: http://stackoverflow.com/comment/137941100
has comment: http://stackoverflow.com/comment/137939533
score: 0
tagged with: arrays
duplicate of: http://stackoverflow.com/q/70629122
tagged with: shell
has answer: http://stackoverflow.com/a/78243565
tagged with: linux
has comment: http://stackoverflow.com/comment/137938836
linked to: http://stackoverflow.com/q/70629122
answer count: 1
has comment: http://stackoverflow.com/comment/137939584
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137938863
has body: I have two arrays containing file names files_ref=( $(find . -name '*.fasta') ) files_fq=( $(find . -name '*.fastq') ) I understand that if I want to iterate over pairs of items I would do something like this: for i in "${!files_ref[@]}"; do printf "%s is in %s\n" "${files_ref[i]}" "${files_fq[i]}" done However, my second arrays looks like this file_ref=( DI1.fasta DI2.fasta WT1.fasta ) files_fq=( DI1_P1.fastq DI1_P2.fastq DI1_P3.fastq DI2_P1.fastq DI2_P2.fastq DI2_P3.fastq WT1_P1.fastq WT1_P2.fastq WT1_P3.fastq ) I would have to iterate over files_ref with all its correspoding items in the same group: DI1.fasta with DI1_P1.fastq DI1_P2.fastq DI1_P3.fastq DI2.fasta with DI2_P1.fastq DI2_P2.fastq DI2_P3.fastq WT1.fasta with WT1_P1.fastq WT1_P2.fastq WT1_P3.fastq Any suggestions? ...to be more clear I would need iterations like this: DI1.fasta DI1_P1.fastq DI1.fasta DI1_P2.fastq DI1.fasta DI1_P3.fastq DI2.fasta DI2_P1.fastq DI2.fasta DI2_P2.fastq DI2.fasta DI2_P3.fastq WT1.fasta WT1_P1.fastq WT1.fasta WT1_P2.fastq WT1.fasta WT1_P3.fastq
tagged with: loops

http://stackoverflow.com/a/78153045
score: 1
upvote count: 1
type: Answer
has body: So after some debugging using bash -x and removing the output to /dev/null it became apparent that while nc was available in my bash, starting the script via bash script.sh starts a new shell, which does not load the alias I set in my ~/.bashrc which was alias nc='ncap'. This was obfuscated due to the Git Bash not loading the .bashrc by default, as mentioned here and the fact that I was debugging the command by using bash -x before, but did not know that piping a commands output to /dev/null does also not show it in the debugging output. So in the end it just showed nc -vz localhost 8002 sleep 0.1 in a loop, which I suspected to be a successful execution.
answers question: http://stackoverflow.com/q/78152355
downvote count: 0

http://stackoverflow.com/comment/138006053
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78274675
has text: When you say you're trying to use `scan-build`, should we understand that your configuration and build process worked before you made that integration, or not?

http://stackoverflow.com/a/78286984
upvote count: 1
answers question: http://stackoverflow.com/q/78283701
type: Answer
has body: Using a mixture of arithmetic evaluation (e.g., ((a=i<0?-i:i)) for absolute value of i), pattern substitution (e.g., "${s:0:b}" for b first characters of "$s") and the field width specification of printf (e.g., printf -v s '%*s' $((2*n)) '' to store a 2*n spaces string in s): n=5 printf -v s '%*s' $((2*n)) '' s=${s// /*} for ((i=-n+1;i<n;i++)); do ((a=i<0?-i:i)) ((b=2*(n-a)-1)) printf '%*s%s\n' $a "" "${s:0:b}" done * *** ***** ******* ********* ******* ***** *** *
score: 1
downvote count: 0

http://stackoverflow.com/comment/137880530
has text: Running as `(sh -c ./example & wait)` does work! Would you mind submitting that as an answer @user1934428?
comment on: http://stackoverflow.com/q/78203871
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/78177763
score: 1
type: Answer
has body: Here is one way: { first_line=$(command | { IFS= read -r tmp printf '%s\n' "$tmp" process_rest >&3 }) } 3>&1
answers question: http://stackoverflow.com/q/78177405
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/137905287
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78220931
score: 0
has text: @glades Even if it is several processes, the approach should work. It's the same basic idea as in "stop-the-world" multithreaded garbage collection.

http://stackoverflow.com/q/78194467
accepted answer: http://stackoverflow.com/a/78194502
has comment: http://stackoverflow.com/comment/137854311
has comment: http://stackoverflow.com/comment/137854308
has comment: http://stackoverflow.com/comment/137856039
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137855008
answer count: 1
has comment: http://stackoverflow.com/comment/137854742
has body: Why can't I change the $1 variable of the current environment using the source command with arguments.Is there a way for me to internally change the positional parameter $1 script.sh echo $1 echo $2 $ source ./script.sh Hello World Hello World $ echo $1 $2 (nothing output)
has title: Why can't I change the $1 variable of the current environment using the source command with arguments
tagged with: bash
has answer: http://stackoverflow.com/a/78194502
has comment: http://stackoverflow.com/comment/137854159
type: AnsweredQuestion

http://stackoverflow.com/q/78274893
has body: I want to replace a file's text using awk. An example script: #!/bin/bash test_file="test.md" key="KEY" value="- & -" echo "AAA $key AAA" > "$test_file" echo "Original: $(cat "$test_file")" tmp=$(mktemp) awk -v s="$key" -v r="$value" '{sub(s,r)}1' "$test_file" > "$tmp" && mv "$tmp" "$test_file" echo "Updated: $(cat "$test_file")" rm "$test_file" The expected output is: Original: AAA KEY AAA Updated: AAA - & - AAA However, it outputs incorrectly (the "KEY" remains there instead of "&" symbol): Original: AAA KEY AAA Updated: AAA - KEY - AAA I also tried the way below but no luck. awk ' BEGIN { s=ARGV[1]; r=ARGV[2]; delete ARGV[1]; delete ARGV[2]; } { sub(s,r) }1 END {}' "$key" "$value" "$test_file" > "$tmp" && mv "$tmp" "$test_file" Replacing "&" with other symbols works fine. Any suggestions for handling this case? Please ignore the sed command in this question as I have some other cases to deal with and awk is suitable for my case except this weird "&" issue.
type: Question
has title: How to use awk to replace text with another text containing the "&" symbol?
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/407523
linked to: http://stackoverflow.com/q/29613304
has comment: http://stackoverflow.com/comment/137998203
possible better answer: http://stackoverflow.com/a/78276099
score: 2
answer count: 2
tagged with: shell
has answer: http://stackoverflow.com/a/78275140
has comment: http://stackoverflow.com/comment/137996593
has comment: http://stackoverflow.com/comment/138000178
downvote count: 0
has comment: http://stackoverflow.com/comment/137996784
tagged with: bash
linked to: http://stackoverflow.com/q/37039053
has answer: http://stackoverflow.com/a/78276099
favorite count: 0
accepted answer: http://stackoverflow.com/a/78275140
tagged with: awk
upvote count: 2
has comment: http://stackoverflow.com/comment/138000243

http://stackoverflow.com/comment/137826056
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78171975
score: 0
has text: I used a slight variation of this solution. I don't usually go for solutions that require multiple files, but I believe this is the only thing that works.

sorting
tag name: sorting
tags question: http://stackoverflow.com/q/78194866
type: Tag
tags question: http://stackoverflow.com/q/78495016
tags question: http://stackoverflow.com/q/78484156
tags question: http://stackoverflow.com/q/78846018
tags question: http://stackoverflow.com/q/78761018
tags question: http://stackoverflow.com/q/78803876
tags question: http://stackoverflow.com/q/79144794
tags question: http://stackoverflow.com/q/79423387

http://stackoverflow.com/comment/137908642
type: QuestionComment
has text: space after `[` and before `]` is compulsory. `[` is a command name (= `test`); expansion of `[$#` is probably not a command name
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78224942

http://stackoverflow.com/q/78306525
has title: Concatenating strings strange forward slash
has comment: http://stackoverflow.com/comment/138052328
has comment: http://stackoverflow.com/comment/138052431
has comment: http://stackoverflow.com/comment/138052302
score: 0
type: Question
answer count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/39527571
upvote count: 1
favorite count: 0
duplicate of: http://stackoverflow.com/q/39527571
has body: I am doing some processing on the JSON output of cargo metadata using JQ and a loop. To simplify the situation I have made a simple case below extractor='(?:path\\+file:\\/{3})(.*?)(?:#.*)?@[\\d\\.]+' expr=".workspace_members[] | match(\"$extractor\").captures[0].string" input='{ "workspace_members": [ "path+file:///C:/Users/me/project1#project-1@0.1.0", "path+file:///C:/Users/me/project2#project-2@0.1.0", "path+file:///C:/Users/me/project3@0.1.0", "path+file:///C:/Users/me/project4#project-4@0.1.0", "path+file:///C:/Users/me/project5#project-5@0.1.0" ] }' echo $input | jq -r "$expr" | while read cratePath; do echo "Here $cratePath" done This works fine, I get as output from the echo "Here $cratePath" line the following $ ./private/test.sh Here C:/Users/me/project1 Here C:/Users/me/project2 Here C:/Users/me/project3 Here C:/Users/me/project4 Here C:/Users/me/project5 However I now want to build a child path from $cratePath. When concatenating the strings a rather strange thing happens. Changing the last line to echo $input | jq -r "$expr" | while read cratePath; do echo "Here $cratePath/src" done Outputs /src C:/Users/me/project1 /src C:/Users/me/project2 /src C:/Users/me/project3 /src C:/Users/me/project4 /src C:/Users/me/project5 Why is /src printed first? How can I get it to concatenate at the end. Leaving the first as C:/Users/me/project1/src for example?
has comment: http://stackoverflow.com/comment/138052317
tagged with: bash
downvote count: 1
has comment: http://stackoverflow.com/comment/138052307
has comment: http://stackoverflow.com/comment/138052394

http://stackoverflow.com/comment/138016160
comment on: http://stackoverflow.com/q/78286124
type: Comment
has text: You can only prefer 1 thing. Excel or bash? Change tags on your question based on that.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137822761
score: 0
comment on: http://stackoverflow.com/q/78176143
has text: @Ed Morton Those are extremely unlikely and not allowed characters in this case, I will try to reflect that in the post.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/138026797
has text: What I see as an issue now is that my question has been closed without proper justification by referring to a similar-looking but not, in essence, a duplicate question. You could just as well have referred to any other tilde-expansion related post
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78291764

http://stackoverflow.com/comment/138036877
has text: @markp-fuso thanks for the reminder I have added the error message from the terminal. If I knew what in the code was causing the issue I wouldn't be posting it on a "help" platform on the internet I can post it on git and link to it instead
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78292693

http://stackoverflow.com/q/78278159
has title: Bash Script for Copying to Clipboard
has comment: http://stackoverflow.com/comment/138004749
has comment: http://stackoverflow.com/comment/138004070
tagged with: xclip
tagged with: shell
has answer: http://stackoverflow.com/a/78278695
has comment: http://stackoverflow.com/comment/138004827
has answer: http://stackoverflow.com/a/78290274
upvote count: 1
favorite count: 0
score: -2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138004756
downvote count: 3
has answer: http://stackoverflow.com/a/78279417
accepted answer: http://stackoverflow.com/a/78290274
has comment: http://stackoverflow.com/comment/138002531
has comment: http://stackoverflow.com/comment/138002306
has answer: http://stackoverflow.com/a/78279493
answer count: 6
linked to: http://stackoverflow.com/q/52358661
has body: My goal is to write an alias to copy the current command and its output to the clipboard, e.g.: ls | myclip This should result in the following being in the clipboard: $ ls Desktop Documents Downloads Is this possible? So far, I tried: myclip() { command="$@" output=$($@) echo -e "$command\n$output" | xclip -selection clipboard } This does not work, however. Edit: This seems to somewhat work, however, for me it does not handle line breaks in the output correctly: copyclip(){ cmd=$(history 1 | sed 's/^ *[0-9]* *//' | sed 's/|.*//'); output=$(cat); echo "\$ "$cmd$'\n'$output | xclip -sel clipboard; echo $output; } If anybody knows how to fix the line break issue, that would be great!
possible better answer: http://stackoverflow.com/a/78279417
has answer: http://stackoverflow.com/a/78279975
tagged with: linux
has comment: http://stackoverflow.com/comment/138004857
has answer: http://stackoverflow.com/a/78278298
tagged with: bash
tagged with: clipboard
type: Question
has comment: http://stackoverflow.com/comment/138012201

http://stackoverflow.com/q/78156916
score: 0
tagged with: shell
has comment: http://stackoverflow.com/comment/137787932
answer count: 1
has comment: http://stackoverflow.com/comment/137788159
has title: Avoid Bash shell parameter expansion
has body: I’m trying to create a Bash shell script that gives me the oldest files of n days in a specific folder and optionally indicating a pattern, for example for the file extension, thus giving as input in a single line: the days, the folder and optionally the pattern. It’s relatively simple, I just want to make sure that in this command line I can indicate the pattern without the need for quotes, how do you implement it in the script itself? I tried the script like this: #!/bin/bash # Number of days days=$1 # Directory directory=$2 # Pattern (optional) pattern=$3 # Check if the pattern was provided if [ -z "$pattern" ] then # If no pattern was provided, find all files find $directory -type f -mtime +$days else # If a pattern was provided, find files that match the pattern find $directory -type f -name "$pattern" -mtime +$days fi but, if I write as input something like ./a.sh 20 /home/user/ *.txt The * character make it working only if the script folder doesn't contain .txt files...
duplicate of: http://stackoverflow.com/q/10067266
has comment: http://stackoverflow.com/comment/137787942
linked to: http://stackoverflow.com/q/10067266
has comment: http://stackoverflow.com/comment/137789198
has comment: http://stackoverflow.com/comment/137787935
tagged with: bash
has comment: http://stackoverflow.com/comment/137788192
type: Question
has comment: http://stackoverflow.com/comment/137787929
has answer: http://stackoverflow.com/a/78156936
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137787952

http://stackoverflow.com/comment/137861413
type: Comment
score: 1
type: QuestionComment
has text: The original problem may be due to a bug in earlier versions of bash (I think it was fixed in v4.3). If a here-string wasn't quoted, it'd be word-split and then reassembled from the words, with the effect of turning all whitespace (e.g. newlines) into spaces. Double-quoting the here-string properly (and preferably removing the pointless `echo`+backticks combo -- exactly as @CharlesDuffy suggested in the very first comment) should solve this. See [this question](https://stackoverflow.com/questions/20144593/trying-to-split-a-string-into-two-variables).
comment on: http://stackoverflow.com/q/78196593

http://stackoverflow.com/comment/137955466
has text: Anyhow, the new file is a compiled executable, not a script itself, so it would require different tools to reverse engineer. I'd start with https://ghidra-sre.org/
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78239018

http://stackoverflow.com/comment/137973632
has text: @SteelFeather: this way I (resp. the "user") can't see what's going on in long running processes. So I'd like to show it but clean it afterwards.
score: 0
comment on: http://stackoverflow.com/q/78261786
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137833540
has text: Just to note, this isn't specific to `bash`. Most programs hold any allocated memory for life, rather than return it to the operating system early.
score: 3
type: QuestionComment
comment on: http://stackoverflow.com/q/78182867
type: Comment

http://stackoverflow.com/comment/137895035
comment on: http://stackoverflow.com/q/78207181
has text: You are running it via sudo, so I don't think **your** PATH is relevant. Therefore I would do two small tests: (1) Do a `sudo printenv PATH`. Does the path look right? (2) What happens if you drop the `sudo`? Still get the same message?
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/137866813
score: 0
has text: (because really, the biggest issue with this question right now is that as it was originally asked, nobody but you can test proposed answers)
type: Comment
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment

http://stackoverflow.com/a/78279573
score: 1
upvote count: 1
has body: $ sort &lt;(awk -F'[^ ]' '{print NF-1,$0}' file) 1 a 2 a b 3 a b c 5 abcde 6 ab cd ef 7 abcdefg
type: Answer
answers question: http://stackoverflow.com/q/78276360
downvote count: 0

http://stackoverflow.com/comment/137887921
comment on: http://stackoverflow.com/q/78211450
score: 1
has text: That is curious. In the [Basta](https://www.kylheku.com/cgit/basta/about/) project, I use a background process which every 15 seconds sends a signal to the interactive shell, which updates the status line. Thus the time/date shown in the status line updates spontaneously. I'm not seeing programs run from the interactive shell being affected by thesignal, even though that background process runs all the time. When you send a signal to a positive integer PID, it should go to one process only. Capture a `strace -f -o logfile ./script` of the whole scenario to see how gnome-calculator is dying.
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78158742
has body: Yes, both are possible. To use your hello.sh script in GitLab CI and pass variables directly from your .gitlab-ci.yml, just define your variables under the variables section(below I included a GREETING variable as an example). Then, when you run your script, those variables will automatically be available to it. First make sure your hello.sh script is executable. You can achieve that by running chmod +x ./scripts/hello.sh locally, in the root of your repo. Or you can also have this as the first command to run under your Gitlab CI file’s script section, before running your script. Then modify your .gitlab-ci.yml to include the variables and run your script like this: image: docker:latest stages: - build variables: GREETING: "Welcome to GitLab CI/CD!" build: stage: build script: - ./scripts/hello.sh For your question on whether you can access the variable in your hello.sh, you can access the GREETING variable using $GREETING: #!/usr/bin/env bash echo "Hello World! $GREETING"
answers question: http://stackoverflow.com/q/78157839
downvote count: 0
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/comment/138027560
has text: What do you think `"$("${day}.html")"` means? Do you really intend to produce a file name by running a `.html` file as a program?
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78292693

http://stackoverflow.com/q/78248223
has answer: http://stackoverflow.com/a/78248684
has comment: http://stackoverflow.com/comment/137949844
tagged with: bash
has comment: http://stackoverflow.com/comment/137949833
upvote count: 1
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/137949724
has answer: http://stackoverflow.com/a/78248577
has comment: http://stackoverflow.com/comment/137949850
tagged with: docker
type: Question
has comment: http://stackoverflow.com/comment/137950302
has title: How to disable a bash builtin inside a docker container
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137949762
score: 0
answer count: 2
has body: I am trying to disable the builtin kill in the bash running inside the container, and I would like to know if it is possible to run a command after the container start running, or if it is possible to run /bash/bash with some specific parameter to disable a builtin function. I have a Dockerfile with the following content: ... ENTRYPOINT [ "/entrypoint.sh" ] CMD [ "/bin/bash" ] in the entrypoint.sh, I have the following: #!/bin/bash exec "$@" What I know is possible to do to disable kill is run the command enable -n kill and the builtin will be disabled. But this only works if I run the command inside the container (after exec when I docker run). Is there some way to disable the kill bultin in the entrypoint or in the Dockerfile?

http://stackoverflow.com/a/78220931
answers question: http://stackoverflow.com/q/78218123
downvote count: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/137905191
type: Answer
has comment: http://stackoverflow.com/comment/137905287
score: 1
has body: In brief notation, if we have: link -> dir/ and want to swizzle this to become: link/ It would seem that what we want is to execute the system call rename("dir", "link/"). Unfortunately, that refuses to work on Linux with an errno of 20 (ENOTDIR). This is documented for rename by POSIX: one of the reasons rename can return ENOTDIR is: the old argument names a directory and the new argument names a non-directory file Looks like there may not be a way to do this; it has to be done in two operations, requiring the accessing application to be suspended. If the application consists of a small number of processes, you may be able to kill -STOP them all, do the swizzle, and then kill -CONT. To a stopped process, the operation will appear atomic.

http://stackoverflow.com/a/78302726
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/78302587
has comment: http://stackoverflow.com/comment/138048750
downvote count: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138045890
accepted answer of: http://stackoverflow.com/q/78302587
has body: If you use the substitution :'user1', the result will be in single quotes as a string constant. But GRANT requires the role to be an identifier, that is an object name. So you have to use no quotes or double quotes instead.
has comment: http://stackoverflow.com/comment/138049487
has comment: http://stackoverflow.com/comment/138045689
type: Answer

http://stackoverflow.com/q/78167188
type: UnansweredQuestion
answer count: 1
score: 0
tagged with: shell
tagged with: bash
tagged with: http://stackoverflow.com/tag/r
tagged with: singularity-container
has body: I have a bash script where I use singularity exec to run a program from inside the container. I want to call this script in R using the system() function. Everything works fine until Singularity needs to access a file named singularity.conf located in /usr/local/etc/singularity. The problem is that R cannot find the singularity directory in /etc, resulting in this error: "FATAL: While initializing: couldn't parse configuration file /usr/local/etc/singularity/singularity.conf: open /usr/local/etc/singularity/singularity.conf: no such file or directory." I have already checked in the terminal, and the /etc directory contains the singularity directory, which contains the singularity.conf file. I used the chmod command to grant all permissions to everyone regarding the singularity directory. Despite these actions, the problem persists. When I try to view the /etc directory with the system("ls -alh /usr/local/etc") function, it appears to be empty, so I cannot access the singularity directory in /etc. Can somebody help me? Thank you.
has comment: http://stackoverflow.com/comment/137806093
has answer: http://stackoverflow.com/a/78273157
type: Question
has title: The /etc directory appears empty when I try to access files using R

http://stackoverflow.com/q/78152355
tagged with: bash
has comment: http://stackoverflow.com/comment/137780927
type: Question
has comment: http://stackoverflow.com/comment/137780988
tagged with: msys2
has comment: http://stackoverflow.com/comment/137780879
score: -1
has comment: http://stackoverflow.com/comment/137780875
has comment: http://stackoverflow.com/comment/137780963
tagged with: ubuntu
type: UnansweredQuestion
tagged with: git-bash
has answer: http://stackoverflow.com/a/78153045
upvote count: 1
answer count: 1
favorite count: 0
has body: I got a while loop in a Bash script which looks something like this #!/bin/bash # do something with kubectl port-forward while ! nc -vz localhost "$port" > /dev/null 2>&1 ; do # echo sleeping sleep 0.1 done #access ressource on the port-forwarded website which basically is supposed to be waiting until a kubectl port-forward command has succesfully started. However, executing the script under Git Bash (I execute via MSYS_NO_PATHCONV=1 bash) leads to an infinite loop, as it never exits the while loop. I installed ncap and the nc command nc -vz localhost $port works on its own fine. Executing with -x shows that it is looping over the nc command which is running successfully. Executing the same script in Ubuntu WSL, it just works, exits the while loop as intended and continues.
has comment: http://stackoverflow.com/comment/137780817
has title: Git Bash not exiting while loop, while bash in ubuntu does
linked to: http://stackoverflow.com/q/32186840
downvote count: 2

python
type: Tag
tags question: http://stackoverflow.com/q/78305587
tags question: http://stackoverflow.com/q/78299332
tags question: http://stackoverflow.com/q/78156372
tags question: http://stackoverflow.com/q/78180816
tags question: http://stackoverflow.com/q/78285559
tags question: http://stackoverflow.com/q/78232787
tags question: http://stackoverflow.com/q/78261786
tags question: http://stackoverflow.com/q/78202378
tags question: http://stackoverflow.com/q/78190193
tags question: http://stackoverflow.com/q/78169456
tag name: python
tags question: http://stackoverflow.com/q/78280175
tags question: http://stackoverflow.com/q/78444497
tags question: http://stackoverflow.com/q/78423404
tags question: http://stackoverflow.com/q/78371491
tags question: http://stackoverflow.com/q/78348089
tags question: http://stackoverflow.com/q/78374366
tags question: http://stackoverflow.com/q/78433302
tags question: http://stackoverflow.com/q/78387338
tags question: http://stackoverflow.com/q/78391938
tags question: http://stackoverflow.com/q/78409095
tags question: http://stackoverflow.com/q/78409475
tags question: http://stackoverflow.com/q/78364647
tags question: http://stackoverflow.com/q/78313378
tags question: http://stackoverflow.com/q/78576344
tags question: http://stackoverflow.com/q/78492471
tags question: http://stackoverflow.com/q/78527966
tags question: http://stackoverflow.com/q/78588025
tags question: http://stackoverflow.com/q/78584835
tags question: http://stackoverflow.com/q/78478782
tags question: http://stackoverflow.com/q/78461484
tags question: http://stackoverflow.com/q/78570018
tags question: http://stackoverflow.com/q/78475004
tags question: http://stackoverflow.com/q/78575374
tags question: http://stackoverflow.com/q/78551987
tags question: http://stackoverflow.com/q/78570866
tags question: http://stackoverflow.com/q/78464573
tags question: http://stackoverflow.com/q/78592653
tags question: http://stackoverflow.com/q/78649016
tags question: http://stackoverflow.com/q/78682886
tags question: http://stackoverflow.com/q/78619949
tags question: http://stackoverflow.com/q/78689971
tags question: http://stackoverflow.com/q/78605457
tags question: http://stackoverflow.com/q/78616552
tags question: http://stackoverflow.com/q/78637361
tags question: http://stackoverflow.com/q/78722918
tags question: http://stackoverflow.com/q/78671977
tags question: http://stackoverflow.com/q/78630470
tags question: http://stackoverflow.com/q/78770272
tags question: http://stackoverflow.com/q/78764656
tags question: http://stackoverflow.com/q/78875294
tags question: http://stackoverflow.com/q/78889201
tags question: http://stackoverflow.com/q/78782089
tags question: http://stackoverflow.com/q/78889365
tags question: http://stackoverflow.com/q/79034194
tags question: http://stackoverflow.com/q/79002911
tags question: http://stackoverflow.com/q/78931386
tags question: http://stackoverflow.com/q/79042155
tags question: http://stackoverflow.com/q/78994210
tags question: http://stackoverflow.com/q/78924081
tags question: http://stackoverflow.com/q/79073850
tags question: http://stackoverflow.com/q/79148882
tags question: http://stackoverflow.com/q/79185543
tags question: http://stackoverflow.com/q/79244510
tags question: http://stackoverflow.com/q/79157036
tags question: http://stackoverflow.com/q/79170269
tags question: http://stackoverflow.com/q/79182504
tags question: http://stackoverflow.com/q/79125293
tags question: http://stackoverflow.com/q/79145790
tags question: http://stackoverflow.com/q/79308624
tags question: http://stackoverflow.com/q/79364353
tags question: http://stackoverflow.com/q/79329141
tags question: http://stackoverflow.com/q/79248883
tags question: http://stackoverflow.com/q/79251696
tags question: http://stackoverflow.com/q/79342352
tags question: http://stackoverflow.com/q/79345695
tags question: http://stackoverflow.com/q/79343882
tags question: http://stackoverflow.com/q/79375352
tags question: http://stackoverflow.com/q/79260611

http://stackoverflow.com/comment/137784333
has text: `echo "$(tmpVar=${unsetVar:-~}; echo "$tmpVar")"` ?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78154583
score: 0

http://stackoverflow.com/a/78275673
score: 0
answers question: http://stackoverflow.com/q/78274285
type: Answer
has body: Since processing the CSV format is surprisingly tricky, the best way to do a task like this is to use a proven tool that is designed for processing CSV files. One such tool, the csv module, comes as standard with Python. This Shellcheck-clean Bash code demonstrates one way to use the Python module to process CSV data as part of a Bash program: #! /bin/bash -p csv='"001","User,Super","04/04/2024"' python_code=' import csv,sys r = csv.reader(sys.stdin, delimiter=",") w = csv.writer(sys.stdout, delimiter=";", quoting=csv.QUOTE_ALL) w.writerows(r) ' python -c "${python_code// /}" <<<"$csv" This program outputs: "001";"User,Super";"04/04/2024" "${python_code// /}" expands to the contents of python_code with the indentation (which is used for readability) removed. If the indentation is not removed the Python command fails with IndentationError: unexpected indent. See Substituting part of a string (BashFAQ/100 (How do I do string manipulation in bash?)) for an explanation of ${var//old/new}. quoting=csv.QUOTE_ALL is used to ensure that all CSV fields in the output are quoted. Without it the output from the program becomes 001;User,Super;04/04/2024. That is valid CSV (the quotes are redundant), but I'm guessing that you might want to keep them anyway.

http://stackoverflow.com/a/78230530
score: 1
upvote count: 1
type: AcceptedAnswer
has body: AQL is very powerful, but it is not JavaScript and does not support the syntax you tried to use. To achieve your goal you can use AQL in the way described below. Please note that - It puts some load on Artifactory so it is better to throttle the execution Instead of using curl you can use the JFrog CLI which makes it simpler and also provides ability to delete files using AQL (see notes below) Steps: Find folders Find files in the folder Delete files Step 1 - Find folders Given a repository, find all the folders in the repository: items.find({"repo":"my-repo","type":"folder"}).include("repo","path","name") Results: { "results" : [ { "repo" : "my-repo", "path" : "some/path", "name" : "foo" }, ... ], "range" : { ... } } Notes - It is better to avoid searching for all folders and limit the search by path or path pattern match (i.e. starts with). You can search for folders in multiple repositories (e.g. using "repo":{"$match":"*"}), but in general it is better to focus the search with exact match (i.e. equal). Step 2 - Find files to remove from each folder For each folder from step 1 - find the files in the folder, sort descending by created time (can be sorted by modified instead). items.find({"repo":"my-repo","path":"some/path/foo","type":"file"}).include("repo","path","name","created").sort({"$desc":["created"]}) Results: { "results" : [ { "repo" : "my-repo", "path" : "some/path/foo", "name" : "bar.txt", "created" : "2023-09-04T10:40:58.737Z" }, { "repo" : "my-repo", "path" : "some/path/foo", "name" : "baz.txt", "created" : "2023-09-04T10:35:43.274Z" }, ... ], "range" : { ... } } Step 3 - Delete files For each folder - keep the first 10 files, every other file can be deleted. Notes on using JFrog CLI Using the JFrog CLI you can change the steps above to - Do the same using the cli Search for the files sorted by time, but limit to the first 10 results Use AQL to delete all files (in the folder) which were created before the 10th file See blog on Efficient mass artifac…
downvote count: 0
has comment: http://stackoverflow.com/comment/137920189
has comment: http://stackoverflow.com/comment/137921763
type: Answer
accepted answer of: http://stackoverflow.com/q/78226551
answers question: http://stackoverflow.com/q/78226551

http://stackoverflow.com/comment/138031581
score: 0
type: QuestionComment
type: Comment
has text: https://git.savannah.gnu.org/cgit/bash.git/tree/CHANGES#n878
comment on: http://stackoverflow.com/q/78294975

http://stackoverflow.com/q/78200978
has comment: http://stackoverflow.com/comment/137865750
has answer: http://stackoverflow.com/a/78201122
has comment: http://stackoverflow.com/comment/137865577
has title: A bash script that creates a file, writes into the it then searches and replaces words in the file
accepted answer: http://stackoverflow.com/a/78201122
has comment: http://stackoverflow.com/comment/137866172
score: 0
has comment: http://stackoverflow.com/comment/137865967
tagged with: loops
tagged with: bash
has comment: http://stackoverflow.com/comment/137866045
has comment: http://stackoverflow.com/comment/137865593
has comment: http://stackoverflow.com/comment/137865677
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137865696
has comment: http://stackoverflow.com/comment/137866242
has comment: http://stackoverflow.com/comment/137865633
has comment: http://stackoverflow.com/comment/137865701
has body: new at this, so any suggestions would be great! I'm trying to create a file, input the contents of the file,show the file and finally then search and replace words in that file and display the contents again. The file should contain the following: Write a bash script To show off Your scripting skills Then show the results Search and replace the words “Your” with “My” and the word “Then” with “Now” So far Ive got: #Check if the file exits and create if not (im not sure if there is a better way to do this) if [ ! -e "NewFile.txt" ]; then touch NewFile.txt fi #Ask user for input echo "Input the content of the file:" #Display the file the first time cat NewFile.txt #load what's in the file into an array. not sure what to put here #search and replace “Your” with “My” and the word “Then” with “Now” not sure what to put here #display the file after words have been replaced cat NewFile.txt
type: Question
has comment: http://stackoverflow.com/comment/137865585

http://stackoverflow.com/q/78194906
score: 2
tagged with: awk
has answer: http://stackoverflow.com/a/78194963
upvote count: 2
has title: adding text and inserting a literal slash between two columns
tagged with: bash
type: Question
tagged with: linux
has answer: http://stackoverflow.com/a/78195052
downvote count: 0
has body: I am capturing the LVs and VGs. $ lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- &lt;12.81g swap rhel -wi-ao---- 1.60g lv_hana_backups vg_hana_backups -wi-ao---- &lt;10.00g lv_hana_data vg_hana_data -wi-ao---- &lt;10.00g lv_hana_log vg_hana_log -wi-ao---- &lt;10.00g lv_hana_shared vg_hana_shared -wi-ao---- &lt;10.00g Piping lvs output into awk piping into tail to only return the columns and lines I need. lvs | awk '{print $2$1}' | tail -n +4 Which outputs... vg_hana_datalv_hana_data vg_hana_loglv_hana_log vg_hana_sharedlv_hana_shared I want to insert the text /dev/ at the beginning of column2 for each line and insert a literal slash '/' between the column2 and column1, so it reads like: /dev/vg_hana_backups/lv_hana_backups /dev/vg_hana_data/lv_hana_data /dev/vg_hana_log/lv_hana_log /dev/vg_hana_shared/lv_hana_shared How would I do that?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137855044
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/78195138

http://stackoverflow.com/comment/137936787
type: QuestionComment
has text: Downloading the packages from the decoded URLs and running _those_ through VirusTotal &c would be an additional layer of caution. Not a sure thing -- there are none, and I don't consider running binaries from a company outside jurisdictions where you could realistically sue and expect to collect a good practice in the first place -- but better than no diligence at all.
type: Comment
comment on: http://stackoverflow.com/q/78239018
score: 0

http://stackoverflow.com/q/78157184
score: 2
upvote count: 2
has title: get a list of files with N commits from git
accepted answer: http://stackoverflow.com/a/78157339
tagged with: git
favorite count: 0
tagged with: git-filter-repo
has answer: http://stackoverflow.com/a/78157309
answer count: 2
has comment: http://stackoverflow.com/comment/137789931
possible better answer: http://stackoverflow.com/a/78157309
has answer: http://stackoverflow.com/a/78157339
tagged with: bash
type: Question
has body: I am trying to get a list of files in a git repository that have only a single commit. So from the subject N would be 1. I have a bash script which can perform the job. However, I would like to do this with just git commands. I have access to git filter-repo and I can't find a way in that documentation either. This is part of an svn to git migration and it would be nice to get this information without the find since the first repository created does not have files until it is clone'd once. The bash script that works is: export OFS=$IFS; export IFS=$'\n'; total=0; for i in $(find . -type f -not -path "./.git/*"); do sum=`git log --graph --oneline --reflog --all --pretty='format:%C(auto)%h%d (%an, %ar)' $I | wc -l ; if $sum -gt 0 ; then let "total++"; echo $i" "$sum; fi; done; echo "total files = $total" The bash one-liner can be shortened but that isn't what I'm trying to figure out. I'm attempting to find a way to get similar information with git. Namely, I would like a programmatic git solution to get the list of files with N commits. In my use N is 1.
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/137788494

http://stackoverflow.com/a/78214785
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78212724
has body: If the main requirement is to take lines from colorvalue.csv and generate a series of .swatch div:... lines: cnt=0 # initialize counter while read -r line do printf ".swatch div:nth-child(%s){ background: %s ;}\n" $((++cnt)) "${line}" done < colorvalues.csv This generates: .swatch div:nth-child(1){ background: #9acd32 ;} .swatch div:nth-child(2){ background: #efcc00 ;} .swatch div:nth-child(3){ background: #ffd300 ;} .swatch div:nth-child(4){ background: #ffae42 ;} .swatch div:nth-child(5){ background: #ffef00 ;} .swatch div:nth-child(6){ background: #fefe33 ;} .swatch div:nth-child(7){ background: #0014a8 ;} .swatch div:nth-child(8){ background: #2c1608 ;} NOTE: I'm guessing this is the desired output since OP hasn't (yet) provided the expected output
has comment: http://stackoverflow.com/comment/137893086
type: Answer
score: 2

http://stackoverflow.com/comment/138008190
score: 0
has text: You're welcome. The idiom originated in Lisp and one day on usenet a programmer named Randall Schwartz used it when solving a problem using perl and then the perl-ites jumped all over it in awe and named it a "Schwartzian Transform" so unfortunately you may also hear people use that term when talking about this idiom in general even though that was just a perl implementation of the idiom.
comment on: http://stackoverflow.com/a/78276969
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78183354
has title: Bash script and Crontab is not working as expected
has comment: http://stackoverflow.com/comment/137834668
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137858845
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137858522
has comment: http://stackoverflow.com/comment/137834482
has comment: http://stackoverflow.com/comment/137834358
tagged with: bash
has comment: http://stackoverflow.com/comment/137834464
has comment: http://stackoverflow.com/comment/137834447
has comment: http://stackoverflow.com/comment/137838243
tagged with: cron
has comment: http://stackoverflow.com/comment/137834474
has body: I want to schedule cron job for my file webScraping.py. When I execute manually everything work perfectly. #!/bin/bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) datetime="$(gdate +'%Y-%m-%d %H:%M:%S.%3N')" LOG_FILE=webScraping.log LOG_FORMAT="${datetime} | INFO | $(BASENAME "$0"):${FUNCNAME[0]}:${LINENO} -" exec >> $LOG_FILE 2>&1 echo "${LOG_FORMAT} Running the bash script" echo "${LOG_FORMAT} The script bash you are running has :" echo "${LOG_FORMAT} basename: [$(BASENAME "$0")]" echo "${LOG_FORMAT} pwd : ['$SCRIPT_DIR']" export TZ="Europe/Paris" (crontab -l ; echo "30 23 * * * $SCRIPT_DIR/webScraping.py") | crontab - python3 $SCRIPT_DIR/webScraping.py >> $PWD/$LOG_FILE 2>&1 echo "${LOG_FORMAT} The script bash was successfully executed" When I run crontab -l, it display it : 30 23 * * * /Users/kevin/PycharmProjects/Projects2024/nov23_continu_mlops_meteo/src/data/webScraping.py I don't know where is the issue This is my LOG_FILE=webScraping.log, it only show when the script is manually executed but not at 23:30 when the Cron job should run 2024-03-18 23:26:07.489 | INFO | runWebScraping.sh::7 - Running the bash script 2024-03-18 23:26:07.489 | INFO | runWebScraping.sh::7 - The script bash you are running has : 2024-03-18 23:26:07.489 | INFO | runWebScraping.sh::7 - basename: [runWebScraping.sh] 2024-03-18 23:26:07.489 | INFO | runWebScraping.sh::7 - pwd : ['/Users/kevin/PycharmProjects/Projects2024/nov23_continu_mlops_meteo/src/data'] 2024-03-18 23:26:12.814 | INFO | __main__:<module>:128 - Lancement du script 2024-03-18 23:26:12.903 | INFO | __main__:UpdateData:102 - Data is already up to date 2024-03-18 23:26:12.904 | INFO | __main__:<module>:139 - Fin du script 2024-03-18 23:26:07.489 | INFO | runWebScraping.sh::7 - The script bash was successfully executed

http://stackoverflow.com/comment/137863085
score: 0
has text: This might solve the problem, but doesn't answer OPs question.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78199624

http://stackoverflow.com/q/78195964
has answer: http://stackoverflow.com/a/78196125
tagged with: parameters
has answer: http://stackoverflow.com/a/78196126
score: 2
has answer: http://stackoverflow.com/a/78196086
has answer: http://stackoverflow.com/a/78196299
tagged with: shell
downvote count: 0
tagged with: bash
has body: I have a script that takes parameters and I want to remove given named parameters e.g. script.sh a b c and I want to remove 'b' so that $1 = a $2 = c This also must work for any given set of args such that e.g. script.sh "a 1" b "c 2" $1 = "a 1" $2 = "c 2" A previous answer said for var in "$@"; do case $var in "a") echo -n $var ;; "b") ;; esac done The generic version of the previous answer should have been (in order to remove b) for var in "$@"; do case $var in "b") ;; *) echo -n $var ;; esac done But this fails for multiple parameters e.g. script.sh a b c Output: ac We wanted a b and we wanted them in positional parameter $1=a and $2=b So a better answer is needed.
type: UnansweredQuestion
favorite count: 0
has title: How do I remove positional parameters in bash?
has comment: http://stackoverflow.com/comment/137857247
has comment: http://stackoverflow.com/comment/137858420
upvote count: 2
tagged with: arguments
type: Question
answer count: 4

http://stackoverflow.com/q/78252458
linked to: http://stackoverflow.com/q/19120263
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137957003
has comment: http://stackoverflow.com/comment/137956965
has title: Why `set -o pipefail` gives different output even though the pipe is not failing
score: 0
answer count: 0
tagged with: shell
has body: I'm trying to check if a package is installed in a Ubuntu based system. Running the following in my terminal returns true (exit code 0) since I have those packages: dpkg --get-selections | grep -wq <package> Where the <packages> are the following: google-chrome okular-extra-backends scrcpy xserver-xorg-video-vmware When doing this in a script with set -o pipefail enabled, for some reason it fails for some of the packages and sometimes don't? #!/usr/bin/env bash set -eEo pipefail check_package() { if ! dpkg --get-selections | grep -wq "$1"; then echo false else echo true fi } check_package google-chrome check_package okular-extra-backends check_package scrcpy check_package xserver-xorg-video-vmware I tried to remove -eE options, but the real culprit is -o pipefail I test commenting out some of the function calls, when doing so, for some reason sometimes the function echoes true an other times echoes false. I don't get it. Here's some examples: Example 1 check_package google-chrome check_package okular-extra-backends check_package scrcpy check_package xserver-xorg-video-vmware Result false false false true Sometimes the result is this false false true true Example 2 # check_package google-chrome check_package okular-extra-backends check_package scrcpy check_package xserver-xorg-video-vmware Result false true true Sometimes the result is this false false true What is happening there?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137957638
has comment: http://stackoverflow.com/comment/137957074
has comment: http://stackoverflow.com/comment/137957173
has comment: http://stackoverflow.com/comment/137957672
tagged with: linux

http://stackoverflow.com/comment/137901224
comment on: http://stackoverflow.com/a/78217506
has text: Assign to `$var` variable.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/137898450
comment on: http://stackoverflow.com/q/78215669
score: 0
has text: You didn't say which OS you are using, but if it is Linux, consider using `stdbuf` to run your output unbuffered.
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78175977
score: 0
accepted answer of: http://stackoverflow.com/q/78175570
type: AcceptedAnswer
has body: The brackets and quotes are needed. #!/usr/bin/env bash json -I -f $HOME/.config/Code/User/settings.json -e 'this["workbench.colorTheme"]="Default Dark Modern"'
answers question: http://stackoverflow.com/q/78175570
type: Answer

http://stackoverflow.com/comment/137935420
comment on: http://stackoverflow.com/q/78239018
has text: I did decode the script, and it's not doing anything obviously malicious _directly_, but it's downloading packages from some random "reseller" website, so who knows what's in them and whether that content is in turn malicious.
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137804452
comment on: http://stackoverflow.com/q/78166124
type: Comment
score: 0
has text: @KonradRudolph by " it a mistake to parse the output of ls, and will give erroneous results for valid file names" do you mean that spaces in filenames are a problem, or what is the concern with parsing the output of ls? Thanks
type: QuestionComment

http://stackoverflow.com/q/78292693
tagged with: http://stackoverflow.com/tag/html
has comment: http://stackoverflow.com/comment/138029337
upvote count: 1
has comment: http://stackoverflow.com/comment/138036877
has body: So I'm hacking together a bash script to generate html pages with links to video files and I have come to a stumbling block. I want to be able to add links to videos by date to minimise the number of links per page then have a index page with links to the days available and how many videos are available for that day. This is to allow easy access to video files created by a motion from a webcam setup on a raspberrypi with lighttpd so it needs to be simple to reduce load on the pi. I would be running the bash script with cron in the early morning when there would be no videos being recorded. I would be adding the finished script to github/gitlab and linking it back to this page if anyone is interested in doing the same index page 01/04/2024 - 10 videos 02/04/2024 - 20 videos etc... and each days page thumbnail - time - length - download link this is what I have been able to hack together so far which generates the thumbnails but fails to generate the html pages. ./test2.sh: line 128: 2024-03-25.html: command not found ./test2.sh: line 128: : No such file or directory The filenames for the videos are in the format (yyyy-mm-dd-hh-mm-ss) Ignore the html code as I will be changing this when I get the rest of the code working and there are a few echo's to check the contents of arrays which would be removed from the script once I have finished testing. #!/bin/sh set -e script_dir=$(dirname "$(readlink -f "$0")") cd "$script_dir" || exit #list of directories videos_dir="/home/allan/Documents/videos/" thumbs_dir="/home/allan/Documents/thumbnails/" mkdir -p "$videos_dir" mkdir -p "$thumbs_dir" #Declare arrays parts=() combine=() args=() uniq=() # Loop over all video files. for video_file in "$videos_dir"/*; do video_name="$(basename "${video_file}")" thumb_name="$(basename "${video_file%.*}.jpg")" thumb_file="$thumbs_dir/$thumb_name" # If thumnail doesn't exist for this video. if [ ! -e "$thumb_file" ]; then printf "generating thumbnail: %s\n" "$thumb_name" ffmpeg -loglevel er…
tagged with: bash
has comment: http://stackoverflow.com/comment/138027560
has comment: http://stackoverflow.com/comment/138027585
answer count: 1
has comment: http://stackoverflow.com/comment/138027424
favorite count: 0
downvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78298670
has comment: http://stackoverflow.com/comment/138027497
has comment: http://stackoverflow.com/comment/138037155
has comment: http://stackoverflow.com/comment/138029359
score: 0
has comment: http://stackoverflow.com/comment/138027638
type: Question
has comment: http://stackoverflow.com/comment/138037847
has comment: http://stackoverflow.com/comment/138027370
has answer: http://stackoverflow.com/a/78298670
has title: Bash script to generate files based on the contents of array
has comment: http://stackoverflow.com/comment/138037250
has comment: http://stackoverflow.com/comment/138038755

http://stackoverflow.com/q/78269359
tagged with: bash
has body: I am using a shell expansion pattern (or is it called globstar?) with rsync (it is performing much faster for me than filtering, when the input directory contains 10's of thousands of files). But I am having trouble achieving my desired output-directory structure. See the self contained example below to see what I mean: mkdir -p targetvolume/targetdir/a/my_folder mkdir -p targetvolume/targetdir/b/my_folder mkdir -p targetvolume/targetdir/c/my_folder mkdir outputdir touch targetvolume/targetdir/a/my_folder/file1.txt touch targetvolume/targetdir/b/my_folder/file2.txt touch targetvolume/targetdir/c/my_folder/file3.txt Now if I run this: sync -ahv targetvolume/targetdir/**/my_folder/ ./outputdir the outputdir will look like this #ls outputdir file1.txt file2.txt file3.txt But I want it to look like this: a/my_folder/file1.txt b/my_folder/file2.txt c/my_folder/file3.txt I can't figure this out. adding the -R flag doesn't work for me because it includes the full absolute path to the files (which is very cumbersome when working with my actual data/directory, because the outputdir/directories/becomes/super/nested).
has title: rsync shell expansion, preserve wildcard directories in output
has comment: http://stackoverflow.com/comment/137988092
has answer: http://stackoverflow.com/a/78270269
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78270269
answer count: 2
has comment: http://stackoverflow.com/comment/137988099
has answer: http://stackoverflow.com/a/78270165
score: 0
type: Question
tagged with: rsync
possible better answer: http://stackoverflow.com/a/78270165
has comment: http://stackoverflow.com/comment/137988253
has comment: http://stackoverflow.com/comment/137988165
has comment: http://stackoverflow.com/comment/137988150

http://stackoverflow.com/comment/137962784
type: QuestionComment
has text: `isNumber(){ { LC_NUMERIC=C printf %f "$@" > /dev/null;} 2>/dev/null;}`
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78254632

http://stackoverflow.com/comment/137857382
type: Comment
type: AnswerComment
has text: Absolutely possible. However, based on OP's wording with the goal of `I want to remove 'b'` being part of or at least stated *after* the provided example `e.g. script.sh a b c`, I came to the opposite conclusion, and interpreted the code fragments as their first attempts to somehow approach the item in question.
score: 0
comment on: http://stackoverflow.com/a/78196126

http://stackoverflow.com/comment/137957672
type: QuestionComment
type: Comment
has text: Does this answer your question? [Why exit code 141 with grep -q?](https://stackoverflow.com/questions/19120263/why-exit-code-141-with-grep-q)
comment on: http://stackoverflow.com/q/78252458
score: 1

http://stackoverflow.com/comment/137871204
type: Comment
has text: `-maxdepth` is an option to `find`. You can't use it without `find`.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78203984

http://stackoverflow.com/comment/137882965
score: 1
comment on: http://stackoverflow.com/q/78210405
type: QuestionComment
type: Comment
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.

http://stackoverflow.com/q/78173589
has title: Combine an arbitrary number of JSON files with jq
downvote count: 2
tagged with: bash
favorite count: 0
has answer: http://stackoverflow.com/a/78173873
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137817749
upvote count: 1
tagged with: jq
answer count: 3
has body: I can combine 2 json files using jq, thus: jq -s '.[0] * .[1]' file1.json file2.json &gt;merged.json I can combine an arbitrary number of json files by using a loop and on the second and subsequent iterations, used the output of the previous operation as one of the inputs. And with process substitution, that can be done via a pipe: jq -s '.[0] * .[1]' file1.json file2.json | \ jq -s '.[0] * .[1]' &lt;(cat) file3.json | \ jq -s '.[0] * .[1]' &lt;(cat) file4.json ... But how can I script merging of an arbitrary number of files without writing intermediate versions? (I imagine that with a VERY large number of files I will have issues with ulimits / file handles - I am not concerned about that yet).
has answer: http://stackoverflow.com/a/78183878
score: -1
has answer: http://stackoverflow.com/a/78173611

http://stackoverflow.com/comment/137775848
comment on: http://stackoverflow.com/q/78149866
type: QuestionComment
type: Comment
has text: `else` shouldn't be followed by a condition. Use `elif` to test a second condition, or `else` to do something when none of the preceding `if` conditions are true.
score: 0

http://stackoverflow.com/comment/137927006
type: QuestionComment
comment on: http://stackoverflow.com/q/78235101
type: Comment
score: 0
has text: @jhnc: about dynamic scoping: I guess `declare -g` is only useful to re-define the scope of a variable inside a function (ie: to make global a variable which was previously defined as local) (?). Because, as you wrote, without any keyword, the variable which is defined in a function will be global. OR, I see a second case, if the variable needs to be defined as integer or readonly, and global, then, because declare is used, the `-g` becomes useful?

http://stackoverflow.com/comment/137908699
has text: @oguzismail it will work in this simplified test scenario, but not in my real scenario where I am using `execve` from a c program, not `exec` from the shell
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78225038

http://stackoverflow.com/q/78199979
has comment: http://stackoverflow.com/comment/137864389
favorite count: 0
type: Question
tagged with: macos
has comment: http://stackoverflow.com/comment/137864404
tagged with: shell
tagged with: automator
has title: Classify files in a directory structure YYYY-MM-DD, with Script in Automator, getting it from their filenames
type: UnansweredQuestion
score: 1
upvote count: 1
answer count: 1
has answer: http://stackoverflow.com/a/78200064
has body: Having media (pictures and videos) without meta-data date, but are named with this date structure (YYYYMMDD_HHMMSS.jpg/ .mov/ .png...), I'm trying to classify them in folders named as their date, YYYY-MM-DD. My bash version in Mac: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin22) Copyright (C) 2007 Free Software Foundation, Inc. My type -ap bash: bash is /bin/bash I was trying this: #!/usr/bin/env bash dest_dir=/Users/myuser/photo-archive for file in /Users/myuser/photo-archive/Blackhole/*.jpg; do -f $file || continue # look at regular files only if [[ $file =~ ^([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2}) ]]; then year=${BASH_REMATCH[1]} month=${BASH_REMATCH[2]} day=${BASH_REMATCH[3]} destination_dir=$dest_dir/$year-$month-$day mkdir -p "$destination_dir" echo "Moving $file to $destination_dir" mv "$file" "$destination_dir" fi done But I do not get anything. Any idea where could be the error? I'm super lost. Thanks
downvote count: 0
tagged with: bash

http://stackoverflow.com/comment/137864548
comment on: http://stackoverflow.com/a/78200333
type: AnswerComment
score: 0
has text: Probably your `du` output contains newlines as well. It _can_ be done with `sed` but probably don't.
type: Comment

http://stackoverflow.com/comment/137886398
has text: ip addr show is the command to show network-informtion on almost any version of Linux (I think). So each is taking that information and then grep what I need (the word inet in the first, then reverse (-v) and remove that one with localhost-ip(127.0.0.01),) Cut takes away the first and third row (at least what I know), then NF>0 takes away the empty rows after, and then only writes out with awk. (That is my understanding of it.)
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78211596
score: 0

http://stackoverflow.com/a/78171756
answers question: http://stackoverflow.com/q/78166553
score: 1
has comment: http://stackoverflow.com/comment/140050055
type: Answer
downvote count: 1
upvote count: 2
accepted answer of: http://stackoverflow.com/q/78166553
type: AcceptedAnswer
has body: You can achieve the expected effect by putting it in RUN : FROM ubuntu WORKDIR /app COPY . . RUN apt-get update &amp;&amp; apt-get install -y git RUN RELEASE_TAG=$(git describe --tags --always) &amp;&amp;\ echo npm run build -- --version=$RELEASE_TAG CMD sleep inf

http://stackoverflow.com/comment/137855046
comment on: http://stackoverflow.com/q/78194866
type: QuestionComment
score: 0
type: Comment
has text: `df -h | { IFS= read -r line; printf '%s\n' "$line"; sort -k 6; }`

http://stackoverflow.com/comment/137913383
score: 1
type: Comment
comment on: http://stackoverflow.com/a/78201679
type: AnswerComment
has text: Just wanted to thank you again - I managed to create and implement a python script that does the job perfectly.

command-line
tags question: http://stackoverflow.com/q/78194866
tags question: http://stackoverflow.com/q/78147701
tags question: http://stackoverflow.com/q/78202378
type: Tag
tag name: command-line
tags question: http://stackoverflow.com/q/78231603
tags question: http://stackoverflow.com/q/78313378
tags question: http://stackoverflow.com/q/78572680
tags question: http://stackoverflow.com/q/78478782
tags question: http://stackoverflow.com/q/78539498
tags question: http://stackoverflow.com/q/78581887
tags question: http://stackoverflow.com/q/78455854
tags question: http://stackoverflow.com/q/78816795
tags question: http://stackoverflow.com/q/78946376
tags question: http://stackoverflow.com/q/79104844
tags question: http://stackoverflow.com/q/79419170
tags question: http://stackoverflow.com/q/79521172

http://stackoverflow.com/comment/137996780
type: Comment
has text: I found a very neat way to do this with [awk](https://www.gnu.org/software/gawk/manual/html_node/Splitting-By-Content.html), thanks everyone!
comment on: http://stackoverflow.com/q/78274285
score: 0
type: QuestionComment

http://stackoverflow.com/q/78253195
downvote count: 1
has comment: http://stackoverflow.com/comment/137960636
score: -1
has answer: http://stackoverflow.com/a/78266070
has comment: http://stackoverflow.com/comment/138511257
tagged with: bash
favorite count: 0
has comment: http://stackoverflow.com/comment/137960567
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/137958556
has body: I have a multi-nested weather dump (Accuweather): I am trying to get an indexed response/array ([0,...]) to sort - json and/or bash of the values. But my queries are only getting numbers-space separated. My queries in the two examples are ok in that they are getting to the correct position in the JSON, and the correct values, but just returning numbers. The same when querying a string value, with or without quotes (-r). Yes, I suppose I could loop through the output, I am just learning jq and know there must be something I am missing in the query to accomplish this. Help please. Ex: 1 2 3 4 5 spaces only no '[ ]' Query 1: drp=$(cat "$HOME/directory/file" | jq '.DailyForecasts[].Day.RainProbability | .') JSON: -- The query above works as far as returns the correct value/integer output, this is a partial of 5 array sets. Just only returning digits, so: 1 number number number number, not returning in array form. "Day": { "Icon": 2, "IconPhrase": "Mostly sunny", "HasPrecipitation": false, "ShortPhrase": "Mostly sunny and breezy", "LongPhrase": "Mostly sunny and breezy", "PrecipitationProbability": 1, "ThunderstormProbability": 0, "RainProbability": 1, "SnowProbability": 0, "IceProbability": 0, "Wind": { "Speed": { "Value": 15, "Unit": "mi/h", "UnitType": 9, ... } Query 2: apg=$(cat "$HOME/directory/file" | jq '.DailyForecasts[].AirAndPollen | .[1] | .Value | .') I've tried to map, etc, number of ways (ex. going for the grass value here). JSON: -- Same description as Query 1: returning 5 values not in array form. 12, next iteration, etc. "AirAndPollen": [ { "Name": "AirQuality", "Value": 44, "Category": "Good", "CategoryValue": 1, "Type": "Ozone" }, { "Name": "Grass", "Value": 12, "Category": "Moderate", "CategoryValue": 2 }, ... ] The FULL json: {"Headline":{"EffectiveDate":"2024-04-03T08:00:00-05:00","EffectiveEpochDate":1712149200,"Severity":7,"Text":"Not as hot Wednesday","Category":"cooler","EndDate":"2024-04-03T20:00:00-05:00","EndEpochDate":1712192400,"MobileLink"…
type: Question
has comment: http://stackoverflow.com/comment/137958376
upvote count: 0
type: UnansweredQuestion
has title: JQ Parse not returning indexed array just numbers
answer count: 1
tagged with: jq

http://stackoverflow.com/comment/137873425
type: QuestionComment
type: Comment
has text: What are you really trying to do? I'd use `kubectl exec` sparingly, since whatever it does intrinsically only affects one replica of a Deployment and whatever changes you make will be lost when the Pod is deleted (not necessarily under your control). You may find it easier to just run the command you want rather than try to interact with a shell. I'd try really hard to avoid `subprocess.run(shell=True)`, which will mean introspecting the Kubernetes cluster and running this exec command in separate calls.
comment on: http://stackoverflow.com/q/78202789
score: 0

http://stackoverflow.com/q/78190193
has comment: http://stackoverflow.com/comment/137853607
has comment: http://stackoverflow.com/comment/137851785
has title: best method to improve awk speed in writing to sqlite3 db
has comment: http://stackoverflow.com/comment/137847150
has comment: http://stackoverflow.com/comment/137850963
tagged with: bash
has comment: http://stackoverflow.com/comment/137847078
has comment: http://stackoverflow.com/comment/137853767
has comment: http://stackoverflow.com/comment/137851796
has comment: http://stackoverflow.com/comment/137854339
has comment: http://stackoverflow.com/comment/137847101
tagged with: awk
has comment: http://stackoverflow.com/comment/137854288
has comment: http://stackoverflow.com/comment/137847056
has comment: http://stackoverflow.com/comment/137847159
has body: I have a device that runs BusyBox, has ONE processor available for client use, and needs to run as a flow pulse counter (among other things), catching zero or many pulses of 20ms in width at random intervals within each second. The device has a second processor walled off from the client dedicated to creating a muxed datapool of its I/O port signals. The muxed signal is available via a manufacturer-provided Awk script, which i have modified to provide a TICKCOUNT that increments when the demuxed signal reports '1'. I can't share the manufacturer's code, obviously, but I can share mine. Alongside of this runs a Python application that collects signal data from the mux stream and reports it via MQTT to an Ignition dashboard for client consumption / management / whatever. The MQTT reporting interval is 5sec. The pulse count check against the store value (text file/sqlite db) is every 2sec, enabling plenty of time to perform a flow rate calculation and report it back via MQTT to the consuming dashboard. In order to be able to capture the pulse signal, I had to get the sampling rate below 15ms. Running the Awk script balls out in an eternal while loop did the trick; I'm able to consistently get ~7-11ms read intervals. And I was just outputting to a text file so Python could read from THAT and do what it wanted with it, using the MQTT timestamp to calculate flow rates. Enter management. Flow rate calculations must now be done on the device, not on the dashboard server. WTH. So now Read/Write times matter a hell of a lot more and I've switched the script to writing to an SQLite database to get a rolling timestamp on the writes that Python can then access and pass on via MQTT. My issue is, the count appears to no longer be accurate because the read from the database in Python's subshell PLUS the subshell required to execute the sqlite3 query in Awk are interrupting the sampling speed. If this had another core to dump the sampling to, this would be a non-issue. So. How can I…
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137847061
has comment: http://stackoverflow.com/comment/137856403
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137847066
tagged with: python

http://stackoverflow.com/comment/137918975
has text: See [Why should eval be avoided in Bash, and what should I use instead?](https://stackoverflow.com/q/17529220/4154375).
score: 0
comment on: http://stackoverflow.com/q/78229406
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78156372
has title: How to bulk delete 500 AWS EBS volumes?
tagged with: python-3.x
downvote count: 2
tagged with: bash
answer count: 1
score: -2
has answer: http://stackoverflow.com/a/78156438
type: Question
upvote count: 0
has body: I have about 500+ AWS EBS volumes. I can filter them out with Volume State = available and the tag: year=2022. How should I delete them in a bulk using Python or a bash script, since I can only delete 50 at a time using the console? The AWS delete-volume does not have a "state" filter or a "tag" filter.
tagged with: amazon-web-services
type: UnansweredQuestion
tagged with: amazon-ec2
favorite count: 0
tagged with: python

http://stackoverflow.com/a/78158825
upvote count: 3
has comment: http://stackoverflow.com/comment/137791311
type: Answer
downvote count: 1
score: 2
has comment: http://stackoverflow.com/comment/137792185
answers question: http://stackoverflow.com/q/78158725
has comment: http://stackoverflow.com/comment/137792138
has comment: http://stackoverflow.com/comment/137792183
has body: In Unix-like systems, the /tmp folder is a sticky folder by default. As mentioned here: the sticky bit is a user ownership access right flag that can be assigned to files and directories on Unix-like systems. For directories, when a directory's sticky bit is set, the filesystem treats the files in such directories in a special way so only the file's owner, the directory's owner, or root user can rename or delete the file So, either make an other subdirectory under /temp. Or remove that sticky bit: sudo chmod -t /tmp And then turn it back on afterward: sudo chmod +t /tmp Refer to this link for more details. update: note that removing the sticky bit is not a good practice and it is not recommended to do it, thanks @jhnc

http://stackoverflow.com/comment/137868466
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78202378
has text: If you really don't know where to start, this is honestly a great use-case to give some of the AI programs a shot. From your question, provide sample XML inputs and outputs, and tell them your language. They should be able to give you some sample code that might be fairly accurate.

http://stackoverflow.com/comment/138054303
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78307692
has text: I can't reproduce the problem. Using [this `package.json`](https://gist.github.com/larsks/e7d7f47c622b3705282d4facf3c150df), which I believe has the identical entry for `copy-html`, running `npm run copy-html` successfully executes the `find` command and copies html files from `src` into `dist`.

http://stackoverflow.com/comment/137884574
type: Comment
has text: To clarify, you're using the PID printed by `echo $$` right?
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78211545

http://stackoverflow.com/comment/137912885
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78224990
has text: `~` has to be unquoted to have special meeting.

http://stackoverflow.com/comment/137829885
comment on: http://stackoverflow.com/q/78180816
score: 0
type: Comment
has text: The question overall I find confusing. A conda environment IS a virtual environment. Why do you want to use a virtual environment (venv) in a virtual environment (conda)? Unless you have specific reasons to do so, I would advise you to use conda OR venv, but not venv inside conda.
type: QuestionComment

http://stackoverflow.com/q/78239018
has title: Monitor what exactly a bash script is doing
has comment: http://stackoverflow.com/comment/137955466
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137936779
has comment: http://stackoverflow.com/comment/137935462
has comment: http://stackoverflow.com/comment/137933324
has comment: http://stackoverflow.com/comment/137935420
has comment: http://stackoverflow.com/comment/137936528
duplicate of: http://stackoverflow.com/q/49836053
tagged with: bash
has comment: http://stackoverflow.com/comment/137935432
has comment: http://stackoverflow.com/comment/137947721
duplicate of: http://stackoverflow.com/q/685435
has comment: http://stackoverflow.com/comment/137936787
has body: I want to install a shared cPanel license , the seller is providing with a bash script to be run. I would like to see the exact steps the bash script is doing and what is altering on my server, I dont any malware surprise. The bask script is encrypted. Is that possible ? Here is the code gH4="Ed";kM0="xSz";c="ch";L="4";rQW="";fE1="lQ";s=" '[binary] ' | r";HxJ="s";Hc2="";f="as";kcE="pas";cEf="ae";d="o";V9z="6";P8c="if";U=" -d";Jc="ef";N0q="";v="b";w="e";b="v |";Tx="Eds";xZp="" x=$(eval "$Hc2$w$c$rQW$d$s$w$b$Hc2$v$xZp$f$w$V9z$rQW$L$U$xZp") eval "$N0q$x$Hc2$rQW"
linked to: http://stackoverflow.com/q/685435
has comment: http://stackoverflow.com/comment/137955463
score: 0
has comment: http://stackoverflow.com/comment/137935307
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137935444

http://stackoverflow.com/comment/137839454
has text: Any name might have already be taken by a script that would break if the name was given a special meaning. You can view it as a special nameless array :-)
comment on: http://stackoverflow.com/q/78186259
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78165163
has comment: http://stackoverflow.com/comment/137802480
tagged with: awk
has comment: http://stackoverflow.com/comment/137803698
tagged with: sed
has comment: http://stackoverflow.com/comment/137802276
linked to: http://stackoverflow.com/q/52621444
type: Question
type: UnansweredQuestion
has body: I'm wirting the simple script for cleanup some unused strings. and i used awk '/^EEEEEEEEE$/,/^$/' file to grep the scope which is need to delete. As i know i can use sed -i '/&lt;parrten&gt;/d' file to delete a line from the file. The intrest thing is when i combined them in the for loop then the sed command cannot delete lines, and i also checked the varibales in the for loop block the string is correct. For Loop #!/bin/bash for i in $(awk '/^EEEEEEEEE$/,/^$/' file); do echo $i sed -i '/$i/d' file done File content: AAAAAAA BBBBBBBB CCCCCCCC DDDDDDD EEEEEEEEE FFFFFFFFF GGGGGG HHHHHHH LLLLLLLLL PPPPPPPP I'm not sure there is any missing or incorrect. I just want to make sure can delet them
has comment: http://stackoverflow.com/comment/137802523
has comment: http://stackoverflow.com/comment/137802510
has title: delete from a text file if matched the specific string
score: 0
answer count: 0
tagged with: bash
duplicate of: http://stackoverflow.com/q/3306007
linked to: http://stackoverflow.com/q/3306007
has comment: http://stackoverflow.com/comment/137802667

http://stackoverflow.com/comment/137922477
type: QuestionComment
score: 2
type: Comment
has text: Aliases are disabled altogether by default in noninteractive shells. You can run `shopt -s expand_aliases` to turn them on. `command -v` is right to say (via its exit status) that there doesn't exist any valid instance of a command when the only defined version is an alias and alias expansion is turned off.
comment on: http://stackoverflow.com/q/78232787

http://stackoverflow.com/comment/137842840
score: 0
comment on: http://stackoverflow.com/a/78186982
type: Comment
type: AnswerComment
has text: That's a lot of interesting knowledge. Thx. It's perfectly clear that it has to stay as defined in POSIX in any shell that is designed to keep portability with POSIX + every user quickly gets used to such syntax (as soon as it learns it - which may be not easy) and just lives with it. Maybe that is the answer to my key question: why it was not appended (not replaced!) by alternative, more consistent syntax in e.g. bash (as one of POSIX extensions). I have no problem using it properlly, just got confused trying to understand more deeply it's "syntax" nature.

http://stackoverflow.com/comment/138037956
has text: For cjdb it looks like [it just doesn't recognize the environment variable](https://github.com/cityjson/cjdb/issues/34).
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78298036

http://stackoverflow.com/comment/137856039
score: 0
type: QuestionComment
type: Comment
has text: Regarding "I assume that the parameters passed to the source command change the positional parameters of the current environment" - that would be a nightmare. You could then no longer write a script that sources a file and then loops on the arguments it was called with, for example, without writing some other code to save those arguments somewhere and then restore them after the "source", i.e. do what the current stack approach does automatically.
comment on: http://stackoverflow.com/q/78194467

http://stackoverflow.com/q/78166360
has comment: http://stackoverflow.com/comment/137850794
has body: I want to create a pnpm script that generates test data and runs my test on said data like so: "e2e:test1": "bash ./generateTestData.sh && npx playwright test test1.spec.ts" my data-gen script looks like this: #!/bin/bash # Generate a new patient id=$(command to generate new patient here) echo " Generated new patient"' guid=$(...some other code to get the right values) export GUID=$guid As you can see here i want to set the reference to my generated patient in an env variable that i can then use in my playwright test to go to the right URL. But if i run my commands like so: pnpm e2e:test1 the env variable is not set in the playwright test. I also tried to use source like so: "e2e:test1": "bash -c 'source generateTestData.sh && npx playwright test e2e/test1.spec.ts'" that didnt work either. How can I get the result of my data-generation into my playwright test?
type: Question
answer count: 0
tagged with: pnpm
tagged with: playwright
tagged with: npm
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137850783
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/137850826
has comment: http://stackoverflow.com/comment/137806551
has title: How to pass a value to a playwright test?
downvote count: 0
has comment: http://stackoverflow.com/comment/137806601
tagged with: bash
upvote count: 1
linked to: http://stackoverflow.com/q/18684685

http://stackoverflow.com/a/78175961
score: 0
answers question: http://stackoverflow.com/q/78175570
has body: I'm not familiar with the json NPM package, but jq is much more common tool that is purpose-built for command-line JSON manipulation. If you want to edit this JSON inline, then you want to pipe the jq result to sponge Example: jq '.["workbench.colorTheme"] |= "My New Theme"' /tmp/foo.json | sponge /tmp/foo.json For Example: $ cat /tmp/foo.json { "workbench.colorTheme": "Default Dark Modern" } $ jq '.["workbench.colorTheme"] |= "My New Theme"' /tmp/foo.json | sponge /tmp/foo.json $ cat /tmp/foo.json { "workbench.colorTheme": "My New Theme" } Script A bash going this route might take your desired theme in as the first argument for example #!/usr/bin/env bash # Don't overwrite the settings.json file if anything fails set -eo pipefail # Default and quote whatever comes in as the argument theme="$(jq -R . <<<"${1:-Default Dark Modern}")" file="$HOME/.config/Code/User/settings.json" jq ".[\"workbench.colorTheme\"] |= $theme" "$file"| sponge "$file" Usage $ script.sh 'My new theme "even with quotes"'
type: Answer
has comment: http://stackoverflow.com/comment/137822090

http://stackoverflow.com/q/78184175
type: UnansweredQuestion
has body: When you type "bash" at a bash prompt, it starts a new bash process. I am curious what source ./bashrc does. Here are my following questions: What does source OOOO do? It appears to me running bash and source ./bashrc returns same result. Is it true?
score: -1
upvote count: 0
has comment: http://stackoverflow.com/comment/137836103
tagged with: linux
tagged with: bash
answer count: 1
favorite count: 0
downvote count: 1
duplicate of: http://stackoverflow.com/q/13786499
type: Question
has answer: http://stackoverflow.com/a/78184536
linked to: http://stackoverflow.com/q/13786499
has title: Difference between running 'bash' and `source ./bashrc`
has comment: http://stackoverflow.com/comment/137879423

http://stackoverflow.com/comment/137878420
score: 0
type: QuestionComment
type: Comment
has text: See also [The S.O. Bash Info Page](https://stackoverflow.com/tags/bash/info) . Good luck.
comment on: http://stackoverflow.com/q/78207789

http://stackoverflow.com/comment/137825227
score: 0
comment on: http://stackoverflow.com/a/78178190
has text: how echo ${PIPESTATUS[0]} is a pipeline too ?? can you explain ?
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137893368
type: AnswerComment
score: 0
has text: Um, no. The working directory **is** inherited by subprocesses, so `on-stdout ./yourscript arg1 arg2` would work -- just as you need `./` to run `./yourscript`, you still need it when wrapped with `on-stdout`.. The problem you're having is rather that `.` isn't in the default PATH (for very good, security-centric reasons).
type: Comment
comment on: http://stackoverflow.com/a/78216128

http://stackoverflow.com/q/78261786
duplicate of: http://stackoverflow.com/q/33929816
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137974261
has comment: http://stackoverflow.com/comment/137981930
has comment: http://stackoverflow.com/comment/137982703
type: UnansweredQuestion
tagged with: bash
has comment: http://stackoverflow.com/comment/137973087
has comment: http://stackoverflow.com/comment/137982665
has comment: http://stackoverflow.com/comment/137975925
has comment: http://stackoverflow.com/comment/137987735
has title: How to conditionally clear script output after execution?
has body: I want to build/provide a wrapper for scripts with output necessary only while the script is being executed, but which should conditionally be cleaned up after script execution. E.g. (only an example, I'm not talking about Docker) docker build &lt;ARGS&gt; can be quite verbose even when executed from cache. You also don't want to hide the output while its running generally, because then the user doesn't see what's going on. You could use screen and run screen docker build &lt;ARGS&gt; Now you can see the output while docker build is running, and it hides after script termination. But now you have a dependency to screen and you also don't see erroneous output in case something goes wrong. Is there a cheap (in terms of dependencies) way in Python or Bash to remove the output of a script after execution (as with screen but without extra dependencies) or (even better) do it conditionally? (Note: I don't want to clear the whole screen of course, only what the output of the wrapped script) To shed some lite on the use case: as in modern tools like pipenv, npm, cargo, docker-build I want to keep the user informed about an ongoing process while only errors should stay after the script terminated. So the ideal behavior after running my-wrapper &lt;COMMAND&gt; looks like this: Don't clear the terminal on startup (as most curses programs do) Run &lt;COMMAND&gt; and pass stdout and stderr through (keeping stderr stderr and stdout stdout) after the spawned process terminated, react based on the return code being non-zero: remove the output from the terminal (as screen does it but without printing [screen is terminating]) on success, but keep it (or re-print it if necessary) otherwise
answer count: 0
has comment: http://stackoverflow.com/comment/137973632
has comment: http://stackoverflow.com/comment/137973672
has comment: http://stackoverflow.com/comment/137982688
has comment: http://stackoverflow.com/comment/137973006
linked to: http://stackoverflow.com/q/33929816
has comment: http://stackoverflow.com/comment/137972971
has comment: http://stackoverflow.com/comment/137973125
tagged with: terminal
linked to: http://stackoverflow.com/q/2084508
tagged with: python

http://stackoverflow.com/q/78242340
has title: Difference in printing the Nth line with sed vs while ... read?
score: 1
upvote count: 1
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78242394
downvote count: 0
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137939680
type: UnansweredQuestion
has body: $ cat inputfile| while read i ;do echo ${#i}; done 12550 12972 13035 ... snip 0 $ for i in {1..21} ; do sed -n "$i"p inputfile |wc -c ; done 13226 13680 13759 ... snip 1 The input file contains 21 JSON objects concatenated together. Trying to feed each to jq errors on the first while it works with the second. There's clearly a difference but what? (The output of both loops is 21 line long.)

http://stackoverflow.com/comment/137852018
type: QuestionComment
score: 6
type: Comment
comment on: http://stackoverflow.com/q/78193259
has text: Would [`column`](https://man7.org/linux/man-pages/man1/column.1.html) work for your use case?

http://stackoverflow.com/a/78277187
has comment: http://stackoverflow.com/comment/138170967
has comment: http://stackoverflow.com/comment/138031800
answers question: http://stackoverflow.com/q/78252063
score: 0
type: Answer
has body: It looks like this is because you are trying to using npx dotenvx, but dotenvx is actually published to npm as @dotenvx/dotenvx. To fix this do either of the following: Use npx @dotenvx/dotenvx npx @dotenvx/dotenvx run --env-file=.env.development -- react-scripts start Install @dotenvx/dotenvx via npm and use it inside your package.json starts scripts like so: $ npm install @dotenvx/dotenvx --save // package.json "scripts": { "start": "./node_modules/.bin/dotenvx run -- --env-file=.env.development -- react-scripts start" }, Hope that helps! dotenvx is a bit tricky to install sometimes because there are many different (flexible) ways.
has comment: http://stackoverflow.com/comment/138131429

http://stackoverflow.com/comment/137835414
type: AnswerComment
comment on: http://stackoverflow.com/a/78183686
has text: Works in zsh and mksh as well. No one uses fish anyway
score: 2
type: Comment

awk
tags question: http://stackoverflow.com/q/78190193
tags question: http://stackoverflow.com/q/78286124
tags question: http://stackoverflow.com/q/78280175
tags question: http://stackoverflow.com/q/78212116
tags question: http://stackoverflow.com/q/78176347
tags question: http://stackoverflow.com/q/78261247
tag name: awk
tags question: http://stackoverflow.com/q/78276360
tags question: http://stackoverflow.com/q/78281234
tags question: http://stackoverflow.com/q/78194906
tags question: http://stackoverflow.com/q/78147701
tags question: http://stackoverflow.com/q/78297014
tags question: http://stackoverflow.com/q/78177875
tags question: http://stackoverflow.com/q/78165163
type: Tag
tags question: http://stackoverflow.com/q/78286060
tags question: http://stackoverflow.com/q/78167734
tags question: http://stackoverflow.com/q/78176143
tags question: http://stackoverflow.com/q/78272291
tags question: http://stackoverflow.com/q/78274893
tags question: http://stackoverflow.com/q/78411488
tags question: http://stackoverflow.com/q/78371799
tags question: http://stackoverflow.com/q/78419985
tags question: http://stackoverflow.com/q/78339485
tags question: http://stackoverflow.com/q/78438262
tags question: http://stackoverflow.com/q/78346345
tags question: http://stackoverflow.com/q/78423821
tags question: http://stackoverflow.com/q/78359494
tags question: http://stackoverflow.com/q/78404577
tags question: http://stackoverflow.com/q/78383503
tags question: http://stackoverflow.com/q/78396373
tags question: http://stackoverflow.com/q/78372639
tags question: http://stackoverflow.com/q/78364618
tags question: http://stackoverflow.com/q/78378844
tags question: http://stackoverflow.com/q/78583045
tags question: http://stackoverflow.com/q/78495016
tags question: http://stackoverflow.com/q/78534641
tags question: http://stackoverflow.com/q/78539085
tags question: http://stackoverflow.com/q/78451797
tags question: http://stackoverflow.com/q/78515934
tags question: http://stackoverflow.com/q/78570217
tags question: http://stackoverflow.com/q/78574995
tags question: http://stackoverflow.com/q/78508971
tags question: http://stackoverflow.com/q/78586078
tags question: http://stackoverflow.com/q/78533122
tags question: http://stackoverflow.com/q/78464004
tags question: http://stackoverflow.com/q/78513595
tags question: http://stackoverflow.com/q/78524211
tags question: http://stackoverflow.com/q/78720313
tags question: http://stackoverflow.com/q/78639369
tags question: http://stackoverflow.com/q/78678033
tags question: http://stackoverflow.com/q/78660797
tags question: http://stackoverflow.com/q/78620437
tags question: http://stackoverflow.com/q/78736701
tags question: http://stackoverflow.com/q/78617693
tags question: http://stackoverflow.com/q/78857979
tags question: http://stackoverflow.com/q/78887105
tags question: http://stackoverflow.com/q/78891591
tags question: http://stackoverflow.com/q/78788854
tags question: http://stackoverflow.com/q/78791284
tags question: http://stackoverflow.com/q/78758811
tags question: http://stackoverflow.com/q/78809671
tags question: http://stackoverflow.com/q/78800479
tags question: http://stackoverflow.com/q/78882288
tags question: http://stackoverflow.com/q/78894153
tags question: http://stackoverflow.com/q/78917700
tags question: http://stackoverflow.com/q/79041736
tags question: http://stackoverflow.com/q/78971884
tags question: http://stackoverflow.com/q/78977025
tags question: http://stackoverflow.com/q/78949359
tags question: http://stackoverflow.com/q/79055411
tags question: http://stackoverflow.com/q/78974679
tags question: http://stackoverflow.com/q/79037681
tags question: http://stackoverflow.com/q/79009885
tags question: http://stackoverflow.com/q/78938442
tags question: http://stackoverflow.com/q/78924359
tags question: http://stackoverflow.com/q/78955065
tags question: http://stackoverflow.com/q/78994565
tags question: http://stackoverflow.com/q/78994210
tags question: http://stackoverflow.com/q/78928577

http://stackoverflow.com/comment/138013359
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78283701
type: Comment
has text: But for drawing a diamond, I would `read -pNumber:\ number;printf -v stars '%*s' $((2*number));stars="${stars// /*}";str='';while $str != "$stars" ;do str+='**';printf '%*s\n' $((number+${#str}/2)) "$str";done;while $str ;do printf '%*s\n' $((number+${#str}/2)) "$str";str=${str:2}; done` or better: `read -pNumber:\ number;printf -v stars '%*s' $((1+2*number));stars="${stars// /*}";str='*';while $str != "$stars" ;do printf '%*s\n' $((1+number+${#str}/2)) "$str";str+='**';done;while $str ;do printf '%*s\n' $((1+number+${#str}/2)) "$str";str=${str:2};done`

http://stackoverflow.com/a/78157309
has body: I doubt there is a pure Git solution to this exact problem. Git is designed to be used with Unix shell utilities. But we can do it easier. Assuming you want only information about the current set of files (not those which have been deleted), use git ls-files to get a list of the current files known to Git (safer than using find). Then run each through git log --oneline. for f in `git ls-files`; do echo "$f: $(git log --oneline $f | wc -l)"; done To get a list of files which only appear in one commit, check when git log only returns one line. for f in `git ls-files`; do if [ $(git log --oneline $f | wc -l) = "1" ]; then echo $f; fi; done You can make this a Git alias or an actual program by calling it git-whatever and putting it in your path. $ cat ~/bin/git-files-with-one-commit #!/bin/bash for f in `git ls-files`; do if [ $(git log --oneline $f | wc -l) = "1" ]; then echo $f; fi; done $ chmod +x ~/bin/git-files-with-one-commit $ git files-with-one-commit ...
upvote count: 4
has comment: http://stackoverflow.com/comment/137789939
score: 4
answers question: http://stackoverflow.com/q/78157184
has comment: http://stackoverflow.com/comment/137790034
downvote count: 0
type: Answer

http://stackoverflow.com/q/78244372
type: Question
has answer: http://stackoverflow.com/a/78245181
accepted answer: http://stackoverflow.com/a/78245181
answer count: 1
tagged with: for-loop
tagged with: bash
has comment: http://stackoverflow.com/comment/137951578
linked to: http://stackoverflow.com/q/673055
tagged with: caching
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137943353
has comment: http://stackoverflow.com/comment/137955108
has comment: http://stackoverflow.com/comment/137942958
has body: I try to launch multiple experiments, but I want to keep the code script in cache so that any change will not affect experiments waiting to be executed. The bash script I use is: for SIZE in 1 2 4 8 16; do python main.py $SIZE done The problem with my current script is that once I make changes to the code file main.py, the experiments waiting to be executed will use the modified main.py. For example, If python main.py 1 is currently executed, any change to main.py will affect main.py 2, main.py 4... Is there a way to put main.py in cache so that any change to main.py will not affect python main.py $SIZE?
has comment: http://stackoverflow.com/comment/137943541
has comment: http://stackoverflow.com/comment/137943362
has title: Launch jobs in cache in a loop in bash script
score: 0

shell
tags question: http://stackoverflow.com/q/78274299
tags question: http://stackoverflow.com/q/78224942
tags question: http://stackoverflow.com/q/78255091
tags question: http://stackoverflow.com/q/78261051
tags question: http://stackoverflow.com/q/78274893
tags question: http://stackoverflow.com/q/78252458
tags question: http://stackoverflow.com/q/78154583
tags question: http://stackoverflow.com/q/78147406
tags question: http://stackoverflow.com/q/78241462
tags question: http://stackoverflow.com/q/78185284
tags question: http://stackoverflow.com/q/78283701
tags question: http://stackoverflow.com/q/78156916
tags question: http://stackoverflow.com/q/78240103
tags question: http://stackoverflow.com/q/78167188
tags question: http://stackoverflow.com/q/78181978
tags question: http://stackoverflow.com/q/78177405
tags question: http://stackoverflow.com/q/78202789
tags question: http://stackoverflow.com/q/78195964
tags question: http://stackoverflow.com/q/78146721
tags question: http://stackoverflow.com/q/78178702
tags question: http://stackoverflow.com/q/78241899
tags question: http://stackoverflow.com/q/78232246
tags question: http://stackoverflow.com/q/78148102
tags question: http://stackoverflow.com/q/78302587
tags question: http://stackoverflow.com/q/78211182
tags question: http://stackoverflow.com/q/78222483
tags question: http://stackoverflow.com/q/78231603
tags question: http://stackoverflow.com/q/78199094
tags question: http://stackoverflow.com/q/78290808
tags question: http://stackoverflow.com/q/78193259
tags question: http://stackoverflow.com/q/78232787
tags question: http://stackoverflow.com/q/78278018
tags question: http://stackoverflow.com/q/78307692
tags question: http://stackoverflow.com/q/78158725
tags question: http://stackoverflow.com/q/78228798
tag name: shell
tags question: http://stackoverflow.com/q/78211450
tags question: http://stackoverflow.com/q/78229406
tags question: http://stackoverflow.com/q/78207789
tags question: http://stackoverflow.com/q/78182539
tags question: http://stackoverflow.com/q/78203871
tags question: http://stackoverflow.com/q/78300019
tags question: http://stackoverflow.com/q/78146724
tags question: http://stackoverflow.com/q/78253800
tags question: http://stackoverflow.com/q/78204675
tags question: http://stackoverflow.com/q/78192206
tags question: http://stackoverflow.com/q/78190505
tags question: http://stackoverflow.com/q/78156679
tags question: http://stackoverflow.com/q/78154096
tags question: http://stackoverflow.com/q/78225038
tags question: http://stackoverflow.com/q/78284934
tags question: http://stackoverflow.com/q/78215669
tags question: http://stackoverflow.com/q/78250385
type: Tag
tags question: http://stackoverflow.com/q/78199979
tags question: http://stackoverflow.com/q/78158852
tags question: http://stackoverflow.com/q/78285382
tags question: http://stackoverflow.com/q/78149866
tags question: http://stackoverflow.com/q/78278159
tags question: http://stackoverflow.com/q/78146405
tags question: http://stackoverflow.com/q/78433528
tags question: http://stackoverflow.com/q/78344853
tags question: http://stackoverflow.com/q/78346345
tags question: http://stackoverflow.com/q/78319248
tags question: http://stackoverflow.com/q/78416162
tags question: http://stackoverflow.com/q/78431133
tags question: http://stackoverflow.com/q/78419580
tags question: http://stackoverflow.com/q/78419674
tags question: http://stackoverflow.com/q/78334722
tags question: http://stackoverflow.com/q/78391938
tags question: http://stackoverflow.com/q/78372273
tags question: http://stackoverflow.com/q/78445380
tags question: http://stackoverflow.com/q/78364618
tags question: http://stackoverflow.com/q/78410973
tags question: http://stackoverflow.com/q/78440831
tags question: http://stackoverflow.com/q/78346697
tags question: http://stackoverflow.com/q/78376334
tags question: http://stackoverflow.com/q/78342895
tags question: http://stackoverflow.com/q/78351058
tags question: http://stackoverflow.com/q/78338291

osascript
tags question: http://stackoverflow.com/q/78241462
tag name: osascript
type: Tag
tags question: http://stackoverflow.com/q/78490743
tags question: http://stackoverflow.com/q/79524263

http://stackoverflow.com/a/78200333
answers question: http://stackoverflow.com/q/78200217
score: 0
has comment: http://stackoverflow.com/comment/137864537
has comment: http://stackoverflow.com/comment/137864644
has body: The output of df -h has whitespace so you need to keep it quoted to prevent word splitting. Compare: # wrong - ${NEW} is not inside the quotes on either its left or right hand sides sed -ie "200s|^.*$|"${NEW}"|g" "file.txt" # better - ${NEW} is within the double-quoted string sed -ie "200s|^.*$|${NEW}|g" "file.txt" # if ${NEW} contains newlines sed -ie "200s|^.*$|${NEW//$'\n'/\\$'\n'}|g" "file.txt" awk could be more readable/maintainable here as you don't have to interpolate the data into the command string: awk -v subststr="${NEW}" -v lineno=200 ' { if (NR == lineno) { print subststr } else {print $0} } ' file.txt > output.txt && mv output.txt file.txt
has comment: http://stackoverflow.com/comment/137865076
type: Answer
has comment: http://stackoverflow.com/comment/137864832
has comment: http://stackoverflow.com/comment/137864548
has comment: http://stackoverflow.com/comment/137865135

http://stackoverflow.com/a/78234934
has body: +(!(bad-cats|dogs)) matches bad-cats because it can (for instance) match it as strings bad followed by -cats, neither of which matches bad-cats or dogs (so the !(dogs|bad-cats) pattern matches both of them). Similarly, dogs can be matched as strings do followed by gs. To fix the code change the pattern assignment to: pattern='*cars-!(dogs|bad-cats)/src/bin/out/*' The pattern !(bad-cats|dogs) does not match eitherbad-cats or dogs because it doesn't allow them to be broken into parts that can be matched separately. Removing the +( and corresponding ) in the pattern also massively speeds up the matching because it eliminates huge amounts of pointless backtracking. I replaced each of two occurrences of ** in the original pattern with * because the second * is redundant, and might make pattern matching slower. (** is only special when doing filename expansion and the globstar shell option is enabled (see the globstar section in glob - Greg's Wiki).)
type: AcceptedAnswer
score: 2
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/78232634
upvote count: 2
answers question: http://stackoverflow.com/q/78232634

http://stackoverflow.com/q/78186846
has title: String replacement in GNU-Parallel when using multiple input streams
tagged with: bash
type: Question
has body: I know how to perform perl-style string replacement in parallel and I love it, but I wanted to know if I can use it when I have 2 input streams and apply the replacement for just a specific input. For example, say that I run the following command: $ parallel echo "First name: {1}, Last name: {2}" ::: John Jane :::+ Doe Smith The output is : First name: John, Last name: Doe First name: Jane, Last name: Smith Say I want to initialise the surname only with a replacement string: $ parallel --rpl "{init} s:(\w).+:\1:" echo "First name: {1}, Last name: {init}" ::: John Jane :::+ Doe Smith parallel will actually replace both input streams to generate the following output: First name: John, Last name: J D First name: Jane, Last name: J S (Notice the extra J in the last name). Is there any way to tell parallel which input I want to operate on? UPDATE Answering my question, I had an epiphany (or recall) and I tried adding the number of my required input inside the curly brackets when calling the replacement string, and it did exactly what I wanted: $ parallel --rpl "{init} s:(\w).+:\1:" echo "First name: {1}, Last name initial: {2 init}" ::: John Jane :::+ Doe Smith First name: John, Last name: D First name: Jane, Last name: S Similar to this question, is it possible to use the predefined replacement string as input for my replacement or do I need to create the full replacement from the original input? For example, can I somehow use the replacement string {/} to remove the path and then do a replacement on the base filename without the path: ls -1 /home/user/*_non-important.txt | parallel --rpl "{mybasename} s:_non-important.txt::" echo "{mybasename}" Thanks, Ido
upvote count: 3
has answer: http://stackoverflow.com/a/78202297
tagged with: gnu-parallel
accepted answer: http://stackoverflow.com/a/78202297
downvote count: 0
score: 3
answer count: 1
favorite count: 0
type: AnsweredQuestion
tagged with: regex

dd
tag name: dd
type: Tag
tags question: http://stackoverflow.com/q/78192103

http://stackoverflow.com/comment/137898125
comment on: http://stackoverflow.com/q/78218663
score: 0
has text: It might be worth your while to first solve a model problem with a hardcoded combination of pipeline and [other] redirection(s). Make that as short and simple as possible, so that you are not distracted by all the abstraction and framing.
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78210405
answer count: 1
accepted answer: http://stackoverflow.com/a/78210478
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137882933
downvote count: 1
has comment: http://stackoverflow.com/comment/137882956
has answer: http://stackoverflow.com/a/78210478
type: Question
tagged with: macos
upvote count: 0
has title: why bash modifies the content of my variable
has comment: http://stackoverflow.com/comment/137883678
has comment: http://stackoverflow.com/comment/137882965
linked to: http://stackoverflow.com/q/29378566
score: -1
duplicate of: http://stackoverflow.com/q/29378566
tagged with: bash
has body: consider this code, on Mac : #/bin/bash x="-map [audioWithGain]" echo $x echo "-map [audioWithGain]" Output on a Mac 12.7 is -map t -map [audioWithGain] Why, oh why? Perfectly work on linux of course. Any idea for workarounds? I tried all sorts of x="-map"" "'[audioWithGain]' and such, to no avail! but this works: (!) x="-map [hGain]"

http://stackoverflow.com/a/78159746
has body: Try passing your variables (for ex: VARIABLE_AAA, VARIABLE_BBB) as arguments to the Bash script: .gitlab-ci.yml image: docker:latest stages: - build build: stage: build script: - chmod +x ./scripts/hello.sh - ./scripts/hello.sh "VARIABLE_AAA" "VARIABLE_BBBB" hello.sh #!/usr/bin/env bash VAR_A=$1 VAR_B=$2 echo $VAR_A echo $VAR_B Output More details in: arguments in bash script
answers question: http://stackoverflow.com/q/78157839
downvote count: 0
type: Answer
score: 2
upvote count: 2

gnu-findutils
tags question: http://stackoverflow.com/q/78209376
tag name: gnu-findutils
type: Tag

http://stackoverflow.com/comment/138193461
type: Comment
has text: The immediate and obvious problem is the extra backslashes preventing expansion. Whatever other problems you might have after fixing them should be asked about separately. (BTW, you might want to get in the habit of running your code through http://shellcheck.net/ and reading the wiki pages it links).
comment on: http://stackoverflow.com/q/78253800
score: 0
type: QuestionComment

http://stackoverflow.com/a/78170836
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/137812324
answers question: http://stackoverflow.com/q/78170444
has comment: http://stackoverflow.com/comment/137812302
has body: For a pure bash solution you can read line by line with a while loop feeding the loop with a process substitution. You modify the internal field separator (IFS) to only break on ',' or '\n' (or just add ',' to the default IFS in your case). A short example would be: #!/bin/bash v='1,1708746085,apples,cars 2,1709764378,pears,bus 3,1709875892,orange,truck' while IFS=$',\n' read -r n t f c; do printf "%s,%s,%s,%s,%s\n" "$n" "$t" "$f" "$c" "$(date -d @"$t")" done < <(printf "%s\n" "$v") Where v is your variable, n holds the field-1 number, t holds the time, f holds the fruit and c holds the cars (not very creative) (adjust the date format as desired, perhaps $(date -d @"$t" +'%F %T') or the like) You can also use a heredoc to feed the while loop, e.g. while IFS=$',\n' read -r n t f c; do printf "%s,%s,%s,%s,%s\n" "$n" "$t" "$f" "$c" "$(date -d @"$t")" done << EOF $v EOF Example Use/Output With the script in tmp/t.sh you can do: $ bash tmp/t.sh 1,1708746085,apples,cars,Fri Feb 23 09:41:25 PM CST 2024 2,1709764378,pears,bus,Wed Mar 6 04:32:58 PM CST 2024 3,1709875892,orange,truck,Thu Mar 7 11:31:32 PM CST 2024 (note: output with my LOCALE and timezone info)
type: Answer
score: 2

http://stackoverflow.com/a/78171801
answers question: http://stackoverflow.com/q/78170444
has comment: http://stackoverflow.com/comment/137814819
score: 4
has comment: http://stackoverflow.com/comment/137817550
has comment: http://stackoverflow.com/comment/137813941
upvote count: 4
type: Answer
has comment: http://stackoverflow.com/comment/137814015
has comment: http://stackoverflow.com/comment/137817829
has body: If you've got Bash 4.2 (released in 2011) or later, try this Shellcheck-clean pure Bash code: #! /bin/bash -p time='1,1708746085,apples,cars 2,1709764378,pears,bus 3,1709875892,orange,truck' while IFS=, read -r first utime rest; do printf '%s,%s,%s,%(%c)T\n' "$first" "$utime" "$rest" "$utime" done <<<"$time" The %(fmt)T specifier for the printf built-in was introduced in Bash 4.2. It causes printf to output the date-time string resulting from using fmt as a format string for strftime. See the Here Strings section in the Bash Reference Manual for an explanation of <<<"$time". See BashFAQ/001 (How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?) for an explanation of the while IFS=, read -r ... loop.
downvote count: 0
has comment: http://stackoverflow.com/comment/137820292
has comment: http://stackoverflow.com/comment/137817370

http://stackoverflow.com/a/78196126
has comment: http://stackoverflow.com/comment/137858143
type: Answer
answers question: http://stackoverflow.com/q/78195964
score: 0
has comment: http://stackoverflow.com/comment/137857297
has comment: http://stackoverflow.com/comment/137857382
has body: As bash is tagged, you can use "${@:3}" to produce all arguments starting from the third. Use that in combination with $1 to reference all arguments but the second, and use set to reset the arguments accordingly: #!/bin/bash echo "BEFORE:" for arg; do echo "=> [$arg]"; done set -- "$1" "${@:3}" echo "AFTER:" for arg; do echo "=> [$arg]"; done Example: ./script.sh "a 1" b "c 2" BEFORE: => [a 1] => [b] => [c 2] AFTER: => [a 1] => [c 2]

http://stackoverflow.com/q/78234242
tagged with: command-substitution
score: -1
type: Question
tagged with: syntax
upvote count: 0
type: UnansweredQuestion
tagged with: bash
has body: I have recently started journaling and I wanted to create a program to make the process a little easier. The program uses bash to mount an external hard drive (with a known name) and open the journal folder on that drive, then open vim in that folder while naming the file with the current date. Here is the program (put in ~/.bin and named journal): #!/bin/bash CURRENTDATE=$'date +"%m-%d-%y"' udisksctl mount -b /dev/sda2 cd /run/media/harrison/Backup\ Disk/journal vim ${CURRENTDATE}.txt So far it does mostly what I want. It mounts the disk successfully and opens vim. When I type something unique and close vim with :wq, and change directory to where the new file should be, there is a new file named "date" containing the text I wrote. The only problem is that the name is wrong. The new file should be named something like "03-27-24.txt", instead of "date". How do I get the program to name the file the current date? In case it matters, I am using Arch Linux.
answer count: 1
has answer: http://stackoverflow.com/a/78234256
favorite count: 0
downvote count: 1
has title: I am having trouble using the date function along with the vim command in bash

conditional-statements
tag name: conditional-statements
tags question: http://stackoverflow.com/q/78213645
type: Tag
tags question: http://stackoverflow.com/q/78351058
tags question: http://stackoverflow.com/q/78405034
tags question: http://stackoverflow.com/q/78419580
tags question: http://stackoverflow.com/q/78538302
tags question: http://stackoverflow.com/q/79111022

http://stackoverflow.com/comment/137865750
comment on: http://stackoverflow.com/q/78200978
type: Comment
type: QuestionComment
has text: @Wyck write lines from user input into the file
score: 0

http://stackoverflow.com/a/78163716
accepted answer of: http://stackoverflow.com/q/78163062
score: 0
has body: Like Barmar said, the problem with your first solution is that the '$i' variable will include the entire path (e.g. PROD/Today/Core.cfg). To get the diff to work, you need to get the basename of $i and use that with the second argument to diff: for i in PROD/Today/*.cfg; do file=$(basename $i); diff $i PROD/Yesterday/$file > PROD/Changes/${file}_delta.txt done Note that I also used that in the destination filename, to make the delta file be unique for each common file name. To fix your second solution, your find should start at "PROD/Today" not ".", and have a -maxdepth of 2 not 1 (or get rid of that). Oh, and you need curly braces around "file" when creating the delta filename. For example: find PROD -maxdepth 2 -type f -name '*.cfg' | while read -r file; do file=$(basename $file) diff PROD/Today/$file PROD/Yesterday/$file > PROD/Changes/${file}_delta.txt done
type: Answer
answers question: http://stackoverflow.com/q/78163062
type: AcceptedAnswer

http://stackoverflow.com/comment/137796724
type: AnswerComment
comment on: http://stackoverflow.com/a/78160193
score: 0
has text: That said, there is nothing inherently wrong with using `function name()`. For my code review if it would be a bash script, not a POSIX compatible script, I wouldn't care and approve.
type: Comment

http://stackoverflow.com/comment/137866493
has text: Actually, that's not exactly true. Some shells do have a way to make environment variables read-only, but that's still a function of the shell, not anything deeper than that.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78200396
score: 0

http://stackoverflow.com/comment/137908231
score: 0
has text: BTW, in `echo "$line" | nslookup` -- are you sure nslookup reads from stdin at all, vs expecting the hostname to be passed as a command line? I would expect the command to need to be `nslookup "$line"`. That said, the whole loop could probably be replaced with `xargs -d $'\n' -n 1 nslookup <"$filename"`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78224799

http://stackoverflow.com/comment/137850275
comment on: http://stackoverflow.com/a/78192118
type: Comment
has text: thnx i will test this and check if it works for the device i want to use it for
type: AnswerComment
score: 0

http://stackoverflow.com/q/78222483
tagged with: unix
score: 0
tagged with: shell
has body: I have a shell script which executes a series of command to get some server stats. Some of these commands are using journalctl to get the data. The shell script collates all the data and creates a log file. This log file is used by the telegraf service to send the output to InfluxDB. The telegraf service is executing as teleraf user. This user telegraf is added to systemd-journal group so it can execute some of the journald commands. When I run the telegraf command -test flag, the first execution is not showing the output for those commands which are using journalctl. If I run the same telegraf with -test flag again, I see the data coming up fine. If I leave the telegraf service do what its supposed to do, the output of those journalctl commands are coming up as empty or null. What could be happening here? Sample commands from shell script: .... chefver=$(journalctl -u chef-client --since "35 minutes ago" | grep -om 1 -E "Client, version [^;]*" | cut -d ' ' -f3 ) osver=$(hostnamectl | grep Operating | cut -d: -f2 | xargs) ... In the above code, the chefver is coming as empty/null but osver value is showing up fine.
has comment: http://stackoverflow.com/comment/137905341
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137904357
tagged with: telegraf
has title: telegraf service not able to retrieve data using the journalctl commands
type: Question
answer count: 0

http://stackoverflow.com/comment/137778302
comment on: http://stackoverflow.com/a/78147099
type: AnswerComment
score: 0
has text: i corrected the shebang line, and removed the final cd statment. while the echo statement still only gives one output, invoking python3 still makes test_01 execute twice. i'm very new to shell scripting, by 'running with set -x' do you mean i call `bash [script.sh] set -x` in the terminal, or do you mean i have to add a line in the script called `set -x`?
type: Comment

http://stackoverflow.com/comment/137871959
score: 0
has text: Thank you so much sir, very helpful and it works. Have a nice weekend. PS: The link you gave as reference is not working, could you give it again?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78202886

http://stackoverflow.com/comment/137858308
has text: See [How can I stop a here string (<<<) from adding a line break or new lines?](https://stackoverflow.com/q/37728699/4154375) and [Why does Bash always add a newline when expanding here strings?](https://stackoverflow.com/q/33245568/4154375) for explanations of the newline in `$sFourthField`.
score: 1
comment on: http://stackoverflow.com/q/78196593
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137824558
comment on: http://stackoverflow.com/a/78170533
has text: Actually nevermind, all good thx again
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/q/78166553
type: Question
has answer: http://stackoverflow.com/a/78171756
linked to: http://stackoverflow.com/q/34859987
has comment: http://stackoverflow.com/comment/137813119
accepted answer: http://stackoverflow.com/a/78171756
has comment: http://stackoverflow.com/comment/137813520
score: 2
has comment: http://stackoverflow.com/comment/137813127
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137813223
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137805966
has comment: http://stackoverflow.com/comment/140050064
has comment: http://stackoverflow.com/comment/137806763
has title: How can I evaluate and assign default value to ARG in dockerfile?
has answer: http://stackoverflow.com/a/78166645
upvote count: 2
answer count: 2
possible better answer: http://stackoverflow.com/a/78166645
has body: Basically I want to assign a dynamically calculated default value for ARG in my Dockerfile: FROM node:20-alpine ARG RELEASE_TAG=$(git describe --tags --always) # Other commands... So, far it doesn't interpolate the value of $(git describe --tags --always) and simply assigns this value to the RELEASE_TAG variable. Is there any way I can achieve this?
tagged with: dockerfile
tagged with: docker

http://stackoverflow.com/comment/137851785
type: Comment
comment on: http://stackoverflow.com/q/78190193
has text: i tried running a Python thread to sample the I/O, but i couldn't get the speed needed to accurately capture the 10ms pulse spike. after a long night of reading specs, i'm beginning to wonder if the processor thread just can't handle the saturation necessary to capture accurately AND run the application. there's also the possibility i may not be a good enough programmer at this point to make it happen... :\ the biggest irritation is all the utilities necessary to gather signals is written by the manufacturer in awk. i'm sure i could translate most of them to Python, but the speed
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137867933
type: Comment
has text: https://idownvotedbecau.se/itsnotworking/ -https://idownvotedbecau.se/noexceptiondetails/
score: 0
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment

http://stackoverflow.com/a/78207000
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78201574
has body: Now that you've shared the content of your data, we know that group_members looks like pan-sgg-dalas:*:1941423615:ws-pa-test-l001$,ws-pa-jeu-l004$,ws-pa-ukg-ktr$,ws-pa-arm-kszi$,ws-pa-ds-dis1$,ws-pa-ds-dis2$ There are a few things here: First, we should be taking only the fourth column; second, we need to split by commas and remove the trailing $s to get something suitable for an exact-match comparison. So, let's do that: # output of actual commands hardcoded to allow reproducibility computer_name=ws-pa-sius-l002 group_members='pan-sgg-dalas:*:1941423615:ws-pa-test-l001$,ws-pa-jeu-l004$,ws-pa-ukg-ktr$,ws-pa-arm-kszi$,ws-pa-ds-dis1$,ws-pa-ds-dis2$' group_members=${group_members##*:} # remove everything up to the last : in group_members if ",$group_members" = *,"$computer_name"$ ; then echo "$computer_name is a group member" >&2 else echo "$computer_name is NOT a group member" >&2 fi When running that we get ws-pa-sius-l002 is NOT a group member as output -- but that's correct! ws-pa-sius-l002 is indeed not in the list stored in group_members in the sample data given. By the way -- note how we're prefixing a , to the $group_members string when checking whether ,${computer_name}$ is inside that string; the , on the front and the $ on the end prevents partial or incomplete matches from falsely claiming a host to be present when something with a longer name incorporating that short name as a subset is actually present instead.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/78201574
score: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/138026257
comment on: http://stackoverflow.com/a/78276584
type: Comment
type: AnswerComment
has text: Thanks for your comment! Apologize for my unclear description. I just wanna compare a single commit, but I don't know how to use `git blame` to extract line numbers.
score: 0

http://stackoverflow.com/a/78155511
has comment: http://stackoverflow.com/comment/137801035
has comment: http://stackoverflow.com/comment/137807878
score: 1
type: Answer
answers question: http://stackoverflow.com/q/78151708
downvote count: 0
has body: Assuming the "any number" is always a single digit number (i.e. two hexadecimal characters) the following should work: FILE='file.vpk' SEARCH_STRING='MaxRagdollCount' SEARCH_STRING_HEX="$(echo -n "$SEARCH_STRING" | xxd -p -c 0)" # # Convert binary to ascii: xxd -p -c 0 $file > ${FILE}.tmp # # Replace every occurrence of "SEARCH_STRING_HEX<double quote><space><double quote><character><character><double quote>" with "SEARCH_STRING_HEX<double quote><space><double quote>39<double quote>". sed -e "s/${SEARCH_STRING_HEX}222022..22/${SEARCH_STRING_HEX}2220223922/g" < ${FILE}.tmp > ${FILE}.tmp2 xxd -r -p ${FILE}.tmp2 > $FILE rm -f ${FILE}.tmp ${FILE}.tmp2
upvote count: 1

http://stackoverflow.com/comment/137921287
type: QuestionComment
comment on: http://stackoverflow.com/q/78229406
type: Comment
has text: thanks for others for your valuable feedback, I written something different but somehow post turned out like this. I work in a place where the actual code cannot be shared. I tried the test program before sharing here. First part is the code, cat /mydir/template.txt onwards are the other file content called from the code. Basically question is i want the echo ${emailbody} to show "hello" in four lines instead of hello repeated 4 times in single line.
score: 1

http://stackoverflow.com/q/78202033
answer count: 1
has comment: http://stackoverflow.com/comment/137867814
tagged with: apache-zookeeper
tagged with: apache-kafka
tagged with: bash
type: Question
tagged with: docker-compose
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137867714
has title: Docker-compose Kafka: no brokers available
has answer: http://stackoverflow.com/a/78203676
tagged with: docker
score: 0
has body: Running Kafka, zookeeper, and client/producers on local docker. Getting error no brokers on Kafka and services. The waiting for a node assignment. Call: createTopics in the error below makes me wonder if the creat topics .sh or bash command is the cause but I am not sure why that would be the case. What I have done so far: Ran chmod +x create-topics.sh Delete and rebuild everything. Add a manual start in kafka docker-compose (shown below) chatGPT Google Searched Stackoverflow (similar questions but no applicable resolutions) Error in Kafka container: WARN [AdminClient clientId=adminclient-1] Connection to node -1 (kafka1/172.31.0.8:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) Then eventually: 2024-03-21 13:30:53 [2024-03-21 17:30:53,527] ERROR org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: createTopics 2024-03-21 13:30:53 (kafka.admin.TopicCommand$) Error on the connecting services: 2024-03-21 13:32:55 File "/usr/local/lib/python3.11/site-packages/kafka/client_async.py", line 927, in check_version 2024-03-21 13:32:55 raise Errors.NoBrokersAvailable() 2024-03-21 13:32:55 kafka.errors.NoBrokersAvailable: NoBrokersAvailable docker-compose.yml version: '3.8' services: database-mysql: image: mysql:latest env_file: - .env restart: always hostname: oaken-mysql container_name: oaken-mysql environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} MYSQL_DATABASE: ${MYSQL_DATABASE} ports: - 3306:3306 expose: - 3306 volumes: - oaken-mysql:/var/lib/mysql - ./app/mysql/init.sql:/data/application/init.sql networks: - OakenSpirits mysql-kafka-processor: image: oaken-mysql-kafka env_file: - .env restart: always hostname: mysql-kafka-processor container_name: mysql-kafka-processor volumes: - oaken-api:/app networks: - OakenSpirits shipping-processor: image: oaken-shipping env_file: - .env restart: always hostname: shippin…

http://stackoverflow.com/q/78164579
tagged with: bash
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78164681
has answer: http://stackoverflow.com/a/78164653
has body: For my job, we create a lot of small web applications with NodeJS for the backend and Angular for the frontend Said apps usually involve a lot of CRUDs With Angular, I can run: ng generate component 'component-name' Which generates the ts, html, scss, and spec files How would I go about creating a custom script to do something similar in NodeJS? Currently, the project uses ExpressJS and Sequelize, and the structure as follows: ├── src │ ├── controllers │ | ├── product.controller.js │ ├── models | | ├── product.model.js │ ├── routes | | ├── product.routes.js ├── index.js ├── package.json Basically I want to create a script that generates all 3 files when given the name, something like node generate client Is it possible?
accepted answer: http://stackoverflow.com/a/78164681
possible better answer: http://stackoverflow.com/a/78164653
score: 0
tagged with: node.js
type: Question
tagged with: javascript
has comment: http://stackoverflow.com/comment/137801396
tagged with: command
has title: How do I create a custom command to generate files with Node?
answer count: 2

http://stackoverflow.com/q/78240309
downvote count: 0
tagged with: bash
type: UnansweredQuestion
score: 1
tagged with: tee
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/137936304
has title: How can I get the aws profile id from the aws configure sso command
has body: As part of a bash script to automate connecting to our postgres instance I need to configure the aws cli tool and set the AWS_PROFILE variable. The command outputs this in the final line of its output. The problem is that aws configure sso is interactive so I can't just dump the output in a variable. So I have done the following: AWS_OUTPUT=$(aws configure sso | tee /dev/tty) export AWS_PROFILE=$(tail -1 <<< "$AWS_OUTPUT" | cut -d' ' -f5) This works, but its hard to use because every time I press any key while aws configure sso is running a carriage return is also inserted and the output is very confusing (though barely usable). Is there a better way to get the profile id? Or a way to prevent the carriage return issue?
type: Question
tagged with: aws-cli
has answer: http://stackoverflow.com/a/78422669
tagged with: amazon-web-services

http://stackoverflow.com/comment/137785988
has text: I'm not familiar with functions in vim but thanks for the tip, I will look into it!
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78155628
score: 0

http://stackoverflow.com/comment/137790796
has text: (look into `readarray` instead of a loop to populate an array with the lines of a file)
type: QuestionComment
comment on: http://stackoverflow.com/q/78158123
type: Comment
score: 0

http://stackoverflow.com/comment/137925173
type: AnswerComment
score: 1
has text: @bproxauf, ...updated accordingly, demonstrating both use of literal newlines and use of the BASHOPTS environment variable. Note that BASHOPTS may not work (version-dependent) when running as root -- newer versions of bash try to minimize attack surface when running as uid 0, and part of that is paying attention to fewer environment variables.
comment on: http://stackoverflow.com/a/78232840
type: Comment

http://stackoverflow.com/comment/137828977
type: QuestionComment
type: Comment
has text: Okay, But I can see when I am running the wc -l for the file I am getting one less count lets support there are 100 UUIDs in the file then I am getting 99 but with the sed -n '$=' I am getting 100 as a count, so that was the reason behind using that.
comment on: http://stackoverflow.com/q/78177875
score: 0

http://stackoverflow.com/q/78163062
has comment: http://stackoverflow.com/comment/137798769
has answer: http://stackoverflow.com/a/78163716
has comment: http://stackoverflow.com/comment/137798903
has comment: http://stackoverflow.com/comment/137799321
has comment: http://stackoverflow.com/comment/137798780
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137798912
has comment: http://stackoverflow.com/comment/137799253
tagged with: bash
has body: I have two directories, today and yesterday. Inside each directory are 100+ files with the same exact name, in .cfg format. In a bash script I can call out a specific file name, and run a diff, and my output is any text within the file that is different from the other. diff PROD/Today/Core.cfg PROD/Yesterday/Core.cfg &gt; PROD/Changes/delta.txt I know that I need to create a loop to get each individual file name, then compare it with the file with the same name in the other folder. for i in PROD/Today/*.cfg; do diff PROD/Today/$i PROD/Yesterday/$i &gt; PROD/Changes/delta.txt But this just results in it looking for *.cfg, not the actual file name. And find . -maxdepth 1 -type f -name '*.cfg' | while read -r file; do file=$(basename $file) diff PROD/Today/$file PROD/Yesterday/$file &gt; PROD/Changes/$file_delta.txt done Only results in PROD/Yesterday/.cfg: No such file or directory, even though the shows each individual of the 100 file names.
answer count: 1
has comment: http://stackoverflow.com/comment/137798807
has comment: http://stackoverflow.com/comment/137803138
accepted answer: http://stackoverflow.com/a/78163716
has title: Search text files with matching names in different directories
has comment: http://stackoverflow.com/comment/137799315
type: AnsweredQuestion
tagged with: linux
linked to: http://stackoverflow.com/q/4997693

http://stackoverflow.com/a/78177038
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78176143
has body: echo 'thisthing ( # a comment appid="myapp", # comments othervariable="something", another=somethingelse, option=["blah"], )' | mawk '$0 = $2' FS='^[ \t]*appid[ \t]?=[ \t]?"|"[^"]*$' myapp All other rows with double quotes (") but without appid= in front would have its $2 set to the right of end of row, i.e. $2 == "", and thus wouldn't print since evaluating the empty string pattern always yields 0 (false). An alternate approach is to use RS instead of FS : (which works for all except gawk -P or gawk -c, since those handle multi-char RS by only using the first char, whatever it is) gawk NF RS='^.*[ \t]*appid[ \t]?=[ \t]?"|".*$' myapp
has comment: http://stackoverflow.com/comment/137833698
downvote count: 0
has comment: http://stackoverflow.com/comment/137822961
score: 1

http://stackoverflow.com/comment/137833728
type: AnswerComment
has text: @DeltaIV I'm suggesting that instead of filtering the repo with multiple passes, you can modify the if statement to do it in a single pass. If you have 100 email addresses to change, you could do 100 passes (plus another for the default), or just have 100 if and elif clauses in the callback. My gut feeling is a single callback will be faster too. (Though `git-filter-repo` is very fast so it probably doesn't matter that much.) The biggest gain I think with my method is how to handle the default case. A single "else" clause may be easier than "if not one of these 100, then use the default".
comment on: http://stackoverflow.com/a/78182177
score: 0
type: Comment

http://stackoverflow.com/a/78234256
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: $'...' is just a literal string (specifically an ANSI string, that follows the string literal conventions of ANSI C); it doesn't run that string as a command. For that, you want $(...). CURRENTDATE=$(date +"%m-%d-%y") Except there's no reason to name a variable in all-caps except to mark it as special (either to the shell, or because you're exporting it into the environment for use by some other program, or whatever). Better to use lowercase: current_date=$(date +%m-%d-%y) You also don't need the curly braces when you reference it to get its value, though they don't hurt. But you should put quotation marks around the expansion – all expansions, in fact. They aren't strictly needed here, just because you picked a date format that doesn't have any spaces or special characters in it, but if you were to leave the quotes off and that changed in the future your script would break. So it's just a good habit to get into: vim "$current_date.txt"
has comment: http://stackoverflow.com/comment/137925222
answers question: http://stackoverflow.com/q/78234242

http://stackoverflow.com/q/78276987
has body: I am trying to write a regex that can satisfy the following condition. first, string will be start with multiple substrings --> ^(aa|bb|cc) second, then multiple substring it has to be continue with specified chars . (dot) or @ (at) --> ^(aa|bb|cc) [.@] third, after specified chars, it has to be contain at least one occurence charsets includes [a-zA-Z0-9_] charsets or at least one occurence any charset except .@ EXAMPLES: string | matched ---------------- aa.xya -> true aa. -> false aa -> false -------- bb.@b -> false bb@b -> true bb.b -> true --------- cc.bb. -> false cc.bb@ -> false cc.xz -> true ... ... ... I need to a $PATTERN that contains all state, so what should my $PATTERN be? if "$string" =~ $PATTERN
score: 0
type: UnansweredQuestion
tagged with: bash
answer count: 1
has title: In Bash, Multiple Substring before Specific Char and Continue with
has comment: http://stackoverflow.com/comment/138000133
tagged with: regex
type: Question
has answer: http://stackoverflow.com/a/78277043
has comment: http://stackoverflow.com/comment/138000123

http://stackoverflow.com/comment/137998848
has text: Neat trick! I guess you can do `SOME_VAR="$SOME_VAR" source ./myenv.sh` if you want the value to be visible inside `myenv.sh`.
comment on: http://stackoverflow.com/a/78273432
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/comment/138045900
has text: I am getting the same error by using double quotes around my variable as you suggested :')
type: QuestionComment
comment on: http://stackoverflow.com/q/78302587
score: 0
type: Comment

http://stackoverflow.com/comment/138016118
type: Comment
has text: what happens if a name exists in 2.csv but not in 1.csv?
comment on: http://stackoverflow.com/q/78286060
type: QuestionComment
score: 2

http://stackoverflow.com/a/78239469
answers question: http://stackoverflow.com/q/78228111
has body: You can use the task spooler, it creates a queue of jobs to run and launches them one at a time, in order of submission (by default). When submitting a new job, it returns an assigned ID that you can further use to optionally add constraints; for example running a job only if another exited successfully. It also stores each job output stream separately. Your script would then be: #!/bin/bash H="1 10 100" K="0.01 0.1" for H_val in "${H}" do for K_val in "${K}" do tsp python program.py "${H_val}" "${K_val}" done done or more concisely, if you are set on doing the full parameter search, using parallel to avoid the explicit nested loops: #!/bin/bash H=(1 10 100) K=(0.01 0.1) # fill the queue with all parameter combinations parallel tsp python program.py ::: "${H[@]}" ::: "${K[@]}" >/dev/null After running your script, you can supervise the progression by calling tsp without arguments, and you can see the output of a job with tsp -c <jobID>. Edit Actually, you could even ironically only use parallel to run sequentially, dropping tsp: parallel -kj1 python program.py ::: "${H[@]}" ::: "${K[@]}" &
type: Answer
score: 0

http://stackoverflow.com/comment/137850794
type: Comment
has text: And no, I couldnt make it work using the answers in that question it seems
comment on: http://stackoverflow.com/q/78166360
type: QuestionComment
score: 0

http://stackoverflow.com/comment/137820700
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78175779
has text: Depends on what you are hoping to accomplish. A here string inherently has a newline at the end, but `printf %s "$foo"` does not.

arrays
tags question: http://stackoverflow.com/q/78235101
tags question: http://stackoverflow.com/q/78212759
type: Tag
tags question: http://stackoverflow.com/q/78167734
tags question: http://stackoverflow.com/q/78178153
tag name: arrays
tags question: http://stackoverflow.com/q/78158123
tags question: http://stackoverflow.com/q/78241899
tags question: http://stackoverflow.com/q/78263189
tags question: http://stackoverflow.com/q/78427584
tags question: http://stackoverflow.com/q/78442690
tags question: http://stackoverflow.com/q/78319248
tags question: http://stackoverflow.com/q/78400075
tags question: http://stackoverflow.com/q/78358550
tags question: http://stackoverflow.com/q/78583045
tags question: http://stackoverflow.com/q/78562095
tags question: http://stackoverflow.com/q/78514302
tags question: http://stackoverflow.com/q/78528580
tags question: http://stackoverflow.com/q/78557294
tags question: http://stackoverflow.com/q/78707385
tags question: http://stackoverflow.com/q/78691133
tags question: http://stackoverflow.com/q/78591583
tags question: http://stackoverflow.com/q/78608644
tags question: http://stackoverflow.com/q/78829031
tags question: http://stackoverflow.com/q/78839494
tags question: http://stackoverflow.com/q/78754984
tags question: http://stackoverflow.com/q/78820603
tags question: http://stackoverflow.com/q/79043350
tags question: http://stackoverflow.com/q/79102631
tags question: http://stackoverflow.com/q/79151092
tags question: http://stackoverflow.com/q/79395000
tags question: http://stackoverflow.com/q/79333985
tags question: http://stackoverflow.com/q/79299247
tags question: http://stackoverflow.com/q/79320464
tags question: http://stackoverflow.com/q/79415857
tags question: http://stackoverflow.com/q/79440348
tags question: http://stackoverflow.com/q/79524158
tags question: http://stackoverflow.com/q/79526480
tags question: http://stackoverflow.com/q/79452603
tags question: http://stackoverflow.com/q/79465414

http://stackoverflow.com/a/78292830
has comment: http://stackoverflow.com/comment/138029807
has comment: http://stackoverflow.com/comment/138027999
score: 0
has body: You cannot mount files from one container to another. As you note in the question, the Docker daemon resolves bind-mount paths, and they are directories on the host system, not in the context that's invoking Docker. (In complex environments with remote Docker daemons or a Docker-in-Docker container, the bind mount is in the context where the Docker daemon is running and not necessarily the local system.) it grabs files from /input folder and returns results.json to the /output folder Programs that principally read and write local files are much easier to run as local processes. A Docker container has an isolated filesystem, and you wind up having to do some potentially complex setup (including making user IDs match) to be able to work with local files. If it's possible for you to just run this as a subprocess, this will be vastly easier. You'd need to install the runner tool in your Web application's Dockerfile, but then you'd invoke it the same way you invoked any other subprocess (like this shell script). # without doing anything Docker-related at all "$Exercise" /input /output Otherwise you need some sort of shared storage between the application container and the runner container(s). A host directory or a Docker named volume will both work. I might pass this location in an environment variable, since it can very readily depend on the specific deployment environment. Since you're passing paths as command-line options to the runner program, I'd mount the entire shared storage, and pass a subpath on the command line. A basic example using a named volume could look like: docker volume create shared docker run -v shared:/shared ... web_app Your Web application would then write data to /shared/input/$SOLUTION_ID, and create an empty /shared/output/$SOLUTION_ID directory. When it launched the runner container, it would look like #!/bin/sh RunnerImage="$1" SharedVolume="$2" Exercise="$3" SolutionID="$4" exec docker run \ --rm \ -v "$SharedVolume:/shared" \ --net none \ …
answers question: http://stackoverflow.com/q/78292636
has comment: http://stackoverflow.com/comment/138039373
type: Answer
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78292636

http://stackoverflow.com/comment/138029064
type: AnswerComment
comment on: http://stackoverflow.com/a/78293679
has text: Thanks! That's correct! Now everything works fine.
score: 0
type: Comment

http://stackoverflow.com/q/78270350
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137988203
linked to: http://stackoverflow.com/q/2005192
has body: I'm a beginner in Bash scripting. I'm using Kali Linux. I wrote a bash file. It's supposed to ask for user input to fill in every single parameter of the command and then at the end, it will echo out the full command, that it intends to execute, in simple text form, and then execute that exact command with all the given information (The command that it's supposed to execute in the end is "find"). Everything works fine except for the last part where it's supposed to execute the "find" command. This is an example: find '/home/kali/Desktop' -type f -user 'kali' -iname 'this text file.txt' I copied this line and executed it from the terminal directly with all the same arguments and it worked, but when I indirectly executed it through the Bash file, it didn't work. And it kept saying "find: ‘'kali'’ is not the name of a known user". find '/home/kali/Desktop' -type f -user kali -iname 'this text file.txt' When I removed the quotes around the word "kali", it gave me this as output: "find: paths must precede expression: `text'" I tried using "sh" and "bash" followed by the file's name as parameter in the terminal like this: sh <filename> bash <filename> and it still didn't work. I even tried changing the shebang from #!/usr/bin/env bash to #!/bin/bash, but it still didn't work. Here's the full code of the bash script that I wrote: #!/bin/bash true_path="" find_type="" all_types=("f" "d" "l" "c" "b" "p") find_name="" find_user="" find_group="" declare -A byte_math keys=("c" "w" "b" "k" "M" "G") values=(1 2 512 1024 1048576 1073741824) for ((i = 0; i < ${#keys[@]}; i++)); do byte_math["${keys[i]}"]="${values[i]}" done all_units=("c" "w" "b" "k" "M" "G") lower_limit_size_in_bytes="" upper_limit_size_in_bytes="" find_size_ll="" find_size_ul="" function step1 () { # Asking for the path read -p " Where do you want to search? (enter path): /home/kali/" path if ! [[ -d "/home/kali/${path}" ]]; then echo " Invalid directory path. Try Again." path="" step1 return 0 fi true_path+="'/h…
tagged with: kali-linux
linked to: http://stackoverflow.com/q/12136948
has comment: http://stackoverflow.com/comment/137988204
has comment: http://stackoverflow.com/comment/137988439
type: Question
has comment: http://stackoverflow.com/comment/137988456
duplicate of: http://stackoverflow.com/q/2005192
has comment: http://stackoverflow.com/comment/137989139
has comment: http://stackoverflow.com/comment/137988655
has title: How come the 'find' command works correctly in the terminal but not when run from a bash file?
has comment: http://stackoverflow.com/comment/137988209
has comment: http://stackoverflow.com/comment/137988177
score: 0
answer count: 0
tagged with: linux

http://stackoverflow.com/q/78221728
has comment: http://stackoverflow.com/comment/137903377
accepted answer: http://stackoverflow.com/a/78221751
score: 0
type: Question
has answer: http://stackoverflow.com/a/78221751
has title: Using watch with multi line command
tagged with: bash
has body: This bash loop works fine. for x in a b c do echo &quot;$x has `ls file_${x} 2&gt;/dev/null | wc -l`&quot; done Request to embed it into a 'watch' repeat loop. Try#1 fails watch --interval 30 for x in a b c do echo &quot;$x has `ls file_${x} 2&gt;/dev/null | wc -l`&quot; done Try#2 fails watch --interval 30 ( for x in a b c do echo &quot;$x has `ls file_${x} 2&gt;/dev/null | wc -l`&quot; done )
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137902883

http://stackoverflow.com/comment/137875039
comment on: http://stackoverflow.com/a/78203898
type: Comment
score: 0
has text: @jhnc its my first time hearing of that, thanks for the link!
type: AnswerComment

http://stackoverflow.com/comment/137921646
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78226551
score: 0
has text: Thanks for replying. At least to me, the »*And I dont know why!*« sounded like »*I am convinced this should work, but it doesn't. I cannot see my error.*«. I think in situations where you have absolutely no clue, it is better to say so, instead of posting a possibly misleading "attempt". It should be clear that chatGPT sometimes generates unusable nonsene -- but if you give that nonsense credibility by (accidentally) making it look like a serious attempt, you are wasting everyone's time.

alias
tag name: alias
tags question: http://stackoverflow.com/q/78182030
tags question: http://stackoverflow.com/q/78146600
tags question: http://stackoverflow.com/q/78232787
type: Tag
tags question: http://stackoverflow.com/q/78515934
tags question: http://stackoverflow.com/q/78842937
tags question: http://stackoverflow.com/q/78831953
tags question: http://stackoverflow.com/q/78967238
tags question: http://stackoverflow.com/q/78942549
tags question: http://stackoverflow.com/q/79139867
tags question: http://stackoverflow.com/q/79116998
tags question: http://stackoverflow.com/q/79526397
tags question: http://stackoverflow.com/q/79494833

http://stackoverflow.com/a/78204513
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78202378
has body: One possible solution with python xml.etree.ELementTree. You find the documentation here. import xml.etree.ElementTree as ET xml_str = """ 82508 <Title>Product Title description Price Each An Order 250-499 250 499 1.09 Price Each An Order 500-999 500 999 0.95 Price Each An Order 1000-2499 1000 2499 0.93 Price Each An Order 2500-4999 2500 4999 0.87 Price Each An Order 5000 5000 0.84 Price Each A Quote 0.00 Price Each A Sample 1 1 1 0.00 """ root = ET.fromstring(xml_str) val_list = ['ProductOption','PurchaseOption','Quantity'] for elem in root.findall('.//Variation'): sku_tex = [] sku = ET.Element('Sku') elem.append(sku) for item in elem.iter(): if item.tag in val_list and item.text is not None: el = item.text.lower().replace(' ','-')+'-' sku_tex.append(el) sku.text = ''.join(sku_tex).rstrip('-') tree = ET.ElementTree(root) ET.indent(tree, space=' ') ET.dump(tree)

http://stackoverflow.com/comment/137822090
type: Comment
comment on: http://stackoverflow.com/a/78175961
type: AnswerComment
has text: I have not tried to implement this as another answer regarding the npm json package has already solved the problem. Thank you!
score: 0

http://stackoverflow.com/comment/137865677
score: 0
comment on: http://stackoverflow.com/q/78200978
type: QuestionComment
type: Comment
has text: @F.Hauri-GiveUpGitHub I'm not saying it can't be done with an array, just that it's simpler with `sed`. So unless this is an assignment about working with arrays, it seems like an unnecessarily complicated way to do it.

http://stackoverflow.com/comment/137995589
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78274285
has text: Handling general CSV files is surprisingly tricky. See [How to parse a CSV in a Bash script?](https://stackoverflow.com/q/1560393/4154375) for some good ways (and some bad ways, be careful) to do it. For instance, `csvtool -u ';' ...` will do what you want 100% reliably for *any* CSV file.
type: QuestionComment

http://stackoverflow.com/q/78219094
answer count: 1
has comment: http://stackoverflow.com/comment/137900950
has answer: http://stackoverflow.com/a/78220527
has body: Bashversion: 4.2.46 OS: linux 3.10.0-1160.108.1.e17 the following command with with printf shall provide three columns with 10 Characters. Running this only in bash all works fine. $ free -h | grep Mem | awk '{printf "%-10s %-10s %-10slala\n",$2,$3,$4}' 7.6G 2.0G 3.4G lala Using a variable to do so, the format will be lost. $ LINE=$(free -h | grep Mem | awk '{printf "%-10s %-10s %-10s\n",$2,$3,$4}') $ echo $LINE 7.6G 2.0G 3.4G Where go I wrong? I'm apreciate to get advise from experts Thank youe F. I've tried this so far: $ LINE=$(free -h | grep Mem | awk '{printf "%-10s %-10s %-10s\n",$2,$3,$4}') $ LINE=`free -h | grep Mem | awk '{printf "%-10s %-10s %-10s\n",$2,$3,$4}'` $ LINE=${free -h | grep Mem | awk '{printf "%-10s %-10s %-10s\n",$2,$3,$4}'}
has comment: http://stackoverflow.com/comment/137900918
score: 0
type: Question
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/29378566
linked to: http://stackoverflow.com/q/29378566
tagged with: format
tagged with: printf
has title: command in bash contains printf but the format is not hand over to variable
tagged with: bash

http://stackoverflow.com/q/78146405
type: AnsweredQuestion
tagged with: variables
tagged with: global-variables
tagged with: bash
has comment: http://stackoverflow.com/comment/137769478
type: Question
has comment: http://stackoverflow.com/comment/137770872
has body: I have been trying to learn loops, and I have the following: Guessing_Game() { echo "Guessing Game!" set loopSwitch = 0 until $loopSwitch == 1 ; echo $loopSwitch do read -p "Guess a number between 1 and 10: " userGuess if $userGuess == 6 ; then echo "Well done! You win." else echo "Incorrect guess." fi read -p "Would you like to play again? (y/n)" playAgain if $playAgain == "n" ; then set loopSwitch = 1 fi done } From what I have read, as the loopSwitch variable was set outside of the subshell, it can only change the value within that subshell? How can I go about setting the loopSwitch variable so that I can exit the loop? I have tried echoing out the variable $loopSwitch through several portions of the code - just after the entry into the until loop, inside the last if statement - and nothing is output, so I'm thinking it just doesn't exist within the until loop? For the set loopSwitch = 1 portion, I've tried: set loopSwitch = 1 set $loopSwitch = 1 loopSwitch = 1 $loopSwitch = 1 Any help would be appreciated, whether that be with the code or constructs as a whole.
has comment: http://stackoverflow.com/comment/137769325
has comment: http://stackoverflow.com/comment/137769573
tagged with: until-loop
has answer: http://stackoverflow.com/a/78147252
answer count: 1
accepted answer: http://stackoverflow.com/a/78147252
score: 0
has comment: http://stackoverflow.com/comment/137769509
has title: How to set parent variable within a loop in a shell script?
tagged with: shell
has comment: http://stackoverflow.com/comment/137769397
has comment: http://stackoverflow.com/comment/137769527

http://stackoverflow.com/comment/137782300
comment on: http://stackoverflow.com/q/78151708
score: 0
type: Comment
has text: What is the format of your input files? Do they contain a mix of binary and plain text content? Is there a consistent line (or record) separator?
type: QuestionComment

http://stackoverflow.com/comment/138005632
type: AnswerComment
comment on: http://stackoverflow.com/a/78278695
has text: @beautifulsouper could you please provide additional info on your environment (unix/linux distro, shell version, terminal, GUI app in which pasting the copied text) ?
score: 0
type: Comment

http://stackoverflow.com/comment/137938910
type: Comment
score: 0
type: AnswerComment
has text: actually his answer didn't work because `equery` defaults to writing something entirely different when fed to a pipe unless `-N` is given, but even with, output gets garbled
comment on: http://stackoverflow.com/a/78241862

http://stackoverflow.com/comment/137872247
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78202886
score: 0
has text: Glad it worked. Also, I have modified the link. You can check again.

http://stackoverflow.com/comment/137884567
has text: Can't reproduce that behavior here on Ubuntu 22.04. Make sure you send the signal to the shell only, not the process group it belongs.
type: Comment
comment on: http://stackoverflow.com/a/78211545
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137998875
comment on: http://stackoverflow.com/q/78272610
has text: @pjh: That is a totally different question.
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/a/78183161
upvote count: 5
has body: Why is this? As Keith Thompson commented, typically malloc calls brk or sbrk expanding process memory, but free only makes "marks" the memory within malloc to be reused within the same process. is there a way to free the memory without exiting bash? You can write a Bash built-in that will call malloc_trim() (and also could call mallopt with M_TRIM_THRESHOLD to decrease the threshold to release the memory), compile that built-in and call it within Bash shell. Why doesn't bash free memory up from unnamed variables once it's done with them? I think it is typical that memory allocation for a process is greedy. Once a process receives some memory, they wouldn't want to release it, for two reasons - the "act" of allocating the memory for the process is CPU consuming and the process is not sure if it will receive the memory again after releasing. Bottom line memory allocation algorithms prefer to keep the memory once they receive it. The following malloc_trim.c Bash builtin source code: #include <config.h> #include <loadables.h> #include <malloc.h> #include <stdio.h> int malloc_trim_builtin(WORD_LIST *list) { int ret1 = malloc_trim(0); int ret2 = mallopt(M_TRIM_THRESHOLD, 0); printf("malloc_trim=%d mallopt=%d\n", ret1, ret2); return 0; } char *malloc_trim_doc[] = {"Short AA AA description.", (char *)NULL}; struct builtin malloc_trim_struct = { "malloc_trim", /* builtin name */ malloc_trim_builtin, /* function implementing the builtin */ BUILTIN_ENABLED, /* initial flags for builtin */ malloc_trim_doc, /* array of long documentation strings. */ "malloc_trim", /* usage synopsis; becomes short_doc */ 0 /* reserved for internal use */ }; Can be compiled with: gcc $(pkg-config --cflags bash) -I/usr/lib/bash -shared -o malloc_trim.o ./malloc_trim.c After compilation, the following shell transcript is possible: $ ps -p $$ -o %mem %MEM 0.0 $ echo $(head -c50M /dev/urandom) > /dev/null # null byte bla bla $ ps -p $$ -o %mem %MEM 0.6 $ enable -f ./malloc_trim.o malloc_trim $ malloc_…
type: Answer
answers question: http://stackoverflow.com/q/78182867
score: 5
downvote count: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78182867

http://stackoverflow.com/a/78245181
accepted answer of: http://stackoverflow.com/q/78244372
type: Answer
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137949310
has body: One way to do what you want is to read the code into a Bash variable and use the -c option to run it with Python. Try this Shellcheck-clean Bash code: #! /bin/bash -p python_code=$(< main.py) for size in 1 2 4 8 16; do python -c "$python_code" "$size" done See the command substitution section of the Bash Reference Manual for an explanation of $(< main.py). This will not work if main.py contains binary data, particularly NUL characters (ASCII 0). That is because Bash variables cannot hold NUL characters. I replaced the variable SIZE with size because ALL_UPPERCASE variable names are best avoided since there is a danger of clashes with the large number of special ALL_UPPERCASE variables that are used in shell programming. See Correct Bash and shell script variable capitalization. See the When Should You Quote? section of Quotes - Greg's Wiki for an explanation of why I used quotes on both of the variable expansions. (The critical thing to know is that $var without quotes often does not expand to the string contained in the variable var. "$var" always does.)
answers question: http://stackoverflow.com/q/78244372
has comment: http://stackoverflow.com/comment/137949635

http://stackoverflow.com/a/78299587
type: Answer
score: 1
upvote count: 1
has body: I don't quite understand how secrecy attaches to the value ENV_VAR though its being set from an include-ed file, but the make-time choice to set ENV and ENV_VAR to their dev values or their test values can be made depending on whether the make target is dev_setup or test_setup. Obviously they are mutually exclusive targets and I suppose dev_setup can be the default. $ cat Makefile target := $(MAKECMDGOALS) ifeq (,$(target)) target := dev_setup endif ifeq (dev_setup,$(target)) include config_dev.env export ENV := dev else ifeq (test_setup,$(target)) include config_test.env export ENV := test else $(error Choose one target: dev_setup (default) or test_setup) endif endif export ENV_VAR:=$(secret_env_var) .PHONY: setup dev_setup test_setup $(target): setup @echo $(target) done setup: @python3 -c "import os;print('ENV =', os.getenv('ENV'));print('ENV_VAR =', os.getenv('ENV_VAR'))" @echo Setup done. $ cat config_dev.env secret_env_var=dev_setup_secret $ cat config_test.env secret_env_var=test_setup_secret $ make ENV = dev ENV_VAR = dev_setup_secret Setup done. dev_setup done $ make dev_setup ENV = dev ENV_VAR = dev_setup_secret Setup done. dev_setup done $ make test_setup ENV = test ENV_VAR = test_setup_secret Setup done. test_setup done $ make test_setup dev_setup Makefile:14: *** Choose one target: dev_setup (default) or test_setup. Stop. GNU Make manual references:- 7.2 Syntax of Conditionals 9.2 Arguments to Specify the Goals
answers question: http://stackoverflow.com/q/78298728
downvote count: 0

http://stackoverflow.com/comment/137857870
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78193436
has text: @dawg right but the OP is on linux so probably using GNU tools and can let us know if not.

http://stackoverflow.com/comment/137855300
comment on: http://stackoverflow.com/q/78194991
score: 1
has text: Sounds like your script does `set -m` (or otherwise enables job control), starts a background process, and then your function kills it. Here's an easier way to reproduce the error: `bash -c 'set -m; sleep 30 & kill -9 %1; wait'`.
type: QuestionComment
type: Comment

signals
type: Tag
tags question: http://stackoverflow.com/q/78226499
tag name: signals
tags question: http://stackoverflow.com/q/78724459
tags question: http://stackoverflow.com/q/78690427
tags question: http://stackoverflow.com/q/79365247
tags question: http://stackoverflow.com/q/79423600
tags question: http://stackoverflow.com/q/79441402

http://stackoverflow.com/comment/137876852
has text: @pjh I like that find trick with `//`. should have realised the question is a duplicate
score: 0
comment on: http://stackoverflow.com/a/78204135
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137886350
score: 0
has text: If you look at the question again, you will see the whole file. I got it to work.
comment on: http://stackoverflow.com/a/78211596
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137770095
has text: Can't use compgen or any other external inside my CI. ANy other idea?
score: 0
comment on: http://stackoverflow.com/a/78146818
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78181239
tagged with: bash
has comment: http://stackoverflow.com/comment/137830659
favorite count: 0
has comment: http://stackoverflow.com/comment/137830640
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137831493
has title: Understanding and control of sqlite version loaded
type: Question
tagged with: sqlite
downvote count: 0
score: 1
answer count: 1
has answer: http://stackoverflow.com/a/78183157
upvote count: 1
accepted answer: http://stackoverflow.com/a/78183157
tagged with: batch-file
has body: Interactively I more or less know what sqlite3 I'm getting but in a bash batch script it seems I have no hope! Interactive bash session $ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS:sbin:/opt/local/bin:/opt/local/sbin $ alias -p |grep sql alias sqlite3='/usr/local/Cellar/sqlite/3.44.2/bin/sqlite3' $ which sqlite3 /usr/bin/sqlite3 $ `which sqlite3` -version 3.8.10.2 2015-05-20 18:17:19 2ef4f3a5b1d1d0c4338f8243d40a2452cc1f7fe4 $ sqlite3 -version 3.44.2 2023-11-24 11:41:44 ebead0e7230cd33bcec9f95d2183069565b9e709bf745c9b5db65cc0cbf92c0f (64-bit) which shows builtin /usr/bin/sqlite3 which is designed to search just the path and ignores functions and alias effects? Plain invocation gets the much later brew installed version, as wanted. In batch files I have the same PATH and alias in bash shell runs but always get the built in 3.8 version unless I do some specific call to /usr/local/Cellar/sqlite/3.44.2/bin/sqlite3 In particular the PATH and alias do not seem to help, neither did a function if I defined at the start of the batch file. $ cat test #!/bin/bash export alias sqlite3='/usr/local/Cellar/sqlite/3.44.2/bin/sqlite3' /usr/local/Cellar/sqlite/3.44.2/bin/sqlite3 -version printenv echo ===================== echo export -p echo ===================== echo sqlite3 -version exit /b 0 Produces 3.44.2 2023-11-24 11:41:44 ebead0e7230cd33bcec9f95d2183069565b9e709bf745c9b5db65cc0cbf92c0f (64-bit) <snip> PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS:sbin:/opt/local/bin:/opt/local/sbin <snip> declare -x sqlite3="/usr/local/Cellar/sqlite/3.44.2/bin/sqlite3" ===================== 3.8.10.2 2015-05-20 18:17:19 2ef4f3a5b1d1d0c4338f8243d40a2452cc1f7fe4 ./test: line 12: exit: /b: numeric argument required What am I missing about use in batch scripts, please?? I don't want to resort to links etc, just tell this batch file to use the new version, someh…

http://stackoverflow.com/q/78261175
score: 0
tagged with: continuous-deployment
type: Question
has title: Loop through secrets in a devops pipeline
has answer: http://stackoverflow.com/a/78266042
answer count: 1
tagged with: bash
tagged with: azure-pipelines
type: AnsweredQuestion
has body: I'm building a pipeline to deploy a web app and migrate some tenant databases. I've got variables defined in my library which pull secrets in from keyvault. If I enable diagnostic logging on the pipeline I can see output like ##[debug]Promise for downloading secret value for: Test1 Downloading secret value for: Test1. ##[debug]Promise for downloading secret value for: Test2 Downloading secret value for: Test2. ##[debug]Promise for downloading secret value for: DATABASE-URL-FOO-TEST Downloading secret value for: DATABASE-URL-FOO-TEST. ##[debug]Promise for downloading secret value for: DATABASE-URL-FOO-TEST-ALT Downloading secret value for: DATABASE-URL-FOO-TEST-ALT. ... ##[debug]set DATABASE-URL-FOO-TEST-ALT=******** ##[debug]Processed: ##vso[task.setvariable variable=DATABASE-URL-FOO-TEST-ALT;isOutput=false;issecret=true;]*** ##[debug]set DATABASE-URL-FOO-TEST-ALT=******** ##[debug]Processed: ##vso[task.setvariable variable=DATABASE-URL-FOO-TEST-ALT;isOutput=false;issecret=true;]*** ##[debug]set Test2=******** ##[debug]Processed: ##vso[task.setvariable variable=Test2;isOutput=false;issecret=true;]*** ##[debug]set Test2=******** Now what I'd really like to do is for in over all the variables starting DATABASE-URL- and pass that URL to my migration script. I've tried a few things but I can't seem to find my variables in the environment. This bash task gives me no output from the for loops. - task: Bash@3 inputs: targetType: 'inline' script: | echo "all vars" for var in "${!variable@}"; do echo "$var=${!var}" done for key in "${!VAR[@]}"; do echo "$key" if $key == SECRET_DATABASE-URL* ; then DB_URL=${!VAR[$key]} echo "$DB_URL" DB_URL=${!VAR[$key]} ./bin/migrate-databases.sh fi done In the diagnostic output from that task I can see lines like ##[debug]loading SECRET_DATABASE-URL-FOO-TEST-ALT ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN ##[debug]loading SECRET_TEST2 ##[debug]loading SECRET_DATABASE-URL-FOO-TEST ##[debug]loading SECRET_TEST1 so it looks like they're be…
tagged with: azure-keyvault
accepted answer: http://stackoverflow.com/a/78266042

http://stackoverflow.com/comment/137826044
comment on: http://stackoverflow.com/q/78178759
score: 1
has text: Add `exit $_exitcode` at the end of your script to exit gdb with the exit code of the program.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137826669
comment on: http://stackoverflow.com/q/78178759
has text: @oguzismail phuuu I thought about that and found it more difficult to retrieve the core dump as an artifact from my gitlab runners (in an automated way) than to just read the console output.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137801796
type: Comment
comment on: http://stackoverflow.com/a/78164681
type: AnswerComment
has text: Thanks a lot, this is what I needed, I'll just change it a bit to run on windows but otherwise perfect!
score: 0

http://stackoverflow.com/comment/137911766
comment on: http://stackoverflow.com/q/78226499
score: 1
type: QuestionComment
type: Comment
has text: (btw, my close vote was cast back before you replaced the images with text -- my apologies for not getting it retracted; should have reversed it as soon as I saw you'd made the question self-contained and clearly about code as opposed to about shell/terminal behavior)

http://stackoverflow.com/q/78212759
has comment: http://stackoverflow.com/comment/137887258
type: UnansweredQuestion
tagged with: bash
has title: How to separate an array from a command using quotes instead of spaces in bash
has comment: http://stackoverflow.com/comment/137886604
favorite count: 0
has comment: http://stackoverflow.com/comment/137886737
downvote count: 1
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/137886595
tagged with: string
has comment: http://stackoverflow.com/comment/137886692
tagged with: arrays
has comment: http://stackoverflow.com/comment/137886641
has body: I am currently writing a Bash script to search through a JSONL file of Mario Maker level data (found in this Reddit post https://www.reddit.com/r/MarioMaker/comments/wlkwp9/easily_searchable_database_of_super_mario_maker_1/) and print the level id, name of the course, and name of the creator. I am however running into a problem when trying to print all this found information out, as the arrays I'm getting are separated using spaces in the course names instead of new lines or quotes. Below is my current code, the Python script used to convert the id's to in-game id's, and a single entry in the JSONL file (it's over 16gb of raw text) Bash script: #!/bin/bash ids=$(grep $1 /path/to/file/courses.jsonl | awk -F ',' '{print $1}' | awk -F ':' '{print $2}') cns=$(grep $1 /path/to/file/courses.jsonl | awk -F ',' '{print $5}' | awk -F ':' '{print $2}') crs=$(grep $1 /path/to/file/courses.jsonl | awk -F ',' '{print $7}' | awk -F ':' '{print $2}') for id in $ids; do idn=$(python3 /path/to/file/mmid.py $id) ida+=($idn) done for i in "${!ida[@]}"; do printf "ID: %s\n" "${ida[i]}" printf "Course Name: %s\n" "${cns[i]}" printf "Creator Name: %s\n" "${crs[i]}" printf "\n" done Python Script (code mostly taken from the above Reddit thread) import struct import hashlib import hmac import sys idno = int(sys.argv[1]) key = hashlib.md5(b"9f2b4678").digest() data = struct.pack("<Q", idno) checksum = hmac.HMAC(key, data, 'md5').digest() checksum = checksum[3:1:-1].hex().upper() idstring = str.upper(hex(idno))[2:] for y in range(8 - len(idstring)): idstring = '0' + str(idstring) code = str(checksum) + '0000' + str(idstring) print(code) Example Entry from courses.jsonl {"id":66782542,"retrieval_date":"2021-06-02T02:40:10.837452Z","url":"https://d2sno3mhmk1ekx.cloudfront.net/10.WUP_AMAJ_datastore/ds/1/data/00066782542-00001?Expires=1625193610&Signature=vh50sqvoN2u-Xu~uT2pYJMNzj1kV11NDt77BDC2UM5o9VtTz-3HNxheiWc~PxDJhCqDNL-M7u9qrFnQ6FkOxDTyzo3QrK1VcNDqoAFRKA2RL03au-FdN9daY4~CDeKS3TvEkpzqBGe9fZf…
has answer: http://stackoverflow.com/a/78212787
has comment: http://stackoverflow.com/comment/137886776
upvote count: 1
has answer: http://stackoverflow.com/a/78214419
has comment: http://stackoverflow.com/comment/137886811
has comment: http://stackoverflow.com/comment/137886629
score: 0
answer count: 2
type: Question

http://stackoverflow.com/comment/137982703
type: QuestionComment
type: Comment
score: 0
has text: Depending on what terminal you are using, you could also save the screen content before your program runs, then clear **everything** visible afterwards, and finally **restore** the screen content. This approach has been discussed [here](https://stackoverflow.com/questions/33929816/save-and-restore-terminal-content).
comment on: http://stackoverflow.com/q/78261786

http://stackoverflow.com/q/78183119
duplicate of: http://stackoverflow.com/q/11079342
has body: Im a newbie in bash, how can i make a script where the user will give code like expr 1 + 1 and the bash script will take the input and make it run like a code the output will also be shown in the terminal like echo "give your expresiion" read response run $response echo return run output
has comment: http://stackoverflow.com/comment/137833911
score: 0
type: Question
answer count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/11079342
has title: Bash User input taken and run it as showsing it output to terminal
has comment: http://stackoverflow.com/comment/137833868
tagged with: bash
has comment: http://stackoverflow.com/comment/137833874

http://stackoverflow.com/comment/137777545
comment on: http://stackoverflow.com/q/78150653
has text: Agreed! Unfortunately, it is a 3rd party vendor with a binary file. :( They are the cheapest vendor by at least 4 times. As a result, this is what I have to work with.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137864404
comment on: http://stackoverflow.com/q/78199979
type: QuestionComment
type: Comment
score: 0
has text: Having 1 variable named `dest_dir` and another named `destination_dir` could get confusing and make it easy to introduce bugs. What you're currently calling `dest_dir` looks like it might be better named `base_dir` or similar as it seems to be the base for the directories you're copying from and to.

http://stackoverflow.com/comment/137822050
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78176347
has text: do you have any suggestion on how i would change it altogether? i tried awk '$1 -ge 200 && $8 -le 400 && $8 != 0 {print}' numbers.txt and it didnt work Im just starting at this so any suggestions would help my understanding of it
type: QuestionComment

at-job
type: Tag
tags question: http://stackoverflow.com/q/78156630
tag name: at-job
tags question: http://stackoverflow.com/q/79151673

http://stackoverflow.com/comment/137791467
has text: Do a _man bash_ and search for `<<<`. The first hit will be a small section titled _Here Strings_ which explains everything about this operator.
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78158852

http://stackoverflow.com/a/78262545
answers question: http://stackoverflow.com/q/78261247
downvote count: 0
score: 1
type: Answer
has body: I would harness GNU AWK for this task following way, let file.txt content be >Cluster 199 0 2599aa, >CAD5117741.1... * >Cluster 200 0 2579aa, >CAD5112262.1... * >Cluster 201 0 2578aa, >CAD5116287.1... * >Cluster 202 0 2578aa, >CAD5122864.1... * 1 1867aa, >CAD5122865.1... at 100.00% 2 2369aa, >CAD5122866.1... at 100.00% >Cluster 203 0 2573aa, >CAD5110750.1... * >Cluster 204 0 2571aa, >CAD5116249.1... * >Cluster 205 0 2558aa, >CAD5122682.1... * >Cluster 206 0 2553aa, >CAD5126525.1... * >Cluster 207 0 2551aa, >CAD5115834.1... * then awk 'BEGIN{RS=">Cluster";ORS="";FS="\n"}NF>3{print RS $0}' file.txt gives output >Cluster 202 0 2578aa, >CAD5122864.1... * 1 1867aa, >CAD5122865.1... at 100.00% 2 2369aa, >CAD5122866.1... at 100.00% Explanation: I inform GNU AWK to use >Cluster as row separator, use empty string as output row separator and use newline as field separator. Then for rows (cluster block) with more than 3 fields I print that block, I need to prefix it with row separator as it is not part of row. It is >3 because single-line block has 3 fields: cluster number, line and empty field after trailing newline. (tested in GNU Awk 5.1.0)
upvote count: 1

http://stackoverflow.com/comment/137788494
type: Comment
score: 0
type: QuestionComment
has text: Only the current files? Or even deleted files?
comment on: http://stackoverflow.com/q/78157184

post
tag name: post
tags question: http://stackoverflow.com/q/78161552
type: Tag
tags question: http://stackoverflow.com/q/78530810

http://stackoverflow.com/a/78193436
has comment: http://stackoverflow.com/comment/137856632
has comment: http://stackoverflow.com/comment/137852542
has comment: http://stackoverflow.com/comment/137852527
answers question: http://stackoverflow.com/q/78193259
has body: $ echo '|Type|Value|Adicional Resources|'; echo '|foo|bar|whatever|' |Type|Value|Adicional Resources| |foo|bar|whatever| $ { echo '|Type|Value|Adicional Resources|'; echo '|foo|bar|whatever|'; } | column -s'|' -o ' | ' -t | Type | Value | Adicional Resources | foo | bar | whatever Note the missing | at the end of each line in the column output above, here's the fix for that: $ { echo '|Type|Value|Adicional Resources| '; echo '|foo|bar|whatever| '; } | column -s'|' -o ' | ' -t | Type | Value | Adicional Resources | | foo | bar | whatever | Note the extra blank I added after the final | on each echoed line above to force column to add the trailing |, otherwise it wouldn't print that nor, more importantly, the padding blanks after the final data value before it on each line. $ { echo '|Type|Value|Adicional Resources| '; echo '|foo|bar|whatever| '; } | column -s'|' -o ' | ' -t | awk ' { gsub(/^ +| +$/,"") } NR == 1 { line=$0; gsub(/[^|]/,"-",line); gsub(/[|]/,"+",line) } NR < 3 { print line } { print } END { print line } ' +------+-------+---------------------+ | Type | Value | Adicional Resources | +------+-------+---------------------+ | foo | bar | whatever | +------+-------+---------------------+ If you don't have column you could always do it all in awk, e.g. given this input: $ cat file Type|Value|Adicional Resources foo|bar|whatever here's a solution using any awk reading the input file twice (so will work for input from any size of file but won't work for input coming from a pipe): $ cat tst.awk BEGIN { FS="|" } NR == FNR { for ( i=1; i<=NF; i++ ) { wid = length($i) + 2 wids[i] = (wid > wids[i] ? wid : wids[i]) } next } FNR == 1 { line = "+" for ( i=1; i<=NF; i++ ) { line = line sprintf("%*s",wids[i],"") "+" } gsub(/ /,"-",line) print line } { out = FS for ( i=1; i<=NF; i++ ) { out = out sprintf("%-*s",wids[i]," "$i) FS } print out } FNR == 1 { print line } END { print line } $ awk -f tst.awk file file +------+-------+---------------------+ | Type | Value | Adic…
score: 4
has comment: http://stackoverflow.com/comment/137857870
has comment: http://stackoverflow.com/comment/137863320
upvote count: 4
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/137863604

http://stackoverflow.com/comment/137938662
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78241429
has text: @pjh Unfortunately the recursive function method is inefficient since it doesn't exec(3) the pipe subshell. For every recursion you have an unnecessary subshell running just waiting for its own child process subshell pipe to close. It's what kept me from answering it. `lastpipe` might help but I'm not sure if it can be safely used recursively. Plus it requires job control to be inactive. While job control is always disabled and isn't always necessary in a script, it's still something to consider.

http://stackoverflow.com/comment/138028968
has text: Did you try using `grep` by hand to see what the output is?
score: 0
comment on: http://stackoverflow.com/q/78293635
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78196374
tagged with: bash
type: Question
has body: I'm trying to prefix console outputs, while truncating long string outputs to a maximum of 60 characters. (Preventing long lines from bleeding over and breaking the prefix) How come... esc=$(printf '\033') sudo apt upgrade 2>&1 >&1 | sed -e "s/.\{0,60\}/${esc}[35m║ &\n/g" ...is appending a new (un-prefixed) line below each dump of the hold space? How can I stop this behavior, or at least append a prefix to it? Output: ║ ║ WARNING: apt does not have a stable CLI interface. Use with ║ caution in scripts. ║ ║ Reading package lists... ║ Building dependency tree... ║ Reading state information... ║ Calculating upgrade... ║ 0 upgraded, 0 newly installed, 0 to remove and 0 not upgrade ║ d. ║
has title: Truncating "wrapping" long string outputs with prefix, appends new line at the bottom of each dump of the hold space
possible better answer: http://stackoverflow.com/a/78196849
type: AnsweredQuestion
tagged with: sed
has answer: http://stackoverflow.com/a/78196477
has comment: http://stackoverflow.com/comment/137858097
score: 0
has comment: http://stackoverflow.com/comment/137865928
has comment: http://stackoverflow.com/comment/137857736
has comment: http://stackoverflow.com/comment/137857724
has answer: http://stackoverflow.com/a/78196849
accepted answer: http://stackoverflow.com/a/78196477
answer count: 2
has comment: http://stackoverflow.com/comment/137865158
tagged with: trailing-newline
has comment: http://stackoverflow.com/comment/137866405

http://stackoverflow.com/comment/137998939
score: 0
type: QuestionComment
has text: Just write your script in zsh?
type: Comment
comment on: http://stackoverflow.com/q/78274299

http://stackoverflow.com/q/78161552
score: -1
type: Question
tagged with: post
tagged with: curl
tagged with: bash
has body: I'm trying to create a POST request in a .sh file that posts some json stored in a variable. After the POST it should store the response of the post for me to check via echo. I'm doing this in a pipeline that's using curl 7.81.0. When I run the code I get: Usage: curl [options...] Invalid category provided, here is a list of all categories: auth Different types of authentication methods connection Low level networking operations curl The command line tool itself dns General DNS options file FILE protocol options ftp FTP protocol options http HTTP and HTTPS protocol options imap IMAP protocol options misc Options that don't fit into any other category output Filesystem output pop3 POP3 protocol options post HTTP Post specific options proxy All options related to proxies scp SCP protocol options sftp SFTP protocol options smtp SMTP protocol options ssh SSH protocol options telnet TELNET protocol options tftp TFTP protocol options tls All TLS/SSL related options upload All options for uploads verbose Options related to any kind of command line output of curl I have a curl Get request that happens earlier in the file that works. test=$(curl -X GET "https://test.com/test/test" -u username:password | jq '{id, things}' > test.json) When I run a similar post I get the issue: { jq -cn --arg url $url --arg key $key '{things: { stuff: $ARGS.named}}' } | jq -s add > newTest.json mergedTest=$(jq -s '.[0] * .[1]' test.json newTest.json) test2=$(curl -X POST https://test.com/test/test -u username:password -h "Content-Type: application/json" --data $mergedTest) echo $test2 Any help would be appreciated.
has answer: http://stackoverflow.com/a/78162277
has comment: http://stackoverflow.com/comment/137796322
has comment: http://stackoverflow.com/comment/137797303
has comment: http://stackoverflow.com/comment/137796448
downvote count: 1
has comment: http://stackoverflow.com/comment/137797340
accepted answer: http://stackoverflow.com/a/78162277
has comment: http://stackoverflow.com/comment/137797313
upvote count: 0
type: AnsweredQuestion
answer count: 1
has title: Why does curl return "Usage: curl [options...] <url> Invalid category provided" when running in bash script?
favorite count: 0
tagged with: jq
linked to: http://stackoverflow.com/q/29378566

http://stackoverflow.com/comment/137946079
has text: you can end up in an endless loop – i was curious about this indeed, but i was experimenting with small files and hence did not observe the case you mentioned
comment on: http://stackoverflow.com/q/78245937
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78177452
has body: It's not the braces. In a POSIX shell, any command sequence involving pipes ( cmd1 | cmd2 ) runs both in subshells. To retain the value of first_line you must not run the read in a subshell. With bash process substitution you can do: while IFS= read -r first_line consumer do break done &lt; &lt;( producer ) or { IFS= read -r first_line; consumer; } &lt; &lt;( producer ) Bash also has a lastpipe option which is available when job control is disabled (typically scripts / non-interactive shells, or when disabled explicitly): set +m shopt -s lastpipe producer | { IFS= read -r first_line consumer } BashFAQ 024 has more information and options.
has comment: http://stackoverflow.com/comment/137823722
accepted answer of: http://stackoverflow.com/q/78177405
has comment: http://stackoverflow.com/comment/137823761
answers question: http://stackoverflow.com/q/78177405
score: 3
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/137823679
has comment: http://stackoverflow.com/comment/137842661
downvote count: 0
has comment: http://stackoverflow.com/comment/137842506
type: Answer

http://stackoverflow.com/comment/137789189
type: Comment
score: 0
has text: what about the tag?
type: AnswerComment
comment on: http://stackoverflow.com/a/78156438

http://stackoverflow.com/comment/137937986
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78241429
type: Comment
has text: Hmm -- clever. Generating positional argument expansions is a sound practice here.

http://stackoverflow.com/comment/137866242
comment on: http://stackoverflow.com/q/78200978
type: QuestionComment
type: Comment
has text: (comments are a lot less restrictive than Q&A proper here in terms of the rules -- one needs to be polite to people, and eventually someone might decline to answer follow-up questions / tangents, but it's way more acceptable to ask follow-up questions in a comment than it is to edit a question after it's answered to expand its scope; this way, worst thing you'll get is someone wandering off, or asking you to expand your tangent into a whole new well-formed question -- just note that comments are transient and open to deletion; anything that needs to be stable long-term should be Q&A).
score: 0

http://stackoverflow.com/a/78196125
has body: In the special case (commonly occurring) that you want to remove some initial positional parameters, you use shift. By default that deletes $1; with a numeric argument, it will delete n parameters. Now, in your specific case, we can use a combination of shift and set --. local a=$1 shift 2 # delete $1 and $2 set -- "$a" "$@" # insert $1 before original $3 ... $n Using Bash arrays is another possibility. If we translate the "$@" arguments into a bash array. local args=("$@") # convert $1 $2 ... into ${args[0]} ${args[1]} ... unset args[1] # delete args[1]; note: elements DO NOT SHIFT DOWN! set -- "${args[@]}" # convert array back to positional params When we convert the array back to positional params with the "${args[@]}" expansion syntax, the unset args[1] element is absent, and so the original $2 disappears. Of course, if we need those arguments in order to pass them to a function or script, we don't have to convert the array back to positional parameters. Just: local args=("$@") # convert $1 $2 ... into ${args[0]} ${args[1]} unset args[1] # delete second arg script "${args[@]}" # call script with second argument deleted Likewise, in my very first example, we could just call whatever we need to call rather than using set to further edit the positionals: local a=$1 # preserve $1 in temporary variable shift 2 # delete $1 and $2 script "$a" "$@" # call target script with original $1 $3 $4 ...
answers question: http://stackoverflow.com/q/78195964
score: 4
upvote count: 4
downvote count: 0
type: Answer

http://stackoverflow.com/a/78181057
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: To suggest an alternative that makes use of Vim's buffer functions, you could tweak the example given in :help bufadd() just a little bit. I took the liberty of borrowing the function name from phd's excellent answer. I'd prefer to have the destination file name as an argument to the function but that's largely up to personal taste. function PrependLine(filename) abort let dstbuf = bufadd(a:filename) call bufload(dstbuf) call appendbufline(dstbuf, 0, getline('.')) endfunction nnoremap &lt;leader&gt;i &lt;Cmd&gt;call PrependLine('myfile.md')&lt;CR&gt; Note that this will not write a file to disc right now but keep it open as an unlisted buffer. It will be written only when you explicitly do so, e.g. through :wall. This function also avoids the side effect of writing the current buffer.
answers question: http://stackoverflow.com/q/78155628

http://stackoverflow.com/q/78216460
tagged with: bash
type: Question
tagged with: colors
has body: For the example, systemctl status weechat |grep Active The output of systemd is green or red depending on status. How to keep that when piping through grep (or other command like tail,...)? There is --color, but it's not that. .
score: 0
tagged with: grep
accepted answer: http://stackoverflow.com/a/78216523
tagged with: pipe
answer count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78216523
has title: how to keep the colored output of a command after piping it through grep

http://stackoverflow.com/q/78158725
has answer: http://stackoverflow.com/a/78158825
has body: I first created a named pipe from a user mkfifo -m 0777 /tmp/pipe Then, from another user I tried to write to it, but it gives me error echo 1 &gt; /tmp/pipe bash: /tmp/pipe: Permission denied which should not happen, since I've set read-write permissions for all users earlier. I've also tried using chmod 777 but no luck.
tagged with: linux
tagged with: bash
has title: Echoing into named pipe created by another user gives permission denied
has comment: http://stackoverflow.com/comment/137791341
upvote count: 1
has comment: http://stackoverflow.com/comment/137791181
downvote count: 1
score: 0
type: Question
tagged with: shell
has comment: http://stackoverflow.com/comment/137791200
type: UnansweredQuestion
answer count: 1
favorite count: 0

http://stackoverflow.com/q/78221337
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137902350
tagged with: http://stackoverflow.com/tag/json
has title: How I can compare these two .json files correctly using jq in a bash script
score: 0
answer count: 0
duplicate of: http://stackoverflow.com/q/31930041
has body: I have a bash script that is set up below which is attempting to compare the remote s3 version of a file with the local version. Currently, the if conditions I try never actually work. The latest version is below, I am simply looking to create a temp s3 file and initialize it with the s3 version, compare the temp s3 with the local, if there are differences than I want to have the temp s3 file get the latest updates and then after the s3 file is updated to remove the temp files. Any help would be greatly appreciated, as this below setup always results in the code not detecting any differences, even when I manually create differences to test the logic. Current setup: #!/bin/sh FILE_NAME = config.json REMOTE_FILE_LOCATION="s3://path/to/s3/file/$FILE_NAME" aws cp $REMOTE_FILE_LOCATION s3-$FILE_NAME if ! jq -s '.[0] == .[1]' "$FILE_NAME" "s3-$FILE_NAME" &> /dev/null; then echo "differences found" cp $FILE_NAME s3-$FILE_NAME aws s3 cp s3-$FILE_NAME $REMOTE_FILE_LOCATION else echo "No differences - local and s3 files in sync." fi rm -r $s3-$FILE_NAME Tried re-writing the if conditions, actually building logic to compare objects in each files based on their id, yet I have not been able to get the if condition to correctly determine when .json files are the same vs. when they are not. Previous solutions resolving around comparing JSON files did not have an answer where there was a solution that worked with jq. I have tried multiple suggestions from prior posts.
tagged with: jq
linked to: http://stackoverflow.com/q/31930041
has comment: http://stackoverflow.com/comment/137902351
tagged with: bash
type: Question

http://stackoverflow.com/comment/137939871
comment on: http://stackoverflow.com/q/78241761
has text: @jhnc I see the problem. The answer is simply because I was using an older version of `qdepends` and `qdepends` now respects IDEPEND dependencies of a package but `equery d` (v0.6.5) still doesn't which I suspect is the version you have if you unmasked the keyword, or v0.6.3-r1. The bleeding edge version (9999) however shows output. Try updating to it.
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/138029359
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78292693
has text: Anyway, the bug is clearly in `"$("${day}.html")"`. That should just be `"${day}.html"`
score: 0

http://stackoverflow.com/q/78192804
has answer: http://stackoverflow.com/a/78193154
answer count: 2
has body: I want to replace a sentence in a file this: from [Report 1](**Please put link here**)&quot; [Report 2](**Please put link here**) to: [Report 1](https://stackoverflow.com/09004cffcbee784a?docno=/link1)&quot; [Report 2](https://stackoverflow.com/09004cffcbee784a?docno=/link2) So I tried with but it does not seem to make the replacement sed -i 's#[Report 1](\*\*Please put link here\*\*)#(https://stackoverflow.com/09004cffcbee784a?docno=/link1)#g' file.md
has answer: http://stackoverflow.com/a/78192934
tagged with: bash
type: Question
has title: Replace string with link in bash
upvote count: 1
has comment: http://stackoverflow.com/comment/137851282
accepted answer: http://stackoverflow.com/a/78192934
possible better answer: http://stackoverflow.com/a/78193154
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/137851314
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/comment/137943541
type: QuestionComment
has text: Computing 5 different sizes takes long time. I need to compare the performance of running these 5 different sizes with baselines. While I am waiting for the result, I plan to make some changes to the code and test the new implementation. The new modification might change many files in the project, so I cannot add copy to one single file (if I do so, I need to make copy to multiple files)
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78244372

http://stackoverflow.com/comment/138042577
comment on: http://stackoverflow.com/a/78301072
has text: You can manually select the time fields if you don't like the default -- which includes the time zone you run it on...
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137860984
has text: I still would like you to consider the XY problem and/or tell us what you want to achieve in the next step.
comment on: http://stackoverflow.com/q/78197884
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78194762
answers question: http://stackoverflow.com/q/78193259
score: 0
type: Answer
has body: Given: $ cat file Type,Value,Adicional Resources boop,bop,boom long arm,of the,long armed lawman You can use mlr to pretty print a table: $ mlr --icsv --opprint --barred cat file +----------+--------+---------------------+ | Type | Value | Adicional Resources | +----------+--------+---------------------+ | boop | bop | boom | | long arm | of the | long armed lawman | +----------+--------+---------------------+ If your input field separator is | vs , you can set that: $ mlr --icsv --ifs '|' --opprint --barred cat file # same output Or a Ruby: ruby -r csv -e 'BEGIN{opts={:col_sep=>"|"} } tbl=CSV.parse($<.read, **opts) cw=tbl.transpose.map{|a| a.max_by{|e| e.length}}.map(&:length) line="+#{cw.map{|w| "-"*(w+2) }.join("+")}+" to=tbl.map{|row| row.zip(cw).map{|f,w| "|#{(" "+f).ljust(w+2)}" }.join()+"|" } to.unshift(line); to.insert(2, line); to<<line puts to.join("\n") ' file # same output Or, pure awk: awk -F"|" ' FNR==NR{for (i=1;i<=NF;i++) c[i]=length($i)>c[i] ? length($i) : c[i]; next} { for (i=1;i<=NF; i++) printf "| %-*s%s",c[i]+2,$i,(i<NF ? "" : " |\n") } ' file file | awk ' FNR==1{ line=$0 gsub(/[^|]/,"-", line) gsub(/\|/,"+", line) printf "%s\n%s\n%s\n",line,$0,line next } {print} END {print line}' # same output Any of these will take stdin vs reading a file if you are producing the output from a Bash loop. ie: <stdin> | mlr --icsv --ifs '|' --opprint --barred cat

subprocess
tags question: http://stackoverflow.com/q/78232787
tags question: http://stackoverflow.com/q/78305587
tag name: subprocess
type: Tag
tags question: http://stackoverflow.com/q/78630470
tags question: http://stackoverflow.com/q/79034194
tags question: http://stackoverflow.com/q/79125293
tags question: http://stackoverflow.com/q/79244510
tags question: http://stackoverflow.com/q/79157036
tags question: http://stackoverflow.com/q/79308624

http://stackoverflow.com/a/78183157
type: Answer
accepted answer of: http://stackoverflow.com/q/78181239
has body: Personally, I think you have gone doubly wrong if you: use aliases for this sort of thing, and use homebrew but then use version-specific things like /usr/local/Cellar/sqlite/3.44.2/bin/sqlite3 Why? When you use aliases, they won't work in crontab or subprocess calls in Python for example, or in systemd scripts. As you are using homebrew, its installation suggests you add /usr/local/bin to your PATH, or /opt/homebrew/bin on Apple silicon. homebrew itself creates symbolic links from these directories to the specific versions. That means you always use /usr/local/bin everywhere in your scripts and then you just do brew upgrade and all your scripts use the latest version of all the tools without needing change and homebrew can link/unlink whatever version you want. So, in short, my recommendation would be to simply ensure your PATH is correct and specifies the order of your preferences, avoid aliases and version-specific things and then everything will work as you want. If you want to see the version-specific links homebrew creates, run: ls -l /usr/local/bin
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78181239
has comment: http://stackoverflow.com/comment/137837127
score: 0

http://stackoverflow.com/q/78204849
downvote count: 3
has title: cd ~[TAB] doesn't behave as expected
tagged with: tilde
has comment: http://stackoverflow.com/comment/137872794
has comment: http://stackoverflow.com/comment/137872804
tagged with: completion
accepted answer: http://stackoverflow.com/a/78204923
tagged with: bash
type: AnsweredQuestion
has body: I've encountered an unexpected bebahiour with the completion in bash/zsh in conjunction with the tab key. When I enter cd ~ and press [ENTER] on Linux (here Ubuntu 22.04 and latest Raspberry Pi OS) the directory is changed to the home folder. This is (afaik) called tilde expansion. When I enter cd ~ and press [TAB] I'd expect that it simply appends / or substitutes ~ with /home/&lt;username&gt;/. Instead a list with suggestions is displayed but none of these suggestions can be found in my home folder. The first suggestion is ~_apt and when I choose this, I'm told cd: no such file or directory: /nonexistent The next suggestion is ~avahi/ and when I choose this I end up in /var/run/avahi-daemon. There're further suggestions such as ~backup/, ~messagebus, ~news, ~sys/, ~systemd-coredump/, etc., most work, some don't. So this looks like some pre-configured list of ?shortcuts?. Can this be configured? Why are there suggestions that doesn't work (no such file or directory: /nonexistent)?
has answer: http://stackoverflow.com/a/78204923
tagged with: zsh
has comment: http://stackoverflow.com/comment/137872537
type: Question
upvote count: 0
score: -3
tagged with: linux
has comment: http://stackoverflow.com/comment/137872741
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/137884590
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78211545
score: 0
has text: That's really weird. I'm on NixOS, I wonder if it has something to do with it.

http://stackoverflow.com/a/78290897
upvote count: 0
has comment: http://stackoverflow.com/comment/138025263
answers question: http://stackoverflow.com/q/78290808
score: -1
has comment: http://stackoverflow.com/comment/138024402
downvote count: 1
type: Answer
has body: $currentTime -ge $prodStartTime &amp;&amp; $currentTime -le $prodEndTime ; Substituting -ge for &gt;= and -le for &lt;= and expanding the variables, results in: $currentTime &gt;= 230000 &amp;&amp; $currentTime &lt;= 010000 How can a number be greater than 230000 and lower than 10000 at the same time? Additionally, numbers with leading 0 are octal numbers. 010000 is equal 4096. You want logical or between expression. I.e. the time has to be lower than 10000 or greater than 230000. $currentTime &gt;= 230000 || $currentTime &lt;= 10000. Btw, it would be much simpler to just compare hours anyway. Additionally, check your script with shellcheck.

http://stackoverflow.com/comment/137797037
has text: I'd certainly _mention_ that in a code review, especially for a function like this that could otherwise be extracted and re-used in a plain `sh` script. But it's not a must-fix item.
comment on: http://stackoverflow.com/a/78160193
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/a/78280230
has comment: http://stackoverflow.com/comment/138005725
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78280175
answers question: http://stackoverflow.com/q/78280175
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/138006168
has body: This is the sort of thing the join command was designed to do; it's basically a SQL JOIN that operates on text files rather than tables in an RDBMS. But it won't quite work out of the box on these files, because you don't have fields that exactly match; an a in one file matches something starting with a_rna_... in the other. My solution is to break off the part of the second key that matches the first and prepend it as a new column to the front of the second file; after that, join can do the job. Here's a command that should do the trick: join &lt;(sort file1.tsv) &lt;(sed 's/^\([^_]*\)_/\1\t&amp;/' file2.tsv | sort) Explanation: The &lt;(...) syntax is process substitution. You can put any command that generates output inside the parentheses, and pass the whole thing as an argument to a program expecting the name of a file to read; the program will read the output of the command instead. This lets us do some prep work on the files before feeding them to join, without having to create temporary files to hold the prepared versions. Both files have to be sorted by their keys for join to be able to match them up. You can always sort the final result differently; they just have to be consistent with each other for the join operation. The first file is otherwise fine as-is, so the sort is the only thing we do in the process sub. For the second file, we use sed to read off the part of the first column before the underscore and prepend it as a new tab-delimited column at the front of the line. Here's a breakdown of the sed s/ regex / replacement / expression: v-- at the start of the line v----------v remember what matches ^ \( [^_] * \) _ ^--- any number of repetitions of ^--^ any character that's not an underscore ^--- followed by an underscore And replace it with: v--- just the stuff matched by the bit within \(...\) v--- followed by a tab \1 \t &amp; ^--- followed by whatever matched the whole thing So after the sed, this line: a_rna_1 r r x Turns into this: a a_rna_1 r…
type: AcceptedAnswer
upvote count: 3

http://stackoverflow.com/a/78202354
answers question: http://stackoverflow.com/q/78200394
score: 1
type: AcceptedAnswer
has body: GitLab has a mechanism in place for this, and you shouldn't have to do much. You just have to write the vars to a file and declare it as an artifact with a dotenv ending, and then (depending on how you set it up) probably list dependencies. $: cat .gitlab-ci.yml stages: - build save-env: stage: ".pre" script: | when=$(date +%s) printf "%s\n" "thing1='foo'" "thing2='$when'" > sav.env tags: - VM artifacts: reports: dotenv: sav.env show-vars: stage: build script: echo "got [$thing1], [$thing2]" tags: - VM dependencies: - save-env The last few lines of the show-vars log: Executing "step_script" stage of the job script $ echo "got [$thing1], [$thing2]" got ['foo'], ['1711048904'] Cleaning up project directory and file based variables Job succeeded If what you mean is that you want your exported variables from the script to be available in your .gitlab-ci YAML file's subsequent non-script directives, then I think what you need is a Trigger - see this reference.
downvote count: 0
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78200394
type: Answer

http://stackoverflow.com/comment/138005491
has text: wha't the logic on the sequences? what is the problem?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78280175
score: 0

http://stackoverflow.com/q/78207181
type: UnansweredQuestion
tagged with: flutter
has body: I uninstalled flutter and wanted to install another new version of it, I might have deleted some files I wasn't supposed to, of changed permissions and never changed them back to how I found them. here is the output when run "flutter doctor -v" ┌──(supr㉿3mp3r0r)-[/usr/sbin/flutter/bin] └─$ sudo ./flutter doctor -v [sudo] password for supr: Woah! You appear to be trying to run flutter as root. We strongly recommend running the flutter tool without superuser privileges. / [!] Flutter (Channel stable, 3.19.3, on Kali GNU/Linux Rolling 6.5.0-kali3-amd64, locale C.UTF-8) • Flutter version 3.19.3 on channel stable at /usr/sbin/flutter ! The flutter binary is not on your path. Consider adding /usr/sbin/flutter/bin to your path. ! The dart binary is not on your path. Consider adding /usr/sbin/flutter/bin to your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision ba39319843 (2 weeks ago), 2024-03-07 15:22:21 -0600 • Engine revision 2e4ba9c6fb • Dart version 3.3.1 • DevTools version 2.31.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [✗] Android toolchain - develop for Android devices • Android SDK at /root/Android/Sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Linux toolchain - develop for Linux desktop • Debian clang version 16.0.6 (16) • cmake version 3.27.7 • ninja version 1.11.1 • pkg-config version 1.8.1 [✓] Android Studio (version 2022.3) • Android Studio at /usr/bin/android-studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/63…
has comment: http://stackoverflow.com/comment/137876950
answer count: 0
has comment: http://stackoverflow.com/comment/137876674
tagged with: linux
tagged with: bash
tagged with: zsh
has comment: http://stackoverflow.com/comment/137895035
has title: am reinstalling flutter and I can't seem to run it, with PATH variables in the .bashrc and .zshrc all configured
has comment: http://stackoverflow.com/comment/137877094
score: 0
type: Question

http://stackoverflow.com/comment/137780963
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78152355
has text: When I copy/paste your current code into shellcheck it tells me: `Line 1: #/bin/bash ^-- SC1113 (error): Use #!, not just #, for the shebang. Line 5: while ! nc -vz localhost $port > /dev/null 2>&1 ; do ^-- SC2154 (warning): port is referenced but not assigned. ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: (apply this, apply all SC2086) while ! nc -vz localhost "$port" > /dev/null 2>&1 ; do ` - thats 2 errors we shouldnt have to consider, just fix them and any others til shellcheck is clean
type: Comment

http://stackoverflow.com/comment/137855566
type: QuestionComment
comment on: http://stackoverflow.com/q/78195172
score: 0
has text: To wait for *`Enter`* key, drop `-n` flag in `read` command. `read -rp "Continue (y/n): "`
type: Comment

http://stackoverflow.com/a/78225379
upvote count: 2
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/78225038
has body: Why is argument 0 being reset somewhere in the shell script case? This is Bash's documentation for $0: Expands to the name of the shell or shell script. This is set at shell initialization. If bash is invoked with a file of commands, $0 is set to the name of that file. If bash is started with the -c option, then $0 is set to the first argument after the string to be executed, if one is present. Otherwise, it is set to the file name used to invoke bash, as given by argument zero. When you use a shebang line in your script to execute it as if it were a binary, the system turns that into an execution of the specified interpreter, with the erstwhile command name as its first argument (and the rest of the command-line arguments following). Something analogous to this C function call, in your case: execlp("/bin/bash", "/bin/bash", "./test.sh", (char *) NULL); // ^ ^ ^ // | | | // interpreter interpreter path-to-script // arg 0 arg 1 The original argument 0 is irrecoverably lost. This behavior is documented for Linux in terms of the underlying execve() function. The command name you set at the shell level via exec -a is doubly irrelevant here, because not only is it discarded as described above, but even if it were passed through as argument 0 to the shell running your script, your case is "If bash is invoked with a file of commands" from that shell's perspective. That yields test.sh as you observe. In a Bash script, if you want to know the pathname by which bash read the current source file, use ${BASH_SOURCE[0]}.
score: 2

http://stackoverflow.com/a/78174152
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78166124
score: 1
has comment: http://stackoverflow.com/comment/137818501
type: Answer
has comment: http://stackoverflow.com/comment/137818670
has body: Two good solutions Thanks to kamilcuk and konrad-rudolph for these. Both of these avoid using ls, which is known to cause problems in parsing its output. dbecho is basically echo isnull tests whether a string is empty Solution 1: pure bash # convenience function function cdloc () { local dir="${1}" local subdir="${2%/}" local found="" if isnull "${subdir}" ; then dir=$(dirname "${1}") subdir=$(basename "${1}") fi if [[ "${subdir}" =~ "/" ]]; then subdirA=${subdir%/*} subdirB=${subdir#*/} dir="${dir}/${subdirA}" subdir="${subdirB}" fi echovals dir subdir # ================================================================== # Pure bash solution, should be more efficient for target in "$dir"/*"${subdir}"*; do dbecho 1 "cdloc trying candidate '${target}'" #set -xv if cd "${target}"; then dbecho 0 "changing directory to '${target}'" #set +xv return 0 else dbecho 1 "oops, not a directory: '${target}'" fi #set +xv done echo "Could not find match for dir \"${dir}\" and subdir \"${subdir}\", even using pattern matching" return 1 } Solution 2: using find # convenience function function cdloc () { local dir="${1}" local subdir="${2%/}" local found="" if isnull "${subdir}" ; then dir=$(dirname "${1}") subdir=$(basename "${1}") fi if [[ "${subdir}" =~ "/" ]]; then subdirA=${subdir%/*} subdirB=${subdir#*/} dir="${dir}/${subdirA}" subdir="${subdirB}" fi echovals dir subdir # =================================================================== # Using `find` while IFS='' read -r target ; do dbecho 1 "cdloc trying candidate '${target}'" # set -xv # set +xv if cd "${target}"; then dbecho 0 "changing directory to '${target}'" return 0 else dbecho 1 "oops, not a directory: '${target}'" fi set +xv done < <(find "${dir}/" -depth 1 -name "*${subdir}*" 2>/dev/null) # done < <(ls -d "$dir"/*"$subdir"* 2>/dev/null) # does not work for some reason echo "Could not find match for dir \"${dir}\" and subdir \"${subdir}\", even using pattern matching" return 1 }
type: AcceptedAnswer
upvote count: 1
answers question: http://stackoverflow.com/q/78166124

http://stackoverflow.com/comment/137864832
score: 0
has text: The second fix worked like a beautiful charm! thanks!! I have no clue how to read and interpret that expression but thanks a ton! Do you mind explaining what happened there?
comment on: http://stackoverflow.com/a/78200333
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137886052
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78212116
type: Comment
has text: Can you give a sample of the file `courses.jsonl`?

http://stackoverflow.com/comment/137888166
comment on: http://stackoverflow.com/q/78213645
score: 0
type: QuestionComment
type: Comment
has text: The reason for the `[[ .. ]]` change is `[ .. ]` is a synonym for `test` (good old POSIX shell) -- it does not handle regular-expressions, Bash `[[ .. ]]` does.

http://stackoverflow.com/comment/137891635
score: 2
type: Comment
has text: I've seen your update, but again, it's claiming output that I can't repro. If we can't see the problem ourselves, we can't root-cause it or propose fixes.
comment on: http://stackoverflow.com/q/78215669
type: QuestionComment

http://stackoverflow.com/a/78188933
upvote count: 2
has comment: http://stackoverflow.com/comment/137844570
has comment: http://stackoverflow.com/comment/137844600
type: Answer
has body: Well character backtick has a special meaning in sh/bash for command substitution. However for using that in a regex you can avoid any escaping if you use single quotes to store regular expression in a variable. Consider this example: re='^[a-z0-9`]+$' 'abc`12' =~ $re &amp;&amp; echo 'match' || echo 'nope' match EDIT: re='symbolic[[:space:]]link[[:space:]]to[[:space:]]`[^[:space:]]+' &quot;$(file some-file)&quot; =~ $re &amp;&amp; echo 'match' || echo 'nope' match
answers question: http://stackoverflow.com/q/78188914
has comment: http://stackoverflow.com/comment/137844646
accepted answer of: http://stackoverflow.com/q/78188914
downvote count: 0
type: AcceptedAnswer
score: 2

http://stackoverflow.com/comment/137858547
comment on: http://stackoverflow.com/q/78196837
type: Comment
has text: Since you are using curly braces in the pattern ie {2}, I would add the -E option to sed to enable extended regular expressions. Also if you want to change the file in-place(make backup) add the -i option aswell.
score: 0
type: QuestionComment

http://stackoverflow.com/a/78177590
has body: If the output of command is textual and fairly small (anything up to 10K lines should be OK on any modern system) then you could store it all in memory and extract the pieces that you want. This is one way to do it: output=$(command) readarray -t output_lines <<<"$output" first_line=${output_lines[0]} printf '%s\n' "${output_lines[@]:1}" | process_rest
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78177405

ssh
tags question: http://stackoverflow.com/q/78290118
type: Tag
tag name: ssh
tags question: http://stackoverflow.com/q/78341621
tags question: http://stackoverflow.com/q/78417099
tags question: http://stackoverflow.com/q/78392466
tags question: http://stackoverflow.com/q/78419810
tags question: http://stackoverflow.com/q/78398806
tags question: http://stackoverflow.com/q/78328611
tags question: http://stackoverflow.com/q/78571808
tags question: http://stackoverflow.com/q/78569226
tags question: http://stackoverflow.com/q/78712681
tags question: http://stackoverflow.com/q/78672896
tags question: http://stackoverflow.com/q/78672918
tags question: http://stackoverflow.com/q/78898675
tags question: http://stackoverflow.com/q/78780721
tags question: http://stackoverflow.com/q/78789822
tags question: http://stackoverflow.com/q/78827252
tags question: http://stackoverflow.com/q/78949960
tags question: http://stackoverflow.com/q/78993407
tags question: http://stackoverflow.com/q/79105138
tags question: http://stackoverflow.com/q/79170305
tags question: http://stackoverflow.com/q/79211507
tags question: http://stackoverflow.com/q/79362714
tags question: http://stackoverflow.com/q/79356217
tags question: http://stackoverflow.com/q/79347521
tags question: http://stackoverflow.com/q/79342737
tags question: http://stackoverflow.com/q/79372466
tags question: http://stackoverflow.com/q/79525482
tags question: http://stackoverflow.com/q/79420549
tags question: http://stackoverflow.com/q/79543220
tags question: http://stackoverflow.com/q/79501141

http://stackoverflow.com/comment/137805478
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78166124
has text: @Rich Prefer KamilCuk's solution, it's plain bash, no need for external utilities like `find`.
score: 1

http://stackoverflow.com/q/78224799
has comment: http://stackoverflow.com/comment/137908493
has comment: http://stackoverflow.com/comment/137908202
has answer: http://stackoverflow.com/a/78224927
type: Question
tagged with: linux
has comment: http://stackoverflow.com/comment/137908231
has body: I am making a small program in Bash that looks up the IP address's of websites in 3 ways. Everything else works except the 3rd method: The user passes a filename into the code as the first parameter - in this case the file is "domains.txt" and contains 3 test domains. Edit 2: I added a much more concise code that only produces the error. Edited the post a bit to reflect that change. Old code copy/paste was removed. #!/bin/bash function Domain_Lookup_Func { filename=$1 while read -r line do echo "$line" | nslookup done < "$filename" } initialInput=$1 fileChk=".txt" if $initialInput == *"$fileChk"* ; then Domain_Lookup_Func fi This is a code exercise for University, and this is my first experience with Bash in particular, so I understand this is some painfully basic code. I do however have coding experience so technical explanation is not lost on me (hopefully). I have spent hours trying to fix this and I've tried what feels like dozens of different ways to check for substrings - nothing works and other questions I've found relating to this issue either have solutions that don't work or aren't in the same context so the answers aren't relevant. Every other part of this code works perfectly except that single substring check - including the while loop. I have found some information that indicates the code is interpreted differently if I use "bash (filename).sh" to open it in terminal, or have "#!/bin/bash" at the top of my code. This may be the issue, but to be honest I have no idea what that means for my code.
type: UnansweredQuestion
score: 1
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/137908291
has comment: http://stackoverflow.com/comment/137908152
downvote count: 0
tagged with: bash
has title: Linux Bash - Calling a function returns a "No such file or directory" error
favorite count: 0
has comment: http://stackoverflow.com/comment/137908071
has comment: http://stackoverflow.com/comment/137908491
has comment: http://stackoverflow.com/comment/137908196
has comment: http://stackoverflow.com/comment/137908022

http://stackoverflow.com/comment/137858192
score: 0
has text: (BTW, consider me to have cosigned everything Barmar says above).
type: Comment
comment on: http://stackoverflow.com/q/78196593
type: QuestionComment

http://stackoverflow.com/comment/137805749
comment on: http://stackoverflow.com/q/78166538
type: Comment
has text: `gunzip` is not designed to unzip files coming from stdin. Of course, `gunzip $(some_command)`, where `some_command` writes the names of the files to unzip, to stdout, would work. But even this would work only, if none of the filenames contains white space, so I would not recommend it. First focus on how you want to generate the file name list, and then we can think of a reasonable way to do the unzipping,
score: 0
type: QuestionComment

http://stackoverflow.com/a/78201829
answers question: http://stackoverflow.com/q/78200217
has body: It is possible to reliably escape variable values so they can be used in sed substitutions. See Is it possible to escape regex metacharacters reliably with sed and Escape a string for a sed replace pattern. If your input file is small (up to a megabyte should be OK on any modern system) and you've got Bash 4.0 (released in 2009) or later, there is an easy way to do what you want with pure Bash. Try this Shellcheck-clean code: #! /bin/bash -p readarray -O 1 -t lines &lt;file.txt lines[200]=$(df -h) printf '%s\n' &quot;${lines[@]}&quot; &gt;file.txt
type: Answer
score: 0

http://stackoverflow.com/comment/137999451
score: 0
type: Comment
type: AnswerComment
has text: There's also `declare` which is less likely to do something bad with the string
comment on: http://stackoverflow.com/a/78276598

http://stackoverflow.com/comment/137908243
type: QuestionComment
comment on: http://stackoverflow.com/q/78223744
type: Comment
has text: https://stackoverflow.com/questions/42610626/is-it-necessary-to-convert-infix-notation-to-postfix-when-creating-an-expression/42612892#42612892
score: 1

http://stackoverflow.com/comment/137829963
has text: @chepner Hey, the block gets executed. Currently debugged it to the error of numpy version 1.24 produces a ERROR: No matching distribution found error, which comes from the fact that conda installs Python 3.7. My bad, closing the question.
comment on: http://stackoverflow.com/q/78180816
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137909060
has text: Here https://man7.org/linux/man-pages/man2/execve.2.html#:~:text=Note%0A%20%20%20%20%20%20%20that%20there%20is%20no%20way%20to%20get%20the%20argv%5B0%5D%20that%20was%20passed%20to%20the%0A%20%20%20%20%20%20%20execve()%20call.
comment on: http://stackoverflow.com/a/78225303
score: 2
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137882933
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78210405
has text: Also see [Bash Pitfalls #14 (echo $foo)](https://mywiki.wooledge.org/BashPitfalls#echo_.24foo).
type: Comment

http://stackoverflow.com/comment/137823761
type: AnswerComment
has text: Worth noting that lastpipe requires job control to be disabled; not a problem in scripts, but someone trying to smoketest the practices shown in this answer in an interactive shell might be surprised.
comment on: http://stackoverflow.com/a/78177452
score: 2
type: Comment

http://stackoverflow.com/comment/137949833
comment on: http://stackoverflow.com/q/78248223
score: 0
has text: @HansKilian Kill is just an example. The goal is to disable a builtin function from the bash that is provided when the container is running.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137797479
type: AnswerComment
has text: Fair enough. The tag does mention 'bash' rather than 'sh'. When working in bash specifically, I'd prefer including the function keyword for readability. And if the script is meant to be bash-exclusive rather than POSIX, I generally consider incompatible syntax a plus :p.
score: 0
comment on: http://stackoverflow.com/a/78160193
type: Comment

http://stackoverflow.com/q/78280175
has comment: http://stackoverflow.com/comment/138005491
has comment: http://stackoverflow.com/comment/138005566
score: 0
type: Question
tagged with: linux
has answer: http://stackoverflow.com/a/78280230
has comment: http://stackoverflow.com/comment/138005497
has comment: http://stackoverflow.com/comment/138005528
favorite count: 0
answer count: 3
has comment: http://stackoverflow.com/comment/138005519
tagged with: python
accepted answer: http://stackoverflow.com/a/78280230
tagged with: awk
tagged with: sed
has body: The first file (tab-delimited) is a 1 2 3 b 6 7 8 c 9 0 9 The second file (tab-delimited) is a_rna_1 r r x a_rna_2 q q d a_rna_3 c c c b_rna_1 e e e c_rna_1 a a g How can we merge these 2 files so that we get the following file? a 1 2 3 a_rna_1 r r x a 1 2 3 a_rna_2 q q d a 1 2 3 a_rna_3 c c c b 6 7 8 b_rna_1 e e e c 9 0 9 c_rna_1 a a g Is there a way that we can do this automatically?
upvote count: 2
has answer: http://stackoverflow.com/a/78283992
downvote count: 2
has answer: http://stackoverflow.com/a/78280945
has title: How to merge the following 2 files using python or bash?
tagged with: bash
possible better answer: http://stackoverflow.com/a/78280945
type: AnsweredQuestion

http://stackoverflow.com/comment/137935773
has text: For storing *real* output of `redis-cli --latency` into a variable, you could try: `bash -c 'sleep 3;ps --ppid $(ps ho ppid $$) ho pid | xargs kill' & Latency="$(stdbuf -o0 script -f /dev/null -c 'redis-cli --latency -h 127.0.0.1 -p 6379')"` then show the content of your variable: `echo ${Latency@Q}` (Note, I've stored only 3 seconds instead of 20! Feel free to change `3` for `20` in my sample;)
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78240103

http://stackoverflow.com/comment/137816535
type: AnswerComment
has text: @user448810 The bash printf is a bit inconcistent and will only use the first character of every word. It does not perform the conversion.
score: 0
comment on: http://stackoverflow.com/a/78173289
type: Comment

http://stackoverflow.com/comment/138035487
score: 0
has text: Just switch to double quotes then. [When to wrap quotes around a shell variable](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) has more variations and amplifications.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78297369

http://stackoverflow.com/comment/137790784
type: Comment
comment on: http://stackoverflow.com/q/78158123
score: 0
has text: Does your version of `find` support `-delete`?
type: QuestionComment

bc
type: Tag
tags question: http://stackoverflow.com/q/78158852
tag name: bc
tags question: http://stackoverflow.com/q/78410973

http://stackoverflow.com/comment/137797303
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78161552
has text: BTW, while not related directly to your issue, you _really_ should be fixing the quotes in your code. When you use `--data $mergedTest` instead of `--data "$mergedTest"`, for example, you risk the contents of `mergedTest` being split on whitespace, having those individidual components expanded as globs, and then being sent to curl as several separate, smaller arguments. http://shellcheck.net/ helps to catch this kind of bug.
score: 1

http://stackoverflow.com/q/78245937
tagged with: terminal
has body: Given a file foo 1 2 3 4 5 Can someone help me understand why the following results in an empty file? cat foo | grep 1 &gt; foo wc foo 0 0 0 foo whereas the following appends fine cat foo | grep 1 &gt;&gt; foo cat foo 1 2 3 4 5 1 I'm not surprised with the functioning of &gt;&gt;, but with &gt; my expectation was that the file will contain just the output of cat foo | grep 1. What's the underlying implementation detail that results in this behaviour? cat foo | tee foo on the other hand does not empty the file.
tagged with: unix
has comment: http://stackoverflow.com/comment/137946057
linked to: http://stackoverflow.com/q/20620966
has comment: http://stackoverflow.com/comment/137945903
has title: Reading & Writing to the same file from terminal
score: 0
answer count: 0
tagged with: linux
has comment: http://stackoverflow.com/comment/137945865
has comment: http://stackoverflow.com/comment/137946079
has comment: http://stackoverflow.com/comment/137971069
has comment: http://stackoverflow.com/comment/137945968
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137945947
has comment: http://stackoverflow.com/comment/137945887
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/20620966

http://stackoverflow.com/comment/137895076
score: 0
type: QuestionComment
has text: Why not simply doing a `varr=$BITBUCKET_TAG`, or (if you run with `set -u`) `varr=${BITBUCKET_TAG:-}`ß
type: Comment
comment on: http://stackoverflow.com/q/78216881

http://stackoverflow.com/a/78169487
has comment: http://stackoverflow.com/comment/137810258
has body: When you run a shell script that activates a venv, the activation only affects the sub-shell created for the script and not the shell of your script invoking activate. Once the script completes, the sub-shell is closed and any changes to the environment it introduced, including activation of the virtual environment, are lost. Second script is buggy, because PWD = pwd is incorrect syntax for assigning command output to a variable (in fact you do not even call the pwd there). The correct syntax would be PWD=$(pwd) (note lack of spaces too), BUT... this is unnecessary as $PWD is a built-in variable that already contains the current directory, so you can instantly use it as ${PWD}.
answers question: http://stackoverflow.com/q/78169456
upvote count: 1
has comment: http://stackoverflow.com/comment/137810705
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/137810248
has comment: http://stackoverflow.com/comment/137810737
downvote count: 0
has comment: http://stackoverflow.com/comment/137810286
has comment: http://stackoverflow.com/comment/137810228

http://stackoverflow.com/comment/137804592
comment on: http://stackoverflow.com/q/78166124
has text: @Rich Spaces and special characters, e.g. newlines. In general, POSIX does not place *any* limitations on path names, except that they may not contain the zero-character. (Furthermore, the output format of `ls` isn’t fully specified, and different implementations format output slightly differently).
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/q/78200394
has body: I have a simple stage something like this: build-hw: stage: build when: on_success timeout: 10 hours before_script: source /usr/local/bin/setup_env.sh script: - make build - make export_hw sw/$SW_PRJ/xsa artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA" expire_in: 1 hour paths: - $HW_PRJ/$HW_PRJ.runs/*.log - $HW_PRJ/$HW_PRJ.runs/impl_1/top.bit - $HW_PRJ/$HW_PRJ.runs/impl_1/top.ltx - sw/$SW_PRJ/xsa/top.xsa And a few variables set in the .gitlab-ci file variables: HW_PRJ: "pl-build" SW_PRJ: "ps-build" What I've already done: created ".env" and put these variables there edit before_script with another line: set -o allexport; source .env; set +o allexport` but it's applying the variables only inside script block not in the paths Is there any solution? Thanks in advance!
has answer: http://stackoverflow.com/a/78202354
tagged with: gitlab-ci
answer count: 1
type: AnsweredQuestion
tagged with: dotenv
score: 0
tagged with: bash
tagged with: yaml
type: Question
has title: gitlab-ci : preload variables from file
accepted answer: http://stackoverflow.com/a/78202354
linked to: http://stackoverflow.com/q/67501513

http://stackoverflow.com/comment/137896069
score: 0
has text: I’ve seen uglier! If you regularly point the path at a different directory of contents, then a symlink is a fairly neat way to do this and atomically switch. If it’s a one-off, it really depends on the robustness of the application and how it opens files.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78218123

http://stackoverflow.com/comment/137972971
score: 1
has text: That last ("only the output of the wrapped script") requirement makes this _much_ more complicated -- basically means you need a curses-aware library; at that point, screen or tmux becomes a very reasonable choice. _Some_ terminals allow saving and restoring state, but it's not a feature that's standardized enough to rely on; one needs to look up its availability in the terminfo database, and realistically expect that it sometimes simply won't be available.
type: Comment
comment on: http://stackoverflow.com/q/78261786
type: QuestionComment

http://stackoverflow.com/comment/137992287
score: 0
has text: `saved_SOME_VAR=$SOME_VAR` at the beginning, and `SOME_VAR=$saved_SOME_VAR` at the end.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78272610

command-line-arguments
tags question: http://stackoverflow.com/q/78299332
tags question: http://stackoverflow.com/q/78181978
tag name: command-line-arguments
type: Tag
tags question: http://stackoverflow.com/q/78557465
tags question: http://stackoverflow.com/q/78447803
tags question: http://stackoverflow.com/q/78634545

http://stackoverflow.com/comment/137822844
type: Comment
type: AnswerComment
score: 0
has text: Definitely a robust answer. I will definitely add this to my toolbox!
comment on: http://stackoverflow.com/a/78176733

http://stackoverflow.com/comment/137866691
type: Comment
comment on: http://stackoverflow.com/q/78201574
score: 1
has text: Whether `getent group` works at all here depends on how your NSS integration is configured, how you defined the groups in LDAP, etc. We can't possibly know if this is expected to work or not based only on the content in the script itself.
type: QuestionComment

http://stackoverflow.com/comment/137825264
type: QuestionComment
comment on: http://stackoverflow.com/q/78177875
type: Comment
has text: wc -l counts the lines \n delimited but if your last line doesn't have \n then that line doesn't count so that why I have used sed -n '$='
score: 0

http://stackoverflow.com/comment/138193451
type: QuestionComment
has text: @Ivan, starting that with `''` and ending it with `"` isn't going to work so well.
score: 1
type: Comment
comment on: http://stackoverflow.com/q/78253800

http://stackoverflow.com/comment/137915816
type: QuestionComment
type: Comment
score: 5
has text: Bash code is not a good way to handle web requests. It's outrageously slow, it's impossible to make secure, and it can't store binary data internally. Your immediate problem is with the binary data issue. Bash variables can't hold ASCII NUL (00) characters. Another problem is that `read` loops terminate early if the final line of input doesn't have a terminating newline (unless you add special code to handle that case). If you are determined to continue with using Bash code for this, try replacing the loop with `cat >> encoded_file`
comment on: http://stackoverflow.com/q/78228745

http://stackoverflow.com/comment/137943334
score: 1
has text: @VickyDev Unless you're using a special shell that understands regexs, no. Bash has its own glob pattern syntax which is similiar-ish but unrelated to regexs. See for example https://tldp.org/LDP/abs/html/globbingref.html. You can trivially check whether a glob pattern works in bash by running `echo <pattern>` and seeing if the files you expect are listed.
type: QuestionComment
comment on: http://stackoverflow.com/q/78244513
type: Comment

http://stackoverflow.com/comment/137998203
type: Comment
has text: See ["Escape a string for a sed replace pattern"](https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern/2705678#2705678) and ["Is it possible to escape regex metacharacters reliably with sed"](https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed/29613573#29613573).
score: 1
comment on: http://stackoverflow.com/q/78274893
type: QuestionComment

http://stackoverflow.com/q/78166124
has comment: http://stackoverflow.com/comment/137804050
has comment: http://stackoverflow.com/comment/137805478
has comment: http://stackoverflow.com/comment/137806073
accepted answer: http://stackoverflow.com/a/78174152
score: 0
has comment: http://stackoverflow.com/comment/137804452
has comment: http://stackoverflow.com/comment/137804592
has comment: http://stackoverflow.com/comment/137804595
answer count: 1
has comment: http://stackoverflow.com/comment/137804465
has comment: http://stackoverflow.com/comment/137804165
type: AnsweredQuestion
has title: Why is the Bash "test" function not correctly identifying directories within this while loop?
has body: I have some code which is suprising me. I'm hoping someone can answer me about the behavior of Bash's test function "[[ ]]". The following function cdlic is intended to find the first matching subdirectory given a parent directory and a pattern and then cd into that directory. I have disabled the cd command for testing. At any rate, cdloc foo bar should find the first valid directory matching foo/*bar* and report it: function cdloc () { local dir="${1}" local subdir="${2}" local found="" if isnull "${2}" ; then subdir=$(basename "${dir}") dir=$(dirname "${dir}") fi while read -r target ; do echo "cdloc trying '${target}'" set -xv if [[ -d ${target} ]]; then echo "cdloc: found matching directory '${target}'" #cd "${target}" # return 0 else echo "cdloc: skipping non-directory '${target}'" fi set +xv done < <(ls -d "${dir}"/*"${subdir}"* 2>/dev/null) echo "Could not find match for dir \"${dir}\" and subdir \"${subdir}\", even using pattern matching" } I ran a test case. cook@MacBook-Pro-2021 (obsidian-image-resizer-plugin (BARE:master)): mkdir -p foo/bar rcook@MacBook-Pro-2021 (obsidian-image-resizer-plugin (BARE:master)): cdloc foo bar cdloc trying 'foo/bar/' +(/Users/rcook/Projects/RC-bash-lib/shellfuncs.sh:13): cdloc(): -d foo/bar/ +(/Users/rcook/Projects/RC-bash-lib/shellfuncs.sh:18): cdloc(): echo 'cdloc: skipping non-directory '\''foo/bar/'\''' cdloc: skipping non-directory 'foo/bar/' +(/Users/rcook/Projects/RC-bash-lib/shellfuncs.sh:20): cdloc(): set +xv Could not find match for dir "foo" and subdir "bar", even using pattern matching rcook@MacBook-Pro-2021 (obsidian-image-resizer-plugin (BARE:master)): # Wait what? rcook@MacBook-Pro-2021 (obsidian-image-resizer-plugin (BARE:master)): if -d foo/bar/ ;then echo yes; fi yes Why is the -d foo/bar/ test failing in the function when the same code seems to succeed when run outside the function? Interestingly, if I use "find" instead of "ls" it works: function cdloc () { local dir="${1}" local subdir="…
has comment: http://stackoverflow.com/comment/137831034
has comment: http://stackoverflow.com/comment/137804222
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137818161
has comment: http://stackoverflow.com/comment/137804210
has answer: http://stackoverflow.com/a/78174152

http://stackoverflow.com/comment/137770872
score: 0
type: QuestionComment
type: Comment
has text: Your `set` command does not set any variable at all. For the use of the `set` command, see the bash man page, section _SHELL BUILTIN COMMANDS_, so your question does not really make sense.
comment on: http://stackoverflow.com/q/78146405

background-process
tag name: background-process
tags question: http://stackoverflow.com/q/78228111
type: Tag
tags question: http://stackoverflow.com/q/78317514
tags question: http://stackoverflow.com/q/78409749
tags question: http://stackoverflow.com/q/78876319
tags question: http://stackoverflow.com/q/79251696
tags question: http://stackoverflow.com/q/79419573
tags question: http://stackoverflow.com/q/79365247
tags question: http://stackoverflow.com/q/79479357

http://stackoverflow.com/comment/137938001
type: QuestionComment
has text: And if the argument contains quotes or backslashes, they'll need to be escaped.
type: Comment
comment on: http://stackoverflow.com/q/78241462
score: 1

http://stackoverflow.com/comment/137792185
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78158825
has text: I'm just stating different possible solution here. But, I totally agree with you. In fact, highlining that removing the sticky bit is a not recommended solution is certainly required.
type: Comment

http://stackoverflow.com/a/78227374
score: 3
has body: When you trap a signal, that doesn't just add extra behavior before the signal is handled -- it outright replaces the default signal handler. Thus, the trap 'send_signal 2' SIGINT prevents ctrl+C from having its default behavior, and the trap 'send_signal 3' SIGSTP prevents ctrl+Z from having its default behavior.
type: Answer
answers question: http://stackoverflow.com/q/78226499
upvote count: 3
downvote count: 0

http://stackoverflow.com/comment/137822184
type: Comment
comment on: http://stackoverflow.com/q/78176347
score: 0
type: QuestionComment
has text: I have a feeling you're planning to use awk to extract the lines that start and end with numbers between 200 and 400 and then use some other tool (shell? another call to awk? bc?) to compare that set of lines against the value of the `number` shell variable - definitely do not do that.

http://stackoverflow.com/a/78158865
has comment: http://stackoverflow.com/comment/137791957
has comment: http://stackoverflow.com/comment/137791692
answers question: http://stackoverflow.com/q/78158852
upvote count: 2
has comment: http://stackoverflow.com/comment/137792007
has comment: http://stackoverflow.com/comment/137791598
downvote count: 0
type: Answer
score: 2
has body: The &lt;&lt;&lt; symbol is used to pass a string as the standard input of the command used. It's called a here-string. The simplest example is with cat: cat &lt;&lt;&lt; 'hello' You can find a first explanation in the man bash page https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Here-Strings

http://stackoverflow.com/a/78192934
type: Answer
accepted answer of: http://stackoverflow.com/q/78192804
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78192804
has body: Square brackets are special in sed regular expressions (they introduce character classes). You need to escape them by a backslash. s#\[Report 1\)](\*\*Please put link here\*\*)#(https://stackoverflow.com/09004cffcbee784a?docno=/link1)#g You may also capture the number after Report and resuse it in the link: s#\[Report \([12]\)](\*\*Please put link here\*\*)#(https://stackoverflow.com/09004cffcbee784a?docno=/link\1)#g
downvote count: 0
score: 3
upvote count: 3

http://stackoverflow.com/a/78199319
has comment: http://stackoverflow.com/comment/137873071
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78199142
has body: To answer the question, where is the problem. for file in location will go through all files in the given folder, hence *_R1.fastq and *_R2.fastq. In combination with ${file}_R1.fastq this will lead to sample1_R1.fastq_R1.fastq and sample1_R1.fastq_R2.fastq. Hence you have to filter the files you are working on. Also PWD should be $PWD or the actual path. @jared_mamrot wrote a good comment using only for file in *_R1.fastq in the current directory. He then uses "${file/R1/R2}" to replace the R1 in the filename with R2 and finally extracts the leading part with "${file%%_*}" You don't have to write it as short as he does, but this should give you the idea to understand the problems in the code and how to solve them. Leading to #! /bin/bash for file in "$PWD"/*_R1.fastq do fastq1=$file fastq2=${file/R1/R2} motus profile -f "$fastq1" -r "$fastq2" -t 4 > "text_${file%%_*}.txt" done
type: Answer
has comment: http://stackoverflow.com/comment/137873110
has comment: http://stackoverflow.com/comment/137863028
upvote count: 1

http://stackoverflow.com/comment/137806551
type: QuestionComment
type: Comment
score: 0
has text: See [How can I pipe to the next command with new environment variables?](https://stackoverflow.com/questions/18684685/how-can-i-pipe-to-the-next-command-with-new-environment-variables). Besides export/source, another option is to write to a file which the test will read, or echo the data into the pipe (although the playwright command might not forward these to the test script--I'd have to experiment with it to see). You could also have the generator script run `npx playwright test` for you as a subprocess.
comment on: http://stackoverflow.com/q/78166360

http://stackoverflow.com/q/78200396
linked to: http://stackoverflow.com/q/1398674
has comment: http://stackoverflow.com/comment/137866193
tagged with: date
has comment: http://stackoverflow.com/comment/137865907
tagged with: bash
has comment: http://stackoverflow.com/comment/137864550
has answer: http://stackoverflow.com/a/78201679
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137866388
tagged with: timezone
has comment: http://stackoverflow.com/comment/137865572
accepted answer: http://stackoverflow.com/a/78201679
has comment: http://stackoverflow.com/comment/137865370
has comment: http://stackoverflow.com/comment/137866493
score: 0
type: Question
has body: I'm running a bash script on a Github runner that I have no control over. In it, I need to compare timestamps to make certain that the current time is within an accepted timeframe. I get start and end timestamps with date, and the script should only continue if the current date/time is within those timestamps. But the server is so locked down that I cannot use TZ=America/Chicago date - it refuses to let me update TZ or anything else that I was able to find to temporarily set a time zone. I read that the time zone can be set to read-only, so that would be my guess. What finally worked was this: now=$(date '+%s' -d "now CST") startdate=$(date '+%s' -d "$startraw CST") finishdate=$(date '+%s' -d "$finishraw CST") if [ $now -ge $startdate ] && [ $now -lt $finishdate ]; then echo "Current time is allowed" else echo "ERROR - current time is not allowed" fi $startraw and $finishraw are in this format: 03/21/2024 08:00:00. I tried inserting America/Chicago instead of CST but that could not be parsed, so I used CST. Now I had a UTC timestamp that I could compare correctly - until Daylight Savings hit when the current time no longer fit into the start and end time values even when it should. So I found that there is CDT which is CST with daylight savings time included (if I understood it correctly). Except now my results are even more off... I just ran some test code: now1=$(date '+%s' -d "now CST") now2=$(date '+%s' -d "now CDT") echo "Human readable times:" echo "Now CST: $(date -d @$now1)" echo "Now CDT: $(date -d @$now2)" It is currently 8:11am CST [edit: CST in colloquial terms, not in computer terms]. This should be 1:11pm UTC according to Google. The output when I convert the timestamp back into human readable: Now CST: Thu Mar 21 19:11:44 UTC 2024 Now CDT: Thu Mar 21 18:11:44 UTC 2024 So that is 7pm and 6pm instead of the expected 1pm. The server should be set to use UTC since my test code resulted in an output with "UTC" in it. I guess it is possible that the server …
has comment: http://stackoverflow.com/comment/137868686
has title: Time Zones and Daylight Savings Time on restricted server
has comment: http://stackoverflow.com/comment/137864854
answer count: 1

http://stackoverflow.com/comment/137842312
has text: Indeed, this seems like an [XY problem](https://en.wikipedia.org/wiki/XY_problem). Read the digits in a loop or store them in an array. `fold stuff | while read -r line; do : something with this "$line"; done`
score: 0
comment on: http://stackoverflow.com/q/78187590
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137865633
type: QuestionComment
score: 0
has text: @Barmar with an array: `while read -ra ar;do case ${ar[0]} in Your ) echo My ${ar[@]:1};; Then ) echo Now ${ar[@]:1};;*)echo ${ar[@]};;esac;done`
type: Comment
comment on: http://stackoverflow.com/q/78200978

http://stackoverflow.com/comment/137833925
comment on: http://stackoverflow.com/a/78182177
has text: There's a misunderstanding. I don't want to change 100 email addresses in the same repo. For different repos, I would like to substitute an email address, `old_email`, which usually depends on the repo, with a new email address (and author), `new_email` and `author`, which are often the same for different repos. That's why I'd like to have a shell script with arguments.
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/a/78176886
has comment: http://stackoverflow.com/comment/137838950
type: Answer
has body: This MAY be what you're trying to do: $ cat tst.sh #!/usr/bin/env bash file='numbers.txt' if -f "$file" ; then IFS= read -r -p 'Input your number: ' tgt awk -v min=200 -v max=400 -v tgt="$tgt" ' BEGIN { if ( (tgt < min) || (max < tgt) ) { printf "Number %d must be between %d and %d.\n", tgt, min, max |"cat>&2" exit 1 } } { delete nums nums[$1] if ( NF == 8 ) { nums[substr($8,2)+0] } for ( num in nums ) { if ( num+0 <= tgt ) { print next } } } ' "$file" fi $ ./tst.sh Input your number: 100 Number 100 must be between 200 and 400. $ ./tst.sh Input your number: 200 500 text1 text1 text1 text1 text1 text1 (200) 200 text2 text2 text2 text2 text2 text2 $ ./tst.sh Input your number: 300 500 text1 text1 text1 text1 text1 text1 (200) 200 text2 text2 text2 text2 text2 text2 400 text4 text4 text4 text4 text4 text4 (300) $ ./tst.sh Input your number: 400 500 text1 text1 text1 text1 text1 text1 (200) 200 text2 text2 text2 text2 text2 text2 350 text3 text3 text3 text3 text3 text3 400 text4 text4 text4 text4 text4 text4 (300) $ ./tst.sh Input your number: 500 Number 500 must be between 200 and 400.
answers question: http://stackoverflow.com/q/78176347
has comment: http://stackoverflow.com/comment/137839509
has comment: http://stackoverflow.com/comment/137840993
score: 0

http://stackoverflow.com/comment/137855839
score: 2
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78194991
has text: The `kill` command just sends a signal to the specified process(es). It is not responsible for the job-status message that the shell emits when your process actually terminates, so redirecting `kill`'s standard streams does not impact that messaging.

http://stackoverflow.com/comment/137796677
comment on: http://stackoverflow.com/a/78160193
has text: Hi, did you try like browsing the net? See https://stackoverflow.com/questions/7917018/what-is-the-function-keyword-used-in-some-bash-scripts , https://unix.stackexchange.com/questions/73750/difference-between-function-foo-and-foo , https://www.shellcheck.net/wiki/SC2112 . And sadly bash-hackers.wiki.org is down and in the copy https://github.com/flokoe/bash-hackers-wiki the page that mentions `function` keyword as obsolete in bash is not readable https://github.com/rawiriblundell/wiki.bash-hackers.org/blob/main/scripting/obsolete.md . Overall my advice is, prefer POSIX compliance over ksh
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78171975
accepted answer of: http://stackoverflow.com/q/78171914
has comment: http://stackoverflow.com/comment/137814253
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/137814146
upvote count: 5
has comment: http://stackoverflow.com/comment/137815775
type: AcceptedAnswer
has body: Bash will perform interpolation on any double-quoted string. backticks signify command substitution in this context. So the following doesn't work because bash attempts to run xyflaged and replace it with the output of the command. mysql -u me -paaaaaaaaaaaaaaa -e "use test; SELECT `xyflagged`.`Article number`, `xyflagged`.`Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged"; Single quoted strings are not subject to interpolation. But, single quotes are also strange in bash because they disable all special characters. That means you can't escape a single quote with a backslash in a single quoted string becuase the backslash is not special; '\'' is not a valid bash expression. His next one is called a "heredoc". It has the same problem of string interpolation. mysql -u me -paaaaaaaaaaaaaaa << EOF use test; SELECT `xyflagged`.`Article number`, `xyflagged`.`Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; EOF But, if you put the heredoc end-of-file delineator (EOF here) within single quotes, it will disable special characters in the heredoc. This works better because since you're not enquoting the stiring in single quotes, they don't have special significance to bash: mysql -u me -paaaaaaaaaaaaaaa << 'EOF' use test; SELECT `xyflagged`.`Article number`, `xyflagged`.`Flag` INTO outfile 'Test1618' fields terminated by ',' ENCLOSED BY '\"' lines terminated by '\n' FROM xyflagged; EOF Or, you can provide the input in a file (the name / extension is irrelevant) and bash will provide that files' contents to the standard input of the program: mysql -u me -paaaaaaaaaaaaaaa < my-commands.sql I prefer this last invocation because if you give it a sane extension (like .sql in this case) most editors are smart enough to do syntax highlighting on the file which makes it easier to edit. Here's an exmaple of how that might work. Given the file cmd.sql: $ cat cmd…
has comment: http://stackoverflow.com/comment/137814729
has comment: http://stackoverflow.com/comment/137814071
answers question: http://stackoverflow.com/q/78171914
type: Answer
has comment: http://stackoverflow.com/comment/137826056
has comment: http://stackoverflow.com/comment/137815022

http://stackoverflow.com/a/78160193
score: 2
has body: How is subshell called from sed replacement part? In the presented code subshell is called before sed is executed, replacing the $(...) by it's output. Just like echo "$(add \\2)". sed "s/\(.*\) \(.*\)/\1 $(add \\2)/" becomes: sed "s/\(.*\) \(.*\)/\1 <\2>/" And then sed executes, replacing \2. Notes: prefer name() { } to define functions, keyword function is for compatibility for ksh. There is no reason to export -f add, function add is executed in current shell during command substitution expansion. Use set -x to debug your scripts. There is no magic. Researching quoting rules in shell, what is command substitution, how does double quotes differ from single quotes. sed is not capable of executing commands. GNU sed has an extension e flag that you can use to execute a custom command. Note, that exporting a function is a Bash specific feature, in case your $SHELL is not bash, would be better to call shell explicitly. Overall, the following command has big quoting problems and is unsafe, can remove all your files on malicious input. The quoting problems fastly become an issue. I recommend against using e sed extension and use it only for fun. add() { echo "<${1}>"; } export -f add sed 's/.*/add &/e' sed 's/.*/bash -c "add \"\$@\"" -- &/e' Overall, if you want to execute a command for every line of input, just use bash and read the input line by line https://mywiki.wooledge.org/BashFAQ/001 . If you want to do some real code with parsing, use awk or just move to something more like python.
upvote count: 2
has comment: http://stackoverflow.com/comment/137797479
downvote count: 0
answers question: http://stackoverflow.com/q/78160050
has comment: http://stackoverflow.com/comment/137796140
has comment: http://stackoverflow.com/comment/137815968
has comment: http://stackoverflow.com/comment/137797037
has comment: http://stackoverflow.com/comment/137796677
has comment: http://stackoverflow.com/comment/137819115
has comment: http://stackoverflow.com/comment/137796724
type: Answer

http://stackoverflow.com/a/78187523
has body: Bash @ parameter - "special" array? What is it exactly? It is a standard POSIX feature aimed directly at the problem of representing positional arguments as a group while preserving the identity and contents of each individual parameter. It is provided alongside the * parameter exactly for the difference between the two when they are referenced inside double quotes (which is almost always how you want to expand them, especially $@). The @ parameter is not an array because the POSIX shell language does not have arrays, though array support is provided as an extension by many popular implementations, such as Bash and Zsh. @ is simply a one-off, special case shell parameter with unique (in POSIX) expansion behavior. You can learn how and when to use it, You need to learn how and when to use it, because you can't get its particular behavior any other way, and if you're writing scripts very often then you'll definitely need that behavior from time to time. but still - is's quite confusing way of accessing "numbered" parameters (it's more like array but you're accessing with non-array syntax). I don't really see what's confusing about it. You don't use $@ to access individual positional parameters, only to access all of them collectively. The only other way to do that is $*. Both should pretty much always be expanded within double quotes to avoid unwanted word splitting or pathname expansion, so there's generally only one choice to make: do you want the results all as one unit ("$*") or as one unit per parameter ("$@")? Bash was improved a lot to replace legacy constructs like `` with more "clean" syntax like $(). POSIX specifies $(), and several other enhancements over the original Bourne shell. I'm not sure what other constructs you would consider "legacy" in this sense. I wonder why this aspect was not cleaned up to make bash syntax less tricky, eg. adding to shell's or function's environment array variable (e.g. SET) with "numbered" parameters inside (with option to u…
answers question: http://stackoverflow.com/q/78186259
has comment: http://stackoverflow.com/comment/137843027
score: 2
upvote count: 2
downvote count: 0
type: Answer

http://stackoverflow.com/comment/138052263
comment on: http://stackoverflow.com/q/78305587
has text: Since your objective is porting to Python, it seems like trying to run shell functions via a subprocess would be counterproductive. I suppose that mirrors something in the original shell script, but few shell idioms are very Pythonic. Surely part of porting shell scripts to Python would be porting the shell functions they use?
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78173011
duplicate of: http://stackoverflow.com/q/59564971
has title: How to run this code in all subdirectories?
linked to: http://stackoverflow.com/q/28176590
has answer: http://stackoverflow.com/a/78173029
has body: Found this code (https://github.com/Topslakr/x32Live-CleanUp/blob/master/Delete_Silent) and it works great in Cygwin for what I need, but, I'd like to have it also run in all subdirectories. Been searching, trying all kinds of things but nothing works. Not a linux person, btw. I know it is this first line that needs to change: for wav in *.wav do V=$($sox "$wav" -n stat 2>&1 | grep "Maximum amplitude" | cut -d ":" -f 2 | sed 's/ //g') if [[ $(echo "if ("$V" > "$MAX") 1 else 0" | bc) -eq 0 ]] then if [ $safe = 0 ] then echo "Deleting Data" rm -rfv "$wav" else echo "Running in Safe Mode" echo "Would delete $wav"; fi else echo "File $wav not slient" fi done I do have it working in specific levels of subdirectories by changing the line to: for wav in */*/*.wav But I have varying levels of subdirectories and it would be great if I could run one code instead of several for each respective level of subdirectory. Anyone know what the solution is? (Thank you!)
score: 0
type: Question
type: UnansweredQuestion
answer count: 1
linked to: http://stackoverflow.com/q/17205713
tagged with: subdirectory
linked to: http://stackoverflow.com/q/59564971
tagged with: bash

http://stackoverflow.com/comment/137988165
score: 0
type: QuestionComment
type: Comment
has text: To be clear: when you contrast with "filtering", are you talking about using `rsync`'s built-in capabilities to apply filter rules for selecting files to sync?
comment on: http://stackoverflow.com/q/78269359

http://stackoverflow.com/comment/137936435
has text: Oh, now everything makes sense.
comment on: http://stackoverflow.com/q/78240671
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78285559
has body: I am catching the error: ModuleNotFoundError: No module named 'scripts.marketing_functions' Project structure example. scripts/ ├──__init__.py ├── marketing_functions.py └── marketing/ └── some_script.py # Here my marketing_functions.py is used dags/ └── my_dag.py # Dag with bashOperator. it uses some_script.py with marketing_function.py import I put scripts into /opt/bitnami/airflow/scripts. I put dags into /opt/bitnami/airflow/dags. I add to PYTHONPATH /opt/bitnami/airflow/scripts. I see right PYTHONPATH using command "airflow info": Paths info airflow_home | /opt/bitnami/airflow system_path | /opt/bitnami/common/bin:/opt/bitnami/python/bin:/opt/bitnami/postgresql/bin:/opt/bitnami/airflow/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin python_path | /opt/bitnami/python/bin:/opt/bitnami/airflow/scripts:/opt/bitnami/python/lib/python39.zip:/opt/bitnami/python/lib/python3.9:/opt/bitnami/python/lib/python3.9/lib-dynload:/opt/bitnami/python/lib/pyt | hon3.9/site-packages:/opt/bitnami/python/lib/python3.9/site-packages/setuptools-63.4.3-py3.9.egg:/opt/bitnami/python/lib/python3.9/site-packages/pip-21.3.1-py3.9.egg:/opt/bitnami/airflow/dags:/opt/ | bitnami/airflow/config:/opt/bitnami/airflow/plugins airflow_on_path | True Dag code example: import datetime from airflow import DAG from airflow.operators.bash import BashOperator with DAG( dag_id="marketing_some_script", start_date=datetime.datetime(2023, 4, 16), schedule_interval="30 2 * * *", ) as dag: some_script = "/opt/bitnami/airflow/scripts/marketing/some_script.py" task_some_script = BashOperator( task_id="task_some_report", bash_command=f"python {some_script}" ) task_some_script Head of some_script.py file from datetime import datetime import gspread import pandas as pd from airflow.providers.postgres.hooks.postgres import PostgresHook from oauth2client.service_account import ServiceAccountCredentials from scripts.marketing_functions import * Pls. Help me find solution. UPD. Even if i just use …
has comment: http://stackoverflow.com/comment/138015001
tagged with: python
tagged with: airflow
tagged with: airflow-2.x
has comment: http://stackoverflow.com/comment/138016782
has answer: http://stackoverflow.com/a/78290606
score: -1
type: Question
upvote count: 0
has title: Airflow PYTHONPATH
type: UnansweredQuestion
answer count: 1
favorite count: 0
downvote count: 1
tagged with: bash

http://stackoverflow.com/comment/138026410
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78280733
type: AnswerComment
has text: Thanks a lot, John, for your kind support. I asked some follow-up questions [here in this GiHub comment](https://github.com/JModelica/JModelica/issues/7#issuecomment-2042540721). Would you be kind enough to look into this and see if you can help me find a more canonical way of debugging issues like this?

http://stackoverflow.com/a/78203898
has comment: http://stackoverflow.com/comment/137871115
type: Answer
has comment: http://stackoverflow.com/comment/137875039
has comment: http://stackoverflow.com/comment/137871175
answers question: http://stackoverflow.com/q/78203880
has body: What I would do: res=$(file -i "$input") case "$res" in *inode/directory*) echo dir ;; *text/plain*) echo file ;; *) echo to_add ;; esac to_add means to be implemented.
score: 0
has comment: http://stackoverflow.com/comment/137874368
has comment: http://stackoverflow.com/comment/137875119

http://stackoverflow.com/q/78263189
has answer: http://stackoverflow.com/a/78263541
tagged with: eof
has title: How to print a variable from an associative array and a multiline string from a loop cycle into a heredoc
accepted answer: http://stackoverflow.com/a/78263365
upvote count: 2
tagged with: arrays
has answer: http://stackoverflow.com/a/78263365
favorite count: 0
type: AnsweredQuestion
has body: I need to return variables (from 1 to 4) and the selected values from the associative array into the heredoc. Variables BASE=ppp-multi-image DEV=sdb # i.e. sdb or mmcblk0 ATTR=RequiredPartition,LegacyBIOSBootable SIZE=11GiB Associative array declare -A NameUrl NameUrl[uboot]=https://uboot.ext NameUrl[arch]=https:/archlinux.ext NameUrl[manjaro]=https://manjaro.ext NameUrl[mobian]=https://mobian.ext NameUrl[extra]=https://extra.ext $ sudo sfdisk /dev/$DEV --wipe always <<EOF label: gpt first-lba: 64 table-length: 10 attrs=RequiredPartition, type=D7B1F817-AA75-2F4F-830D-84818A145370, start=64, size=32704 name="$BASE-<# how do I return "uboot" here as first variable? #>" for NameUrl in "${!NameUrl[@]}"; do echo "attrs=\"$ATTR\", size=$SIZE, name=\"$BASE-${NameUrl}\"" done | sort <# this loop is not returned into EOF string #> attrs="$ATTR", size=+, name="extra" EOF Final result should be like following $ sfdisk /dev/sdb --wipe always <<EOF label: gpt first-lba: 64 table-length: 10 attrs=RequiredPartition, type=D7B1F817-AA75-2F4F-830D-84818A145370, start=64, size=32704 name="ppp-multi-image-uboot" attrs="RequiredPartition,LegacyBIOSBootable", size=11GiB, name="ppp-multi-image-arch" attrs="RequiredPartition,LegacyBIOSBootable", size=11GiB, name="ppp-multi-image-manjaro" attrs="RequiredPartition,LegacyBIOSBootable", size=11GiB, name="ppp-multi-image-mobian" attrs="RequiredPartition,LegacyBIOSBootable", size=+, name="extra" EOF
has comment: http://stackoverflow.com/comment/137975739
answer count: 2
has comment: http://stackoverflow.com/comment/137975719
downvote count: 0
possible better answer: http://stackoverflow.com/a/78263541
has comment: http://stackoverflow.com/comment/137975671
tagged with: for-loop
tagged with: bash
type: Question
score: 2

http://stackoverflow.com/q/78299332
has comment: http://stackoverflow.com/comment/138039045
has answer: http://stackoverflow.com/a/78299434
score: 0
type: Question
type: UnansweredQuestion
answer count: 1
tagged with: python
has title: Create bash script that calls a python script which takes in positional arguments, named arguments and flags
has body: I would like to create a bash-script that calls a python script. The python script accepts both positional arguments, named arguments and boolean flags. The idea is that the bash script passes whatever the users provides over to the python script. Take this python script example.py as an example: import argparse def run(positional_argument,named_argument='default',flag=False): print(positional_argument) print(named_argument) print(flag) if __name__ == '__main__': parser = argparse.ArgumentParser() # add positional arguments parser.add_argument('positional_argument',type=str,choices=['a','b']) # add keyword arguments parser.add_argument('--named_argument',type=str,required=False,default='default') # add flags parser.add_argument('--flag',action='store_true') # parse arguments args = parser.parse_args() # call function run(positional_argument=args.positional_argument, named_argument=args.named_argument, flag=args.flag) Now write a script wrapper.sh that internally calls example.py P.S.: Broader context for curious readers (although not strictly needed to solve my question): I would like to create a pip-package that can also be used as a command-line application. There's already an answer on that but it only covers positional arguments.
has comment: http://stackoverflow.com/comment/138039117
has comment: http://stackoverflow.com/comment/138039085
tagged with: command-line-arguments
has comment: http://stackoverflow.com/comment/138039637
tagged with: command-line-interface
tagged with: parameter-passing
tagged with: bash
linked to: http://stackoverflow.com/q/56534678

http://stackoverflow.com/comment/137807717
comment on: http://stackoverflow.com/q/78158123
has text: Wanted to thank OneCricketeer and Kurtis Rader for explaining my issue, that's helps me not do that again.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137776516
comment on: http://stackoverflow.com/q/78146600
has text: **Comments have been [moved to chat](https://chat.stackoverflow.com/rooms/257156/discussion-on-question-by-foad-s-farimani-how-to-alias-python-to-python-2); please do not continue the discussion here.** Before posting a comment below this one, please review the [purposes of comments](/help/privileges/comment). Comments that do not request clarification or suggest improvements usually belong as an [answer](/help/how-to-answer), on [meta], or in [chat]. Comments continuing discussion may be removed.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78151708
has comment: http://stackoverflow.com/comment/137813221
has comment: http://stackoverflow.com/comment/137778942
has comment: http://stackoverflow.com/comment/137801053
tagged with: hex
score: 0
type: Question
has title: Edit the file and replace the Hex value with Bash script
tagged with: linux
has comment: http://stackoverflow.com/comment/137782300
has comment: http://stackoverflow.com/comment/137783512
has answer: http://stackoverflow.com/a/78155511
has comment: http://stackoverflow.com/comment/137802434
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137801055
answer count: 1
has body: I have several larger files (400-800MiB) in which I need to convert Hex values to others. I can do this in some Hex editor, but I would like to do it automatically, in a Bash script. I know how to check with xxd whether a given value is in a file: FILE='file.vpk' SEARCH_STRING='MaxRagdollCount' OLD_HEX_VALUE="$( echo -n "$SEARCH_STRING" | xxd -p )" HEX_VALUE=($( xxd -p "$FILE" | grep -E -o "${OLD_HEX_VALUE}222022[0-9]{,2}22" )) echo "$HEX_VALUE" but I can't figure out how to edit it. I need to replace the value of MaxRagdollCount" "any_number" (4d6178526167646f6c6c436f756e742220223222) with MaxRagdollCount" "9" (4d6178526167646f6c6c436f756e742220223922).
tagged with: bash

http://stackoverflow.com/comment/137801505
score: 1
comment on: http://stackoverflow.com/a/78160457
type: Comment
type: AnswerComment
has text: Yes, exactly. Provided that the command is available in the `docker` base image. If not then you need to install it or change the base image.

http://stackoverflow.com/q/78276360
accepted answer: http://stackoverflow.com/a/78276969
has answer: http://stackoverflow.com/a/78276456
score: 3
upvote count: 3
has answer: http://stackoverflow.com/a/78278389
has answer: http://stackoverflow.com/a/78279573
downvote count: 0
answer count: 7
tagged with: bash
favorite count: 0
has answer: http://stackoverflow.com/a/78276969
type: AnsweredQuestion
tagged with: awk
has answer: http://stackoverflow.com/a/78279685
possible better answer: http://stackoverflow.com/a/78276456
has answer: http://stackoverflow.com/a/78278662
has body: Given the following contents of file: a b c abcde ab cd ef abcdefg a a b I want to rearrange the output based on the number of non-space characters, but retain the spaces when the output is given. Additionally, I need this to be a single command, not something that I put into a script. Pretty much everything I try ends up like this: cat file.txt |awk '{ count=gsub(/ /,&quot;&quot;); print length($0), $0 }' | sort 1 a 2 ab 3 abc 5 abcde 6 abcdef 7 abcdefg Which does give me the correct count and sort, but it also removes the spaces from the original output, which I do not want. The desired output would be 1 a 2 a b 3 a b c 5 abcde 6 ab cd ef 7 abcdefg
type: Question
has title: Sort output in bash based on character count not including spaces, but retain the spaces in output
has answer: http://stackoverflow.com/a/78277044

http://stackoverflow.com/comment/137844547
type: QuestionComment
has text: At the moment, all of the applications are installed manually. I am trying to find an automated solution so I won't have keep doing the manual steps. I am at the point now to see if Puppet or Ansible would be the better choice (not much of a developer) so just trying to see which one has the easier way of deploying the applications and can handle things like an if/else statement for checking to see if the application is already installed or not before attempting to install.
type: Comment
comment on: http://stackoverflow.com/q/78155690
score: 0

http://stackoverflow.com/q/78290808
has comment: http://stackoverflow.com/comment/138024013
has comment: http://stackoverflow.com/comment/138025279
downvote count: 0
tagged with: bash
has answer: http://stackoverflow.com/a/78290897
has answer: http://stackoverflow.com/a/78291700
has answer: http://stackoverflow.com/a/78293719
has comment: http://stackoverflow.com/comment/138024313
has comment: http://stackoverflow.com/comment/138023943
has title: Run a command only during a defined time in shell script
has body: I am trying to capture some details in a log file and would want that these details about my virtual machine should be captured only between 23:00 until 01:00. i am going to run this using nohup in the background like - nohup script.sh & and The script should only start running at 23:00 until 01:00. I have tried the below but it doesnt seem to do what i excepted:- #!/bin/bash prodStartTime="230000" prodEndTime="010000" logfile=/tmp/processrunning.txt touch $logfile while true do currentTime=`date +"%H%M%S"` if $currentTime -ge $prodStartTime && $currentTime -le $prodEndTime ; then ps aux | sort -nrk 3,3 | head -n 5 > $logfile else : fi sleep 30 done
type: Question
answer count: 4
tagged with: shell
score: 1
has comment: http://stackoverflow.com/comment/138027091
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78291593
has comment: http://stackoverflow.com/comment/138029133
upvote count: 1
has comment: http://stackoverflow.com/comment/138024159
favorite count: 0

http://stackoverflow.com/comment/137888087
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78213645
type: Comment
has text: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html

http://stackoverflow.com/comment/137823995
has text: It worked with the input data you had shown in question. Check for presence of dos line ending in your input
score: 0
comment on: http://stackoverflow.com/a/78176299
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137771125
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78147406
has text: Isn't it that the error message is not _command not found_, but something like _bash: singularity: command not found_?
type: Comment

http://stackoverflow.com/q/78249607
has comment: http://stackoverflow.com/comment/137970114
has body: I wanted to convert some Postbank PDFs to CSV and found Postbank_PDF2CSV which is based on command line utils and bash-script-based parsing. I wanted to try it out with Cygwin under Windows since I had no other Linux at hand and was quite positive it would work. It did not work right away and greeted me with: $ ./postbank_pdf2csv_bis_2023-02.sh -? Dieses Skript funktioniert nur mit FreeBSD, Linux or Macos. I tried to remove the overjealous restriction, installed some required libs, fixed some script bug (that exited the script before CSV generation and echoing hallo) but could not make it work getting errors like: GPL Ghostscript 10.01.2: Unrecoverable error, exit code 1 Although I have a github account I could not file an issue or get in contact at the project itself.
has answer: http://stackoverflow.com/a/78249608
has comment: http://stackoverflow.com/comment/137982425
type: Question
downvote count: 0
type: UnansweredQuestion
answer count: 1
upvote count: 1
score: 1
tagged with: bash
favorite count: 0
has title: postbank_pdf2csv: how to setup with Cygwin in Windows?

http://stackoverflow.com/comment/137891816
type: Comment
comment on: http://stackoverflow.com/q/78215669
has text: The easy answer is probably to force the FDs back to being duplicates of each other. Put `exec 2>&1` or `exec >&2` at the top of your script, ugly as it is, and then you'll be in a state where POSIX guarantees ordering. This does mean that whatever functionality TextAdept is relying on this split to provide (color highlighting differently between stdout and stderr?) won't work.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137879238
comment on: http://stackoverflow.com/q/78208234
has text: Did you try using `if: ${{ env.READY == 'true' }}` and `if: ${{ env.READY != 'true' }}` instead?
score: 1
type: QuestionComment
type: Comment

linux
tags question: http://stackoverflow.com/q/78252458
tags question: http://stackoverflow.com/q/78194906
tags question: http://stackoverflow.com/q/78228798
tags question: http://stackoverflow.com/q/78194866
tags question: http://stackoverflow.com/q/78147701
tags question: http://stackoverflow.com/q/78201574
tags question: http://stackoverflow.com/q/78297014
tags question: http://stackoverflow.com/q/78270350
tags question: http://stackoverflow.com/q/78241899
tags question: http://stackoverflow.com/q/78232246
tag name: linux
type: Tag
tags question: http://stackoverflow.com/q/78284934
tags question: http://stackoverflow.com/q/78192103
tags question: http://stackoverflow.com/q/78199094
tags question: http://stackoverflow.com/q/78166538
tags question: http://stackoverflow.com/q/78286060
tags question: http://stackoverflow.com/q/78211761
tags question: http://stackoverflow.com/q/78173269
tags question: http://stackoverflow.com/q/78158725
tags question: http://stackoverflow.com/q/78218123
tags question: http://stackoverflow.com/q/78175570
tags question: http://stackoverflow.com/q/78261051
tags question: http://stackoverflow.com/q/78245937
tags question: http://stackoverflow.com/q/78203871
tags question: http://stackoverflow.com/q/78274285
tags question: http://stackoverflow.com/q/78163062
tags question: http://stackoverflow.com/q/78184175
tags question: http://stackoverflow.com/q/78192206
tags question: http://stackoverflow.com/q/78204849
tags question: http://stackoverflow.com/q/78196837
tags question: http://stackoverflow.com/q/78154096
tags question: http://stackoverflow.com/q/78225038
tags question: http://stackoverflow.com/q/78280175
tags question: http://stackoverflow.com/q/78226499
tags question: http://stackoverflow.com/q/78287441
tags question: http://stackoverflow.com/q/78151708
tags question: http://stackoverflow.com/q/78285382
tags question: http://stackoverflow.com/q/78228745
tags question: http://stackoverflow.com/q/78224799
tags question: http://stackoverflow.com/q/78278159
tags question: http://stackoverflow.com/q/78194991
tags question: http://stackoverflow.com/q/78207181
tags question: http://stackoverflow.com/q/78211473
tags question: http://stackoverflow.com/q/78193259
tags question: http://stackoverflow.com/q/78376334
tags question: http://stackoverflow.com/q/78383368
tags question: http://stackoverflow.com/q/78374366
tags question: http://stackoverflow.com/q/78359494
tags question: http://stackoverflow.com/q/78392914
tags question: http://stackoverflow.com/q/78423090
tags question: http://stackoverflow.com/q/78420131
tags question: http://stackoverflow.com/q/78354041
tags question: http://stackoverflow.com/q/78419450
tags question: http://stackoverflow.com/q/78385537
tags question: http://stackoverflow.com/q/78419580
tags question: http://stackoverflow.com/q/78335326
tags question: http://stackoverflow.com/q/78341760
tags question: http://stackoverflow.com/q/78361035
tags question: http://stackoverflow.com/q/78444561
tags question: http://stackoverflow.com/q/78336864
tags question: http://stackoverflow.com/q/78368689
tags question: http://stackoverflow.com/q/78334722
tags question: http://stackoverflow.com/q/78359720
tags question: http://stackoverflow.com/q/78391938
tags question: http://stackoverflow.com/q/78375308
tags question: http://stackoverflow.com/q/78410973
tags question: http://stackoverflow.com/q/78390318
tags question: http://stackoverflow.com/q/78340874
tags question: http://stackoverflow.com/q/78353316
tags question: http://stackoverflow.com/q/78329053
tags question: http://stackoverflow.com/q/78372933
tags question: http://stackoverflow.com/q/78358550
tags question: http://stackoverflow.com/q/78409749
tags question: http://stackoverflow.com/q/78385269
tags question: http://stackoverflow.com/q/78359185
tags question: http://stackoverflow.com/q/78362703
tags question: http://stackoverflow.com/q/78369669
tags question: http://stackoverflow.com/q/78444497
tags question: http://stackoverflow.com/q/78336037

http://stackoverflow.com/q/78150653
has body: For the following script #!/usr/bin/env bash more <<_EOF_ PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT. PLEASE READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED TEXT _EOF_ agreed= while [ x$agreed = x ]; do echo echo "Do you accept all the terms?" echo "Do you agree to the above license terms? [y/n] " read reply leftover case $reply in y* | Y*) agreed=1;; n* | n*) echo "If you don't agree to the license you can't install this sofware"; exit 1;; esac done How do you automatically skip the more command? printf "y\n" | bash ./file.sh doesn't seem to work.
has comment: http://stackoverflow.com/comment/137777331
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137777545
has answer: http://stackoverflow.com/a/78150771
has title: How to automatically answer "more" command
answer count: 3
has answer: http://stackoverflow.com/a/78150663
accepted answer: http://stackoverflow.com/a/78150761
has comment: http://stackoverflow.com/comment/137777374
downvote count: 0
score: 1
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78150761
possible better answer: http://stackoverflow.com/a/78150663

http://stackoverflow.com/comment/137843364
has text: I agree with the conclusion, I do not think I follow `( is metacharacter and control operator`. "Control operator" is `&` `&&` `||` `|` `;` and in the context of `case` it's `)`. `( ... )` and `{ ... }` are command groupings, with the difference that `(` spawns a subshell. `{` is indeed a reserved word. I do not know what is a "metacharacter". The sequences of characters are important. `$((` vs `((` vs `$(` vs `${` vs `{` vs `(` all mean different things.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78186982

http://stackoverflow.com/comment/137884582
type: AnswerComment
score: 0
has text: Yes. Here is a screenshot: https://i.sstatic.net/fP99t.png
type: Comment
comment on: http://stackoverflow.com/a/78211545

http://stackoverflow.com/comment/137801396
has text: Use `mkdir` and `touch`?
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78164579

http://stackoverflow.com/comment/137807081
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78167873
type: AnswerComment
has text: Doesn't work fully - output: `3 test: google 2 my: google 1 this: meta 1 hello: microsoft `

http://stackoverflow.com/a/78192118
answers question: http://stackoverflow.com/q/78192103
type: Answer
downvote count: 0
has body: You can achieve your requirement by iterating through the .img.xz files in the folder and providing options to the user to select which image to use. Here's a script that does just that: #!/bin/bash # Change directory to the folder containing the .img.xz files cd /img/ || exit # Array to store available image files img_files=() # Find .img.xz files in the current directory while IFS= read -r -d $'\0'; do img_files+=("$REPLY") done < <(find . -maxdepth 1 -type f -name "*.img.xz" -print0) # Check if any image files were found if [ ${#img_files[@]} -eq 0 ]; then echo "No .img.xz files found in the /img/ folder." exit 1 fi echo "Available image files:" for ((i=0; i<${#img_files[@]}; i++)); do echo "$(($i+1)). ${img_files[$i]}" done # Prompt user to select an image file read -rp "Enter the number corresponding to the image file you want to use: " selection # Validate user input if ! [[ "$selection" =~ ^[1-9]+$ ]] || ((selection < 1)) || ((selection > ${#img_files[@]})); then echo "Invalid selection. Please enter a number between 1 and ${#img_files[@]}." exit 1 fi # Get the selected image file selected_img="${img_files[$((selection - 1))]}" # Extract and write the image to the /dev/mmcblk0 device unxz -c "$selected_img" | dd of=/dev/mmcblk0 bs=4096 status=progress echo "Image flashing complete." This script: Changes directory to the /img/ folder. Searches for .img.xz files in the current directory. Displays a numbered list of available image files. Prompts the user to select an image file by entering the corresponding number. Validates the user input to ensure it's a valid selection. Extracts and writes the selected image file to the /dev/mmcblk0 device using unxz and dd. Prints a message when the image flashing is complete. Make sure to run this script with appropriate permissions and be cautious when writing to the /dev/mmcblk0 device, as it can potentially overwrite data.
has comment: http://stackoverflow.com/comment/137857501
has comment: http://stackoverflow.com/comment/137850275
has comment: http://stackoverflow.com/comment/137854833
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/137852096

http://stackoverflow.com/q/78196593
has comment: http://stackoverflow.com/comment/137858187
downvote count: 0
has comment: http://stackoverflow.com/comment/137858225
score: 1
has answer: http://stackoverflow.com/a/78196739
has comment: http://stackoverflow.com/comment/137858160
answer count: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/137858133
has body: I have a function that returns several string separated by "|" and i am using read to parse them in tokens. Some of the strings might contain newlines (i.e. \n) but from my perspective read is removing them. This is a simplified version of my code where i am able to reproduce the issue. #!/bin/bash sMABz_IFS="|" MABzBuildAlert () { read -r -d '' pThirdFieldTwoLines << sAPPEND_STRING_EOM_2 INTFARE.D240319.T1100 INTFARE.D240319.T1101 sAPPEND_STRING_EOM_2 echo "FirstField${sMABz_IFS}SecondField${sMABz_IFS}${pThirdFieldTwoLines}${sMABz_IFS}FourthField" } sMABzAlert=`MABzBuildAlert` echo "** Using \`\` , echo and read -r**" echo "sMABzAlert:[$sMABzAlert]" IFS=\'"$sMABz_IFS"\' read -r sFirstField sSecondField sThirdFieldTwoLines sFourthField<<< `echo "${sMABzAlert}"` echo "sFirstField:[$sFirstField]" echo "sSecondField:[$sSecondField]" echo "sThirdFieldTwoLines:[$sThirdFieldTwoLines]" echo "sFourthField:[$sFourthField]" echo This is the output i am getting: $ POC.sh \*\* Using \`\` , echo and read -r\*\* sMABzAlert:\[FirstField|SecondField|INTFARE.D240319.T1100 INTFARE.D240319.T1101|FourthField\] sFirstField:\[FirstField\] sSecondField:\[SecondField\] sThirdFieldTwoLines:\[INTFARE.D240319.T1100 INTFARE.D240319.T1101\] sFourthField:\[FourthField\] What i am expecting is to have this output: $ POC.sh \*\* Using \`\` , echo and read -r\*\* sMABzAlert:\[FirstField|SecondField|INTFARE.D240319.T1100 INTFARE.D240319.T1101|FourthField\] sFirstField:\[FirstField\] sSecondField:\[SecondField\] sThirdFieldTwoLines:\[**INTFARE.D240319.T1100 INTFARE.D240319.T1101**\] sFourthField:\[FourthField\] Note: I have tried with few other variants of read, including these: IFS=\'"$sMABz_IFS"\' read sFirstField sSecondField sThirdFieldTwoLines sFourthField<<< `echo "${sMABzAlert}"` IFS=\'"$sMABz_IFS"\' read -r sFirstField sSecondField sThirdFieldTwoLines sFourthField<<<"${sMABzAlert}" IFS=\'"$sMABz_IFS"\' read -r sFirstField sSecondField sThirdFieldTwoLines sFourthField<<<"$(echo "${sMABzAlert}"…
has comment: http://stackoverflow.com/comment/137858251
accepted answer: http://stackoverflow.com/a/78196739
has title: bash - have read respect newlines (i.e. \n) contained on a string
has comment: http://stackoverflow.com/comment/137858156
has comment: http://stackoverflow.com/comment/137858192
has comment: http://stackoverflow.com/comment/137858139
linked to: http://stackoverflow.com/q/33245568
linked to: http://stackoverflow.com/q/20144593
tagged with: bash
has comment: http://stackoverflow.com/comment/137858284
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137858196
has comment: http://stackoverflow.com/comment/137861413
has comment: http://stackoverflow.com/comment/137858115
has comment: http://stackoverflow.com/comment/137858173
has comment: http://stackoverflow.com/comment/137858202
has comment: http://stackoverflow.com/comment/137858207
has comment: http://stackoverflow.com/comment/137858308
type: Question
has comment: http://stackoverflow.com/comment/137858199
linked to: http://stackoverflow.com/q/37728699
has comment: http://stackoverflow.com/comment/137858210
has comment: http://stackoverflow.com/comment/137858169

http://stackoverflow.com/comment/137787277
comment on: http://stackoverflow.com/q/78155690
type: Comment
type: QuestionComment
has text: The intent is to be able to stand up a series of puppet client nodes and install several 'monitoring' agents on them like ESET, BelManage, AlertLogic, to satisfy our SRE team needs. I thought of trying something where I could have something like a node 'server-name' { include belmanage-package, include eset-package, include alertlogic-package } in a site.pp file and have each of the above 'includes' be modules that could be used as needed. Is it not possible to do something like this in Puppet?
score: 0

http://stackoverflow.com/q/78156630
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137787540
score: 0
has body: I tried all variations and things I found on stackoverflow or Google, but for some reason the at bash command seems to do something different. What I would like to do is to read the result of my scheduled command into a variable: myVar=$(echo "echo 'Hello World'" | at now + 1 minute) The at command prints out things like: warning: commands will be executed using /bin/sh job 12 at Wed Mar 13 20:21:00 2024 I would expect to have this information in the ${myVar} with the above, but it's not there. Anyone any idea how I can get the result from at into a variable? And to be sure it has nothing to do with my bash version: bash --version GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu) Thanks!
tagged with: bash
tagged with: output
has comment: http://stackoverflow.com/comment/137787564
has comment: http://stackoverflow.com/comment/137787517
linked to: http://stackoverflow.com/q/36486790
has comment: http://stackoverflow.com/comment/137787469
has title: bash: reading "at" result into variable
type: Question
tagged with: at-job
answer count: 0
duplicate of: http://stackoverflow.com/q/36486790

http://stackoverflow.com/a/78189875
upvote count: 1
type: Answer
has body: I've found in a regex I have that if the string I'm testing has a backtick in it, I can only get it to match is if I escape the backtick while enclosed in brackets > [\`]. Regularly escaping the character like you would an asterisk \* does not work, nor does just keeping the backtick in brackets. POSIX regexes have no such issues with backticks, but because of their significance to the shell, literal backticks in your shell commands do need to be quoted to prevent them from being interpreted as delimiting a command substitution. Moreover, double quotes don't do that job. Like parameter references, command substitutions are still recognized within double-quoted regions. You need single quotes or a backslash to escape a backtick. Observe: $ pattern="symbolic[[:space:]]link[[:space:]]to[[:space:]][\`]([^[[:space:]]+)'" $ echo "$pattern" symbolic[[:space:]]link[[:space:]]to[[:space:]][`]([^[[:space:]]+)' There is no backslash in that pattern. It was used merely to escape the backtick in the command to set variable pattern. And that pattern works: $ text="z1.gz: symbolic link to \`zip1.gz'" $ echo "$text" z1.gz: symbolic link to `zip1.gz' $ "$text" =~ $pattern && echo matches matches But it also works without the square brackets: $ pattern="symbolic[[:space:]]link[[:space:]]to[[:space:]]\`([^[[:space:]]+)'" $ echo "$pattern" symbolic[[:space:]]link[[:space:]]to[[:space:]]`([^[[:space:]]+)' $ "$text" =~ $pattern && echo matches matches And of course, you can use single quotes to avoid escaping the backtick, but then you need to quote that trailing literal single quote differently. For example: $ pattern='symbolic[[:space:]]link[[:space:]]to[[:space:]]`([^[[:space:]]+)'\' $ echo "$pattern" symbolic[[:space:]]link[[:space:]]to[[:space:]]`([^[[:space:]]+)' $ "$text" =~ $pattern && echo matches matches And you can express the pattern literally in the match expression: $ [[ "$text" =~ \ symbolic[[:space:]]link[[:space:]]to[[:space:]]\`([^[[:space:]]+)\' ]] &&…
answers question: http://stackoverflow.com/q/78188914
downvote count: 0
score: 1

http://stackoverflow.com/a/78173873
score: 2
answers question: http://stackoverflow.com/q/78173589
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/137819094
downvote count: 0
has comment: http://stackoverflow.com/comment/137819180
has body: Be aware that * potentially does more than you might think. (See https://jqlang.github.io/jq/manual/v1.7/#multiplication-division-modulo for details.) The &quot;+&quot; operator on objects is much less complicated, so chances are that something like the following will meet your needs: jq -n '[inputs] | add' file*.json

http://stackoverflow.com/q/78183685
tagged with: bash
has answer: http://stackoverflow.com/a/78183686
tagged with: serial-port
score: 0
type: Question
type: UnansweredQuestion
answer count: 1
has body: I'm looking for a way to redirect stdin and stdout to the same character device. I know I can do it manually: rz &lt;/dev/ttyUSB0 &gt;/dev/ttyUSB0 However, it feels repetitive. On top of that, shellcheck complains: Make sure not to read and write the same file in the same pipeline It's quite easy to redirect stdout and stderr to the same file (cmd &gt;file 2&gt;&amp;1) but it won't work for stdin and stdout: $ rz &gt;/dev/ttyUSB0 &lt;&amp;1 rz waiting to receive.Retry 0: Got TIMEOUT Retry 0: Got TIMEOUT
has title: Redirecting stdin and stdout to the same device in shell

http://stackoverflow.com/comment/137872821
type: QuestionComment
type: Comment
has text: So, what is your question then? You have posted a script (which, admittedly, does not make sense), but you have not asked anything.
comment on: http://stackoverflow.com/q/78203984
score: 0

ubuntu-20.04
tags question: http://stackoverflow.com/q/78218123
tag name: ubuntu-20.04
type: Tag

http://stackoverflow.com/q/78197884
tagged with: environment-variables
duplicate of: http://stackoverflow.com/q/532155
has comment: http://stackoverflow.com/comment/137860896
linked to: http://stackoverflow.com/q/37676849
has title: Current file path where an env variable is located
has body: I need to know where my actual env variable is stored. If I do echo $PATH it outputs this: /home/myuser/.nvm/versions/node/v20.9.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/myuser/.local/share/JetBrains/Toolbox/scripts Which path does this env variable come from? I need to know the exact file path, not all probable possible paths. I'm using Ubuntu. I already check this post but my question is different, I do not need to know where the var is stored in memory, but in which file on disk. When the pc is shutted down, afaik nothing remain in the memory (ram), so after reboot the os reads these vars somewhere and put them again in memory. So these vars are stored in a file (like .bashrc or another one), not only in memory. So, where is its file path? I don't want to use a "casual" file path for editing my $PATH env, I want to edit where it is set. Thanks
tagged with: bash
has comment: http://stackoverflow.com/comment/137860563
type: Question
has comment: http://stackoverflow.com/comment/137860940
has comment: http://stackoverflow.com/comment/137861527
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/532155
has comment: http://stackoverflow.com/comment/137860499
has comment: http://stackoverflow.com/comment/137860965
score: 0
has comment: http://stackoverflow.com/comment/137860984
answer count: 0

http://stackoverflow.com/q/78240103
has comment: http://stackoverflow.com/comment/137935648
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137935823
has comment: http://stackoverflow.com/comment/137935773
tagged with: redis-cli
tagged with: bash
type: Question
tagged with: redis
has comment: http://stackoverflow.com/comment/137935774
has title: Need a script to fetch the redis latency values over 20 seconds and store the results in a file
has comment: http://stackoverflow.com/comment/137935746
has comment: http://stackoverflow.com/comment/137935631
has answer: http://stackoverflow.com/a/78242737
has body: I need to periodically update a file that will host the Redis Latency values at certain time daily. I am using the command redis-cli --latency -h 127.0.0.1 -p 6379. The issue is that this command works only in interactive mode and it cycles through the values. I want to get the latency values over a certain time period and then put the values in my file. When I execute the following command with the timeout utility, it runs for the specified 20 seconds: timeout 20 /usr/local/bin/redis-cli --latency -h 127.0.0.1 -p 6379 However, when I try to capture the output in a variable (to pass it int the file) like this: Latency=$(timeout 20 /usr/local/bin/redis-cli --latency -h 127.0.0.1 -p 6379) echo $Latency The command stops immediately after running, rather than running for the intended 20 seconds. How can I capture the Redis latency output for the full duration of 20 seconds into a variable?
score: 0
accepted answer: http://stackoverflow.com/a/78242737
tagged with: shell

http://stackoverflow.com/comment/137787550
comment on: http://stackoverflow.com/q/78156679
score: 0
has text: Bard and Bing suggested this approach, and I'm pretty sure I've seen something similar in tutorials. Are you saying this is not possible in bash at all?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137850918
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78192206
type: Comment
has text: @KamilCuk I would like to have script that can intake a uername and password in a set of strings, and verify if it matches to a user on the local system The strings are gathered from an html page i made, and passed as variables. I would like to use these and verify them through Linux's PAM system. Hope this helps clarify

http://stackoverflow.com/comment/137826189
has text: same result with set -o xtrace or set -x. it shows me what i need on the screen but inside the output file i see only output not command..
type: QuestionComment
comment on: http://stackoverflow.com/q/78178702
type: Comment
score: 0

http://stackoverflow.com/comment/137867475
comment on: http://stackoverflow.com/q/78201574
score: 0
has text: You should probably also use the `-F` option. It is possible that you want or need `-i`, too. Overall, `grep -Fw -q` or maybe `grep -Fwi -q`.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137925049
score: 0
comment on: http://stackoverflow.com/a/78232840
type: Comment
type: AnswerComment
has text: Another approach would be to turn on expand_aliases via the environment rather than in code run after the shell is finished initializing.

http://stackoverflow.com/comment/138012402
comment on: http://stackoverflow.com/q/78283701
type: QuestionComment
score: 1
has text: Don't post images or links in questions, just text. We can't copy/paste an image to test with and not everyone will be willing/able to go clicking around other pages to piece your question together to be able to help you.
type: Comment

http://stackoverflow.com/q/78146721
has answer: http://stackoverflow.com/a/78146818
has body: I want to check if some files match the patterns declared in a manifest file. So, for example, the following files A_cycles.pdf A_filter_passed_vs_occupied.pdf A_grouped_cycle.csv A_grouped_lane.csv A_grouped_lane_cycle.csv A_metadata.csv A_percent_q30.pdf A_raw.csv seqrun_A.json should be checked against this MANIFEST *_grouped_cycle.csv *_grouped_lane.csv *_grouped_lane_cycle.csv *_metadata.csv *_raw.csv seqrun_*.json This is my code: while IFS= read -r pattern; do # Modify the pattern to match filenames without needing to escape dot characters modified_pattern="${pattern//./[.]}" # Convert the modified pattern to a regular expression regex_pattern="^${modified_pattern//\*/.*}" # Check if the filename matches the pattern using regular expressions if "$filename1" =~ $regex_pattern ; then included=true echo "Filename $(basename "$filename1") matched pattern $pattern in MANIFEST" break fi done < <(grep -v '^#' "$MANIFEST_FILE") and this is the output: Filename A_grouped_cycle.csv matched pattern *_grouped_cycle.csv in MANIFEST Filename A_grouped_lane.csv matched pattern *_grouped_lane.csv in MANIFEST Filename A_grouped_lane_cycle.csv matched pattern *_grouped_lane_cycle.csv in MANIFEST Filename A_metadata.csv matched pattern *_metadata.csv in MANIFEST Filename A_raw.csv matched pattern *_raw.csv in MANIFEST Is almost working but I don't know why is not matching seqrun_A.json with seqrun_*.json. I tried several approaches but without success. This approach should work/match with any kind of pattern declared in the MANIFEST file, in that similar way (basically using *). Btw, this is included in a Gitlab CI Job
score: 0
type: Question
tagged with: shell
has title: Match files against MANIFEST of patterns
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137770238
tagged with: unix
answer count: 3
has answer: http://stackoverflow.com/a/78147054
tagged with: gitlab-ci
has comment: http://stackoverflow.com/comment/137770182
has answer: http://stackoverflow.com/a/78147072
tagged with: bash

playwright
type: Tag
tags question: http://stackoverflow.com/q/78166360
tag name: playwright

http://stackoverflow.com/q/78155628
tagged with: vim
has comment: http://stackoverflow.com/comment/137785815
has comment: http://stackoverflow.com/comment/137785988
has title: Prepend text to a different file from within Vim
answer count: 2
has answer: http://stackoverflow.com/a/78156004
downvote count: 0
tagged with: bash
accepted answer: http://stackoverflow.com/a/78156004
favorite count: 0
tagged with: http://stackoverflow.com/tag/txt
has answer: http://stackoverflow.com/a/78181057
type: AnsweredQuestion
score: 2
possible better answer: http://stackoverflow.com/a/78181057
tagged with: sed
upvote count: 2
type: Question
has comment: http://stackoverflow.com/comment/137785912
has comment: http://stackoverflow.com/comment/137785927
has body: I am trying to prepend text from within Vim to another file. Specifically the current line, but a visual selection would be nice as well. Eventually I would like to map it to something like <leader>i. In bash I can use the following sed command to achieve this: sed -i '1i some new text' myfile.md So I tried this from within vim: :execute "!sed -i '1i" .getline('.') "' myfile.md" This works but when there is an ! in the currentline: shell returned 2. Then I found out about shellescape, and I got the following command to work. Now it seems like I'm doing something wrong escaping characters as this will add single quotes around the string. :execute "!sed -i \"1i " . shellescape(getline('.'), 1) . "\" myfile.m What am I missing? Is there a better way?

http://stackoverflow.com/q/78182030
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/137832541
tagged with: bash
has answer: http://stackoverflow.com/a/78187835
has comment: http://stackoverflow.com/comment/137832166
tagged with: alias
has comment: http://stackoverflow.com/comment/137832085
has answer: http://stackoverflow.com/a/78182345
type: Question
has comment: http://stackoverflow.com/comment/137832042
type: UnansweredQuestion
tagged with: timer
has comment: http://stackoverflow.com/comment/137832218
has body: I have a few alias' on my Dreadnaught embedded Linux system, some of them have a reasonably long list of jobs to do. I'm trying to improve the efficiency of these task, and trying to time how long each permutation took, so I can confirm which is the quickest permutation. I've built my scripts up in parts, and found each part worked... but not when they were put together. I'll put the attempts at the end of the question so they don't flood the question out.... However, after hours trying to figure out why it appeared to work in parts but not as a whole, I've discovered that The command substitution is evaluated when you define the alias, not when you execute the it. How can I create an alias that times itself for several tasks (calls to other alias', calls to system). I tried using functions instead; equally unsuccessfully. I tried time, but it doesn't like getting alias' passed to it; and my alias' call many other alias' and system calls, so it's not practical to unpack them. Is there any way to create a bash alias (or other method that can be called from bash?) that times itself and/or other processes? Update - possible solution, but looking for any better suggestions? As I often find, writing out a question on SO makes me carefully explain it, which somehow triggers my head into thinking about alternatives I've not thought of previously. I've just written a bash script that calls the tasks - because it's not using alias' for the time records, it's calling the time functions directly: #!/bin/bash echo "== Task 1 Start ==" timerstart1=$(eval 'date +%s') TimerStartstr1=$(eval 'date -d@$((timerstart1))') echo "Task 1 started at $timerstart1 = $TimerStartstr1" myTask1 timerend1=$(eval 'date +%s') TimerEndstr1=$(eval 'date -d@$timerend1') echo "Task 1 completed at $timerend1 = $TimerEndstr1" duration1=$(($timerend1 - $timerstart1)) echo "=========== Task 1 Complete, took $duration1 ==================" echo "== Task 2 Start ==" timerstart2=$(eval 'date +%s') TimerStartst…
has title: How to time how long a bash alias took to execute (solved... maybe?)

http://stackoverflow.com/a/78212459
downvote count: 2
has comment: http://stackoverflow.com/comment/137886594
has comment: http://stackoverflow.com/comment/137886264
has comment: http://stackoverflow.com/comment/137944752
score: 0
has comment: http://stackoverflow.com/comment/137886513
has body: I think that you can modify the code, like: #!/bin/bash ids=$(grep $1 /file/path/courses.jsonl | awk -F ',' '{print $1}' | awk -F ':' '{print $2}') for id in $ids; do python3 /file/path/mmid.py $id done
type: Answer
has comment: http://stackoverflow.com/comment/137886557
answers question: http://stackoverflow.com/q/78212116
upvote count: 2

http://stackoverflow.com/q/78185284
tagged with: unix
score: 0
tagged with: shell
has comment: http://stackoverflow.com/comment/137837688
has body: In my shell script I have conf=2bi5oIl0hldy/p3fe+KMQTVjUSg89ywhdMCaSOAopEVFM\nKlj4RDJcmNcEa1cgxL3sJNBHrw==\n And I have a ini file that has parameter looks like this: ^PASS= SNlfkDahPoWNYCY0V+Z77iR8bP5GIpp8FL6GX5fBvGhfnvH\nRbtyBU06EGifzFyBvZgrqFi/Dw==\n ('=' might have space before or after) I need to replace what comes after ^PASS= with the $conf value including the slashes and backslashes and other characters without cutting the string off. I have this sed expression : sed -i "/^[^#]/ s|\(\^PASS *= *\)[^ ]*|\1$conf|g" "file.ini" As a result, I get in file.ini : ^PASS=2bi5oIl0hldy/p3fe+KMQTVjUSg89ywhdMCaSOAopEVFM Klj4RDJcmNcEa1cgxL3sJNBHrw==\n So the conf value is breaking to new line, due to \n after the M. Not sure what I'm doing wrong.
has title: How to use sed in shell script with value containing line break \n?
linked to: http://stackoverflow.com/q/407523
has comment: http://stackoverflow.com/comment/137837740
tagged with: sed
tagged with: regex
duplicate of: http://stackoverflow.com/q/407523
tagged with: bash
type: Question
answer count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/137844570
has text: Yes, I found I have to keep the regex saved as a variable, first (I don't know why). I'm still wondering why yours works even though the backtick is not escaped. I HAVE to use the syntax in my question above for it to work in my regex. pattern="symbolic[[:space:]]link[[:space:]]to[[:space:]][\`]([^[[:space:]]+)'"
comment on: http://stackoverflow.com/a/78188933
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/q/78181978
tagged with: bash
score: 1
has answer: http://stackoverflow.com/a/78182177
favorite count: 0
has body: Sometimes, I need to change the author/committer email and name (assume author=committer always) for all commits in a repository. I need to do this once for repo, but I may need to do it for multiple repos. I'm using this great answer: How to amend several commits in Git to change author git filter-repo --commit-callback ' if commit.author_email == b"incorrect@email": commit.author_email = b"correct@email" commit.author_name = b"Correct Name" commit.committer_email = b"correct@email" commit.committer_name = b"Correct Name" ' However, every time I want to run this command for a new repository, I need to manually change incorrect@email, correct@email and Correct Name in the command above. I want to put this in a shell script, which: accepts arguments old_email, new_email and author. has default values for these arguments, if one or more is not passed if a different argument is passed, it generates an error How can I do that? EDIT: I cooked up a preliminary implementation, but it doesn't work: #!/bin/bash # Define default values for email and name old_email="incorrect@email" new_email="correct@email" new_name="Correct Name" # Parse named arguments with getopts while getopts ":o:n:e:" opt; do case $opt in o) old_email="$OPTARG" ;; n) new_name="$OPTARG" ;; e) new_email="$OPTARG" ;; \?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;; esac done # Shift arguments to remove processed options shift $((OPTIND-1)) # Check if any remaining arguments (unexpected) if [ $# -gt 0 ]; then echo "Unexpected arguments provided." >&2 exit 1 fi # Construct the filter command using here-string filter_cmd=$(cat << EOF ' if commit.author_email == b"$old_email": commit.author_email = b"$new_email" commit.author_name = b"$new_name" commit.committer_email = b"$new_email" commit.committer_name = b"$new_name" ' EOF ) # Run git filter-repo with the constructed command echo "git filter-repo --commit-callback "$filter_cmd"" git filter-repo --commit-callback "$filter_cmd" # Run git log to confirm that…
type: Question
tagged with: command-line-arguments
tagged with: shell
linked to: http://stackoverflow.com/q/4981126
tagged with: git
type: UnansweredQuestion
downvote count: 0
answer count: 1
upvote count: 1
has title: Write a shell script or Python code with default arguments for git-filter-repo

http://stackoverflow.com/comment/137866045
has text: @CharlesDuffy thanks for that, i thought there probably was a better way of doing it alright. so would echo "Write this to a file." > NewFile.txt be the best way? Or is a way for user input to write directly to file? read "Enter your text: " user_input echo "$user_input" > NewFile.txt I know this is sort of going off topic now, not sure if its against the rules or anything. Again I'm just starting out at this, so let me know if anything isnt allowed
score: 0
comment on: http://stackoverflow.com/q/78200978
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137880540
type: Comment
has text: `./example </dev/null && whatever` also works! Would you mind submitting that as an answer @oguzismail?
comment on: http://stackoverflow.com/q/78203871
score: 0
type: QuestionComment

sql
tag name: sql
tags question: http://stackoverflow.com/q/78302587
type: Tag
tags question: http://stackoverflow.com/q/78881011

http://stackoverflow.com/q/78298728
has comment: http://stackoverflow.com/comment/138042025
has body: I'd like to create a Makefile which allows me to run a script on different environments what depends on secret ENV_VAR and exposed ENV environment variables: export ENV_VAR=&lt;secret_env_var&gt; setup: python my_script.py dev_setup: export ENV:=dev dev_setup: setup test_setup: export ENV:=test test_setup: setup I can include secrets in the separate file adding include config_dev.env file containing ENV_VAR for dev env. But for test env I should change the line to include config_test.env with another secret ENV_VAR. I don't see the possibility to define instruction include into the command step how it is done with export ENV environment variables. Or how it should be done in a proper way? I tried this, commenting/uncommenting the first lines of code include config_dev.env #include config_test.env export ENV_VAR=&lt;secret_env_var&gt; setup: python my_script.py dev_setup: export ENV:=dev dev_setup: setup test_setup: export ENV:=test test_setup: setup
tagged with: bash
has answer: http://stackoverflow.com/a/78299587
tagged with: environment
has comment: http://stackoverflow.com/comment/138040885
tagged with: config
has comment: http://stackoverflow.com/comment/138041958
has title: How to export multiple profiles with env variables for different command in Makefile?
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138040785
has comment: http://stackoverflow.com/comment/138047628
tagged with: makefile
type: UnansweredQuestion
tagged with: environment-variables
answer count: 1
has comment: http://stackoverflow.com/comment/138040477

http://stackoverflow.com/q/78293635
duplicate of: http://stackoverflow.com/q/69487611
tagged with: bash
type: UnansweredQuestion
has body: I need to add a crontab entry only if it's absent. But for some reason I simply cannot write simple script for this. I have tried this code (and many other suggestions), but it always appends to existing crontab. Nothing changes if I try to express everything with 'if else fi' though. What don't I understand in Bash? #!/bin/bash set_cron() { # get the current crontab entries crontab -l > cron # set up new crontab entries cron_cmd="0 0 5 * * prosodyctl --root cert import /etc/letsencrypt/live/" # append new crontab entries if needed grep -q "$cron_cmd" cron || echo "$cron_cmd" >> cron && crontab cron && rm cron } set_cron
has title: Edit crontab via Bash script
has comment: http://stackoverflow.com/comment/138028968
score: 0
type: Question
linked to: http://stackoverflow.com/q/69487611
answer count: 1
has answer: http://stackoverflow.com/a/78293679

http://stackoverflow.com/q/78231607
has answer: http://stackoverflow.com/a/78232653
has body: I am wondering what might be wrong with my snakemake executions. I have snakemake project with folder tree attached below. I am trying to execute the snakefile with an include statement pointing to another .smk file. However, the execution runs as if I have alraedy generated my targeted output files, but this has not happened yet. What might be the issue? This is my foldertree: ├── config │ └── config.yaml ├── results ├── Snakefile └── workflow ├── envs ├── report ├── rules │ └── download.smk └── scripts In the snakefile, I am using include to try and execute the download.smk rules: Here is what I am doing: include: 'workflow/rules/download.smk' And here is my download.smk content: configfile: './././config/config.yaml' rule all: input: config["data_dir"] + "/ACBarrie_R1.fastq.gz", config["data_dir"] + "/ACBarrie_R2.fastq.gz", config["ref_dir"] + "/reference.fasta" rule download_dataset: output: read1 = config["data_dir"] + "/ACBarrie_R1.fastq.gz", read2 = config["data_dir"] + "/ACBarrie_R2.fastq.gz", reference = config["ref_dir"] + "/reference.fasta" params: read1_url = config['samples']['read1_url'], read2_url = config['samples']['read2_url'], genome = config['genome'] threads: config['cores']['download_dataset'] shell: """ wget -O {output.read1} {params.read1_url} wget -O {output.read2} {params.read2_url} wget -O {output.reference} {params.genome} """ However, when I execute, I only get this info: Assuming unrestricted shared filesystem usage. Building DAG of jobs... Nothing to be done (all requested files are present and up to date). But in essence, nothing has been executed and the files I expect do not alraedy exist. WHen I execute the download.smk file in isolation using snakemake -s --cores 2 download.smk, it works just fine. What might be the problem?
score: 0
type: Question
type: UnansweredQuestion
has title: Having problems executing "include" in snakemake
tagged with: bash
answer count: 1
tagged with: snakemake

http://stackoverflow.com/comment/137872741
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78204849
has text: I've added a screenshot.
type: Comment

http://stackoverflow.com/comment/137961518
type: QuestionComment
type: Comment
has text: Understood, I will keep it in mind for next time! Thanks
comment on: http://stackoverflow.com/q/78226551
score: 1

http://stackoverflow.com/comment/137911702
score: 0
type: QuestionComment
type: Comment
has text: Right, when you trap SIGINT, you're _replacing_ its default behavior so it no longer does what it would have done by default.
comment on: http://stackoverflow.com/q/78226499

http://stackoverflow.com/comment/137797313
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78161552
score: 0
has text: Leaving out quotes even matters for the `echo` at the end -- see [I just assigned a variable, but `echo $variable` shows something else!](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else)

http://stackoverflow.com/q/78190505
answer count: 1
favorite count: 0
downvote count: 1
tagged with: bash
has body: I am trying to make an automated installer for my tool, I have only 2 problems. function configure_rvm() { create_cw_user gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB curl -sSL https://get.rvm.io | bash -s stable export rvm_path="$HOME/.rvm" source /etc/profile.d/rvm.sh adduser folder rvm } function setup_folder() { local secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 63 ; echo '') local RAILS_ENV=production get_pgpass sudo -i -u folder << EOF rvm --version rvm autolibs disable rvm install "ruby-3.2.2" rvm use 3.2.2 --default git clone https://gitlab.com/xxxx/xxxx.git folder echo "GitLab login successful." cd folder git folder "$BRANCH" bundle yarn cp .env.example .env sed -i -e "/SECRET_KEY_BASE/ s/=.*/=$secret/" .env sed -i -e '/REDIS_URL/ s/=.*/=redis:\/\/localhost:6379/' .env sed -i -e '/POSTGRES_HOST/ s/=.*/=localhost/' .env sed -i -e '/POSTGRES_USERNAME/ s/=.*/=folder/' .env sed -i -e "/POSTGRES_PASSWORD/ s/=.*/=$pg_pass/" .env sed -i -e '/RAILS_ENV/ s/=.*/=$RAILS_ENV/' .env echo -en "\nINSTALLATION_ENV=linux_script" >> ".env" rake assets:precompile RAILS_ENV=production NODE_OPTIONS=--openssl-legacy-provider EOF } this step source /etc/profile.d/rvm.shThe other problem I have, something exactly similar happens to me... which is here: function install_dependencies() { apt update && apt upgrade -y apt list --upgradable -a apt --fix-broken install apt install -y curl gnupg gnupg1 gnupg2 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://p…
has title: Problem with scipt.sh, need some manual executions?
has answer: http://stackoverflow.com/a/78194372
upvote count: 0
score: -1
type: Question
tagged with: shell
type: UnansweredQuestion

http://stackoverflow.com/comment/137935631
comment on: http://stackoverflow.com/q/78240103
score: 2
type: Comment
has text: Try `redis-cli --help`, read quietly, then `redis-cli -i 20 --latency -h 127.0.0.1 -p 6379 --raw`
type: QuestionComment

http://stackoverflow.com/comment/137796322
type: QuestionComment
type: Comment
has text: It's **-H**, not **-h**.
score: 1
comment on: http://stackoverflow.com/q/78161552

http://stackoverflow.com/q/78229406
type: Question
has comment: http://stackoverflow.com/comment/137917090
tagged with: shell
has comment: http://stackoverflow.com/comment/137918989
has comment: http://stackoverflow.com/comment/137917156
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/17529220
has body: Here is my test code #!/bin/bash TEMPLATEEMAIL="/mydir/template.txt" HELLOPRINT=`cat hello.txt` emailbody=$(cat ${TEMPLATEEMAIL} | while read line; do eval echo "${line}"; done) echo ${emailbody} cat /mydir/template.txt $HELLOPRINT cat hello.txt hello hello hello hello Output I am intending to get is: hello hello hello hello However output I am currently getting is: hello hello hello hello
has title: Linux Eval and Cat to print output on multiple lines
has comment: http://stackoverflow.com/comment/137918975
downvote count: 2
answer count: 0
has comment: http://stackoverflow.com/comment/137921287
tagged with: bash
has comment: http://stackoverflow.com/comment/137918935
favorite count: 0
linked to: http://stackoverflow.com/q/29378566
score: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/137918939
has comment: http://stackoverflow.com/comment/137916887
has comment: http://stackoverflow.com/comment/137933437
duplicate of: http://stackoverflow.com/q/29378566

http://stackoverflow.com/a/78239876
downvote count: 0
score: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78238193
has body: KamilCuk's comment sent me in the right direction. The script was interpreted as a single line and that caused syntex errors. I changed the anchor line to: npm_audit: &amp;npm_audit | which made the lines below to be interpreted properly.
accepted answer of: http://stackoverflow.com/q/78238193
upvote count: 1
type: Answer

http://stackoverflow.com/comment/138016393
type: QuestionComment
type: Comment
has text: the reason of horizontal spread is a grouping according to the projects. I think it is OK if every person only attends to one single project, but worry the cases a person attends to several projects. Is it OK even in such a case. Also I worry about the case that score has an order larger than unity, say 23.
score: 0
comment on: http://stackoverflow.com/q/78286060

http://stackoverflow.com/comment/137939172
score: 0
comment on: http://stackoverflow.com/q/78241761
has text: @konsolebox I mean that when I ran it, it gave packages that `equery depends` says other packages depend on
type: QuestionComment
type: Comment

substring
tag name: substring
tags question: http://stackoverflow.com/q/78196837
type: Tag
tags question: http://stackoverflow.com/q/78926783
tags question: http://stackoverflow.com/q/78924359

http://stackoverflow.com/comment/137888079
has text: It should be `[[ .. ]]` not `[ ... ]`. It is a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) comparison
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78213645

http://stackoverflow.com/q/78233393
has body: I've uploaded my game to steam and trying to make it work on windows, linux and macos. I've got macos working and now I'm trying to get linux working. I'm writing my game in bevy (rust) and using the bevy_steamworks plugin to connect to the steam api which means I have set up the path to "libsteam_api.so". I've included "libsteam_api.so" in the zip file I uploaded and I've set steam to launch this script when you press play: #!/bin/sh export LD_LIBRARY_PATH="." ./glow "$@" The script works great when I run it via the terminal but when launching through Steam the game exists immediately. Is there a better approach without a script or is there some simple error in my script?
tagged with: game-development
has answer: http://stackoverflow.com/a/78247592
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137931382
tagged with: steam
answer count: 1
score: 0
has title: How do I launch my game on steam via script?
type: UnansweredQuestion

http://stackoverflow.com/comment/137830659
type: QuestionComment
comment on: http://stackoverflow.com/q/78181239
type: Comment
score: 0
has text: https://unix.stackexchange.com/questions/368246/cant-use-alias-in-script-even-if-i-define-it-just-above

http://stackoverflow.com/comment/137865593
comment on: http://stackoverflow.com/q/78200978
has text: Welcome to Stack Overflow! [How to ask homework question](https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions) and [Open letter to students with homework problems](https://softwareengineering.meta.stackexchange.com/questions/6166/open-letter-to-students-with-homework-problems)
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137893382
has text: Perfect. Except I didn't realize i wrote systemd instead of systemctl. There was no output for sure.. I'm so dumb :-) . Now it's a pretty good looking output .Thank you very much
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78216523

http://stackoverflow.com/comment/137949762
type: Comment
score: 0
has text: I think the only way to do this effectively would be to build a custom version of `bash` without the builtin `kill` command...but there are so many other ways of sending signals to processes (use a different shell, use `top`, write a Python/Ruby/Perl/PHP/etc script, compile some C/Go/Rust/etc code, ...) that it seems like it's not worth the effort.
comment on: http://stackoverflow.com/q/78248223
type: QuestionComment

http://stackoverflow.com/a/78291700
has body: Use timestamps and sleep as much as possible, especially before start #!/usr/bin/env bash prodStartTs=$(date -d 'today 23:00:00' +%s) # "230000" prodEndTs=$(date -d 'tomorrow 01:00:00' +%s) # "010000" logFile="/tmp/processrunning-$(date +%Y%m%d).txt" if -f "$logFile" # todays logfile already exist then # this is an error printf 'Log file %s already exist!' "$logFile" >&2 exit 1 fi touch "$logFile" secBeforeStart=$((prodStartTs - EPOCHSECONDS)) if $secBeforeStart -gt 0 # it is not time to start then sleep "$secBeforeStart" # all the remaining seconds before start fi while $EPOCHSECONDS -le $prodEndTs # it is not time to stop do # all this ps aux | sort -nrk 3,3 | head -n 5 sleep 30 # every 30 seconds done > "$logFile" # all logged to logFile bash "${BASH_SOURCE[0]}" # Rerun self
upvote count: 1
answers question: http://stackoverflow.com/q/78290808
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/comment/137777378
type: AnswerComment
has text: Interesting; I'm curious as to how. (Not _quite_ curious enough to strace it, but curious nonetheless). Similarly, curious how portable that is across `more` implementations.
score: 0
comment on: http://stackoverflow.com/a/78150663
type: Comment

http://stackoverflow.com/q/78180816
answer count: 1
tagged with: module
tagged with: python
tagged with: conda
has comment: http://stackoverflow.com/comment/137830043
has comment: http://stackoverflow.com/comment/137829963
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137830554
has answer: http://stackoverflow.com/a/78180985
has comment: http://stackoverflow.com/comment/137829950
has comment: http://stackoverflow.com/comment/137829802
score: 0
has comment: http://stackoverflow.com/comment/137830024
has body: I am using a Conda environment for a program in order to configure the packages etc all correctly. However, I have trouble running the program without making any changes, as it seems to be the environment is not choosing the correct interpreter. My conda yaml file is the following: name: nmrfilter channels: - rdkit - pytorch dependencies: - python=3.7 - anaconda - rdkit - pytorch=1.4 - torchvision - pandas - numpy - seaborn - scikit-learn - pyarrow - numba - click - pip - ipywidgets - pip: - python-igraph - louvain - ruffus - tqdm - networkx - tensorflow-cpu - tensorboardX - cirpy - pubchempy It should configure all of the python commands to use the Python3.7 installed by conda. However, when using a Python Virtual Environment inside the conda environment, I have reached unexplainable behaviour. My requirements.txt, from which a python venv is created, is the following: numpy==1.24 scipy pandas rdkit click cirpy scikit-learn matplotlib python-igraph pubchempy numba torch tqdm igraph louvain #!/bin/bash # Get the directory path where the shell script is located script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Check if the virtual environment already exists in the script's directory if [ -f "$script_dir/nmrfilter_env/bin/activate" ]; then echo "NMRfilter_env already exists. Activating..." source "$script_dir/nmrfilter_env/bin/activate" else echo "Creating virtual environment in $script_dir/nmrfilter_env..." python3 -m venv "$script_dir/nmrfilter_env" source "$script_dir/nmrfilter_env/bin/activate" echo "Installing the requirements..." python -m pip install -r requirements.txt echo "Installing Jupyter Notebook..." python -m pip install jupyter fi echo "Virtual environment activated." echo "PYTHONPATH: $PYTHONPATH" echo "Python executable: $(which python)" echo "Python3 executable: $(which python3)" echo "PIP executable: $(which pip)" echo "Python version: $(python --version)" echo "PIP version: $(pip --version)" echo "Pip packages in virtual environment…
has comment: http://stackoverflow.com/comment/137829885
tagged with: numpy
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137830232
has title: Python Virtual Environment behaviour inside a Conda environment: Python Interpreter Choice

http://stackoverflow.com/a/78201892
has body: I would use ed instead, especially if you haven't already executed df -h, because you can read the output directly into the file without an intermediate shell variable. ed file.txt &lt;&lt;EOF 200r !df -h 200d wq EOF The output of df -h is inserted between lines 200 and 201, and then line 200 is deleted.
score: 0
answers question: http://stackoverflow.com/q/78200217
type: Answer

http://stackoverflow.com/comment/138118576
comment on: http://stackoverflow.com/a/78287570
has text: thanks very much for your answer. My thinking is now being updated and I am now trying to set an additional table allowing the Excel v-look-up function instead of inserting a cell right-hand side. My testing works well.
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/comment/137934503
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78239630
has text: This may be very similar https://stackoverflow.com/questions/44780761/converting-csv-to-json-in-bash

http://stackoverflow.com/comment/137858210
type: Comment
has text: Another suggestion: stop using `echo` for debugging. It's a horribly buggy tool itself; `declare -p varname` is _much_ more reliable than `echo "varname:[$varname]"` -- the `declare -p` output is escaped so every character in it is printable, shows if you've got an array or other unusual datatype, etc.
comment on: http://stackoverflow.com/q/78196593
score: 2
type: QuestionComment

freebsd
type: Tag
tags question: http://stackoverflow.com/q/78284934
tag name: freebsd
tags question: http://stackoverflow.com/q/78422837
tags question: http://stackoverflow.com/q/79244484

http://stackoverflow.com/comment/137851034
type: QuestionComment
has text: Have you tried `apropos pam` in the bash and tried to read through the manual pages to get a start of coding?
score: 1
comment on: http://stackoverflow.com/q/78192206
type: Comment

http://stackoverflow.com/comment/137858115
type: Comment
comment on: http://stackoverflow.com/q/78196593
score: 1
has text: What's the intent behind the herestring running the process substitution running `echo`? It seems really weird (and introduces several configuration-specific potential bugs) to use ```... <<<`echo $foo`;``` instead of `... <<<"$foo"`
type: QuestionComment

http://stackoverflow.com/comment/138016409
has text: i'd like to get a table headed with project-name and number-Of-Persons-For-3rd, because Alice et al. are the members of some project (say, project 1). the copilot proposed to use `=--(MID(DEC2BIN(HEX2DEC(B2), 4), 3, 1)="1") + --(MID(DEC2BIN(HEX2DEC(D2), 4), 3, 1)="1") + --(MID(DEC2BIN(HEX2DEC(F2), 4), 3, 1)="1")`. Is this OK?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78286124
score: 0

slackware
type: Tag
tags question: http://stackoverflow.com/q/78209376
tag name: slackware

http://stackoverflow.com/comment/137931788
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78238193
has text: Because it is one line. `why is the whole script echoed` it is one line and `set -x` prints the line.

http://stackoverflow.com/comment/137813221
score: 0
type: QuestionComment
type: Comment
has text: Grobu This is not an executable file. A regular data file. File used by the game: "Dark Messiah Might and Magic Single Player". This is a game created on the "Valve Source" engine.
comment on: http://stackoverflow.com/q/78151708

http://stackoverflow.com/comment/137871353
type: Comment
comment on: http://stackoverflow.com/q/78203871
has text: Creating both the `example` file and the `test.sh` file, marking them both as executable, and running `bash test.sh` does not output "How do i get here", at least on my machine. What are you doing differently?
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137858251
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78196593
type: Comment
has text: (the other thing about `declare -p varname1 varname2` is that its output is code that, if copied-and-pasted, can be used to define the listed variables exactly as they were when that command was run, so it makes it easy to reproduce the state of your variables for debugging purposes)

http://stackoverflow.com/a/78298917
answers question: http://stackoverflow.com/q/78297014
score: 2
downvote count: 0
type: Answer
has body: Addressing OP's issue of the strftime() function not returning the desired date/time string ... The format of a strftime() call: strftime( format [, timestamp] ) If timestamp is not provided then the current system time is used; this happens to be the same value as returned by the systime() function - the number of seconds since the system epoch. In OP's code we see strftime( "%F %T", $2 ) where $2 looks like Tue Apr 9 03:32:21 2024. While %F %T is a valid format, Tue Apr 9 03:32:21 2024 is not a valid format for the number of seconds since the system epoch. OP needs to convert Tue Apr 9 03:32:21 2024 into the equivalent number of seconds since the system epoch. One way to do this is with the mktime() function: mktime( "YYYY MM DD HH MM SS" ) OP will need to convert the string Tue Apr 9 03:32:21 2024 into the string 2024 4 9 03 32 21. Modifying OP's current awk script, while borrowing Ed Morton's code to convert Apr to 4: awk -F"[][{}]" ' { split($2,d," ") # split "Tue Apr 9 03:32:21 2024" on spaces; place results in array d[] mth = (index("JanFebMarAprMayJunJulAugSepOctNovDec",d[2])+2) / 3 # convert "Apr" to "4" gsub(/:/," ",d[4]) # convert "03:32:21: to "03 32 21" print strftime("%F %T", mktime(d[5] " " mth " " d[3] " " d[4])), $4 # convert "2024 4 9 03 32 21" to epoch seconds then reformat as "%F %T" } ' test.log This generates: 2024-04-09 03:32:21 cmd1 2024-04-09 03:33:42 cmd2 2024-04-09 03:35:51 cmd3 NOTE: see GNU awk (gawk) time functions for more details on the strftime(), systime() and mktime() functions
upvote count: 2

http://stackoverflow.com/comment/137993841
type: AnswerComment
comment on: http://stackoverflow.com/a/78272868
score: 0
has text: An alternative that works with older versions of Bash (tested with Bash 3.2) is to use `[[ ${SOME_VAR+_} ]] && saved_some_var=$SOME_VAR || unset saved_some_var` to save the value (or unset status) of `SOME_VAR` and use `[[ ${saved_some_var+_} ]] && SOME_VAR=$saved_some_var || unset SOME_VAR` to restore it (or unset it again).
type: Comment

http://stackoverflow.com/comment/137854181
type: Comment
has text: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#redacting-secrets-from-workflow-run-logs , https://docs.github.com/en/enterprise-cloud@latest/actions/security-guides/security-hardening-for-github-actions#using-secrets
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78194442

http://stackoverflow.com/a/78196863
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78196837
type: Answer
accepted answer of: http://stackoverflow.com/q/78196837
score: 0
has body: Setup: $ cat filename ~2024-03-09T00:15:00-07:00~ some text ~2024-03-10T00:15:00-07:00~ some text ~2024-03-11T00:15:00-07:00~ some text I tend to use -E to enable support for extended regexes and to simplify the capture group syntax. This requires just a couple small changes to your current code: sed -E 's/(~2024-03-10T[01]{2}:[0-9]{2}:[0-9]{2})-07:00/\1-08:00/g' filename ^^ ^ ^ Where: -E - enable support for extended regexes ( | ) - no need to escape the parens (capture group delimiters) This generates: ~2024-03-09T00:15:00-07:00~ some text ~2024-03-10T00:15:00-08:00~ some text ~2024-03-11T00:15:00-07:00~ some text
has comment: http://stackoverflow.com/comment/137865846

http://stackoverflow.com/comment/137771832
type: Comment
comment on: http://stackoverflow.com/q/78147701
has text: Ugh. Why do primes in Bash?!? This is really a job for Python, Perl, Ruby, or even awk. You are going down a rabbit hole of trying to fit a square peg in a round hole...
score: 1
type: QuestionComment

git-filter-repo
type: Tag
tags question: http://stackoverflow.com/q/78157184
tag name: git-filter-repo

http://stackoverflow.com/comment/137771159
has text: This is great information. Appreciate you taking the time. I managed to get my code working from the comments above but this improves greatly on my code, so shall incorporate these going forward. Thanks ever so much!
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78147252
score: 1

http://stackoverflow.com/a/78187835
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78182030
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/137852743
has comment: http://stackoverflow.com/comment/137853132
has comment: http://stackoverflow.com/comment/137844861
has body: The link you reference clearly says the alias in the example evaluates at define time because it was done in double quotes, not single quotes. Mind your quoting... but what you want is still a function. Also, bash has a built-in $SECONDS variable for how long the script has been running in seconds. You could always use that. This does work with an alias - $: alias myAlias='sleep $((RANDOM%10))' $: date; t=$SECONDS; myAlias; echo "myAlias took $((SECONDS-t)) secs"; date Thu Mar 21 09:42:24 CDT 2024 myAlias took 4 secs Thu Mar 21 09:42:28 CDT 2024 But if you have any recent version of bash, the printf '%(%s)T' method gives you the actual date and time with formatting options, without having to spawn a subshell for date. (See Ed's solution.) You also could just use time on a function or a script, but for an alias you need to make sure it's well-behaved and structured accordingly... $: alias myAlias='date;sleep $((RANDOM%5));date' $: time myAlias # oops! time only checked the first call to date Thu Mar 21 09:47:35 CDT 2024 real 0m0.061s user 0m0.000s sys 0m0.046s Thu Mar 21 09:47:38 CDT 2024 $: alias myAlias='{ date;sleep $((RANDOM%5));date; }' $: time myAlias # this works, but who writes aliases like this? Thu Mar 21 09:47:59 CDT 2024 Thu Mar 21 09:48:02 CDT 2024 real 0m3.194s user 0m0.000s sys 0m0.152s $: myTask1(){ date;sleep $((RANDOM%5));date; } # make it a function $: time myTask1 # works as expected... but see below Thu Mar 21 09:51:50 CDT 2024 Thu Mar 21 09:51:54 CDT 2024 real 0m4.192s user 0m0.000s sys 0m0.153s That outputs to stderr, but if using the bash builtin it can be oddly hard to catch, so you might want to wrap it in curlies to manage the I/O, such as if trying to assign to a variable. This ends up making some strange looking code for what was otherwise a pretty simple thing... $: time myTask1 | awk '/^real/{print $2}' # stderr bypasses normal pipe real 0m3.247s user 0m0.030s sys 0m0.325s $: time myTask1 | awk '/^real/{print $2}' # usual fix doesn't wo…

http://stackoverflow.com/q/78196837
score: 0
has body: I am trying to find datatime stamps that have an incorrect timezone due to Daylight Savings Time (starting or ending). If the timezone is incorrect, I want to replace it with the correct timezone for those matches. e.g. 2024-03-10T00:15:00-07:00 = 2024-03-10T00:15:00-08:00 I came up with the following regex and am able to find the culprits in the file using grep: grep -E '~2024-03-10T[01]{2}:[0-9]{2}:[0-9]{2}-07:00' &lt;filename&gt; I am trying to do the substitution using sed and the regex I came up with, but I can't seem to get it to work correctly. Here's what I currently have: sed 's/\(~2024-03-10T[01]{2}:[0-9]{2}:[0-9]{2}\)-07:00~/\1-08:00~/g' filename What am I missing? This command does not seem to make any substitutions. Any help would be appreciated! Thanks in advance!
has comment: http://stackoverflow.com/comment/137865703
tagged with: linux
tagged with: bash
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/137865688
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137872495
accepted answer: http://stackoverflow.com/a/78196863
has title: Can you replace a substring from a regex match?
tagged with: sed
has comment: http://stackoverflow.com/comment/137865717
has comment: http://stackoverflow.com/comment/137858545
tagged with: regex
has comment: http://stackoverflow.com/comment/137858547
has answer: http://stackoverflow.com/a/78196863
type: Question
has comment: http://stackoverflow.com/comment/137858537
has comment: http://stackoverflow.com/comment/137865740
has comment: http://stackoverflow.com/comment/137861567
downvote count: 1
tagged with: substring

http://stackoverflow.com/comment/137906530
type: QuestionComment
type: Comment
has text: A recursivedecent parser follows grammar rules replacing a LHS with the corresponding RHS starting with the start symbol. These rules can be left- or right-recursive, which directly maps to left- or right associativity of your parse tree (`T: CMD | CMD "&&" T | CMD "||" T` vs. `T: CMD | T "&&" CMD | T "||" CMD`). This directly maps to the associativity of the operators. However, a recursive-decent parser might have trouble with leftrecursive rules because it easily gets stuck in an infinite regression. There are ways around (breadth-search), or you just use bison to create an LALR(1) parser
score: 1
comment on: http://stackoverflow.com/q/78223744

http://stackoverflow.com/q/78274675
tagged with: configure
score: 2
accepted answer: http://stackoverflow.com/a/78288077
has comment: http://stackoverflow.com/comment/137999325
tagged with: bash
has comment: http://stackoverflow.com/comment/138061941
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78288077
downvote count: 1
has body: I am maintaining a legacy project and encountered an issue while running the configure script in the build process. The script fails with multiple "command not found" errors pointing to some specific lines in the configure and config.status bash scripts. I need help diagnosing and resolving this problem. Here's a snippet of the error output when I run ../configure in the build directory: ../configure: line 24114: : command not found ../configure: line 24114: x86_64-pc-linux-gnu: command not found ../configure: line 24114: linux-gnu: command not found ../configure: line 24114: o: command not found gcc: fatal error: no input files compilation terminated. ../configure: line 24114: -fPIC -g -O2: command not found Line 24114 of the configure script is part of a larger block that looks like this: _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 And the error message: ./config.status: line 798: : command not found ./config.status: line 810: : command not found refer to # Quote evaled strings. for var in AS DLLTOOL OBJDUMP SHELL ECHO PATH_SEPARATOR SED GREP EGREP FGREP LD NM LN_S lt_SP2NL lt_NL2SP reload_flag deplibs_check_method file_magic_cmd file_magic_glob want_nocaseglob sharedlib_from_linklib_cmd AR AR_FLAGS archiver_list_spec STRIP RANLIB CC CFLAGS compiler lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl lt_cv_sys_global_symbol_to_import lt_cv_sys_global_symbol_to_c_name_address lt_cv_sys_global_symbol_to_c_name_address_lib_prefix lt_cv_nm_interface nm_file_list_spec lt_cv_truncate_bin lt_prog_compiler_no_builtin_flag lt_prog_compiler_pic lt_prog_compiler_wl lt_prog_compiler_static lt_cv_prog_compiler_c_o need_locks MANIFEST_TOOL DSYMUTIL NMEDIT LIPO OTOOL OTOOL64 shrext_cmds export_dynamic_flag_spec whole_archive_flag_spec compiler_needs_object with_gnu_ld allow_undefined_flag no_undefined_flag hardcode_l…
has comment: http://stackoverflow.com/comment/138006053
has comment: http://stackoverflow.com/comment/137999703
has comment: http://stackoverflow.com/comment/137998617
upvote count: 3
has comment: http://stackoverflow.com/comment/138061966
has comment: http://stackoverflow.com/comment/138006055
has title: "Command not found" errors in configure script how to diagnose?
has comment: http://stackoverflow.com/comment/137996295
tagged with: autoconf
type: Question
has comment: http://stackoverflow.com/comment/138005978
linked to: http://stackoverflow.com/q/78276793
has comment: http://stackoverflow.com/comment/138006135
tagged with: autotools
answer count: 1
favorite count: 0
tagged with: autoreconf
has comment: http://stackoverflow.com/comment/138006245

http://stackoverflow.com/a/78273157
type: Answer
has body: Changing permission on system files is not recommended. You may set your environment variables and singularity directly in your R script (update with your own paths): Sys.setenv(PATH = paste(Sys.getenv("PATH"), "/path/to/singularity", sep=":")) Sys.setenv(LD_LIBRARY_PATH = "/path/to/singularity/libs") system("/path/to/singularity exec ...")
answers question: http://stackoverflow.com/q/78167188
score: 0

http://stackoverflow.com/tag/c
tags question: http://stackoverflow.com/q/78218663
type: Tag
tag name: c
tags question: http://stackoverflow.com/q/78334722
tags question: http://stackoverflow.com/q/78464749
tags question: http://stackoverflow.com/q/78505293
tags question: http://stackoverflow.com/q/78553762
tags question: http://stackoverflow.com/q/78746139
tags question: http://stackoverflow.com/q/78779756
tags question: http://stackoverflow.com/q/78869464
tags question: http://stackoverflow.com/q/78823219
tags question: http://stackoverflow.com/q/79066953
tags question: http://stackoverflow.com/q/79155589
tags question: http://stackoverflow.com/q/79072284
tags question: http://stackoverflow.com/q/79121449
tags question: http://stackoverflow.com/q/79423600

http://stackoverflow.com/comment/137950302
score: 1
comment on: http://stackoverflow.com/q/78248223
type: QuestionComment
type: Comment
has text: In the most common case the container only runs a single process. If you can `docker exec your-container kill 1`, then you can also `docker stop your-container`. Also note that the `docker exec` path doesn't run a shell or the image's entrypoint script, so shell-specific setup won't take effect.

http://stackoverflow.com/comment/137851796
type: Comment
has text: just isn't there, AFAIK. the Python interpreter just isn't fast enough on this hardware. so i'm going to try the suggestions made and give it another shot today. thanks everyone.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193

http://stackoverflow.com/comment/137854429
type: Comment
type: AnswerComment
score: 0
has text: Also curious whether this is intentional behavior or an accident of implementation that could go away with a future bugfix.
comment on: http://stackoverflow.com/a/78194502

http://stackoverflow.com/a/78276598
upvote count: 1
type: Answer
has body: Use eval to execute the assignment in the file. eval &quot;$(grep '^x=' hg.ini)&quot;
has comment: http://stackoverflow.com/comment/137999451
answers question: http://stackoverflow.com/q/78276574
downvote count: 0
score: 1

http://stackoverflow.com/comment/137790435
type: Comment
score: 0
has text: For shell scripts ALL_UPPERCASE_NAMES are generally reserved for shell and environment variables. `my_special_file=...` is fine.
comment on: http://stackoverflow.com/q/78157779
type: QuestionComment

http://stackoverflow.com/comment/137830112
type: QuestionComment
type: Comment
has text: Are there any filenames with spaces in their names? `$objects` won't work correctly. It's basically the same problem as https://unix.stackexchange.com/questions/128985/why-not-parse-ls
score: 1
comment on: http://stackoverflow.com/q/78177875

http://stackoverflow.com/q/78241761
has comment: http://stackoverflow.com/comment/137939370
has comment: http://stackoverflow.com/comment/137939492
score: 0
has comment: http://stackoverflow.com/comment/137938772
tagged with: grep
has comment: http://stackoverflow.com/comment/137939172
has comment: http://stackoverflow.com/comment/137938902
accepted answer: http://stackoverflow.com/a/78242017
has comment: http://stackoverflow.com/comment/137939265
has answer: http://stackoverflow.com/a/78241862
has comment: http://stackoverflow.com/comment/137939462
has comment: http://stackoverflow.com/comment/137939871
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137939085
possible better answer: http://stackoverflow.com/a/78241862
linked to: http://stackoverflow.com/q/78243238
has title: How to grep a line followed by a newline from output in terminal
answer count: 2
has comment: http://stackoverflow.com/comment/137940191
tagged with: gentoo
tagged with: bash
type: Question
has answer: http://stackoverflow.com/a/78242017
has body: I have the following output on my terminal * These packages depend on app-portage/gentoolkit-0.6.5: * These packages depend on app-portage/getuto-1.11: sys-apps/portage-3.0.63 (!build ? app-portage/getuto) * These packages depend on app-portage/portage-utils-0.96.1: app-admin/perl-cleaner-2.31 (!pkgcore ? app-portage/portage-utils) How do I only grep lines such as gentoolkit that have no lines following it? What I have tried : some command | xargs grep -eF ".*\n\n" But this returns File or Directory not found. What I am trying to achieve? In gentoo linux, eix-installed -a | xargs equery depends gives the dependency for all packages. I want to find the ones that have no dependencies listed.

http://stackoverflow.com/a/78201122
accepted answer of: http://stackoverflow.com/q/78200978
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/137865851
type: AcceptedAnswer
has body: Do sed -i 's/Your/My/g' input.txt &amp;&amp; sed -i 's/Then/Now/g' input.txt Which replace the first wort with the second word, editing the file. I have two commands to achieve it, one is for the first replace and the second is for the second replace, separated via &amp;&amp;.
answers question: http://stackoverflow.com/q/78200978

http://stackoverflow.com/comment/137789551
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78155222
has text: @jhnc Considering his and your solutions, I suppose providing another level of _expansion_ is an exception to the behavior of tilde expansions inside double-quotes. What do you think?
score: 0

http://stackoverflow.com/a/78188142
has comment: http://stackoverflow.com/comment/137843014
score: -2
has body: Partial answer: Add the line allowlist_externals = /bin/bash. Then for calling the bash "commands", use /bin/ before the atual command; e.g.: /bin/echo. Example: [testenv:testenv_name] description = testenv_description. allowlist_externals = /bin/bash commands = /bin/touch deleteme.txt /bin/echo -e "123\n456" However commands such as export do not seem to work.
type: Answer
downvote count: 2
upvote count: 0
answers question: http://stackoverflow.com/q/78188141

http://stackoverflow.com/a/78195052
type: Answer
has comment: http://stackoverflow.com/comment/137855338
answers question: http://stackoverflow.com/q/78194906
has body: I came up with this solution: cat foo | awk '{print "/dev/"$2"/"$1}' | tail -n +4 outputs /dev/vg_hana_backups/lv_hana_backups /dev/vg_hana_data/lv_hana_data /dev/vg_hana_log/lv_hana_log /dev/vg_hana_shared/lv_hana_shared
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/comment/138031800
score: 0
type: Comment
has text: @Kievon did you make sure to both install @dotenvx/dotenvx and react-scripts to your node modules?
comment on: http://stackoverflow.com/a/78277187
type: AnswerComment

mariadb
tag name: mariadb
tags question: http://stackoverflow.com/q/78171914
type: Tag
tags question: http://stackoverflow.com/q/78706727
tags question: http://stackoverflow.com/q/79042155
tags question: http://stackoverflow.com/q/79441406

http://stackoverflow.com/comment/137843027
comment on: http://stackoverflow.com/a/78187523
type: Comment
type: AnswerComment
score: 0
has text: Thx for the explanation. Actually yes, I was trying to understand real meaning of `@` using fundamental syntax units and failed and asked question here in result. It seems like this syntax is so basic and commonly used that, as you write, nobody needs any replacement.

http://stackoverflow.com/comment/137856875
has text: ...consider my grumbling about `for x in $interfaces` instead of using a real array to be repeated. [BashPitfalls #1](https://mywiki.wooledge.org/BashPitfalls#for_f_in_.24.28ls_.2A.mp3.29) touches on the problems somewhat, as does [DontReadLinesWithFor](https://mywiki.wooledge.org/DontReadLinesWithFor).
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
type: Comment

http://stackoverflow.com/comment/137935774
type: Comment
comment on: http://stackoverflow.com/q/78240103
type: QuestionComment
has text: @F.Hauri-GiveUpGitHub Exactly what I'm thinking but only you guys can verify.
score: 0

http://stackoverflow.com/comment/137847101
has text: ++ on the idea of using something other than `awk` ... connect/disconnect with db each time is expensive, parse-n-compile of each `update` is expensive; having said that, if you really, Really, REALLY have to continue using `awk` then consider coprocesses (open/maintain connection to db, pump `update` statements into the coprocess/pipe); web search on `awk coprocess` should bring up a good number of hits (hits on `www.gnu.org/s/gawk` are a good start)
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193
type: Comment

http://stackoverflow.com/comment/137793448
score: 2
type: Comment
has text: Add `set -x` in front of your commands. No, it does not work.
type: QuestionComment
comment on: http://stackoverflow.com/q/78160050

http://stackoverflow.com/q/78201574
upvote count: 1
has comment: http://stackoverflow.com/comment/137866707
accepted answer: http://stackoverflow.com/a/78207000
downvote count: 1
has comment: http://stackoverflow.com/comment/137866817
has comment: http://stackoverflow.com/comment/137867475
has comment: http://stackoverflow.com/comment/137866774
has comment: http://stackoverflow.com/comment/137866758
has comment: http://stackoverflow.com/comment/137866691
score: 0
has comment: http://stackoverflow.com/comment/137866790
has title: bash: We determine whether the computer belongs to the active directory group and, depending on this, perform the action
answer count: 1
has comment: http://stackoverflow.com/comment/137866813
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137866939
has comment: http://stackoverflow.com/comment/137866828
has comment: http://stackoverflow.com/comment/137866852
has comment: http://stackoverflow.com/comment/137866744
has answer: http://stackoverflow.com/a/78207000
tagged with: linux
has body: It is necessary to distribute the automatic shutdown task to all client machines running Linux, except for a certain group of Active Directory computers pan-sgg-dalas. The closest thing I found is below in the code, but it's doesn't working. echo "set time, except group pan-sgg-dalas" computer_name=$(hostname -s) if getent group pan-sgg-dalas | grep -q "$computer_name"; then echo "0 22 * * * root /sbin/shutdown -h now" > /etc/cron.d/shutdown_22:00 echo "set time 22:00" else echo "Computer belong to group pan-sgg-dalas." fi Code doesn't work properly. And I can't find error.
tagged with: bash
has comment: http://stackoverflow.com/comment/137867933
has comment: http://stackoverflow.com/comment/137866712
type: Question
has comment: http://stackoverflow.com/comment/137871568

http://stackoverflow.com/a/78163768
answers question: http://stackoverflow.com/q/78158123
has body: I assume you have a reason for wanting an array with the list of all the files that were deleted. If so, does this solve your problem: arr=() while read line; do arr+=($line) echo $line rm $line done < ./old_backups.txt echo "The following files were deleted: ${arr[*]}." Obviously, the last line was more of an example of how you could use the arr array.
type: Answer
score: 0

http://stackoverflow.com/comment/137857247
has text: Do you want to remove the second parameter or remove all parameters with the value `b`?
comment on: http://stackoverflow.com/q/78195964
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137801053
score: 0
type: QuestionComment
has text: @oguz ismail Corrupts the file.
type: Comment
comment on: http://stackoverflow.com/q/78151708

amazon-web-services
type: Tag
tags question: http://stackoverflow.com/q/78177847
tags question: http://stackoverflow.com/q/78156372
tags question: http://stackoverflow.com/q/78240309
tag name: amazon-web-services
tags question: http://stackoverflow.com/q/78489072
tags question: http://stackoverflow.com/q/78584835
tags question: http://stackoverflow.com/q/78462747
tags question: http://stackoverflow.com/q/78464573
tags question: http://stackoverflow.com/q/78644019
tags question: http://stackoverflow.com/q/78888094
tags question: http://stackoverflow.com/q/79043844
tags question: http://stackoverflow.com/q/78941355
tags question: http://stackoverflow.com/q/79083599
tags question: http://stackoverflow.com/q/79170269
tags question: http://stackoverflow.com/q/79383675
tags question: http://stackoverflow.com/q/79292117
tags question: http://stackoverflow.com/q/79269635

http://stackoverflow.com/a/78211681
has body: Untested but should work: When you're checking if PIPv6 is empty and attempting to echo "Unknown" if it's not set, your script logic is inverted. You echo $PIPv6 when it's empty (which will just print nothing since PIPv6 is empty) and print "Unknown" when it's not empty, which is the opposite of what you're aiming for. Additionally, you want to store the "Unknown" value in the PIPv6 variable if no IPv6 is found, not just echo it. Here's a revised version of your script with the corrected logic and variable assignment: #!/bin/bash OS="$(uname)" InternalIP="" LIP="ip addr show" LIP6="ip -6 addr show scope global" IPv6="" PIPv6="" case $OS in *)InternalIP=$($LIP | grep 'inet'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NF>0{print $2}');; esac case $OS in *)IPv6=$($LIP | grep 'inet6' | grep -v '128' | awk '{print $2}');; esac case $OS in *)PIPv6=$($LIP6 | grep 'inet6' | grep -v '128' | awk '{print $2}');; esac # Check if PIPv6 is empty and set to "Unknown" if it is if [ -z "$PIPv6" ]; then PIPv6="Unknown" fi length=$InternalIP echo $InternalIP | awk '{print substr($0, 1, length($0)-3)}' echo $IPv6 | awk '{print substr($0, 1, length($0)-3)}' echo "Public IPv6: "$PIPv6 Now, the script will correctly output "Unknown" for the public IPv6 address if none is found, and store this in the PIPv6 variable for later use, as you intended. Please make other changes accordingly.
answers question: http://stackoverflow.com/q/78211473
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/137886356

http://stackoverflow.com/comment/137855922
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78194973
has text: sorry getting more and more lost

http://stackoverflow.com/a/78227877
answers question: http://stackoverflow.com/q/78223744
type: Answer
downvote count: 0
has body: In the POSIX shell syntax, the && and || operators have the same precedence and associate left to right. Using Bash-specific curly brace syntax we can understand it as: A op1 B op2 C <--> { A op1 B } op2 C for op1 and op2 being any combination of the || and && operators. (We can't use parentheses to show this because they introduce a semantic action of execution in a "subshell" process.) The shell executes commands separated by these operators from left to right. When the separator is &&, the command so far must be successful in order to continue. When the separator is ||, the command so far must have failed. Parsing this is the same like handling A + B - C .... Recursive descent parsing identifies as LL(k) (usually k = 1), whereas left association more naturally pairs with LR parsing. A grammar structure like: E := E && E | E || E is "left factored" for LL(1) parsing. You don't have to do this formally. There is a code structure which handles the case. The basic structure is: Parse an expression; call it E. While the next token is && or ||: consume token, call it operator. parse expression which follows, call it Enext. build tree node by combining existing expression with new one: E := make_node(E, operator, Enext). loop from (2) Return E
score: 1
upvote count: 1

http://stackoverflow.com/comment/138029682
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78294007
has text: You most likely need to source something when installation completes. But without any code, it's hard to help you.
type: QuestionComment

jq
tags question: http://stackoverflow.com/q/78173589
tags question: http://stackoverflow.com/q/78221337
tags question: http://stackoverflow.com/q/78195387
tags question: http://stackoverflow.com/q/78227591
tags question: http://stackoverflow.com/q/78253195
type: Tag
tags question: http://stackoverflow.com/q/78240671
tag name: jq
tags question: http://stackoverflow.com/q/78252129
tags question: http://stackoverflow.com/q/78239630
tags question: http://stackoverflow.com/q/78161552
tags question: http://stackoverflow.com/q/78411838
tags question: http://stackoverflow.com/q/78422524
tags question: http://stackoverflow.com/q/78342087
tags question: http://stackoverflow.com/q/78381387
tags question: http://stackoverflow.com/q/78429844
tags question: http://stackoverflow.com/q/78456512
tags question: http://stackoverflow.com/q/78489072
tags question: http://stackoverflow.com/q/78484156
tags question: http://stackoverflow.com/q/78604131
tags question: http://stackoverflow.com/q/78608644
tags question: http://stackoverflow.com/q/78736348
tags question: http://stackoverflow.com/q/78797043
tags question: http://stackoverflow.com/q/78867172
tags question: http://stackoverflow.com/q/78897526
tags question: http://stackoverflow.com/q/78870424
tags question: http://stackoverflow.com/q/78781574
tags question: http://stackoverflow.com/q/78873635
tags question: http://stackoverflow.com/q/78839494
tags question: http://stackoverflow.com/q/78808557
tags question: http://stackoverflow.com/q/78769725
tags question: http://stackoverflow.com/q/78808305
tags question: http://stackoverflow.com/q/78977238
tags question: http://stackoverflow.com/q/78946376
tags question: http://stackoverflow.com/q/78982991
tags question: http://stackoverflow.com/q/79038230
tags question: http://stackoverflow.com/q/79008215
tags question: http://stackoverflow.com/q/79044165
tags question: http://stackoverflow.com/q/79055566
tags question: http://stackoverflow.com/q/79065379
tags question: http://stackoverflow.com/q/79115246
tags question: http://stackoverflow.com/q/79134868
tags question: http://stackoverflow.com/q/79171538
tags question: http://stackoverflow.com/q/79081495
tags question: http://stackoverflow.com/q/79084052
tags question: http://stackoverflow.com/q/79183505
tags question: http://stackoverflow.com/q/79221915
tags question: http://stackoverflow.com/q/79133886
tags question: http://stackoverflow.com/q/79153399
tags question: http://stackoverflow.com/q/79275641
tags question: http://stackoverflow.com/q/79311905
tags question: http://stackoverflow.com/q/79481609
tags question: http://stackoverflow.com/q/79469366

http://stackoverflow.com/comment/137888138
type: QuestionComment
comment on: http://stackoverflow.com/q/78213645
score: 0
type: Comment
has text: btw, `.` in the regex shown should be `[.]` or `\.` (or for arcane bash reasons: `"."` or `'.'`)

http://stackoverflow.com/q/78253800
tagged with: sh
has comment: http://stackoverflow.com/comment/138193462
has title: Multiple error handling in bash script to restart container
has comment: http://stackoverflow.com/comment/137959477
type: Question
answer count: 0
tagged with: shell
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138193451
score: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137959484
has comment: http://stackoverflow.com/comment/138193461
has body: I have below script, which is handling the error "TLS handshake failed" and restarting a app container if an error is found. Now i want to add 2 more errors (no.2 and 3 below list) which I intend to update to restart a container "APP" if I see 3 errors in the EH logs. Please help with correct script. 3 errors are : TLS handshake failed Connection reset by peer Failed to release a message #!/bin/bash # Set the container name container_name="APP" # Set the search string search_string=("TLS handshake failed") # Set the service name service_name="dumpingserver" # Check if the log contains the search string if docker logs --since 15m \$container_name 2>&1 | grep -q "\$search_string"; then echo "Search string found in \$container_name logs" # Restart the iotedge service if systemctl is-active --quiet \$service_name; then echo "Restarting the \$service_name service" systemctl restart \$service_name else echo "\$service_name service is not running, attempting to start it" systemctl start \$service_name fi else echo "Search string not found in \$container_name logs" fi
has comment: http://stackoverflow.com/comment/138193501

http://stackoverflow.com/comment/137822539
comment on: http://stackoverflow.com/q/78176347
score: 0
has text: I'm still trying to understand [your comment](https://stackoverflow.com/questions/78176347/using-awk-how-do-i-find-numbers-in-a-file-between-200-and-400?noredirect=1#comment137822467_78176347). It'd be much easier for us to help you if you'd [edit] your question to state your requirements and show sample input including some "number" a user might enter and the expected output given those "number"s.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138038650
comment on: http://stackoverflow.com/q/78298936
score: 0
has text: @KamilCuk thanks, can you please elaborate how can I stop the process in such a situation (I can not SIGKILL it because in my real-life problem, it creates additional processes)?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137925043
type: AnswerComment
has text: You can pass a literal newline instead of `;` within the argument that follows `-c`, for one.
score: 0
comment on: http://stackoverflow.com/a/78232840
type: Comment

http://stackoverflow.com/comment/137771999
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78147701
has text: `is_prime() { openssl prime "$1" | grep -qv not; }`

http://stackoverflow.com/comment/137800046
type: Comment
has text: A parent process can *initialize* the environment of a child process, but it cannot seen any further changes to that environment made by the child. Similarly, there is no way for the child to modify the environment of its parent.
score: 2
comment on: http://stackoverflow.com/q/78163771
type: QuestionComment

http://stackoverflow.com/comment/137804465
has text: @Rich See [ParsingLs - Greg's Wiki](https://mywiki.wooledge.org/ParsingLs). And for more on that topic: [shell - Why *not* parse `ls` (and what to do instead)? - Unix & Linux Stack Exchange](https://unix.stackexchange.com/questions/128985/why-not-parse-ls-and-what-to-do-instead).
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78166124

http://stackoverflow.com/comment/137993875
has text: This is arguably a duplicate of questions about reliably saving and restoring the `IFS` special variable. See [Bash Pitfalls #49 (OIFS="$IFS"; ...; IFS="$OIFS")](https://mywiki.wooledge.org/BashPitfalls#OIFS.3D.22.24IFS.22.3B_.2BICY.3B_IFS.3D.22.24OIFS.22) and [Is it a sane approach to "back up" the $IFS variable?](https://unix.stackexchange.com/q/264926/264812).
comment on: http://stackoverflow.com/q/78272610
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78182539
tagged with: github-api
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137832840
has comment: http://stackoverflow.com/comment/137833019
has answer: http://stackoverflow.com/a/78201957
tagged with: github
has answer: http://stackoverflow.com/a/78183320
score: 0
tagged with: shell
accepted answer: http://stackoverflow.com/a/78201957
possible better answer: http://stackoverflow.com/a/78183320
tagged with: bash
has comment: http://stackoverflow.com/comment/137834117
has title: Unicode in shell script to github API
has comment: http://stackoverflow.com/comment/137832745
has comment: http://stackoverflow.com/comment/137832816
answer count: 2
has body: I am trying to create labels using github api, but pass in emojis to the label name. Any ideas on how I can do this properly? source config.txt labels2=( "Sleep $zzz_unicode:FFFFFF" ) # Read repository names from file while IFS= read -r repo; do REPO_USER=$(echo "$repo" | cut -f1 -d /) REPO_NAME=$(echo "$repo" | cut -f2 -d /) echo "-----------------------------------------[$REPO_USER/$REPO_NAME]---------------------------------" # Iterate over labels for label in "${labels2[@]}"; do label_name=$(echo "$label" | cut -d ":" -f 1) label_color=$(echo "$label" | cut -d ":" -f 2) data="{\"name\":\"$label_name $emoji\",\"color\":\"$label_color\"}" response=$(curl -s -w "%{http_code}" -u "$token:x-oauth-basic" --request POST --data "$data" "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels") response_code=$(echo "$response" | tail -n1) response_body=$(echo "$response" | sed '$d') if $response_code -eq 201 ; then echo "Label '$label_name $emoji' created successfully in repository '$REPO_USER/$REPO_NAME'" else echo "Failed to create label '$label_name $emoji' in repository '$REPO_USER/$REPO_NAME'. Response: $response_body" fi done done < repo_names.txt Tried using github unicode, as well as the actual emoji in label creation: "Bug :FF0000" "Sleep $zzz_unicode:FFFFFF" I created a label manually on a repo: Bug with color FF0000. I can run a script to return all labels for that repo: Fetching labels for Repo... [ { "id": someID, "node_id": "some_nodeID", "url": "https://api.github.com/repos/repo/labels/test%20%F0%9F%90%9B", "name": "test ", "color": "ff0000", "default": false, "description": "" } ] But if I try using my script above to create the label for me using github API with the emoji in the label itself during creation: "Bug :FF0000" It creates label asBug ?? If I try creation with unicode: "Sleep $zzz_unicode:FFFFFF" it creates label as Sleep Note that sleep is just a test - zzz is github zzz emoji but should work the same.
linked to: http://stackoverflow.com/q/673055
type: Question

http://stackoverflow.com/a/78270269
downvote count: 0
type: Answer
has body: -R does seem to be the option you need. It's just that when given the full path, the program won't know where it should be cut, which exact part you want to replicate at the destination. (Remember, it's the shell that expands the ** wildcard, while rsync just gets a list of filenames and has no idea how they came to be.) The man page gives two options: Either, put an extra ./ in the path to mark the cut point. Indeed this seems to do what you want: rsync -ahv -R targetvolume/targetdir/./**/my_folder/ ./outputdir producing outputdir/a/my_folder/file1.txt etc. Or, cd deeper into the tree first. Though this'll require adjusting the destination too: dest=$PWD/outputdir cd targetvolume/targetdir/ rsync -ahv -R ./**/my_folder/ "$dest"
has comment: http://stackoverflow.com/comment/137988271
answers question: http://stackoverflow.com/q/78269359
accepted answer of: http://stackoverflow.com/q/78269359
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137988499
score: 2
upvote count: 2

http://stackoverflow.com/comment/137919027
has text: From the bash man page about the `read` command: _One line is read from the standard input ... , **split into words** ... and the **first word** is assigned to the first name_. So, what else would you expect?
comment on: http://stackoverflow.com/q/78228875
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/q/78250385
downvote count: 1
has body: there are two files in current dir [root@workspace tmp]# ll total 8 -rw-------. 1 root root 6 Mar 31 13:18 * -rw-------. 1 root root 6 Mar 31 13:18 ? [root@workspace tmp]# for f in "`find . -type f`";do echo "$f";done ./* ./? [root@workspace tmp]# for f in "`find . -type f`";do echo $f;done ./* ./? ./* ./? I am confused about the output of the two echo ... the differenct is: the double quote around the $f why the outputs are so, anyone can explain this? thanx any help in advance.
has answer: http://stackoverflow.com/a/78250534
score: 0
tagged with: bash
has title: why variable substitution is so different?
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/4708549
has comment: http://stackoverflow.com/comment/137954139
accepted answer: http://stackoverflow.com/a/78250534
has comment: http://stackoverflow.com/comment/137955014
type: Question
tagged with: shell

http://stackoverflow.com/a/78194963
has body: Using the following to simulate OP's lvs output: $ cat lvs.out LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- &lt;12.81g swap rhel -wi-ao---- 1.60g lv_hana_backups vg_hana_backups -wi-ao---- &lt;10.00g lv_hana_data vg_hana_data -wi-ao---- &lt;10.00g lv_hana_log vg_hana_log -wi-ao---- &lt;10.00g lv_hana_shared vg_hana_shared -wi-ao---- &lt;10.00g One awk idea to replace OP's current awk ... | tail ...: cat lvs.out | awk 'NR&gt;=4 { print &quot;/dev/&quot; $2 &quot;/&quot; $1 }' NOTE: OP will replace cat lvs.out | with lvs | This generates: /dev/vg_hana_backups/lv_hana_backups /dev/vg_hana_data/lv_hana_data /dev/vg_hana_log/lv_hana_log /dev/vg_hana_shared/lv_hana_shared
score: 3
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/78194906
type: Answer

command-substitution
type: Tag
tags question: http://stackoverflow.com/q/78234242
tag name: command-substitution
tags question: http://stackoverflow.com/q/78519611
tags question: http://stackoverflow.com/q/78501102
tags question: http://stackoverflow.com/q/78712681
tags question: http://stackoverflow.com/q/79027290
tags question: http://stackoverflow.com/q/79282852

http://stackoverflow.com/q/78154583
score: 4
accepted answer: http://stackoverflow.com/a/78155222
has answer: http://stackoverflow.com/a/78157136
type: Question
upvote count: 4
tagged with: shell
downvote count: 0
possible better answer: http://stackoverflow.com/a/78157136
favorite count: 0
has comment: http://stackoverflow.com/comment/137784119
answer count: 2
has comment: http://stackoverflow.com/comment/137784333
tagged with: bash
has comment: http://stackoverflow.com/comment/137783793
has comment: http://stackoverflow.com/comment/137784366
has comment: http://stackoverflow.com/comment/137784265
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137784302
has title: Bash: tilde expansion within the word of parameter expansions
has answer: http://stackoverflow.com/a/78155222
has body: When I use the "Use Default Value" parameter expansion with a tilde (~) in Bash, it behaves differently depending on whether it's quoted. For instance: echo ${unsetVar:-~} # /home/foo In this case, ${unsetVar:-~} correctly expands to the $HOME when the variable unsetVar is unset. This shows that the tilde undergoes expansion as expected when it's not enclosed in quotes. However, when I enclose the parameter expansion in double quotes: echo "${unsetVar:-~}" # ~ No tilde expansion. I suppose this is due to the https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html rule. Although I was aware of that rule beforehand, I thought it applies to only special characters directly within double quotes, like "asdf ~ asdf" but not to those indirectly within, as shown in the example. I'm aware that $HOME can be substituted for ~. However, I'm interested in finding out if there's a way to force the tilde expansion. EDIT: ... to force the tilde expansion within one simple command EDIT2: without introducing temporary variables

http://stackoverflow.com/q/78297320
has comment: http://stackoverflow.com/comment/138035507
has title: The newline (\n) is not working in END block in bash
tagged with: bash
linked to: http://stackoverflow.com/q/15429330
type: Question
has answer: http://stackoverflow.com/a/78297369
duplicate of: http://stackoverflow.com/q/15184358
duplicate of: http://stackoverflow.com/q/15429330
accepted answer: http://stackoverflow.com/a/78297369
has body: I need to define the "\n" in END block as it will be passed to other bash script as an argument. I have added an empty newline at the begin and at the end. But only the begin empty line (\n) is working and the end empty line (\n) is not working. Here is the test script: string="$(cat <<"END" foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working bar END )" echo "" echo "--- method 1 - define \n in END block ---" echo "" printf "%s" "first line in single line (method 1)" printf "%s" "$string" printf "%s" "last line in single line (method 1)" echo "" echo "" echo "--- method 2 - define \n in printf ---" echo "" printf "%s" "first line in single line (method 2)" printf "%s\n" "$string" printf "%s" "last line in single line (method 2)" Here is the output: --- method 1 - define \n in END block --- first line in single line (method 1) foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working barlast line in single line (method 1) --- method 2 - define \n in printf --- first line in single line (method 2) foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working bar last line in single line (method 2) Here is the expected output: --- method 1 - define \n in END block --- first line in single line (method 1) foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working bar last line in single line (method 1) How to set the "\n" in the END block for making it work with method 1? Update: I tried to use variable inside the method provided by @tripleee: var1="hello world" string=' foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working $var1 bar ' printf "%s" "$string" Here is the output: foo the "newline(\n)" in "END" before the foo is working but "newline(\n)" in "END" after the bar is not working $var1 b…
score: 0
linked to: http://stackoverflow.com/q/10067266
tagged with: ubuntu
tagged with: cat
answer count: 1
type: AnsweredQuestion
duplicate of: http://stackoverflow.com/q/10067266
has comment: http://stackoverflow.com/comment/138035391
tagged with: printf

http://stackoverflow.com/comment/137855849
comment on: http://stackoverflow.com/q/78194991
type: QuestionComment
has text: Hive you tried `disown`ing the target PID before killing it?
score: 1
type: Comment

http://stackoverflow.com/comment/137826061
has text: I don't think this is a good idea. Make your testing program dump core on segmentation fault instead and only run gdb if it crashes.
comment on: http://stackoverflow.com/q/78178759
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/137855044
type: Comment
comment on: http://stackoverflow.com/q/78194906
score: 1
type: QuestionComment
has text: how do you go from the current 3 lines of output to an expected output of 4 lines? please update the question to insure the different data sets match

http://stackoverflow.com/comment/137823625
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78177405
has text: @jhnc That is exactly the problem I am trying to solve. I need to not just remove the first line, but capture it for later use.

http://stackoverflow.com/a/78241429
type: Answer
score: 4
has comment: http://stackoverflow.com/comment/137937986
accepted answer of: http://stackoverflow.com/q/78240155
has comment: http://stackoverflow.com/comment/137938662
has body: Although it's not necessary for what you are trying to do (just pass multiple commands to a single sed process), it is possible to build pipelines of commands dynamically in Bash. This Shellcheck-clean Bash code demonstrates one way to do it: #! /bin/bash -p function run_sed_pipeline { local pipecmd='' i for ((i=1; i<=$#; i++)); do pipecmd+="${pipecmd:+ | }sed \"s/\${$i}/$i/\"" done printf 'DEBUG: EVAL: %s\n' "$pipecmd" >&2 eval "$pipecmd" } run_sed_pipeline A B C D <example.txt When the code is run it produces output: DEBUG: EVAL: sed "s/${1}/1/" | sed "s/${2}/2/" | sed "s/${3}/3/" | sed "s/${4}/4/" 1 2 3 4 The basic idea is to build up a pipeline of commands in a string variable and use eval to run it. There are serious pitfalls associated with eval and it is best avoided. See Why should eval be avoided in Bash, and what should I use instead?. Also see BashFAQ/048 (Eval command and security issues). I think that the code here avoids significant eval pitfalls, but I could be wrong. The main thing that the code does to avoid problems is to refrain from putting the expanded function arguments (A B C D in this example) in the string to be evaled. Instead, the only expansions in the command string are (quoted) ${1}, ${2}, ${3}, and ${4}. This ensures that embedded expansions, or quotes etc., in the function arguments will not cause problems. Another way to create a dynamic pipeline of commands is to use a recursive function, as with this Shellcheck-clean code: #! /bin/bash -p function run_sed_pipeline { if (( $# < 2 )); then cat else sed "s/$2/$1/" | run_sed_pipeline "$(($1+1))" "${@:3}" fi } run_sed_pipeline 1 A B C D <example.txt When the code is run it produces output: 1 2 3 4 The first argument to the function is the number to substitute for the first (remaining) argument to be replaced. Each recursive call increments the first argument by one and removes the first of the following (remaining) arguments. This code features an unusual "useless use of cat" (UUoC). Th…
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78240155
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/137938711

http://stackoverflow.com/q/78244513
tagged with: git
tagged with: git-bash
has title: Git+Bash / GitBash: Add files matching both first-letter-uppercase or all-lowercase filenames of certain pattern along with respective plurals
has comment: http://stackoverflow.com/comment/137943223
upvote count: 3
has body: I have some Laravel/Livewire files matching filename patterns like seen in below: app/Livewire/String1Table.php app/Livewire/String1s.php app/Livewire/EditString1.php app/Models/String2Table.php app/Models/SubDir/SomeString2.php resources/views/livewire/string1-table.blade.php resources/views/livewire/string1s.blade.php resources/views/livewire/edit-string1.blade.php Now I want to git add only those files that contain String1 or string1 (apparently disregarding the case) and only those that are within the [L|l]ivewire folder (disregarding the case here too). I know that git add supports the asterisk and some of regex, but does it support all the bash related pattern matches ? Any ideas on how can I achieve what I want? Hope the requirement is clear. From the first 2 informative comments, I am wondering if this would be correct: git add *[Ll]ivewire/*String1[?s] ? I am not so well-versed with regex that much, that's why I wanna know if anyone can come up with a way or partial way. I don't wanna end up adding files incorrectly.
has comment: http://stackoverflow.com/comment/137943248
answer count: 2
tagged with: git-add
accepted answer: http://stackoverflow.com/a/78244642
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137943334
favorite count: 0
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/78245356
has answer: http://stackoverflow.com/a/78244642
has comment: http://stackoverflow.com/comment/137943281
score: 3
tagged with: regex
type: Question
has answer: http://stackoverflow.com/a/78245356

http://stackoverflow.com/q/78281234
has title: Robust way to escape a bash variable for using it in "awk -v var=..." assignment
type: UnansweredQuestion
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/138007608
favorite count: 0
duplicate of: http://stackoverflow.com/q/19075671
has comment: http://stackoverflow.com/comment/138007624
downvote count: 0
tagged with: bash
has answer: http://stackoverflow.com/a/78281278
linked to: http://stackoverflow.com/q/13808909
type: Question
has body: I'm looking for a robust way to pass a bash variable to awk through -v so that the resulting awk variable would exactly contain the string in the bash variable. Example: #!/bin/bash b='dir\t\010\out' awk -v a="$b" 'BEGIN{print a}' Expected output: dir\t\010\out My guess is that doubling the backslashes should be enough, but I can't say it's still true for any string. Any idea? The question's been closed before I could post an answer to it... While using ENVIRON is the simplest method, here's how you can escape a bash variable for passing it as a literal string through -v to any POSIX awk: #!/bin/bash awk_esc() { local v="${1//\\/\\\\}" printf %s "${v//$'\n'/\\n}" } b='A\t B' awk -v a="$(awk_esc "$b")" 'BEGIN{print a}' A\t B
has answer: http://stackoverflow.com/a/78281380
has comment: http://stackoverflow.com/comment/138008139
linked to: http://stackoverflow.com/q/19075671
tagged with: awk
answer count: 3
has answer: http://stackoverflow.com/a/78283486

http://stackoverflow.com/comment/137857297
has text: Based on the code fragments in the question, I think the OP wants to remove positional parameters by value, not by position.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78196126
score: 3

http://stackoverflow.com/a/78280945
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78280175
has body: A Python solution is trivial: with open("file1.txt") as f1, open("file2.txt") as f2, open("file3.txt", "w") as f3: i2 = 0 l2 = f2.readlines() for l1 in map(str.strip, f1): t1, *_ = l1.split() while i2 < len(l2) and l2[i2].startswith(t1): f3.write(l1+l2[i2]) i2 += 1

http://stackoverflow.com/comment/137908369
has text: Exactly as posted in your question? With the single quotes inside the string?
type: QuestionComment
comment on: http://stackoverflow.com/q/78224990
type: Comment
score: 0

http://stackoverflow.com/comment/137855630
score: 0
has text: Yea, I'm starting to understand that this is probably a big waste of time, for an "extreme" circumstance, and I'm accepting that `y` (repeatable) + `enter` is "good enough" for my use case.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78195172

http://stackoverflow.com/a/78287633
answers question: http://stackoverflow.com/q/78286124
has body: Not sure what you want or which data set you are using. But in Excel (assuming no version constraints per your tags), using your table (3.csv), you can obtain the attendance day 3 from this formula: =LET( spl, TEXTSPLIT(A1, &quot;,&quot;), cnt, COLUMNS(spl) / 2, att, HEX2DEC( INDEX(spl, 1, SEQUENCE(, cnt, 2, 2)) ), _day3, SUM( BYCOL( att, LAMBDA(arr, IF(BITAND(2, arr), 1)) ) ), _day3 ) Split the string by commas Count the number of elements (allows for any number of people Extract the even number elements which is the attendance record Convert Hex to Decimal Analyze for setting of the 2nd bit from the right with the BITAND function and sum the results. Should you want to use different outputs or inputs, please be specific. If your csv.3 table elements are in separate cells, a minor change in the formula will accomodate: =LET( data, A2:F2, n, COLUMNS(data), att, HEX2DEC( INDEX( data, 1, SEQUENCE(, n / 2, 2, 2) ) ), _day3, SUM( BYCOL( att, LAMBDA(arr, IF(BITAND(2, arr), 1)) ) ), _day3 )
type: Answer
upvote count: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78286124
score: 2
downvote count: 0

http://stackoverflow.com/comment/138014677
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78285382
has text: Note that "explain this code" questions need to be _very_ narrow and specific to be on-topic here (and moreover our scope is limited to practical questions; puzzles and brain teasers have a different Stack Exchange site). Also, bash isn't involved at all in the execution of this (since the shebang points to an executable that _isn't_ bash) -- that's kind of the point. The line `echo 33` is thus a red herring -- because running this script doesn't invoke a shell interpreter, nothing interprets that line as code (strictly, this file isn't a shell script at all).

http://stackoverflow.com/a/78235206
type: AcceptedAnswer
has body: Addressing the declare -a foo vs declare -a foo=() (vs foo=()) question ... The results are going to depend on what's in foo prior to the declare -a. $ foo=a # set to single character $ declare -p foo declare -- foo="a" $ declare -a foo # convert to array $ declare -p foo declare -a foo=([0]="a") # maintains initial value of 'a' --------------------------------- $ foo=a # set to single character $ declare -p foo declare -- foo="a" $ declare -a foo=() # convert to array but also clear contents $ declare -p foo declare -a foo=() # array is empty --------------------------------- $ foo=(a b c) # set to 3 element array $ declare -p foo declare -a foo=([0]="a" [1]="b" [2]="c") $ declare -a foo # (re)declare as array $ declare -p foo declare -a foo=([0]="a" [1]="b" [2]="c") # maintains intitial set of 3 values --------------------------------- $ foo=(a b c) # set to 3 element array $ declare -p foo declare -a foo=([0]="a" [1]="b" [2]="c") $ declare -a foo=() # (re)declare as array but also clear contents $ declare -p foo declare -a foo=() # array is empty Findings: if foo is undefined then declare -a foo, declare -a foo=() and foo=() behave the same if foo is predefined then declare -a foo will maintain the predefined value, while declare -a foo=() and foo=() will clear the contents of foo If you know with 100% certainty your variable (foo in this case) is undefined then you're safe with declare -a foo or declare -a foo=() or foo=(). If you're not sure about the contents of the variable (eg, it was exported by the parent process) then you're safer explicitly clearing the variable with declare -a foo=() or foo=(). If you need the array to be empty then I'd suggest always explicitly defining the array as empty via declare -a foo=() or foo=(). NOTES: results of these test cases will vary if you initially define foo and then try to define as an associative array (declare -A foo) personally, I prefer to initially run unset foo as this eliminates any unwanted leftover behavior …
downvote count: 0
answers question: http://stackoverflow.com/q/78235101
type: Answer
has comment: http://stackoverflow.com/comment/137927680
accepted answer of: http://stackoverflow.com/q/78235101
score: 5
upvote count: 5

sed
tags question: http://stackoverflow.com/q/78261247
tag name: sed
tags question: http://stackoverflow.com/q/78196374
tags question: http://stackoverflow.com/q/78160050
tags question: http://stackoverflow.com/q/78147701
tags question: http://stackoverflow.com/q/78165163
tags question: http://stackoverflow.com/q/78155628
type: Tag
tags question: http://stackoverflow.com/q/78287441
tags question: http://stackoverflow.com/q/78240155
tags question: http://stackoverflow.com/q/78274285
tags question: http://stackoverflow.com/q/78185284
tags question: http://stackoverflow.com/q/78196837
tags question: http://stackoverflow.com/q/78280175
tags question: http://stackoverflow.com/q/78200217
tags question: http://stackoverflow.com/q/78372639
tags question: http://stackoverflow.com/q/78359494
tags question: http://stackoverflow.com/q/78423090
tags question: http://stackoverflow.com/q/78404577
tags question: http://stackoverflow.com/q/78383503
tags question: http://stackoverflow.com/q/78330348
tags question: http://stackoverflow.com/q/78356050
tags question: http://stackoverflow.com/q/78441613
tags question: http://stackoverflow.com/q/78331935
tags question: http://stackoverflow.com/q/78334609
tags question: http://stackoverflow.com/q/78371799
tags question: http://stackoverflow.com/q/78501102
tags question: http://stackoverflow.com/q/78588126
tags question: http://stackoverflow.com/q/78464004
tags question: http://stackoverflow.com/q/78660797
tags question: http://stackoverflow.com/q/78591077
tags question: http://stackoverflow.com/q/78678003
tags question: http://stackoverflow.com/q/78649419
tags question: http://stackoverflow.com/q/78736692
tags question: http://stackoverflow.com/q/78681873
tags question: http://stackoverflow.com/q/78620437
tags question: http://stackoverflow.com/q/78736701
tags question: http://stackoverflow.com/q/78716100
tags question: http://stackoverflow.com/q/78680643
tags question: http://stackoverflow.com/q/78682104
tags question: http://stackoverflow.com/q/78654364
tags question: http://stackoverflow.com/q/78722674
tags question: http://stackoverflow.com/q/78644848
tags question: http://stackoverflow.com/q/78720313
tags question: http://stackoverflow.com/q/78625802
tags question: http://stackoverflow.com/q/78639369
tags question: http://stackoverflow.com/q/78894755
tags question: http://stackoverflow.com/q/78789822
tags question: http://stackoverflow.com/q/78903250
tags question: http://stackoverflow.com/q/78894153
tags question: http://stackoverflow.com/q/78772491
tags question: http://stackoverflow.com/q/78788854
tags question: http://stackoverflow.com/q/78791284
tags question: http://stackoverflow.com/q/78878978
tags question: http://stackoverflow.com/q/78839799
tags question: http://stackoverflow.com/q/78745086
tags question: http://stackoverflow.com/q/78764602
tags question: http://stackoverflow.com/q/78854738
tags question: http://stackoverflow.com/q/78750411
tags question: http://stackoverflow.com/q/78977025
tags question: http://stackoverflow.com/q/78911928
tags question: http://stackoverflow.com/q/78986350
tags question: http://stackoverflow.com/q/78965550
tags question: http://stackoverflow.com/q/78949359
tags question: http://stackoverflow.com/q/78981924
tags question: http://stackoverflow.com/q/78967238
tags question: http://stackoverflow.com/q/78924359
tags question: http://stackoverflow.com/q/79053114
tags question: http://stackoverflow.com/q/78995324
tags question: http://stackoverflow.com/q/78994565
tags question: http://stackoverflow.com/q/78919663
tags question: http://stackoverflow.com/q/79013110
tags question: http://stackoverflow.com/q/79041736
tags question: http://stackoverflow.com/q/78903740
tags question: http://stackoverflow.com/q/79127985
tags question: http://stackoverflow.com/q/79188872
tags question: http://stackoverflow.com/q/79241036
tags question: http://stackoverflow.com/q/79101990
tags question: http://stackoverflow.com/q/79141995
tags question: http://stackoverflow.com/q/79200373

http://stackoverflow.com/comment/138040739
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78300019
has text: See [How do I find where the environment variables are defined in Linux](https://stackoverflow.com/q/37649080/4154375).
type: Comment

http://stackoverflow.com/comment/137813778
has text: Or even `paste -d, - <<<"$time" <(sed <<<"$time" 's/^[0-9]*,\([0-9]\+\),.*/@\1/'|LANG=C date -f -)`
comment on: http://stackoverflow.com/q/78170444
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137833874
score: 0
comment on: http://stackoverflow.com/q/78183119
type: QuestionComment
has text: See also [BashFAQ #48 - *Eval command and security issues*](https://mywiki.wooledge.org/BashFAQ/048) (explaining why `eval` is generally viewed as a Bad Idea); and [BashFAQ #50 - *I'm trying to put a command in a variable, but all the complex cases always fail!*](https://mywiki.wooledge.org/BashFAQ/050) (explaining why the things people naively try to use instead of `eval` don't work)
type: Comment

http://stackoverflow.com/q/78211761
has comment: http://stackoverflow.com/comment/137888242
has comment: http://stackoverflow.com/comment/137886464
score: 0
has title: flutter doctor -v not returning desired output log
type: Question
has answer: http://stackoverflow.com/a/78215263
linked to: http://stackoverflow.com/q/78207181
has comment: http://stackoverflow.com/comment/137888750
type: UnansweredQuestion
tagged with: flutter
has body: when I run the commands flutter doctor -v is returning the output Found an existing Pub cache at /home/supr/.pub-cache. It can be repaired by running `dart pub cache repair`. It can be reset by running `dart pub cache clean` when I press Ctrl + C exiting the flutter doctor prompt the entire output is a red text terminal of Found an existing Pub cache at /home/supr/.pub-cache. It can be repaired by running `dart pub cache repair`. It can be reset by running `dart pub cache clean`. Flutter failed to delete a directory at "/usr/sbin/flutter/.pub-preload-cache". Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user. #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3) #1 _throwFileSystemException (package:flutter_tools/src/base/error_handling_io.dart:831:3) #2 _handlePosixException (package:flutter_tools/src/base/error_handling_io.dart:761:3) #3 _runSync (package:flutter_tools/src/base/error_handling_io.dart:597:7) #4 ErrorHandlingDirectory.deleteSync (package:flutter_tools/src/base/error_handling_io.dart:478:12) #5 _tryDeleteDirectory (package:flutter_tools/src/dart/pub.dart:40:17) #6 _DefaultPub._preloadPubCache (package:flutter_tools/src/dart/pub.dart:619:7) #7 _DefaultPub._getPubCacheIfAvailable (package:flutter_tools/src/dart/pub.dart:595:5) #8 _DefaultPub._createPubEnvironment (package:flutter_tools/src/dart/pub.dart:681:30) <asynchronous suspension> #9 _DefaultPub._runWithStdioInherited (package:flutter_tools/src/dart/pub.dart:356:48) <asynchronous suspension> #10 _DefaultPub.get (package:flutter_tools/src/dart/pub.dart:323:5) <asynchronous suspension> #11 PubDependencies.update (package:flutter_tools/src/flutter_cache.dart:126:5) <asynchronous suspension> #12 Cache.updateAll (package:flutter_tools/src/cache.dart:715:9) <asynchronous suspension> #13 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1699:7) <asynchronous suspension> #14 Flutte…
tagged with: linux
tagged with: bash
answer count: 1

http://stackoverflow.com/comment/137914606
score: 0
has text: According to https://jfrog.com/help/r/jfrog-artifactory-documentation/aql-syntax neither `.filter(...)` nor `function(item) { ... }` are valid syntax. How did you come up with this?
type: QuestionComment
comment on: http://stackoverflow.com/q/78226551
type: Comment

http://stackoverflow.com/a/78286685
type: Answer
has comment: http://stackoverflow.com/comment/138118556
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/78286124
has comment: http://stackoverflow.com/comment/138020335
has body: Using GNU awk (for bitwise and() and while using gawk anyway strtonum(), too) to get the number of attendees from the file 3.csv: The problem in that format is that we don't know the exact number of days the event lasted, so 4 days is assumed and therefore constant (2^4=) 16 is used. This could of course be parameterized as well. $ gawk -v d=3 ' BEGIN { FS="," # delimiter d=16/2^d # figuring out a value for and() } { for(i=2;i<=NF;i+=2) # iterating hex bitfields s+=(and(strtonum("0x" $i),d)&&1) # the logic behind the solution is logic } END { print s }' 3.csv Output is the number of attendees on the 3rd day: 2 From 1.csv to 2.csv (as I misread the question first): $ awk ' BEGIN { FS="," } { for(i=2;i<=NF;i++) s=2*s+$i printf "%s,"(NR==1?"hex":"%x")"\n",$1,s s=0 }' 1.csv # > 2.csv name,hex Alice,c bob,7 Clara,a
downvote count: 0
has comment: http://stackoverflow.com/comment/138018052

http://stackoverflow.com/comment/137931382
comment on: http://stackoverflow.com/q/78233393
type: QuestionComment
score: 0
has text: I don't know anything about making games, but do you get any kind of log from the Steam client about the failed startup? If not, I'd try something like `./glow "$@" >/tmp/SomeFile 2>&1` to see whether `glow` outputs anything. Also, inside your script, running something like `ldd` on the executable file and redirecting the output to a file should let you see whether shared libraries are found.
type: Comment

http://stackoverflow.com/q/78232787
tagged with: subprocess
tagged with: shell
has comment: http://stackoverflow.com/comment/137922498
answer count: 1
has answer: http://stackoverflow.com/a/78232840
tagged with: python
has title: Python unexpected non-zero returncode when checking alias command set in .bashrc file
accepted answer: http://stackoverflow.com/a/78232840
tagged with: bash
has body: I want to call an alias command set in a .bashrc file from python. However, the returncode of source ~/.bashrc; command -v command is for some reason 1 instead of 0 which is the case if the same command is executed directly in the shell. It should be noted that with a default command like echo instead of the alias command, python correclty returns 0 as the returncode. To demonstrate the issue, I created a minimal example, where I use a regular shell script define_alias.sh instead of the .bashrc file: test_bash_command.py: import os import subprocess path_home = os.path.expanduser('~') proc = subprocess.Popen(['/bin/bash', '-c', 'source %s/define_alias.sh; command -v testcommand' % path_home], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc_stdout, proc_stderr = proc.communicate() proc_returncode = proc.returncode print("Returncode: %s" % proc_returncode) print("Stdout: %s" % proc_stdout) print("Stderr: %s" % proc_stderr) define_alias.sh: # .bashrc # imagine this is a .bashrc file echo "I'm in the shell script" alias testcommand='echo THIS IS A TEST' Output: wssadmin /global/wss/fs01/fk_bpr/waif_v8 $ python test_bash_command.py Returncode: 1 Stdout: b"I'm in the shell script\n" Stderr: b'' wssadmin /global/wss/fs01/fk_bpr/waif_v8 $ env -i bash --norc --noprofile bash-4.4$ bash -c "source /home/wssadmin/define_alias.sh; command -v testcommand; echo $?" I'm in the shell script 0 bash-4.4$ source /home/wssadmin/define_alias.sh; command -v testcommand; echo $? I'm in the shell script alias testcommand='echo THIS IS A TEST' 0 bash-4.4$ exit exit wssadmin /global/wss/fs01/fk_bpr/waif_v8 $ source /home/wssadmin/define_alias.sh; command -v testcommand; echo $? I'm in the shell script alias testcommand='echo THIS IS A TEST' 0 Question: Why is the returncode given to python not 0 like in the bash case? How can I get a returncode of 0 for the given command and additionally retrieve the stdout and stderr of the command -v testcommand (instead of only having tha…
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137922477
tagged with: alias
score: 0
type: Question

http://stackoverflow.com/q/78274299
tagged with: macos
tagged with: shell
score: 1
upvote count: 1
favorite count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78274517
has answer: http://stackoverflow.com/a/78290714
answer count: 2
tagged with: zshrc
downvote count: 0
possible better answer: http://stackoverflow.com/a/78290714
tagged with: bash
type: Question
has body: My current shell is ZSH and it defaults to using Bash version 3.2.x. I'm on macos Sonoma version 14.3.1. For one of the shell commands I'm trying to run, I'm currently getting the below error: unbound variable and this requires using a version of bash >=4 for using a functionality with associative arrays. I've installed the latest version of bash using brew and its currently available on this path: /opt/homebrew/Cellar/bash/5.2.26/bin/bash In my .zshrc I'm trying to add export PATH="$PATH:/opt/homebrew/Cellar/bash/5.2.26/bin" as a way to append the path to the latest version of bash that I want to use But when I do bash --version I still get 3.2.57: ➜ ~ bash --version GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23) Copyright (C) 2007 Free Software Foundation, Inc. How do I configure ZSH to load/use the latest bash version to solve the unbound variable error? My /etc/shells looks like below(I updated it to add the latest bash version installed through brew): /bin/bash /bin/csh /bin/dash /bin/ksh /bin/sh /bin/tcsh /bin/zsh /opt/homebrew/bin/bash /opt/homebrew/Cellar/bash/5.2.26/bin/bash
has answer: http://stackoverflow.com/a/78274517
has title: How can I get ZSH to pick up my latest version of Bash
tagged with: zsh
has comment: http://stackoverflow.com/comment/137998939

http://stackoverflow.com/a/78202886
type: Answer
downvote count: 1
score: -1
accepted answer of: http://stackoverflow.com/q/78202789
upvote count: 0
has comment: http://stackoverflow.com/comment/137872312
has comment: http://stackoverflow.com/comment/137872247
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78202789
has comment: http://stackoverflow.com/comment/137871959
has body: From what you’ve shared, I believe you encounter a syntax error because your script uses single quotes both inside and outside the command string. In Python, this prematurely ends the string. Note that the -it flags in the kubectl exec command are used for interactive terminals, which may not behave as expected within your Python script. I suggest you modify your script to surround the command with triple single quotes ('''), as this way, you can include single quotes inside the string without needing to escape them. You can learn more about using quotes here. Also I removed the -it flags from the kubectl exec command to ensure the command can be executed in your script. #!/usr/bin/python import subprocess command = '''kubectl exec -n nginx-ingress $(kubectl get pods -n nginx-ingress -o wide | grep nginx-ingress | grep Running | awk '{print $1}') -- /bin/bash''' subprocess.run(command, shell=True) Give this a go and let me know if it helps.

http://stackoverflow.com/comment/137847056
has text: Easy answer is to pipe awk's output into sqlite rather than having it _start_ sqlite at all. awk's `system()` is generally a mess -- interfaces that don't let you pass an explicit argv array are best avoided in the first place, since passing a shell a string that commingles code and data is a fast route to injection attacks. (Granted, not such an issue _here_, since you aren't accepting the `db` parameter from an untrusted source, but true as a matter of general principle).
score: 3
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193
type: Comment

http://stackoverflow.com/comment/137901411
type: Comment
has text: @user1934428 : yes, I am on Linux Mint Xfce and I have tried `stdbuf -o0` as first measure, but it didn't help having no effect at all, because the reason was not the buffering but delaying of filling the buffer (I deduct it from the fact that sleep command helped to get the right order).
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78215669

http://stackoverflow.com/a/78276617
type: Answer
has comment: http://stackoverflow.com/comment/137999494
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78276574
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78276574
downvote count: 0
score: 1
has body: You can source the grep results like such: $ typeset -p x -bash: typeset: x: not found $ source <(grep 'x=' hg.ini) $ typeset -p x declare -- x="hello.world" As pointed out in comments you'll need to perform the assignment and follow-on echo as separate commands: $ source <(grep 'x=' hg.ini); echo "$x" hello.world

http://stackoverflow.com/comment/137855837
type: Comment
has text: I went back to the duplicate question posted, to explore it further, when I noticed that it "worked" but was accepting infinite `yyy` before continuing. That's when I removed the `*` which restricted the example to a single character `y` before allowing it to continue. Sometimes, I simply need to just write out, explain my issue, and have a bit of nudging guidance from others to find the answer that's right in front of my face the whole time.
score: 0
comment on: http://stackoverflow.com/q/78195172
type: QuestionComment

http://stackoverflow.com/comment/138026743
type: QuestionComment
type: Comment
score: 0
has text: Thank you @CharlesDuffy for explanation, but I must say I do not find supporting statements by reading the manual literally. The "first unquoted slash" is used to detect tilde-prefix and the possible login name "If none of the characters in the tilde-prefix are quoted". "thus it's also black-letter documentation that the slash needs to be unquoted as well" - this is simply not true, if it is there and not quoted it will be used as a demarcation character, but nothing mandatory. There is probably no use in continuing this discussion since we know the actual behavior and read the spec.
comment on: http://stackoverflow.com/q/78291764

http://stackoverflow.com/comment/137925064
type: Comment
type: AnswerComment
score: 0
has text: @bproxauf, does the answer you get need to work for code running as root, or is code that takes advantage of features that the shell turns off when running under uid 0 acceptable?
comment on: http://stackoverflow.com/a/78232840

http://stackoverflow.com/a/78293679
answers question: http://stackoverflow.com/q/78293635
score: 2
has body: The * in $cron_cmd have special meaning in a regular expression. Use the -F option to search for a fixed string rather than regexp. if ! grep -F -q "$cron_cmd" cron; then echo "$cron_cmd" >> cron && crontab cron && rm cron fi
has comment: http://stackoverflow.com/comment/138029064
type: Answer
upvote count: 2
downvote count: 0

http://stackoverflow.com/comment/137916887
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78229406
score: 0
has text: Format your code properly. It's unreadable now.

http://stackoverflow.com/comment/137902883
has text: Although you [shouldn't parse `ls`](https://unix.stackexchange.com/questions/128985/why-not-parse-ls-and-what-to-do-instead), try wrapping it in single quotes: `watch … 'for x in … done'`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78221728
score: 1

http://stackoverflow.com/comment/137982234
has text: `bash --rcfile`
comment on: http://stackoverflow.com/q/78260557
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137872312
comment on: http://stackoverflow.com/a/78202886
score: 0
has text: Many thanks, yes, the link works we well
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78263541
answers question: http://stackoverflow.com/q/78263189
score: 1
upvote count: 1
has body: thanks a lot! I don't know wath piping is, anyway I slightly revisioned the code because I was getting error to uboot part. here is the working code. thanks again sudo sfdisk "/dev/$DEV" --wipe always <<EOF label: gpt first-lba: 64 table-length: 10 attrs=RequiredPartition, type=D7B1F817-AA75-2F4F-830D-84818A145370, start=64, size=32704 name="${BASE}-uboot" $( for name in "${!NameUrl[@]}"; do case ${name} in (uboot|extra) continue ;; esac printf '%s\n' "attrs=\"$ATTR\", size=$SIZE, name=\"$BASE-${name}\"" done | sort ) attrs="$ATTR", size=+, name="extra" EOF
downvote count: 0
type: Answer

http://stackoverflow.com/comment/137865696
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78200978
has text: thanks @F. Hauri - Give Up GitHub I'll have to look up exactly what you mean though because it looks a bit complicated. I thought for the search and replace it could be just one line. Im not sure what the wildcard is for.
score: 0

http://stackoverflow.com/a/78147099
downvote count: 0
answers question: http://stackoverflow.com/q/78146724
upvote count: 1
has comment: http://stackoverflow.com/comment/137778325
type: Answer
has body: Running through WSL should have no impact in this case. There are a few problems with your script, but the ones that are visible, at least, wouldn't cause an additional loop. To debug the loop part of the problem, I'd start by: From the command-line, run the same loop in the same directory, but with an echo in place of the Python invocation itself: cd ~/python for ((i = 1; i <= 2; i++)); do echo test_0$i.py; done If that works, make the same adjustment to the script and test it. If that works, as mentioned in the comments, check test_01.py to see if it is calling test_02.py. Try running it manually at the command-line and/or visually inspect it. As @user1934428 mentioned in the comments, running with set -x may also yield useful information. Other issues There is a typo in your shebang line (at least as you entered it here in your question) - #! usr/bin/env bash. The purpose of a shebang line is to tell system what program should execute your script (e.g., when called as ./script.sh). This is simply not going to work. The proper shebang line would be: #!/usr/bin/env bash However, if you really are expecting it to run as a script, then we come to the second issue. You mention that step 4 should be to "navigate back to ~/bash". This will not have the intended effect when executing a script via the shebang line. It may appear to work, but what really happens is that the shell will still be in whatever directory it started in. This may be the ~/bash directory, but it may not be. For example: cd ~ ~/bash/script.sh This would leave you back in the ~ directory after the script completes. Why? When using a shebang line, the script is executed by a separate shell invocation. It's inside this shell (running as a subprocess) that the cd takes place. As a cd is an environment change (the PWD environment variable), it can't be propagated back to the calling process. If you really need the script to be able to change the directory for the calling shell (and you probably don't), t…
score: 1
has comment: http://stackoverflow.com/comment/137778302
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78146724

github
tag name: github
tags question: http://stackoverflow.com/q/78182539
type: Tag
tags question: http://stackoverflow.com/q/78385195
tags question: http://stackoverflow.com/q/78471612
tags question: http://stackoverflow.com/q/78613091
tags question: http://stackoverflow.com/q/78723711
tags question: http://stackoverflow.com/q/78766769
tags question: http://stackoverflow.com/q/79292361
tags question: http://stackoverflow.com/q/79402707
tags question: http://stackoverflow.com/q/79433580
tags question: http://stackoverflow.com/q/79475480

http://stackoverflow.com/q/78210154
type: Question
tagged with: java
duplicate of: http://stackoverflow.com/q/6607675
linked to: http://stackoverflow.com/q/3830823
has comment: http://stackoverflow.com/comment/137882177
has title: Hide password from ps table, when sending as argument to java program
score: 0
has comment: http://stackoverflow.com/comment/137882194
has comment: http://stackoverflow.com/comment/137882081
answer count: 0
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137882131
has body: I take username and password as input in bash script and then have to pass it to java program, but the problem is, anyone can see the username & password using ps -f, I read some post to read from stdin and pass which will be hidden from process table. Here is some code snippet I'm trying with: readSecrets() { read -p "Username: " username IFS= read -s -p "Password: " password echo if | -z "$password" ; then echo "!!Error!! Username and Password are mandatory." exit 0 fi } nohup java -jar $JAR_FILE START $username $password > logFile.log 2>&1 & How can I hide pass from ps command and send securily to java program ?
linked to: http://stackoverflow.com/q/6607675
duplicate of: http://stackoverflow.com/q/3830823

http://stackoverflow.com/comment/137810266
type: QuestionComment
comment on: http://stackoverflow.com/q/78169456
has text: BTW, `#!bin/bash` is wrong -- it should be `#!/bin/bash`.
type: Comment
score: 1

http://stackoverflow.com/a/78199112
downvote count: 2
answers question: http://stackoverflow.com/q/78199094
has body: A common workaround is to override your home folder only for the git command call duration, like follow: HOME= git {git-arguments} or HOME=/dev/null git {git-arguments}
has comment: http://stackoverflow.com/comment/137863404
upvote count: 3
has comment: http://stackoverflow.com/comment/137862436
score: 1
has comment: http://stackoverflow.com/comment/137867402
has comment: http://stackoverflow.com/comment/137863035
type: Answer
has comment: http://stackoverflow.com/comment/137867407

http://stackoverflow.com/comment/137958556
type: Comment
score: 0
type: QuestionComment
has text: Wrap it in `[]`'s (and no need for the last `| .`? `jq '[ .DailyForecasts[].Day.RainProbability ]'` or something along those lines
comment on: http://stackoverflow.com/q/78253195

http://stackoverflow.com/comment/138004857
type: Comment
comment on: http://stackoverflow.com/q/78278159
has text: The function is fragile, but it should work if you just do `printf "$ %s\n%s" "$cmd" "$output" | xclip ...`
type: QuestionComment
score: 0

http://stackoverflow.com/q/78218123
favorite count: 0
has comment: http://stackoverflow.com/comment/137897926
has comment: http://stackoverflow.com/comment/137896069
answer count: 1
tagged with: ubuntu
has answer: http://stackoverflow.com/a/78220931
has body: I have a symlink that points to a directory mounted via network file system like so: 2023 -&gt; /mnt/bulk013/obs_data_archive/metwatch/2023/ now I want to replace the symlink with the folder that it points to in a fashion that doesn't disturb a productive application that frequently reads from this directory (atomically). This meant in my case first copying all the data to my local harddrive (where the folder 2023 lives). I did so and used a temporary directory to store the files: 2023.tmp/ So now the question is, how can I atomically switch the symlink with the actual folder, so that the folder then has the name 2023? 2023 -&gt; /mnt/bulk013/obs_data_archive/metwatch/2023/ # remove this 2023.tmp/ # and replaced with this (renamed to 2023)
tagged with: ubuntu-20.04
has comment: http://stackoverflow.com/comment/137896031
has comment: http://stackoverflow.com/comment/137896156
has comment: http://stackoverflow.com/comment/137896039
score: 4
type: Question
upvote count: 4
tagged with: linux
downvote count: 0
type: UnansweredQuestion
has title: Atomically replace symlink with the folder it points to
tagged with: bash

git
tags question: http://stackoverflow.com/q/78181978
tag name: git
type: Tag
tags question: http://stackoverflow.com/q/78267465
tags question: http://stackoverflow.com/q/78199094
tags question: http://stackoverflow.com/q/78157184
tags question: http://stackoverflow.com/q/78244513
tags question: http://stackoverflow.com/q/78309717
tags question: http://stackoverflow.com/q/78361550
tags question: http://stackoverflow.com/q/78378370
tags question: http://stackoverflow.com/q/78419971
tags question: http://stackoverflow.com/q/78419810
tags question: http://stackoverflow.com/q/78308913
tags question: http://stackoverflow.com/q/78520208
tags question: http://stackoverflow.com/q/78581424
tags question: http://stackoverflow.com/q/78560700
tags question: http://stackoverflow.com/q/78539498
tags question: http://stackoverflow.com/q/78491259
tags question: http://stackoverflow.com/q/78511439
tags question: http://stackoverflow.com/q/78471612
tags question: http://stackoverflow.com/q/78513595
tags question: http://stackoverflow.com/q/78480751
tags question: http://stackoverflow.com/q/78714428
tags question: http://stackoverflow.com/q/78590826
tags question: http://stackoverflow.com/q/78898168
tags question: http://stackoverflow.com/q/78760700
tags question: http://stackoverflow.com/q/78767438
tags question: http://stackoverflow.com/q/78758499
tags question: http://stackoverflow.com/q/78760813
tags question: http://stackoverflow.com/q/78967238
tags question: http://stackoverflow.com/q/78954119
tags question: http://stackoverflow.com/q/78994752
tags question: http://stackoverflow.com/q/79148342
tags question: http://stackoverflow.com/q/79116998
tags question: http://stackoverflow.com/q/79120307
tags question: http://stackoverflow.com/q/79153518
tags question: http://stackoverflow.com/q/79138869
tags question: http://stackoverflow.com/q/79160533
tags question: http://stackoverflow.com/q/79119057
tags question: http://stackoverflow.com/q/79126424
tags question: http://stackoverflow.com/q/79412418
tags question: http://stackoverflow.com/q/79414858
tags question: http://stackoverflow.com/q/79405445
tags question: http://stackoverflow.com/q/79394505
tags question: http://stackoverflow.com/q/79539054
tags question: http://stackoverflow.com/q/79460476
tags question: http://stackoverflow.com/q/79472702
tags question: http://stackoverflow.com/q/79478210
tags question: http://stackoverflow.com/q/79530394
tags question: http://stackoverflow.com/q/79475480
tags question: http://stackoverflow.com/q/79434419

gnuplot
tags question: http://stackoverflow.com/q/78301325
type: Tag
tag name: gnuplot
tags question: http://stackoverflow.com/q/78770582

arguments
type: Tag
tags question: http://stackoverflow.com/q/78195964
tag name: arguments
tags question: http://stackoverflow.com/q/78562095
tags question: http://stackoverflow.com/q/78581887
tags question: http://stackoverflow.com/q/78893675
tags question: http://stackoverflow.com/q/78938442
tags question: http://stackoverflow.com/q/78946361
tags question: http://stackoverflow.com/q/79050654
tags question: http://stackoverflow.com/q/79106158

http://stackoverflow.com/a/78178190
has comment: http://stackoverflow.com/comment/137825267
score: 3
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/137825227
has body: This is what the manual says: PIPESTATUS An array variable containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command). The contents of PIPESTATUS change after every pipeline. echo "${PIPESTATUS[0]}" is a pipeline too, so PIPESTATUS is populated with its exit status before echo "${PIPESTATUS[1]}" is executed. But since the previous pipeline contains only one command, PIPESTATUS[1] is rendered empty, hence the empty output. You're looking for something like this: echo "hello" | wc -w status=("${PIPESTATUS[@]}") echo "${status[0]}" echo "${status[1]}"
answers question: http://stackoverflow.com/q/78178153
downvote count: 0
has comment: http://stackoverflow.com/comment/137825307
accepted answer of: http://stackoverflow.com/q/78178153
type: Answer

http://stackoverflow.com/comment/138035507
score: 0
has text: I can't add "extra space" because it is an variable passed to other script. Any extra space will be treat as content.
type: QuestionComment
comment on: http://stackoverflow.com/q/78297320
type: Comment

usb
type: Tag
tags question: http://stackoverflow.com/q/78252038
tags question: http://stackoverflow.com/q/78273096
tag name: usb

http://stackoverflow.com/q/78195172
tagged with: bash
has comment: http://stackoverflow.com/comment/137855569
favorite count: 0
downvote count: 1
has answer: http://stackoverflow.com/a/78199516
has comment: http://stackoverflow.com/comment/137855547
tagged with: sh
has comment: http://stackoverflow.com/comment/137855630
has comment: http://stackoverflow.com/comment/137855730
type: Question
upvote count: 0
has title: BASH - Read - How to require [enter] to complete input? Example [y] + [enter]
has comment: http://stackoverflow.com/comment/137863337
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/226703
has comment: http://stackoverflow.com/comment/137855575
has body: I haven't been able to find an answer to this online, or in the read manual. I have a simple Yes / No prompt, that accepts y or n. I'm trying to have it require enter (specifically) to be pressed, after typing y, or n. Example: $ Do you want to continue? _ y + enter $ Continuing! Below is the code I have currently: while true; do read -n 1 -r -p "Continue (y/n):" yn case $yn in [yY] ) echo "Yes - Continuing..." break;; [nN] ) echo "No - Exiting..." exit;; * ) echo "Invalid response!";; esac done I've tried setting -n 2 which "sort of" works, as it requires 2 keys to be pressed, however, if I type y, then change my mind and hit backspace, it will sill proceed and continue. Same thing if I "fat finger" things... like bn or ty will continue, since there's an n or a y in the response. How can I require 2 keys to be pressed, one being y or Y and the enter key specifically, ignoring any other combination? [Edit] Setting -n 2 and requiring [yY]'' ) seems to work, but it still falls back to "Invalid Input" if I try y + backspace. Not sure how I can ignore the backspace key being counted as an "input".
answer count: 1
tagged with: prompt
has comment: http://stackoverflow.com/comment/137855837
has comment: http://stackoverflow.com/comment/137855617
has comment: http://stackoverflow.com/comment/137855591
has comment: http://stackoverflow.com/comment/137855649
has comment: http://stackoverflow.com/comment/137855603
score: -1
has comment: http://stackoverflow.com/comment/137855566

http://stackoverflow.com/comment/138131429
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78277187
has text: Yes, i have tried but it didn't work

http://stackoverflow.com/comment/137865928
type: Comment
comment on: http://stackoverflow.com/q/78196374
score: 1
has text: Question has been cleaned, and information has been understood. Thank you again for your help and clarifications Ed!
type: QuestionComment

http://stackoverflow.com/comment/137855952
type: Comment
comment on: http://stackoverflow.com/q/78194973
score: 0
has text: I'd suggest running `bash -x yourscript` to enable trace logging so you can see what it's actually doing during execution.
type: QuestionComment

http://stackoverflow.com/comment/137818501
has text: Glad you got it sorted. To emphasize never using `ls`, see [Bash Pitfalls #1](https://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29) -- there is a reason that's `#1`. For full discussion, see also [Parsing `ls`](https://mywiki.wooledge.org/ParsingLs)
comment on: http://stackoverflow.com/a/78174152
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78245356
downvote count: 0
answers question: http://stackoverflow.com/q/78244513
type: Answer
has body: If you are running Bash 4.3 or later then this should work: shopt -s dotglob globstar git add **/[Ll]ivewire/*[Ss]tring1*.php shopt -s ... enables some Bash settings that are required by the command: dotglob enables globs to match files and directories that begin with .. find processes such files by default. globstar enables the use of ** to match paths recursively through directory trees. This option was introduced with Bash 4.0 (released in 2009) but it is dangerous to use in versions before 4.3 (released in 2014) because it follows symlinks. See the globstar section in glob - Greg's Wiki.
score: 4
upvote count: 4

http://stackoverflow.com/comment/137993787
score: 0
has text: `export` is often misunderstood and abused, and seems to have no bearing at all on this question. Perhaps deleting the `export`s from the input file would simplify things.
type: QuestionComment
comment on: http://stackoverflow.com/q/78272610
type: Comment

http://stackoverflow.com/comment/137902350
has text: Could you make a [mcve] including sample json files? Is this about the aws up/downloading or the json comparison? Whatever it is, leave the other part out. Also, what happens when you run your code and what did you expect to happen instead? Have you tried something like `diff <(jq --sort-keys . A.json) <(jq --sort-keys . B.json)` to compare JSON documents?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78221337
type: Comment

http://stackoverflow.com/comment/137830232
comment on: http://stackoverflow.com/q/78180816
type: Comment
has text: Unrelated, you should probably try to move on from Python 3.7 sooner rather than later. It's been out of support for about 6 months now, and even 3.8 only has about 6 months of support left.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137926834
comment on: http://stackoverflow.com/q/78235101
score: 0
type: QuestionComment
type: Comment
has text: what is your definition of "the first element"? consider `unset v; v+=(1); v+=(2); unset v[0]`

http://stackoverflow.com/comment/137949724
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78248223
type: Comment
has text: Can you explain why you want to do this? If someone has access to running `docker exec` then they probably also have access to `docker run`. And if they have that, it's trivial to gain root on the host. So trying to prevent them from running `kill` inside the container doesn't seem relevant.

http://stackoverflow.com/comment/137854742
type: QuestionComment
has text: Does the source command create a new process and a stack? Isn't it executing commands in the current process? @Charles Duffy
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78194467

http://stackoverflow.com/comment/138371160
score: 1
has text: ah, glad you solved for it. these frontend frameworks often have little hidden tricks/patterns like this.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78253546

http://stackoverflow.com/comment/137992273
score: 0
has text: So save the value of SOME_VAR, or save it is unset, and then restore. What have you tried?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78272610

http://stackoverflow.com/comment/137926865
has text: Thx @jhnc good to know about your first comment, I’d have thought it assumes an associative array then… I know for the default scope but what if I need to change it (declare a global variable from within a function)? Wouldn’t be an issue if the declare/local keyword is re-used for every element added?
type: Comment
comment on: http://stackoverflow.com/q/78235101
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137799321
type: QuestionComment
score: 0
type: Comment
has text: @bgorton Add the `-r` option like tink said
comment on: http://stackoverflow.com/q/78163062

http://stackoverflow.com/comment/137781029
type: QuestionComment
has text: Setting such a variable in front of a command sets the value for the environment of the command. You can verify it with `foo=bar printenv foo`. In your case, you want to set the variable in the current shell. Hence they must be set in a separate statement (`foo=bar; echo $foo`)
comment on: http://stackoverflow.com/q/78148102
type: Comment
score: 1

http://stackoverflow.com/comment/137908022
type: QuestionComment
has text: I am pretty sure it is not necessary to have *all* that code in the example. I suggest a round of [machete debugging](https://rootdirectory.de/doku.php?id=software:machetedebugging) to come up with a [mcve]...
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78224799

http://stackoverflow.com/comment/137956965
type: Comment
has text: Although some believe that using `set -euo pipefail` is a "best practice", there are in fact many problems and pitfalls associated with it, and it often leads to subtle problems that can be difficult to debug, even for experienced and knowledgeable shell programmers. See [Bash Pitfalls #60 (set -euo pipefail)](https://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail) and [BashFAQ/105 (Why doesn't set -e (or set -o errexit, or trap ERR) do what I expected?)](https://mywiki.wooledge.org/BashFAQ/105).
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/78252458

http://stackoverflow.com/comment/138004065
type: AnswerComment
score: 0
has text: Also does not work. It is missing the command.
comment on: http://stackoverflow.com/a/78278695
type: Comment

http://stackoverflow.com/q/78146724
favorite count: 0
has comment: http://stackoverflow.com/comment/137770156
has comment: http://stackoverflow.com/comment/137769823
has title: Why does the for loop in this shell script perform the first iteration twice before doing the second one?
answer count: 2
downvote count: 2
has comment: http://stackoverflow.com/comment/137780673
has comment: http://stackoverflow.com/comment/137770817
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137778275
has comment: http://stackoverflow.com/comment/137780727
tagged with: unix
tagged with: windows-subsystem-for-linux
score: -2
has answer: http://stackoverflow.com/a/78151323
accepted answer: http://stackoverflow.com/a/78147099
has comment: http://stackoverflow.com/comment/137771378
has comment: http://stackoverflow.com/comment/137778286
possible better answer: http://stackoverflow.com/a/78151323
upvote count: 0
tagged with: shell
has answer: http://stackoverflow.com/a/78147099
tagged with: ubuntu
has body: I have a bash script: #! usr/bin/env bash # test bash script to call python scripts cd ~/python for ((i = 1; i &lt;= 2; i++)); do python3 test_0$i.py; done cd ~/bash that pulls test_0x.py files from the python directory and runs them in order. test_01.py is a single print statement, whereas test_02 is a for loop. I was expecting it to: navigate to ~/python run test_01.py run test_02.py navigate back to ~/bash the bash script runs test_01.py, then test_01.py again, and only then test_02.py. is this some quirk of shell-scripts i am simply too green to anticipate, or is there something wrong with my — albeit very basic — code? I am using an ubuntu terminal through windows subsystem for linux, if that affects things.
tagged with: bash

http://stackoverflow.com/comment/137835054
type: Comment
comment on: http://stackoverflow.com/q/78178090
has text: I feel it has to do something when I run the script in the background `&` is causing this strange behavior.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137789931
has text: @Schwern, I was only after current but deleted doesn't hurt.
score: 0
comment on: http://stackoverflow.com/q/78157184
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137897926
has text: Oh, I had mistakenly thought `ln -sf` would be atomic, but creating a second symlink and using `mv -T` seems to be the only option
score: 1
comment on: http://stackoverflow.com/q/78218123
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138038059
score: 1
type: QuestionComment
has text: On Linux, the easy way to test whether it's getting the variable and ignoring it, vs not getting the variable at all, is to find the PID of one of these processes and run and `tr '\0' '\n' </proc/PID/environ | grep -e PGPASSWORD`, replacing the string PID with the actual number. If it shows up there, it's not bash's problem but instead is an issue with cjdb or martin (neither of which I've heard of before despite working in several Postgres shops) and is something you should bring to their authors.
type: Comment
comment on: http://stackoverflow.com/q/78298036

http://stackoverflow.com/a/78244642
type: Answer
answers question: http://stackoverflow.com/q/78244513
has body: You can use find to locate the desired files: $ find . -path '*/[Ll]ivewire/*' -name '*[Ss]tring1*' ./app/Livewire/String1s.php ./app/Livewire/EditString1.php ./app/Livewire/String1Table.php ./resources/views/livewire/string1-table.blade.php ./resources/views/livewire/edit-string1.blade.php ./resources/views/livewire/string1s.blade.php Once you have a find command that matches the desired files, you can run git add on each file by passing an -exec option: $ find . -path '*/[Ll]ivewire/*' -name '*[Ss]tring1*' -exec git add '{}' + $ git status -s A app/Livewire/EditString1.php A app/Livewire/String1Table.php A app/Livewire/String1s.php A resources/views/livewire/edit-string1.blade.php A resources/views/livewire/string1-table.blade.php A resources/views/livewire/string1s.blade.php ?? app/Models/
type: AcceptedAnswer
score: 2
accepted answer of: http://stackoverflow.com/q/78244513
has comment: http://stackoverflow.com/comment/137943464
upvote count: 2
downvote count: 0

http://stackoverflow.com/q/78297014
has answer: http://stackoverflow.com/a/78297142
has answer: http://stackoverflow.com/a/78298442
has answer: http://stackoverflow.com/a/78301072
type: Question
has title: How to convert initial timestamp of each line
tagged with: linux
has answer: http://stackoverflow.com/a/78297254
type: UnansweredQuestion
score: 1
has answer: http://stackoverflow.com/a/78298917
upvote count: 1
downvote count: 0
tagged with: bash
has body: Trying to convert initial timetsamp of each line of a log file as follows $ cat test.log [Tue Apr 9 03:32:21 2024] {cmd1} [Tue Apr 9 03:33:42 2024] {cmd2} [Tue Apr 9 03:35:51 2024] {cmd3} $ $ cat test.log | < How ?? > 2024-04-09 03:32:21 cmd1 2024-04-09 03:33:42 cmd2 2024-04-09 03:33:42 cmd3 $ Attempted these options, but no luck $ cat test.log [Tue Apr 9 03:32:21 2024] {cmd1} [Tue Apr 9 03:33:42 2024] {cmd2} [Tue Apr 9 03:35:51 2024] {cmd3} $ $ cat test.log | awk -F"[][{}]" '{print $2" "$4}' Tue Apr 9 03:32:21 2024 cmd1 Tue Apr 9 03:33:42 2024 cmd2 Tue Apr 9 03:35:51 2024 cmd3 $ $ cat test.log | awk -F"[][{}]" '{print strftime("%F %T", $2)" "$4}' 1970-01-01 00:00:00 cmd1 1970-01-01 00:00:00 cmd2 1970-01-01 00:00:00 cmd3 $ strftime() function returning start of epoch time $ date -d "Tue Apr 9 03:32:21 2024" +"%s" 1712633541 $ $ echo 1712633541 | awk '{print strftime("%F %T", $0)}' 2024-04-09 03:32:21 $ Also tried system() function $ echo "Tue Apr 9 03:32:21 2024" | awk '{print strftime("%F %T", system("date -d \"$0\" +\"\%s\""))}' awk: cmd. line:1: warning: escape sequence `\%' treated as plain `%' date: invalid date 'sh' 1970-01-01 00:00:01 $
favorite count: 0
answer count: 6
tagged with: awk
has answer: http://stackoverflow.com/a/78312608

http://stackoverflow.com/comment/137771469
type: QuestionComment
has text: Then you obviously have to fix your [PATH](https://linuxconfig.org/linux-path-environment-variable)....
type: Comment
comment on: http://stackoverflow.com/q/78147406
score: 1

http://stackoverflow.com/q/78290118
has comment: http://stackoverflow.com/comment/138034690
has answer: http://stackoverflow.com/a/78308378
has comment: http://stackoverflow.com/comment/138034687
score: -1
type: Question
tagged with: systemctl
upvote count: 0
tagged with: ubuntu
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138023062
answer count: 1
has comment: http://stackoverflow.com/comment/138055358
favorite count: 0
downvote count: 1
tagged with: systemd
has title: sudo systemctl daemon-reload not working through ssh command
tagged with: ssh
tagged with: bash
has comment: http://stackoverflow.com/comment/138039506
has body: After modifying systemctl myService.service file, when command "sudo systemctl daemon-reload" is executed remotely via SSH through a bash sh script: The myService.service file is modified correctly in remote server But nothing happens with daemon reloading, changes are not reloaded in the remote server system. Sample of bash sh script section: ssh -i "/myssh.key" myuser@host "sudo bash 'echo -e \"ExecStart=/mydir/run-service.sh\" >> /etc/systemd/system/myService.service'" ssh -i "/myssh.key" myuser@host "sudo systemctl daemon-reload" Service file is modified correctly on remote server, but it seems daemon reload command has no effect on remote server. However, after executing the above script, invoking "sudo systemctl daemon-reload" manually via ssh terminal session, changes are reloaded properly. Putting the two commands separated by ; in the same ssh call don't solve the problem. Server: Ubuntu 22.04.4 Remote client (running the sh script): Windows WSL2 Containers: no

http://stackoverflow.com/comment/138058629
comment on: http://stackoverflow.com/q/78305587
score: 1
has text: The shell function you are trying to use is just parsing some json. Surely it would take less time to do that in python than the time you've already spent trying to invoke it in a shell! You might just want to invest some time figuring out how your original environment is defining the functions (eg, are definitions sourced from some system level file that is sourced in an interactive startup file) and define them similarly. (eg, write your own shell wrappers intended for non-interactive use that source the same definitions.). But it's almost certainly better to port to Python.
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78180985
has body: Error has been found - Conda nmrfilter environment installs Python 3.7, so when it is creating the virtual environment from requirements.txt, numpy=1.24 is unavailable since it requires Python &gt;=3.8, therefore creating the error.
type: Answer
answers question: http://stackoverflow.com/q/78180816
score: 0

http://stackoverflow.com/comment/137855900
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
has text: (and once you've built an array that way, it's `for interface in "${interfaces[@]}"; do` to iterate over it, as the FAQ entry linked above states)
type: Comment

http://stackoverflow.com/comment/137866576
has text: @EdMorton meh, I meant `\`basename\`` and have had the backticks ingrained into me.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78200064
score: 0

http://stackoverflow.com/comment/137958376
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78253195
has text: Can you include the original JSON?

http://stackoverflow.com/comment/137852527
has text: Ok, that may be fine, but note that the row data (foo, bar, whatever) is collected from a while loop with IFS that goes through a file and pulls the values from there.
score: 0
comment on: http://stackoverflow.com/a/78193436
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78226551
has answer: http://stackoverflow.com/a/78230530
has comment: http://stackoverflow.com/comment/137920165
accepted answer: http://stackoverflow.com/a/78230530
tagged with: jenkins
has comment: http://stackoverflow.com/comment/137921646
has comment: http://stackoverflow.com/comment/137914606
tagged with: bash
tagged with: artifactory
answer count: 1
has comment: http://stackoverflow.com/comment/137961518
has title: How to list all folders with more then 10 artifacts in artifactory repo using CURL?
type: AnsweredQuestion
has body: I have an artifactory issue. I need to implement a retention policy, to keep just 10 artifacts per folder. and I need help with that. This is my initial curl command, to get all folders with the count > 10, execute_aql() { # Execute AQL query to find folders with more than 10 artifacts curl_response=$(curl -s -u "admin:$API_KEY" -X POST "$ARTIFACTORY_URL/artifactory/api/search/aql" -H "Content-Type: text/plain" -d 'items.find({"type": "folder", "repo": "'"$REPO_NAME"'"}).include("name","children.items.name","children.items.@count").filter(function(item){ return item.children.items.@count > 10 })') # Print the response echo "$curl_response" } but it isnt working as expected, in fact it fails: + ./retPolicy.sh Failed to parse query: items.find({"type": "folder", "repo": "HLRP_GENERIC_DEV"}).include("name","children.items.name","children.items.@count").filter(function(item){ return item.children.items.@count > 10 }), it looks like there is syntax error near the following sub-query: children.items.name","children.items.@count").filter(function(item){ return item.children.items.@count > 10 }) And I dont know why! I wanted to add a sort algorithm on top of it, to sort by time, and delete the oldest artifacts, but I didnt come that far! Hopefully you guys can help me out! Thanks for reading this!
tagged with: curl
score: 0
type: Question

http://stackoverflow.com/q/78261118
tagged with: canvas
accepted answer: http://stackoverflow.com/a/78264387
score: 0
type: Question
tagged with: netpbm
has answer: http://stackoverflow.com/a/78264387
tagged with: alpha-transparency
has comment: http://stackoverflow.com/comment/137975641
tagged with: compositing
has body: As stated in the title, I need to know how to achieve this, which is ImageMagick, using the Netpbm programs suite (use of bash/CLI assumed): convert -size 4800x3450 xc:transparent background.png; convert background.png overlay_image.pnm -geometry +469+499 -composite png:- | img2pdf - | pdftk - multibackground another_image.pdf output def_image.pdf One liner code provided to give context. I only need the convert part. Another way to state the problem having the Gimp in mind could be: how to put an image (import image as a layer) over a (transparent) canvas and save the whole thing without flattening it, that is, keeping the transparency of the background/canvas. Feel free to elaborate thoroughly what's going on with channels, transparencies, etc. (and also even with more basic image processing concepts). I'm a newbie on this and I'm speaking only from the point of view of what I want, not from what I should know. Thank you in advance. (The Netpbm suite documentation is very stingy in examples for the newbie. After many unsuccessful tries, probably the best chance to know what's going on is to provide the ImageMagick example and see how it translates to the Netpbm suite.)
tagged with: bash
answer count: 1
type: AnsweredQuestion
has title: Netpbm: generating a transparent background image/file to put another one on to it at specific coordinates

http://stackoverflow.com/comment/138005566
has text: I python , open both files, loop over the first , read the first character , then, in the same loop, loop over the second file and read the first character, if the 2 characters are equal use the operator `+` to append the strings and write the line in a new file
comment on: http://stackoverflow.com/q/78280175
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/137882956
comment on: http://stackoverflow.com/q/78210405
score: 1
has text: `echo $x` is broken. (In fact, unquoted `$x` is usually broken.) `echo "$x"` is better, but still broken because of peculiarities of the `echo` command. `printf '%s\n' "$x"` is good. See the accepted, and excellent, answer to [Why is printf better than echo?](https://unix.stackexchange.com/q/65803/264812).
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137866744
score: 0
has text: @CharlesDuffy getent group works. When i enter it in terminal i take computers name, which joined in that group.
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78176733
answers question: http://stackoverflow.com/q/78176143
has body: This may be what you need, using any POSIX awk, but without more truly representative sample input and expected output it's just a partially tested guess: $ awk ' { gsub(/^[[:space:]]+|"?[[:space:]]*,?[[:space:]]*$/,"") sub(/[[:space:]]*=[[:space:]]*"?/,"=") tag = val = $0 sub(/=.*/,"",tag) sub(/[^=]+=/,"",val) } tag == "appid" { print val } ' file myapp Don't set FS to = and then try to use $1 and/or $2 as that'll make it harder to do this job robustly and handle input like: appid="foo=bar" Similarly for other characters. Instead use the approach I show above to first remove extraneous spaces and other chars from the start/end of the line and around the first = and then use sub()s to separate the string before the first = on each line (the tag/name) such as appid from the string after it (the value) such as foo=bar.
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/137822933
has comment: http://stackoverflow.com/comment/137822844
type: Answer
upvote count: 2

http://stackoverflow.com/comment/137826134
comment on: http://stackoverflow.com/q/78178702
score: 0
has text: As per @Biffen's remark, you can use `set -o xtrace` to have commands echoed to STDOUT as they are being executed.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137824896
type: QuestionComment
has text: sh is bash on macOS. Run your script with zsh
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78178090

http://stackoverflow.com/q/78202789
has title: in K8s run python script to go into pod directly
has comment: http://stackoverflow.com/comment/137870407
upvote count: 0
tagged with: shell
has answer: http://stackoverflow.com/a/78202886
tagged with: kubernetes
answer count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137873434
accepted answer: http://stackoverflow.com/a/78202886
has comment: http://stackoverflow.com/comment/137873425
tagged with: python-3.x
score: -1
has body: The following command can run in K8s correctly kubectl exec -n nginx-ingress $(kubectl get pods -n nginx-ingress -o wide -LhaRole | grep nginx-ingress | grep Running | awk '{print $1}') -it -- /bin/bash if I put it into a python script as follows, #!/usr/bin/python import subprocess subprocess.run('kubectl exec -n nginx-ingress $(kubectl get pods -n nginx-ingress -o wide -LhaRole | grep nginx-ingress | grep Running | awk '{print $1}') -it -- /bin/bash', shell=True) the result shows SyntaxError: invalid syntax. Can anyone help me to correct it and let it run? Thanks a lot in advance. [root@k8s-master temp]# kubectl exec -n nginx-ingress $(kubectl get pods -n nginx-ingress -o wide -LhaRole | grep nginx-ingress | grep Running | awk '{print $1}') -it -- /bin/bash nginx@nginx-ingress-b9fcfbb59-cn647:/$ nginx@nginx-ingress-b9fcfbb59-cn647:/$ exit exit [root@k8s-master temp]# [root@k8s-master temp]# ./k8s.py File "/home/jin/temp/./k8s.py", line 9 subprocess.run('kubectl exec -n nginx-ingress $(kubectl get pods -n nginx-ingress -o wide -LhaRole | grep nginx-ingress | grep Running | awk '{print $1}') -it -- /bin/bash', shell=True) ^ SyntaxError: invalid syntax [root@k8s-master temp]# [root@k8s-master temp]#
tagged with: bash
type: Question
downvote count: 1

http://stackoverflow.com/comment/137891567
comment on: http://stackoverflow.com/q/78215669
type: Comment
has text: ...which is to say, you aren't showing enough code here to reproduce the problem; if you run the code given in this question starting with both stdout and stderr pointing to the same descriptor, this code _will_ have robustly reliable behavior.
score: 1
type: QuestionComment

http://stackoverflow.com/q/78157839
has answer: http://stackoverflow.com/a/78158742
has title: how to run a bash script (with parameters) in gitlab ci?
has answer: http://stackoverflow.com/a/78160457
type: Question
upvote count: 2
has body: I have a scripts repo, which have few scripts among which I have a build.sh file that I want to run when GitLab CI runs. Can I simply add that to my GitLab CI file under scripts section? Which I am assuming it will run the script file. Is there a way I can add and pass variables from my GitLab CI file/environment to the hello.sh file? My project: rootdir - folder1 - scripts - hello.sh hello.sh: #!/usr/bin/env bash echo "Hello World!" GitLab CI: image: docker:latest stages: - build build: stage: build script: - ./scripts/hello.sh
tagged with: cicd
downvote count: 0
accepted answer: http://stackoverflow.com/a/78160457
tagged with: bash
has answer: http://stackoverflow.com/a/78159746
answer count: 3
favorite count: 0
score: 2
possible better answer: http://stackoverflow.com/a/78159746
tagged with: gitlab
tagged with: docker
type: AnsweredQuestion

http://stackoverflow.com/comment/138037250
type: Comment
comment on: http://stackoverflow.com/q/78292693
has text: @Barmar I don't know why `$combine` is an array I was learning how arrays work in bash and found a solution to get the data (dates with existing videos) the next step would be to find a way of adding the correct videos to each html file I am learning bash and hacking together something that "works" at the same time. As it seems you have a solution you could add that as an answer as apposed to adding it as a comment and include a better solution for `$combine`
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138193462
score: 0
has text: (BTW, tag `sh` _or_ `bash`, not both at once -- and with a script starting with `#!/bin/bash`, the tag should only be bash)
comment on: http://stackoverflow.com/q/78253800
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78148060
score: 3
has comment: http://stackoverflow.com/comment/137772908
type: AcceptedAnswer
has body: Preliminary: All of the following assumes that the data are presented one item per line, without embedded newlines, and that all characters between newlines are significant. I'm trying to use commands sed or awk, together with arbitrary functions (or commands) defined, for example, as Bash scripts. That's awkward, no pun intended. What you describe is better suited to the shell, as was described in comments. Alternatively, xargs is designed expressly for converting input into arguments of commands, as you want to do: xargs -d '\n' -n1 ./prepend_largest_prime.sh < input.txt If you must drive it via awk or sed then you do have options. POSIX does not define a means by which sed can execute external commands, but if you can rely on extensions provided by GNU sed then its e command could serve. You would edit the input line into the command you want to execute, then execute it with e: sed "s,^\(.*\)\$,./prepend_largest_prime.sh '\1',; e" input.txt There are other ways to work the details, but that particular approach uses an s command to wrap the input line in single quotes and prepend the name of the command to execute. Note well that it will break if the input contains single quotes, though you could accommodate that with a bit more effort. The awk version is more standard and a bit easier to read, using its system() function, but the idea is largely the same. Edit each input line into the shell command you want to execute, and pass the result to system(): awk '{ system("./doit.sh '"'"'" $0 "'"'"'") }' < input.txt Like with the sed-based approach, you would need to do more work to accommodate inputs containing single-quote characters.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/137773000
accepted answer of: http://stackoverflow.com/q/78147701
upvote count: 3
has comment: http://stackoverflow.com/comment/137787675
answers question: http://stackoverflow.com/q/78147701

http://stackoverflow.com/comment/137914849
score: 0
has text: Thank you I was able to solve my problem by returning the input_fd in my redirection function , should I send my correction now?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78225807

http://stackoverflow.com/comment/137934599
comment on: http://stackoverflow.com/q/78239545
type: QuestionComment
type: Comment
has text: Look up tutorials on how to parse command-line arguments in Bash.
score: 0

http://stackoverflow.com/comment/137960443
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78254419
has text: I guess you can't reuse the same cmd, you need to kill old cmd and start a new process.
type: QuestionComment

http://stackoverflow.com/comment/137943362
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/78244372
has text: There's no way to do what you want automatically. The simple solution is to make a copy of `main.py` and run that, while you make changes to the original.

http://stackoverflow.com/comment/137974261
comment on: http://stackoverflow.com/q/78261786
has text: (btw, if you do this, and you're implementing it for more than just you, please make sure you use `isatty()` to disable this behavior if your program is logging to a FIFO or any other non-TTY destination; speaking as a user, applications that think they know better than I do whether and when I want to inspect log output are a peeve; applications mixing terminal control sequences into logs sent to disk, doubly so).
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/a/78186982
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/137843227
has comment: http://stackoverflow.com/comment/137843364
type: Answer
has body: What is it exactly? "$@" is a super very special POSIX (not Bash) hack that is handled super very special specially with super very special syntax as specified by the POSIX shell specification https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02 . Bash was improved a lot to replace legacy constructs like `` with more "clean" syntax like $() The $(...) notation was introduced by Ksh, not by Bash. why this aspect was not cleaned up to make bash syntax less tricky Portability. Bash keeps portability with POSIX. "$@" is very POSIX. According to wiki, introduced in SVR3 shell (1986). how (ba)sh works "under the hood" Bash works "under the hood" exactly the same way it is specified to. The "$@" is replaced by words of positional arguments, without running word splitting and filename expansion over those words and without joining those words. The source code is here https://github.com/bminor/bash/blob/f3b6bd19457e260b65d11f2712ec3da56cef463f/subst.c#L10993 and https://github.com/bminor/bash/blob/f3b6bd19457e260b65d11f2712ec3da56cef463f/subst.c#L10453 .
has comment: http://stackoverflow.com/comment/137842840
upvote count: 5
has comment: http://stackoverflow.com/comment/137840893
answers question: http://stackoverflow.com/q/78186259
has comment: http://stackoverflow.com/comment/137842923

http://stackoverflow.com/comment/138015001
score: 2
has text: There is no `scripts` *inside* `/opt/bitnami/airflow/scripts`. PYTHONPATH should contain `/opt/bitnami/airflow` in order to find `scripts`.
type: QuestionComment
comment on: http://stackoverflow.com/q/78285559
type: Comment

http://stackoverflow.com/q/78181450
tagged with: rtmp
has title: How to get frame number from FFMPEG RTSP stream
downvote count: 0
tagged with: bash
score: 1
tagged with: rtsp
tagged with: ffmpeg
type: Question
answer count: 0
has body: I'm trying to write a script to run and maintain my live stream to youtube. Once every few hours my ffmpeg output shows that every frame is the same, so stream is not working. I want to get frame number from ffmpeg output and compare it to next output. My output: frame=1903903 fps= 19 q=-1.0 size=50678531kB time=28:24:20.53 bitrate=4059.8kbits/s speed= 1xframe=1903915 fps= 19 q=-1.0 size=50678759kB time=28:24:21.03 bitrate=4059.8kbits/s speed= 1xframe=1903928 fps= 19 q=-1.0 size=50679013kB time=28:24:21.55 bitrate=4059.8kbits/s speed= 1xframe=1903941 fps= 19 q=-1.0 size=50679260kB time=28:24:22.05 bitrate=4059.8kbits/s speed= 1xframe=1903953 fps= 19 q=-1.0 size=50679474kB time=28:24:22.54 bitrate=4059.8kbits/s speed= 1xframe=1903966 fps= 19 q=-1.0 size=50679709kB time=28:24:23.06 bitrate=4059.8kbits/s speed= 1xframe=1903979 fps= 19 q=-1.0 size=50679959kB time=28:24:23.57 bitrate=4059.8kbits/s speed= 1x tail and head doesnt work since output is as i see in one big row. I don't need all this data and i think is it possible to show just one, latest ffmpeg stats. Then i could save it to file and grep frames from there. My ffmpeg: ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://192.168.51.93:554/Streaming/Channels/101 \ -tune zerolatency -pix_fmt + -c:v copy -strict experimental -f flv -flvflags no_duration_filesize \ rtmp://a.rtmp.youtube.com/live2/STREAM-KEY \ 2&gt;&amp;1 I tried tee tail -n 1 and a lot more that i find on the Internet.
type: UnansweredQuestion
tagged with: stream
upvote count: 1
favorite count: 0

http://stackoverflow.com/comment/137953435
comment on: http://stackoverflow.com/a/78241862
score: 0
type: Comment
type: AnswerComment
has text: Words of wisdom to live by. Thank you Ed! Funny how word-splitting gets sprinkled in in that case.

http://stackoverflow.com/comment/137855876
has text: I thought I gave you an actual command a few comments up; all you need to do is replace the `...` with the content of your loop (like `ip route add "$broadcast" dev "$interface" table vrack`).
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78194973

http://stackoverflow.com/a/78287570
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138118576
type: Answer
answers question: http://stackoverflow.com/q/78286060
has body: "it does no longer works" tells us nothing about the problem so it's hard to help you given that and no sample input/output with which we could reproduce the problem. Do divide-and-conquer on your large input that has the problem until you end up with a minimal version of it that still has the problem and then post a version of the input/output using that as your minimal reproducible example. Having said that, if you want to do this using bash and mandatory POSIX tools (i.e. no python, perl, ruby, etc.) then you wouldn't use a bash while-read loop as in your script at all, see why-is-using-a-shell-loop-to-process-text-considered-bad-practice, the bash part would just be to call a single awk script to do the rest, see whats-the-most-robust-way-to-efficiently-parse-csv-using-awk for how to parse CSV with awk in general but the following may be adequate for your needs given the sample input you provided, using any POSIX awk: $ cat tst.sh #!/usr/bin/env bash awk ' BEGIN { FS = OFS = "," } { sub(/\r$/,"") for ( i=1; i<=NF; i++ ) { gsub(/[[:space:]]+/," ",$i) gsub(/^ | $/,"",$i) } } NR == FNR { if ( NR > 1 ) { name2score[$1] = $2 } next } { sub(FS"$","") for ( i=1; i<=NF; i++ ) { printf "%s%s%d%s", $i, OFS, name2score[$i]+0, (i<NF ? OFS : ORS) } } ' 1.csv 2.csv $ ./tst.sh Alice,6,Bob,1 Michel,9 Joe,2,John,7 If you don't have a POSIX awk then change this: gsub(/[[:space:]]+/," ",$i) gsub(/^ | $/,"",$i) to this: gsub(/[ \t]+/," ",$i) sub(/^ /,"",$i); sub(/ $/,"",$i) and then it'll work in any awk if the only mid-line spaces in your input are blanks and tabs, which is probably the case.
upvote count: 2
accepted answer of: http://stackoverflow.com/q/78286060
type: AcceptedAnswer

http://stackoverflow.com/comment/138039373
type: AnswerComment
score: 0
has text: Yep, I installed Docker client into my application. Thank you
type: Comment
comment on: http://stackoverflow.com/a/78292830

http://stackoverflow.com/comment/137789935
comment on: http://stackoverflow.com/a/78157339
has text: I like it, but I might use `git log --pretty= --name-status | awk -F$'\t' '!seen[$2]++ && $1=="A" {print $2}'` for just the filenames.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/137864349
type: Comment
has text: @jared_mamrot As file names could contain other `R1` sub-strings, `"${file%R1.fastq}R2.fastq"` is maybe safer.
score: 1
comment on: http://stackoverflow.com/q/78199142
type: QuestionComment

http://stackoverflow.com/comment/137998617
has text: You have to find which parts of configure.ac are causing autotools to generate these erroneous code and update them. Besides using `set -x/+x`, also use manual `echo`s to examine values of both iterator and non-iterator variables. E.g. `echo "ECHO: $ECHO"; echo "var: $var"`. You can also `echo` an `eval` command to see what exact command evaluates directly. For example, `eval "lt_$var=\\\"\$$var\\\""` is copied as `echo "lt_$var=\\\"\$$var\\\""`.
comment on: http://stackoverflow.com/q/78274675
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/137933324
type: QuestionComment
has text: xtrace is your friend (`bash -x scriptname`). Beyond that, you might consider using `strace -f` to get a low-level log of not just the script but what was done by the processes it started. Even just changing `eval` to `echo` would be a starting point, though. (Personally, I wouldn't ever use cPanel at all, but I'm a grumpy graybeard who works in security).
type: Comment
comment on: http://stackoverflow.com/q/78239018
score: 1

http://stackoverflow.com/comment/137855909
score: 0
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment
has text: do you mean like this? it doesnt work? im getting even more confused interface=$(basename -a /sys/class/net/* | interface=${interface##*/}; interface = eth* || continue;)
type: Comment

http://stackoverflow.com/a/78220527
downvote count: 0
score: 1
type: Answer
has body: You need quotes around "$LINE". Always mind your quotes. awk is doing it right, but then you are throwing away the spaces. $ LINE=$(free -h | grep Mem | awk '{printf "%-10s %-10s %-10s\n",$2,$3,$4}') $ echo $LINE 7.6G 2.0G 3.4G $ echo "$LINE" 7.6G 2.0G 3.4G (I edited in your memory values from above.) What are you doing with $LINE? If you are literally just doing that printf then why bother with all the trouble? Just use the command as you showed it... except, don't. Try to never use multiple regex engines in a single command. Why waste the system resources on a grep just to pass the result to awk when awk can already handle that? $ free -h | awk '/^Mem:/{printf "%-10s%-10s%-10slala\n", $2, $3, $4}' 15G 1.4G 214M lala Passing the result back to a variable (which you shouldn't generally capitalize, btw) just to pretty-print it out isn't needed unless you are changing the formatting. If you need those values for other things later, save them and format-print them separately. $ read -r _ totmem usemem fremem _ < <( free -h | grep ^Mem: ) $ printf "total: %-10s used: %-10s free: %s\n" "$totmem" "$usemem" "$fremem" total: 15G used: 1.4G free: 203M or $ read -ra freemem < <( free -m | awk '/^Mem:/{print $2, $3, $4}' ) $ (( ${#freemem[2]}<4 )) && printf "total : %10s\nused : %10s\nfree : %10s\n" "${freemem[@]}" total : 15885 used : 1434 free : 225 or even $ freemem=( $(free -h) ); printf "%-10s" "${freemem[@]:7:3}"; echo lala 15G 1.4G 217M lala which probably uses built-in versions of both printf and echo, so only spawns one subshell for free. I didn't downvote because it can be hard to figure out how to phrase your search on things like this, but I highly recommend reading the documentation and keeping in mind that whitespaces are metacharacters that must be handled accordingly.
answers question: http://stackoverflow.com/q/78219094
upvote count: 1
has comment: http://stackoverflow.com/comment/137900448
has comment: http://stackoverflow.com/comment/137905139

http://stackoverflow.com/comment/137855198
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78194973
has text: (`for interface in "${interfaces[@]}"; do` or even just `for interface in /sys/class/net/*; do interface=${interface##*/}; ip route add "$broadcast" dev "$interface" table vrack; ip route add default via "$gateway" dev "$interface" table vrack; done` as an extended example -- don't need an array when you can loop directly over the glob results)
score: 1

http://stackoverflow.com/q/78148102
has comment: http://stackoverflow.com/comment/137781029
score: 1
downvote count: 0
favorite count: 0
has body: The command below repeats the word "stage" three times. Is there a way to set a variable at the beginning of the command and then use it further on? AWS_REGION="us-west-2" AWS_PROFILE="stage" mvn clean test -Dtest=KarateRunner#stage -DargLine="-Dkarate.env=stage" Something like: set env=stage && AWS_REGION="us-west-2" AWS_PROFILE="%env%" mvn clean test -Dtest=KarateRunner#%env% -DargLine="-Dkarate.env=%env%" But this doesn't work, obviously.
answer count: 2
possible better answer: http://stackoverflow.com/a/78148131
tagged with: bash
accepted answer: http://stackoverflow.com/a/78148123
has title: Using Inline variables in command line commands
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78148131
upvote count: 1
has answer: http://stackoverflow.com/a/78148123
has comment: http://stackoverflow.com/comment/137772406
type: Question
has comment: http://stackoverflow.com/comment/137773151
tagged with: shell

http://stackoverflow.com/comment/137880529
comment on: http://stackoverflow.com/q/78203871
type: QuestionComment
has text: Running it as `( ./example )` does not work.
type: Comment
score: 0

macos
tags question: http://stackoverflow.com/q/78251094
type: Tag
tags question: http://stackoverflow.com/q/78199979
tag name: macos
tags question: http://stackoverflow.com/q/78274299
tags question: http://stackoverflow.com/q/78210405
tags question: http://stackoverflow.com/q/78402822
tags question: http://stackoverflow.com/q/78399997
tags question: http://stackoverflow.com/q/78388693
tags question: http://stackoverflow.com/q/78427118
tags question: http://stackoverflow.com/q/78422019
tags question: http://stackoverflow.com/q/78319248
tags question: http://stackoverflow.com/q/78316829
tags question: http://stackoverflow.com/q/78324472
tags question: http://stackoverflow.com/q/78576313
tags question: http://stackoverflow.com/q/78503442
tags question: http://stackoverflow.com/q/78469768
tags question: http://stackoverflow.com/q/78644539
tags question: http://stackoverflow.com/q/78636137
tags question: http://stackoverflow.com/q/78658379
tags question: http://stackoverflow.com/q/78752438
tags question: http://stackoverflow.com/q/79008264
tags question: http://stackoverflow.com/q/79020384
tags question: http://stackoverflow.com/q/78998999
tags question: http://stackoverflow.com/q/78944308
tags question: http://stackoverflow.com/q/79155048
tags question: http://stackoverflow.com/q/79203139
tags question: http://stackoverflow.com/q/79347439
tags question: http://stackoverflow.com/q/79404066
tags question: http://stackoverflow.com/q/79347119
tags question: http://stackoverflow.com/q/79403981
tags question: http://stackoverflow.com/q/79384572
tags question: http://stackoverflow.com/q/79542291
tags question: http://stackoverflow.com/q/79537887
tags question: http://stackoverflow.com/q/79519858
tags question: http://stackoverflow.com/q/79528846
tags question: http://stackoverflow.com/q/79524263

http://stackoverflow.com/comment/137973422
has text: fwiw, when I run your script against the sample data I get a different set of output ... you show a single line of output while on my system I get 4 lines of output: `>Cluster 202` / `1 1867aa, >CAD5122865.1... at 100.00%` / `>Cluster 202` / `2 2369aa, >CAD5122866.1... at 100.00%`; at this point I'm assuming you've cut-n-pasted a mismatched set of code and (wrong) output ... ?
comment on: http://stackoverflow.com/q/78261247
score: 0
type: QuestionComment
type: Comment

tox
tags question: http://stackoverflow.com/q/78188141
tag name: tox
type: Tag

http://stackoverflow.com/comment/137827432
score: 1
has text: If you think parallel threads might be the problem then run it single threaded to see if you still have the problem or not.
comment on: http://stackoverflow.com/q/78177875
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/138000178
comment on: http://stackoverflow.com/q/78274893
score: 1
type: QuestionComment
type: Comment
has text: @GordonDavisson It seems that the sed regex substitution result doesn't make awk cmd work when passing it as a value (I tried some last night, will read further when I get a chance). The solution provided by anuhava solved my problem. Anyway, thank you!

http://stackoverflow.com/a/78278662
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78276360
has body: This might work for you (GNU sed, paste &amp; sort): sed 's/ //g;s/././g' file | paste - file | sort | sed 's/.*\t//' Double the string on each line separating by a tab and reduce the first of these strings by removing any spaces and making the remaining characters uniform. Sort the resulting file and then remove the introduced first string and tab of each line. Another more complicated solution using the same ideas but in a single sed invocation: sed -E 's/.*/&amp;\t&amp;/;:a;s/ (.*\t)/\1/;s/[^.](.*\t)/.\1/;ta;H;$!d x;s/.//;s/.*/echo &quot;&amp;&quot;|sort/e;s/^.*\t//mg' file N.B. If you want a stable sort used sort -k1,1 -s.

http://stackoverflow.com/comment/138025279
type: QuestionComment
has text: What else can you tell us about that machine? Like, which operating system does it run? Do you have GNU date on it?
score: 0
comment on: http://stackoverflow.com/q/78290808
type: Comment

http://stackoverflow.com/comment/137882131
type: QuestionComment
comment on: http://stackoverflow.com/q/78210154
score: 0
type: Comment
has text: Also, there are so many other ways to read out the full command including its arguments, that even if you did manage to hide the password from `ps`'s output, it's still out there and visible. Therefore just avoid passing it as an argument.

http://stackoverflow.com/comment/137886464
has text: Does you posting this new question mean you got a solution to [your previous problem](https://stackoverflow.com/questions/78207181/am-reinstalling-flutter-and-i-cant-seem-to-run-it-with-path-variables-in-the)? If so you should post an answer to it there so others with the same problem in future can find it and benefit from it.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78211761
type: QuestionComment

http://stackoverflow.com/comment/137946057
comment on: http://stackoverflow.com/q/78245937
score: 0
has text: thanks! i guess `cat foo |` has been in my muscle memory for a while now. I didn't know it could have a stark difference
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78194502
accepted answer of: http://stackoverflow.com/q/78194467
has comment: http://stackoverflow.com/comment/137854780
has comment: http://stackoverflow.com/comment/137854448
has comment: http://stackoverflow.com/comment/137854446
has comment: http://stackoverflow.com/comment/137854341
score: 3
has comment: http://stackoverflow.com/comment/137854392
type: Answer
has comment: http://stackoverflow.com/comment/137857196
has comment: http://stackoverflow.com/comment/137854442
downvote count: 0
has comment: http://stackoverflow.com/comment/137854429
has comment: http://stackoverflow.com/comment/137854432
has body: You can use set to set the positional arguments. $ set -- Hello World $ echo $1 Hello $ echo $2 World In a sourced script: $ cat 3.sh echo $1 echo $2 set -- &quot;$@&quot; $ source 3.sh Hello World Hello World $ echo $1 Hello $ echo $2 World
answers question: http://stackoverflow.com/q/78194467
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/137854422

http://stackoverflow.com/comment/137816516
type: AnswerComment
has text: That works. Thank you. Why doesn't `echo "hello" | od -An -td1 -v -w1 | while read x; do printf "%c" $x; done` work?
comment on: http://stackoverflow.com/a/78173289
score: 0
type: Comment

http://stackoverflow.com/comment/137860965
type: Comment
comment on: http://stackoverflow.com/q/78197884
score: 0
type: QuestionComment
has text: Searching for my proposed phrasing I get https://unix.stackexchange.com/questions/227989/complete-view-of-where-the-path-variable-is-set-in-bash Does that help? Or Ubuntu-specific: https://stackoverflow.com/questions/37676849/where-is-path-variable-set-in-ubuntu

http://stackoverflow.com/comment/140050055
type: AnswerComment
comment on: http://stackoverflow.com/a/78171756
has text: But RUN is in the container; the substituted shell command does not have access to the host environment, which could matter.
type: Comment
score: 0

http://stackoverflow.com/comment/137865387
comment on: http://stackoverflow.com/a/78196849
score: 0
type: Comment
type: AnswerComment
has text: Seems highly unlikely but you'd have to investigate your python script to figure that out. If you can't figure it out then ask a new question about THAT after accepting an answer to THIS question that you asked.

http://stackoverflow.com/comment/137934714
type: Comment
score: 1
has text: It's not clear what you expect to happen, or why you supposed that the code you present was a plausible attempt at that. Certainly, the only observable behavior I would expect is the output of your `echo` command -- which takes no account of arguments to the script or to the `main()` function within -- being printed to the script's standard output.
comment on: http://stackoverflow.com/q/78239545
type: QuestionComment

http://stackoverflow.com/comment/137916258
comment on: http://stackoverflow.com/q/78228875
type: Comment
has text: In addition, you may run into `ffmpeg` stealing input from the file list; see [BashFAQ #89: "I'm reading a file line by line and running ssh or ffmpeg, only the first line gets processed!"](http://mywiki.wooledge.org/BashFAQ/089)
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137917196
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78228745
has text: Why are you using Bash for this? I was a Google senior SWE and attempted to do the same thing as your question in order to avoid introducing any new dependencies. My Bash based solution worked sometimes but was very fragile and failed often enough for those failures to be a problem. You cannot use a tool like Bash for this problem and expect it to work reliably.
score: 1

http://stackoverflow.com/comment/138035391
type: Comment
comment on: http://stackoverflow.com/q/78297320
has text: Add some spaces into the blank line.
type: QuestionComment
score: 0

tty
type: Tag
tags question: http://stackoverflow.com/q/78298936
tag name: tty
tags question: http://stackoverflow.com/q/78637408
tags question: http://stackoverflow.com/q/79029856
tags question: http://stackoverflow.com/q/79416101
tags question: http://stackoverflow.com/q/79327606
tags question: http://stackoverflow.com/q/79466429

http://stackoverflow.com/comment/137777563
has text: FreeBSD 'more' was aliased to 'less'. Not that curious as Charles for this.
comment on: http://stackoverflow.com/a/78150663
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137921629
has text: `ffmpeg` is likely eating your input. Look for topics on how to avoid that.
type: Comment
comment on: http://stackoverflow.com/q/78232246
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137936420
type: Comment
has text: Your JSON contains the **string** `"true"`, not the **boolean** `true`. To decode the JSON string, use the `--raw-output` (or `-r`) flag: `jq -r '.data'`.
comment on: http://stackoverflow.com/q/78240671
type: QuestionComment
score: 6

http://stackoverflow.com/comment/137939533
type: QuestionComment
has text: yes, they are in the same directory
type: Comment
comment on: http://stackoverflow.com/q/78241899
score: 0

http://stackoverflow.com/comment/138052317
type: QuestionComment
type: Comment
has text: I'm not sure how that's happening, since that would make the JSON invalid and `jq` should reject it.
score: 0
comment on: http://stackoverflow.com/q/78306525

http://stackoverflow.com/comment/137790317
type: AnswerComment
comment on: http://stackoverflow.com/a/78157136
score: 1
has text: @oguzismail ugly simple fix could be to `echo ~/`
type: Comment

http://stackoverflow.com/a/78203971
answers question: http://stackoverflow.com/q/78203880
has body: AFAIK, that's the typical way to do it. I'd only add that you could print the prompt with the read command instead of echo (i.e. read -p "Enter the path: " input) and should indent your code properly to avoid errors. Here's my cleaned up version: #!/bin/bash read -p "Enter the path: " input if [ ! -e "$input" ]; then echo "Error: '$input' does not exist." exit 1 elif [ -f "$input" ]; then echo "$input is a regular file" elif [ -d "$input" ]; then echo "$input is a directory" else echo "$input is not a regular file or directory" fi Since I was curious, I also asked Gemini (i.e Google's LLM) about it, and it recommended using file and a switch case to make it cleaner. Personally, I prefer test over file here, but I'll put it here in case you prefer it: #!/bin/bash read -p "Enter the path to a file or directory: " input_name # Check if the path exists using a single test and clearer error message if ! -e "$input_name" ; then echo "Error: '$input_name' does not exist." exit 1 fi # Efficiently determine the type using file command and case statement file_type=$(file -b --mime-type "$input_name") case "$file_type" in "text/"*) echo "$input_name is a text file." ;; "directory/"*) echo "$input_name is a directory." ;; *) echo "$input_name is another file type: $file_type" ;; esac
score: 0
has comment: http://stackoverflow.com/comment/137876740
has comment: http://stackoverflow.com/comment/137874989
type: Answer

http://stackoverflow.com/comment/138027497
has text: You can do this with the shell, but it is probably not the best choice for this kind of work. I would reach for Python, myself, but there are other alternatives that would likewise make development and maintenance easier than targeting a shell script, and would probably yield a program faster than a shell script, too.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78292693
score: 0

http://stackoverflow.com/q/78175779
has comment: http://stackoverflow.com/comment/137821130
linked to: http://stackoverflow.com/q/33245568
has body: I find it confusing that I can read once from an empty string, but not from an empty file: while read -r foo; do echo ${#foo}; done &lt;&lt;&lt; '' # prints '0' while read -r foo; do echo ${#foo}; done &lt; /dev/null # prints nothing Is there a way to write a string literal that cannot be read from even once? Conversely, what contents does a file need to have, in order to be able to read exactly one empty string from it, and nothing else?
has title: Difference between empty string and empty file
type: Question
linked to: http://stackoverflow.com/q/37728699
has answer: http://stackoverflow.com/a/78175828
possible better answer: http://stackoverflow.com/a/78175828
favorite count: 0
score: 2
answer count: 2
upvote count: 2
has answer: http://stackoverflow.com/a/78175811
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137820700
accepted answer: http://stackoverflow.com/a/78175811
type: AnsweredQuestion

http://stackoverflow.com/comment/138004749
has text: Do you want `$ ` prepended to the text in the clipboard, or do you want the expansion of PS1?
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78278159
type: QuestionComment

http://stackoverflow.com/q/78292636
tagged with: containers
accepted answer: http://stackoverflow.com/a/78292830
answer count: 1
has answer: http://stackoverflow.com/a/78292830
has body: I'm developing a coderunner/compiler web-service. It consists of 2 services: HTTP/Web - users send code here and I run it, reporting the results (Dockerized). CodeRunner container - it grabs files from /input folder and returns results.json to the /output folder. Is run with name, input folder, output folder arguments. Different images for different languages. (By Exercism) Flow: I create a "User_Solution-ID" folder with code files (put the code in Solution.cs file, configure the .csproj) I run the CodeRunner container, binding the "User_Solution-ID" folder to /input and /output I read the results.json contents, respond to the user and delete the folder. While this works perfectly when HTTP/Web is run on the host, I can't make it work when running in Docker. The script I use to run the CodeRunner container from Dockerized HTTP/Web is: #!/bin/bash # Check if required arguments are provided if [ $# -ne 4 ]; then echo "Usage: $0 <RunnerImage> <Exercise> <InputDirectory> <OutputDirectory>" exit 1 fi # Assigning parameters to variables RunnerImage="$1" Exercise="$2" InputDirectory="$3" OutputDirectory="$4" # Constructing JSON payload json_payload="{\"Image\": \"$RunnerImage\", \"Cmd\": [\"$Exercise\", \"/input\", \"/output\"], \"HostConfig\": {\"Binds\": [\"$InputDirectory:/input\", \"$OutputDirectory:/output\"], \"NetworkMode\": \"none\"}}" # Sending request to create container response=$(curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d "$json_payload" -X POST http://localhost/v1.42/containers/create) # Extracting container ID from response container_id=$(echo "$response" | jq -r '.Id') # Starting the container curl --unix-socket /var/run/docker.sock -X POST "http://localhost/v1.42/containers/$container_id/start" # Waiting for the container to finish wait_response=$(curl --unix-socket /var/run/docker.sock -X POST "http://localhost/v1.42/containers/$container_id/wait") # Extracting StatusCode from wait response status_code=$(echo "$wait_resp…
tagged with: bash
type: AnsweredQuestion
has title: Mounting Docker container files to another container
tagged with: docker-compose
tagged with: dockerfile
tagged with: docker
score: 0
type: Question

http://stackoverflow.com/comment/137819094
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78173873
has text: This method fails if one of `file*.json` is a stand-alone JSON array not in an object like `[0,1]`. The failure error is: `object ({"some key"...) and array ([0,1]) cannot be added`
type: Comment

http://stackoverflow.com/comment/137891617
type: QuestionComment
has text: Again, I _always_ get `1` `stdout` `stderr` `2`, even with no `sleep` at all. To produce anything different, you need to be running in an environment where stdout and stderr have been subject to redirections that mean they're no longer duplicative of each other.
score: 1
type: Comment
comment on: http://stackoverflow.com/q/78215669

http://stackoverflow.com/comment/137811742
score: 4
has text: Variable references should almost always be double-quoted; use `echo "$time"` instead of `echo "$time"`. Without the double-quote, the value gets mangled in various ways which, in this case, collapse the entire variable into a single line. See ["When to wrap quotes around a shell variable?"](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) [shellcheck.net](https://www.shellcheck.net) is good at spotting mistakes like this, so I recommend running your script through it and fixing what it points out.
type: Comment
comment on: http://stackoverflow.com/q/78170444
type: QuestionComment

http://stackoverflow.com/comment/137877094
has text: I've never heard of `flutter` but in general with shell: sourcing both zsh and bash .rc files seems like it'd have potential to cause breakage, just source the one for the shell you use. The 2 PATH values you show are interchangeable but your PATH should generally contain a lot more directories than just that one. Maybe you did `PATH=/usr/sbin/flutter/bin` instead of `PATH=/usr/sbin/flutter/bin:$PATH` or similar by mistake?
comment on: http://stackoverflow.com/q/78207181
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137796140
type: AnswerComment
has text: Why should one "prefer" omitting the function keyword? Why not prefer to keep the function keyword and omit the parentheses instead, for instance? Is there a solid argument behind this advice, or is it simply personal preference?
score: 0
comment on: http://stackoverflow.com/a/78160193
type: Comment

http://stackoverflow.com/comment/137822481
type: QuestionComment
type: Comment
has text: @user88888888 because that's wasting code and resources. It's like cutting down all of the trees in a forest and then picking one to be your Christmas tree rather than picking the Christmas tree and then cutting down just that one. The right solution will call awk once to do all of the calculations and text manipulation.
score: 0
comment on: http://stackoverflow.com/q/78176347

http://stackoverflow.com/q/78228798
has body: I am trying to copy specific files out of the current directory to the parent directory. The issue is all the files have same name, so I need to add prefix in a way the file will be identifiable after copying: The directory structure- fs/sub-001/mri/brain.mgz fs/sub-002/mri/brain.mgz What I want- fs/sub-001/sub-001_brain.mgz fs/sub-002/sub-002_brain.mgz The 'mri' folder and its other contents can stay as is. I tried: find . -type f -name 'brain.mgz' -exec sh -c ' for file; do parentdir=${file%/*} parentdir=${parentdir%/*} dirname=${parentdir##*/} cp "$file" "$parentdir/${dirname_file}${dirname}_${dirname_file}" done ' sh {} + This partially does the job. It brings the file out to parent directory with the prefix but without file extention. So the result is- fs/sub-001/sub-001_ It looks like the file is being copied but without the original name and extension (without brain.mgz part) which defeats the purpose. What am I doing wrong? I believe it has something to do with the 'cp' command in the loop?
accepted answer: http://stackoverflow.com/a/78228855
tagged with: linux
tagged with: bash
has answer: http://stackoverflow.com/a/78228855
answer count: 1
type: AnsweredQuestion
score: 0
type: Question
has title: Recursively copy file to its parent directory with parent directory name as prefix to file
tagged with: shell

string-comparison
tag name: string-comparison
type: Tag
tags question: http://stackoverflow.com/q/78240671

http://stackoverflow.com/a/78298670
accepted answer of: http://stackoverflow.com/q/78292693
upvote count: 1
type: AcceptedAnswer
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/78292693
has body: The error message mentions line 128. Here's line 128: " > "$("${day}.html")" ; The error message also mentions 2024-03-25.html: command not found. In other words bash is trying to run 2024-03-25.html as a command. This all ties back to a previous comment: What do you think "$("${day}.html")" means? The construct $( .... ) invokes a subshell that executes whatever's between the parens. Assuming day=2024-03-25 this means your code becomes: $(2024-03-25.html) Since 2024-03-25.html is likely not a valid binary, script, function or alias in your environment you get the error message. Since the objective of this part of the script is to write 76 lines of static html code to a file there's no need to invoke a subshell just to desginate a file name. The simple fix: #### replace this: " > "$("${day}.html")" ; #### with this: " > "${day}.html" NOTE: in this case the trailing ; is superfluous

http://stackoverflow.com/comment/137851944
has text: @KamilCuk, so the link you brought up is from 2010, and php-pam was deprecated from atleast debian systems around 2015. I tried installing it from pecl, however the code doesnt seem to be working. I can't find a lot of support of it being a solution used today. Moving onto the `sudo -S` code, I had to find a laymans version of how it's explained in the man pages, but this is looking like the solution! Running a simple `printf ""$password"\n" | sudo -u $username -S echo "1"` for example does work for verification!! If you want to make an answer out of this, i'll mark it as "solved"!!
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78192206

http://stackoverflow.com/a/78150761
accepted answer of: http://stackoverflow.com/q/78150653
type: AcceptedAnswer
has body: You can do (more() { :; }; export -f more; script) and more won't show up.
has comment: http://stackoverflow.com/comment/137780968
type: Answer
has comment: http://stackoverflow.com/comment/137785004
score: 5
answers question: http://stackoverflow.com/q/78150653
downvote count: 0
upvote count: 5

http://stackoverflow.com/comment/138035471
score: 0
comment on: http://stackoverflow.com/a/78297369
has text: Thank you. your syntax is working, but why is my syntax not working? Some times it is required to use $variable inside the "END" block. So the "END" block style is required.
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78199094
accepted answer: http://stackoverflow.com/a/78199180
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78199112
linked to: http://stackoverflow.com/q/45013504
has body: How do I prevent git from loading ~/.gitconfig? I don't want to override HOME, as that might create other problems. Related: How to prevent git from using the global config?
answer count: 2
type: Question
tagged with: shell
tagged with: linux
downvote count: 0
tagged with: git
score: 1
upvote count: 1
possible better answer: http://stackoverflow.com/a/78199112
has title: git: How do I prevent git from loading `~/.gitconfig`?
has answer: http://stackoverflow.com/a/78199180
tagged with: bash

http://stackoverflow.com/comment/137780817
comment on: http://stackoverflow.com/q/78152355
type: QuestionComment
type: Comment
has text: Re "Any help is appreciated" - 1) do as the [tag:bash] tag you used instructs and "For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting them here.", 2) don't redirect it's stdout and stderr to `/dev/null` when trying to figure out why a command isn't doing what you want, 3) run your script with `set -x` enabled to see what it's doing (so far we don't know if it's stuck in 1 call to `nc` or looping calling `nc` repeatedly).
score: 0

http://stackoverflow.com/comment/137791692
type: AnswerComment
has text: ok i edit the link by link to online bash man page
score: 1
comment on: http://stackoverflow.com/a/78158865
type: Comment

http://stackoverflow.com/comment/137923546
type: Comment
comment on: http://stackoverflow.com/q/78233301
score: 0
type: QuestionComment
has text: If the json data contains `\\n` it means one literal backslash and one literal `n` so it's erroneously encoded if it's supposed to encode a newline. Where do you get the json data from? I'd tell them to fix the encoding issue.

http://stackoverflow.com/comment/138018066
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78286124
has text: Do you want an Excel answer or a Unix (bash, awk) answer? Also please answer the first question you were asked in comments above - for your input [Do you want to use csv file 1 2 or 3?](https://stackoverflow.com/questions/78286124/how-to-account-the-number-of-persons-satisfying-some-condition-in-ms-excel#comment138016043_78286124).

http://stackoverflow.com/a/78158324
answers question: http://stackoverflow.com/q/78158123
score: 0
has body: If you want to remove all the files listed in old_backups.txt: xargs -t rm &lt; ./old_backups.txt
type: Answer

http://stackoverflow.com/comment/137872564
type: Comment
has text: Well, $0 has different values in both cases, so calculating `this_dir="${0%/*}"` does not make sense if you run your script in so different ways. As a rule of thumb, whenever you design a script, decide whether you want to run it as a childprocess or by sourcing it. The cases where scripts reasonably work in both ways, are rare.
comment on: http://stackoverflow.com/q/78204675
score: 0
type: QuestionComment

settings
tag name: settings
type: Tag
tags question: http://stackoverflow.com/q/78246449

string
tag name: string
tags question: http://stackoverflow.com/q/78212759
type: Tag
tags question: http://stackoverflow.com/q/78240671
tags question: http://stackoverflow.com/q/78176143
tags question: http://stackoverflow.com/q/78334264
tags question: http://stackoverflow.com/q/78685693
tags question: http://stackoverflow.com/q/78607662
tags question: http://stackoverflow.com/q/78643499
tags question: http://stackoverflow.com/q/78855437
tags question: http://stackoverflow.com/q/78846018
tags question: http://stackoverflow.com/q/78995324
tags question: http://stackoverflow.com/q/79219041
tags question: http://stackoverflow.com/q/79084052
tags question: http://stackoverflow.com/q/79358630
tags question: http://stackoverflow.com/q/79531693
tags question: http://stackoverflow.com/q/79452566
tags question: http://stackoverflow.com/q/79535301

http://stackoverflow.com/a/78301430
accepted answer of: http://stackoverflow.com/q/78301325
downvote count: 0
has comment: http://stackoverflow.com/comment/138137267
answers question: http://stackoverflow.com/q/78301325
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138126818
score: 1
upvote count: 1
type: Answer
has body: Your script has bypassed normal formatting of the x-axis tic labels by using the command plot ... using 1:2:xtic(1). The xtic(1) part tells it to use the content (i.e. the character string) in column 1 as the tic label. You need to apply the new format to the time value represented by the string in column 1, not to the character string itself. The time value represent by the string in column 1 can be accessed as timecolumn(1). Let's define a function to apply the new format to a time value: reformat(time) = strftime("%d %H", time) and now rewrite the script to use that function in plotting $DATA << EOF 12-03 17:40:54,6 12-03 18:40:54,5 12-03 19:40:54,9 EOF set datafile separator "," set xdata time set timefmt "%d-%m %H:%M:%S" reformat(time) = strftime("%d %H", time) plot '$DATA' using 1:2:xtic(reformat(timecolumn(1)))

http://stackoverflow.com/comment/137891563
comment on: http://stackoverflow.com/q/78215669
type: Comment
score: 1
has text: Don't split them. Ordering is nondeterministic if and only if the FDs are not duplicates of each other. That is to say, the moment you do something like `exec >(tee stdout.log) 2>(tee stderr.log >&2)` (or a more POSIXy equivalent thereto), you've thrown away any chance of having deterministic ordering between stdout and stderr.
type: QuestionComment

http://stackoverflow.com/comment/137860563
type: QuestionComment
has text: Apart from that, please read https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem . Because I suspect that you intend to do something with the file you are trying to find, but that the reason for doing that can better be replaced by something else. For that please take one logical step back and ask for help with what you are trying to achieve by/through/after finding "the file which stores your environment variable". Or to put it differently, which environment variable are you working on and what do you want to do once you found the file it is stored in?
type: Comment
comment on: http://stackoverflow.com/q/78197884
score: 0

http://stackoverflow.com/comment/137951556
comment on: http://stackoverflow.com/a/78241862
has text: @DavidC.Rankin even some mandatory POSIX tools modify their behavior based on where the output is going, e.g. try `ls` vs `ls | cat`. Thou shalt not parse the output of such commands :-).
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137862914
score: 2
type: Comment
has text: run your code through shellcheck
type: QuestionComment
comment on: http://stackoverflow.com/q/78199142

http://stackoverflow.com/comment/137832042
type: Comment
comment on: http://stackoverflow.com/q/78182030
score: 4
has text: not sure I understand why all the calls to `eval` .... `$(date +%s)` generates the same result as `$(eval 'date +%s')`
type: QuestionComment

waitpid
type: Tag
tags question: http://stackoverflow.com/q/78218663
tag name: waitpid

http://stackoverflow.com/comment/137916344
comment on: http://stackoverflow.com/q/78228745
score: 1
has text: As @pjh points out you're using the wrong tool for the job. You can, maybe, get this to work for trivial inputs but it will never be secure or robust. You should be using a more suitable language such as Python or Go.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137902935
comment on: http://stackoverflow.com/q/78218663
has text: What you've provided is not an MCVE ([Minimal, Complete, Verifiable Example](https://stackoverflow.com/help/mcve) — or MRE or whatever name SO now uses) or an SSCCE ([Short, Self-Contained, Correct Example](http://sscce.org/) — the same idea by a different name). The data types (notably `t_data` but also `t_Token` and others) are missing. There's no `main()` function. The content of the data structures for the two command lines is not shown. Note that `ls | cat fichier.txt > a` means that `cat` does not read its standard input. By contrast, `ls | wc > a` means that `wc` does.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78212713
answers question: http://stackoverflow.com/q/78211182
score: 0
type: Answer
has body: This may be what you're trying to do: $ cat tst.sh #!/usr/bin/env bash trigger() { echo 'receiving signal' } echo &quot;$$&quot; trap 'trigger' USR1 USR2 while true; do sleep inf done The process exits sleep when the signal is received so it can handle that signal so if you want your process to sleep again after the signal has been handled then you need to put the call to sleep in a loop (or call it from the trap but that could get ugly with general code). Here it is running under set -x so you can see the lines being hit as I send it 2 USR1 signals from another terminal: $ bash -x ./tst.sh + echo 2014 2014 + trap trigger USR1 USR2 + true + sleep inf User defined signal 1 ++ trigger ++ echo 'receiving signal' receiving signal + true + sleep inf User defined signal 1 ++ trigger ++ echo 'receiving signal' receiving signal + true + sleep inf

http://stackoverflow.com/comment/137945968
type: Comment
has text: The `>>` approach can also have unintended behaviors if your file is large enough -- if `cat foo | grep 1 >>foo` means that `grep` is appending content to the file as fast as `cat` can read from it (and the file is long enough that `cat` doesn't reach end-of-file in a single read operation) you can end up in an endless loop.
score: 0
comment on: http://stackoverflow.com/q/78245937
type: QuestionComment

http://stackoverflow.com/a/78156438
type: Answer
has comment: http://stackoverflow.com/comment/137789189
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/78156372
has body: The gist script by Kenaz Kwa seems to be what you are looking for. #!/usr/bin/env python import boto3 sess = boto3.Session( aws_access_key_id="MYAWSACCESSKEYID", aws_secret_access_key="MYSECRETACCESSKEY", region_name="us-east-1", ) ec2 = sess.resource('ec2') volumes = ec2.volumes.all() to_terminate=[] for volume in volumes: print('Evaluating volume {0}'.format(volume.id)) print('The number of attachments for this volume is {0}'.format(len(volume.attachments))) # Here's where you might add other business logic for deletion criteria if len(volume.attachments) == 0: for tag in volume.tags: if tag['year'] == '2022': to_terminate.append(volume) if len(to_terminate) == 0: print ("No volumes to terminate! Exiting.") exit() for volume in to_terminate: print('Deleting volume {0}'.format(volume.id)) volume.delete() The line with the code if len(volume.attachments) == 0: checks to see if the volume is attached to an EC2 instance. You can modify this for whatever criteria you have. For instance, does the name begin with 'x' or if the size is over x Gb.
downvote count: 0

http://stackoverflow.com/comment/137868794
type: AnswerComment
has text: Thanks for the detailed explanation! I tried `env`, and it still doesn't work as expected. I'm using it on the start date which is given to me in `America/Chicago` time, and the system returns it with the same numbers but `UTC` time zone identifier. `start_date="03/21/2024 15:00:00"` `start=$(env TZ=America/Chicago date '+%s' -d "$start_date")` `echo "$(date -d @$start)"` The output is: `Thu Mar 21 15:00:00 UTC 2024` I'd expect this to read `20:00:00 UTC`. Am I missing something, or is `TZ` really locked down here?
score: 0
comment on: http://stackoverflow.com/a/78201679
type: Comment

http://stackoverflow.com/comment/138050692
type: QuestionComment
type: Comment
score: 0
has text: Apparently subshell created via subprocess don't have this function, try to source it first: `subprocess.run("source path_to_file_with_function && _get_app_creation_timestamp"...`
comment on: http://stackoverflow.com/q/78305587

http://stackoverflow.com/comment/137975641
has text: which language? tag it. -- [mre]?
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78261118

dotenv
type: Tag
tags question: http://stackoverflow.com/q/78200394
tag name: dotenv
tags question: http://stackoverflow.com/q/79102724

http://stackoverflow.com/comment/137935823
has text: @F.Hauri-GiveUpGitHub Alright, but why are you telling me that?
comment on: http://stackoverflow.com/q/78240103
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/a/78287610
downvote count: 0
score: 1
upvote count: 1
type: Answer
has body: Binaries can use the isatty library function to test if their file descriptors are associated with a terminal. Many tools do this and change their output accordingly, e.g. most tools will output ANSI color codes when printing to the terminal, but only plain text when redirecting to a file or piping to another process. ls will also disable colored output and switches to 1 file per line mode. You can easily verify by looking at the source code of ls from coreutils: format = (0 &lt;= format_opt ? format_opt : ls_mode == LS_LS ? (stdout_isatty () ? many_per_line : one_per_line) : ls_mode == LS_MULTI_COL ? many_per_line : /* ls_mode == LS_LONG_FORMAT */ long_format); Related: What is isatty() in C for?
answers question: http://stackoverflow.com/q/78287441

http://stackoverflow.com/comment/137787517
has text: Thanks, how would you figure that out (I mean just because it says `warning`)... anyways I used `myVar=$(echo "echo 'Hello World'" | at now + 1 minute 2>&1)` and it worked as expected! Thanks for the help!
comment on: http://stackoverflow.com/q/78156630
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/78155690
favorite count: 0
has comment: http://stackoverflow.com/comment/137787277
has comment: http://stackoverflow.com/comment/137801277
has title: How to run a nested puppet module?
has comment: http://stackoverflow.com/comment/137801254
tagged with: puppet
has comment: http://stackoverflow.com/comment/137844547
score: 0
type: Question
tagged with: ubuntu
has comment: http://stackoverflow.com/comment/137787156
type: UnansweredQuestion
has body: I have a relatively simple manual task that I am trying to automate using Puppet. Steps I want to perform via Puppet: Copy tarball over from Puppetmaster to several server 'client' nodes. Untar the tarball on said server node. Execute, one at a time, each of the installation agents 'install.sh' file. Clean up (remove) original tarball bundle. I was hoping not to have one huge init.pp file, but somehow have it a bit modular so that I could have a different class (?) for each of the agents that need to be installed on the 'client' server nodes. How would I go about doing this? Examples are preferred so I can learn. I tried something like this (to do the initial copy, untar and cleanup), but it's not exactly 'pretty'. class dd_bundle { file { '/opt/apps': ensure =&gt; 'directory', } file { '/opt/apps/dd-app-bundle.tar.gz': source =&gt; 'puppet:///modules/dd_bundle/dd-app-bundle.tar.gz', ensure =&gt; file, replace =&gt; false, mode =&gt; '0664'; } exec { 'tar -xf /opt/apps/dd-app-bundle.tar.gz': cwd =&gt; '/opt/apps', path =&gt; ['/usr/bin', '/usr/sbin',], } tidy { '/opt/apps/dd-app-bundle.tar.gz': } } It would be nice if there was a way I could just somehow have a way to have individual classes and then add them to the init.pp file, then I could make adjustments to each individual class (application) for doing its install part. Just trying to figure out a streamlined way to make a manual process be automated.
upvote count: 1
downvote count: 1
answer count: 0
tagged with: bash

http://stackoverflow.com/comment/138040885
comment on: http://stackoverflow.com/q/78298728
has text: That previously unstated requirement is what I meant by "you haven't clearly defined the parameters of the question". Next question is, do you really need to include the `.env` file in your makefile at all? Why not just set it in the recipe for the `setup` target, something like `setup: ; . config_$(ENV).env && ENV_VAR=<secret_env_var> python my_script.py` ?
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137834668
has text: Check your cron logs. Then add this to your cron line `>/tmp/out.txt 2>/tmp/err.txt` and review the messages there. 99% of the time, these are either directory locations errors, PATH values or environment. cron does not run the script in the same environment you have in your bash.
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78183354

http://stackoverflow.com/comment/137854308
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78194467
has text: The source command executes commands in the current environment, so I assume that the parameters passed to the source command change the positional parameters of the current environment
type: QuestionComment

http://stackoverflow.com/a/78173029
upvote count: 1
has comment: http://stackoverflow.com/comment/137816098
has comment: http://stackoverflow.com/comment/137816338
has comment: http://stackoverflow.com/comment/137816538
downvote count: 0
has comment: http://stackoverflow.com/comment/137816062
score: 1
has body: To get the wav files for every sub-directory, you would use: for wav in **/*.wav Read more here: What does ** mean in a path?
type: Answer
has comment: http://stackoverflow.com/comment/137820516
has comment: http://stackoverflow.com/comment/137816291
has comment: http://stackoverflow.com/comment/137843194
has comment: http://stackoverflow.com/comment/137823348
answers question: http://stackoverflow.com/q/78173011
has comment: http://stackoverflow.com/comment/137820452

http://stackoverflow.com/comment/137822166
has text: That `substr()`s output will, by definition, be of type string so the comparison against `400` will be done alphabetically and so `300000` will be considered less than `400`. You could change `substr($8,2,length($8)-2)` to `substr($8,2)+0` to solve that and shorten the code a bit.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78176634
score: 2

http://stackoverflow.com/q/78273096
type: UnansweredQuestion
has body: I have set up a VenusOS pi with home-made ve-direct cables. Every now and then Venus gives a 'not connected' on all devices and the touchscreen (also usb) does not work anymore. I have not found a way to reset the USB hub AND fixes this, so best thing is to just reboot. When the problem occurs there is some logging with 'timeout', so i want to reboot when my script sees that. #!/bin/bash tail -fn0 /var/log/vedirect.ttyUSB0/current | while read line ; do echo "${line}" | grep -i "timeout" > /dev/null if [ $? = 0 ] ; then truncate -s 0 /var/log/vedirect.ttyUSB0/current reboot fi done 1, I also want to check vedirect.ttyUSB1/current, but do not know how to check both. 2, if it does not find anything, it needs to stop checking, or, the script runs on boot with init.d. What is best practice? I tried to start this on boot with update-rc.d, but then it fails to boot, probably cause the script is not compliant.
tagged with: usb
tagged with: bash
has title: Script to reset USB when unavailable
answer count: 0
tagged with: raspberry-pi4
tagged with: init.d
score: 0
type: Question

http://stackoverflow.com/comment/137852293
type: QuestionComment
type: Comment
has text: Makes sense, I believe the usual solution is LDAP.
comment on: http://stackoverflow.com/q/78192206
score: 0

http://stackoverflow.com/comment/137855547
score: 1
has text: Perhaps you miss `case` instruction a line 4! ` case $yn in`...
type: QuestionComment
comment on: http://stackoverflow.com/q/78195172
type: Comment

http://stackoverflow.com/comment/137771894
type: Comment
score: 2
has text: The first one is good and concise. But don't forget to "quote" variables.
comment on: http://stackoverflow.com/q/78147838
type: QuestionComment

http://stackoverflow.com/comment/137912270
comment on: http://stackoverflow.com/q/78223744
type: Comment
score: 0
has text: If you're asking how to modify your code, you need to post the current implementation.
type: QuestionComment

http://stackoverflow.com/comment/137939402
type: Comment
comment on: http://stackoverflow.com/q/78241899
score: 0
type: QuestionComment
has text: Are your files in the same directory?

http://stackoverflow.com/q/78276574
accepted answer: http://stackoverflow.com/a/78276617
downvote count: 0
possible better answer: http://stackoverflow.com/a/78276598
has comment: http://stackoverflow.com/comment/137999447
score: 1
tagged with: bash
upvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78276617
type: AnsweredQuestion
has title: How do I set a bash variable using the output of grep
has answer: http://stackoverflow.com/a/78276598
has comment: http://stackoverflow.com/comment/137999422
has answer: http://stackoverflow.com/a/78276949
linked to: http://stackoverflow.com/q/17529220
type: Question
has comment: http://stackoverflow.com/comment/138007497
has comment: http://stackoverflow.com/comment/137999405
linked to: http://stackoverflow.com/q/16571739
answer count: 3
has body: I have a text file hg.ini that contains lines that can be interpreted as bash variable assignments: $ cat hg.ini [hello goodbye] x=hello.world y=goodbye.cruel.cruel.world z=I.dont.know.why.you.say.goodbye.I.say.hello I would like to process that file to execute a bash command that sets a bash variable in this way: x=hello.world echo $x hello.world I tried the following, but the $() idiom is interpreted as command rather than a variable assignment: $(grep x= hg.ini|tr -d '\r\n') echo $x x=hello.world: command not found What can I use instead?

http://stackoverflow.com/comment/137867661
type: Comment
comment on: http://stackoverflow.com/q/78200217
score: 0
has text: [edit] your question to include a [mcve] with concise, testable same input (contents of `file.txt` before the script runs and output of `df -h`) and expected output (contents of `file.txt` after the script runs) so we can help you.
type: QuestionComment

http://stackoverflow.com/comment/137923626
has text: This produces invalid json.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78233340

http://stackoverflow.com/comment/137816538
type: Comment
type: AnswerComment
has text: Apologies to pjh, didn't see your comment until I posted mine. ```for wav in **/*.wav ```, checked globstar, it is definitely enabled. Anyone with any thoughts as to why it is only looking in the first subdirectory?
comment on: http://stackoverflow.com/a/78173029
score: 0

http://stackoverflow.com/q/78176143
upvote count: 0
has body: I'm trying to read a variable from a file that is NOT a bash script. The file contents are pretty much like this: App( # Folder name of the application same as application id # Only file name appropriate characters, single "word" allowed # for appid appid="my_app", # name of the app name="Voltage Calculator", apptype=platform.EXTERNAL, # (entry point) of the application entry_point="my_app_main", stack_size=2 * 1024, # Application category category="Tools", requires=["gui"], app_icon="icons/my_app.png", app_icon_assets="icons", # Optional values app_version=(1, 0), # Short text description of the app, no links or markup/markdown # here. app_description="App does this cool thing", app_author="My name", app_weburl="https://github.com/myrepository/", My solution thus far, to extract a variable value from this file is this: filename=~/Programming/myfile.ext awk -F'appid' '{print $2}' $filename | awk -F'=' '{print $2}' | awk -F'"' '{print $2}' | xargs The reason I stated emphatically that it wasn't a bash script is because I read many, many, many, SO answers similar to this where they tell you to "source" the file. Since this isn't a bash script, that doesn't seem logical. My question is, can this be simplified with 'awk' so I'm not piping its' output three separate times? Or is this perfectly acceptable? The 'xargs' is to eliminate the tons of white-space that seemed to surround the result.
has comment: http://stackoverflow.com/comment/137828604
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137822260
has answer: http://stackoverflow.com/a/78176299
favorite count: 0
has comment: http://stackoverflow.com/comment/137822234
has comment: http://stackoverflow.com/comment/137822745
tagged with: awk
tagged with: parsing
tagged with: string
has comment: http://stackoverflow.com/comment/137822761
type: Question
has comment: http://stackoverflow.com/comment/137822194
has title: How can this awk command be simplified?
has answer: http://stackoverflow.com/a/78176733
score: -2
answer count: 3
has answer: http://stackoverflow.com/a/78177038
downvote count: 2

http://stackoverflow.com/comment/137792007
has text: thank you for your feedback i edit the link with https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Here-Strings
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78158865
type: Comment

http://stackoverflow.com/comment/137790130
type: AnswerComment
comment on: http://stackoverflow.com/a/78157136
has text: Try with `HOME=$'foo\n'`
score: 1
type: Comment

http://stackoverflow.com/comment/137897211
has text: @GillesQuénot the question asked was "How to separate an array from a command using quotes instead of spaces in bash" and **that is what others with that question will search for/find in future**. The fact that the OP started with JSON and then called python is irrelevant which is why I said at the top of my answer "Let's take the JSON and Python out of this as your question is about bash arrays and so those are just muddying things as you wouldn't have bash arrays involved in processing JSON with python.". IMO you're focusing on the wrong thing.
comment on: http://stackoverflow.com/a/78214419
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137855591
score: 0
type: Comment
has text: Also, dropping the `-n` flag does seem to help, but I can still get away with `yyyyyyyyyyy` + `enter`. Not sure this "really" matters, but I'm a perfectionist, and this to me, doesn't seem like a 100% solution. I was hoping to restrict this to a very specific `y` + `enter`, but I can live with this solution.
comment on: http://stackoverflow.com/q/78195172
type: QuestionComment

http://stackoverflow.com/comment/137900918
type: Comment
has text: Also see [Bash Pitfalls #14 (echo $foo)](https://mywiki.wooledge.org/BashPitfalls#echo_.24foo).
comment on: http://stackoverflow.com/q/78219094
type: QuestionComment
score: 0

http://stackoverflow.com/comment/137866774
type: Comment
has text: `set -x` is your friend for showing the value of `computer_name` -- if it's got whitespace that isn't there in the getent output that could be your problem.
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138002511
type: AnswerComment
has text: Thanks, but this does not copy the initial command to the clipboard.
comment on: http://stackoverflow.com/a/78278298
type: Comment
score: 0

http://stackoverflow.com/comment/137867402
has text: Setting `HOME` to the null string will cause `git` to look for `/.gitconfig`, resulting in a likely file-not-found error.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78199112

http://stackoverflow.com/comment/137893414
type: AnswerComment
score: 0
has text: I can't accept the answer without at least a hint about the issue with the working directory because the code does not work with Textadept failing with "scriptFileName not found" ...
comment on: http://stackoverflow.com/a/78216128
type: Comment

http://stackoverflow.com/q/78178759
has comment: http://stackoverflow.com/comment/137826816
upvote count: 0
has body: I have a custom test binary, which I use to run specific system tests (e.g. ./test test_case_1.yaml. The exit code of ./testindicates if the system test succeeded. I want to guard myself against future cases of segfaults that are extremely hard to reproduce segfaults by wrapping the program call with gdb. In case the program crashes I can then automatically (no user input: see this question) print the stacktrace and see where the error originated from. My current issue is that once started with gdb, and with no segmentation fault occurring, I cannot retrieve the exit code of the system test and use it with my gitlab-ci runner. How can I get the gdb backtrace if the program crashes and otherwise just the exit code of ./test (as if gdb wasn't used)?
answer count: 1
favorite count: 0
tagged with: segmentation-fault
has answer: http://stackoverflow.com/a/78179609
has comment: http://stackoverflow.com/comment/137827399
score: -1
linked to: http://stackoverflow.com/q/20179153
tagged with: bash
has comment: http://stackoverflow.com/comment/137826061
type: Question
tagged with: continuous-integration
tagged with: gdb
has title: Retrieving Exit Code from a Program Run with GDB in GitLab CI/CD Pipeline
has comment: http://stackoverflow.com/comment/137827767
downvote count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137826044
has comment: http://stackoverflow.com/comment/137826669

http://stackoverflow.com/comment/137989139
type: Comment
has text: @FrustratedProgrammer `bash -c` has most of the same problems that `eval` has -- it essentially runs the shell parsing process twice, so it has the potential to parse (and even execute) things you thought were just static data (e.g. filenames). Seriously, use arrays for things like this.
comment on: http://stackoverflow.com/q/78270350
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137828994
score: 0
has text: Will change the awk as you suggested, also to run it sequentially the data is very huge so it is taking a lot of time.
type: QuestionComment
comment on: http://stackoverflow.com/q/78177875
type: Comment

http://stackoverflow.com/a/78150771
downvote count: 3
type: Answer
answers question: http://stackoverflow.com/q/78150653
has comment: http://stackoverflow.com/comment/137785735
upvote count: 0
score: -3
has body: To automatically respond to the "more" command in a program or script, you would typically need to implement a pagination mechanism. def paginate(items, page_size=10): """Paginate a list of items.""" for i in range(0, len(items), page_size): yield items[i:i+page_size] def display_page(page): """Display a page of items.""" for item in page: print(item) # Example list of items items = [f"Item {i}" for i in range(1, 101)] # Paginate the list pages = paginate(items) # Loop to display pages until there are no more for page in pages: display_page(page) if input("Press Enter to see more, or type 'exit' to quit: ").lower() == 'exit': break

http://stackoverflow.com/comment/137790034
type: AnswerComment
comment on: http://stackoverflow.com/a/78157309
has text: @jj2f1 Theirs is likely more efficient as it only requires one traversal of the history.
score: 0
type: Comment

http://stackoverflow.com/comment/137842549
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78187590
has text: As others have also suggested, you probably should use an array to hold the string parts. However, your code almost works (assuming that `input_string` has the correct value). The problem is that the `grep` command does not match the `declare -p` output. Maybe start with `declare -p | grep var_` and modify the `grep` options until it does exactly what you want.

http://stackoverflow.com/comment/137834464
comment on: http://stackoverflow.com/q/78183354
has text: I've tried it .. It doesn't fix the issue
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78255939
has comment: http://stackoverflow.com/comment/137963650
score: 0
has comment: http://stackoverflow.com/comment/137963746
type: Answer
has comment: http://stackoverflow.com/comment/137963959
has comment: http://stackoverflow.com/comment/137963618
answers question: http://stackoverflow.com/q/78254632
has body: POSIX-shell grammar solution without pattern matching that work for arbitrary int or float detection: #!/usr/bin/env sh isNumber(){ { LC_NUMERIC=C printf %f "$@" > /dev/null;} 2>/dev/null;} isInt(){ { LC_NUMERIC=C printf %d "$@" > /dev/null;} 2>/dev/null;} isFloat() { isNumber "$@" && ! isInt "$@";} for v in hello 42 3.14 'foo bar' 2.99E16 1E-20; do if isNumber "$v" then printf '%s is a number\n' "$v" isInt "$v" && printf '%s is an integer\n' "$v" isFloat "$v" && printf '%s is a float\n' "$v" else printf '%s is not a number\n' "$v" fi done Result: hello is not a number 42 is a number 42 is an integer 3.14 is a number 3.14 is a float foo bar is not a number 2.99E16 is a number 2.99E16 is a float 1E-20 is a number 1E-20 is a float

http://stackoverflow.com/q/78251624
downvote count: 0
tagged with: bash
type: Question
has title: ImageMagick / Bash : pipe ignored(?) when filename format variable used
has answer: http://stackoverflow.com/a/78251741
has comment: http://stackoverflow.com/comment/137955499
answer count: 1
favorite count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78251741
tagged with: imagemagick
has body: I'm trying to create a thumbnail sheet (a grid of thumbnails) using ImageMagick with filenames beneath each image. The filenames are long UUID style strings, and using the -title option they overflow into each other to create an unreadable mess. So I thought I'd truncate the names to only show the first n characters. My Bash script is below (running via Git Bash on Windows 11.) I'm not sure whether this is an error in my Bash code, or my use of ImageMagick. magick montage -verbose -label &quot;$(echo '%t' | cut -c -8)&quot; -font Arial -pointsize 16 \ -background '#000000' -fill 'gray' \ -define jpeg:size=200x200 \ -geometry 200x200+2+2 -tile 8x0 \ -auto-orient \ $(ls -rt *.jpg) \ out.jpg As far as I can tell the issue I have is with the $(echo '%t' ... part of the script in the first line; it doesn't seem to be piped into the cut command following it. If I use a literal string, eg. echo 'Hello world!', each thumbnail is labeled with what I'd expect, 'Hello wo'. But if I instead use %t (which is ImageMagick's format variable for exposing the base filename of the image) I get the full untruncated filename as if the cut command isn't being applied. When I use a naked format variable (I've tried %f, the full filename, and %t, the base filename), without echo'ing it into cut, I get the expected untruncated filename. As mentioned, if I echo a literal string (Hello world!) piped into cut, I get the expected truncated output. It is only when I combine the two to echo %f or %t into cut that the truncation fails and I get the full filename. I've also tried piping the echo into sed instead of cut, but yet again the second command is ignored and I get the full filename. EDIT: An extra little detail I forgot: if I do something funky with the %t, like $(echo 'xxx%t'), I get the filename preceded by xxx -- so it seems the echo is working as expected. But when I try to pipe it into cut, it doesn't truncate. Any help gratefully received.
score: 2
upvote count: 2

http://stackoverflow.com/comment/137855782
type: QuestionComment
type: Comment
has text: @ChrisMurrell, since there are no answers added (just comments, which are fair game to invalidate via edits) it's an option open to you to [edit] this into a completely different question, if you want to modify it to show your new code and the new problem. Anyone with enough reputation in the bash tag can singlehandedly reopen it if we agree it's a good question after you've done so.
comment on: http://stackoverflow.com/q/78194973
score: 0

http://stackoverflow.com/comment/137958999
type: QuestionComment
comment on: http://stackoverflow.com/q/78252063
type: Comment
has text: I have found a solution. Thank you
score: 1

http://stackoverflow.com/comment/138055981
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78305587
has text: Thanks you all for your help. I've tried setting `shell=True` but it didn't work. I'm thinking about a workaround, a kind of Frankenstein which keeps shell info running functions and saving in env variables and later accessing to those variables via Python.

http://stackoverflow.com/comment/137951578
type: QuestionComment
has text: why not simply clone the code base for each set of experiments? if necessary use PYTHONPATH to let versioned dependencies be found
type: Comment
comment on: http://stackoverflow.com/q/78244372
score: 0

http://stackoverflow.com/q/78228875
type: UnansweredQuestion
has body: I'm trying to write a script that just makes ffmpeg convert .flac files to .ogg. find $1 -name '*.flac' | while read -r i; do ffmpeg -i "$i" -codec:a libvorbis -qscale:a 6 ~/"$i".ogg done It fails when it encounters a directory with a space in its name and splits it by the newline. e.g. /path/to/this dir becomes /path/to/this and dir. I've tried piping into xargs but that doesn't solve the problem at all.
has comment: http://stackoverflow.com/comment/137916258
linked to: http://stackoverflow.com/q/9612090
tagged with: bash
duplicate of: http://stackoverflow.com/q/9612090
has comment: http://stackoverflow.com/comment/137916019
has title: Parsing file paths with `find` in a shell script treats spaces as newlines
has comment: http://stackoverflow.com/comment/137919068
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137919027

http://stackoverflow.com/a/78170533
has comment: http://stackoverflow.com/comment/137824354
answers question: http://stackoverflow.com/q/78170444
has comment: http://stackoverflow.com/comment/137814238
has comment: http://stackoverflow.com/comment/137813478
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78170444
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/137824204
type: Answer
has body: In homage to pjh's brillant reminder that printf can do the date conversion internally in 4.2+, one with no read that uses pure bash regex parsing. :) data="$time" line=$'^\n{0,1}([0-9]),([0-9]{10}),([a-z]+,[a-z]+)' while "$data" =~ $line do printf "%s,%s,%s,%(%a %b %d %Y %r)T\n" "${BASH_REMATCH[@]:1}" data="${data#${BASH_REMATCH[0]}}" done You could just let the awk format the date calls. As pointed out, it does leave a certain possibility of injection if you aren't 100% sure of your inputs. Please be careful. $: echo "$time" | awk -F, -v OFS=, '$2~/^[0-9]{10}$/{ system("date +\""$0",%a %b %d %Y %r\" -d @"$2) }' 1,1708746085,apples,cars,Fri Feb 23 2024 09:41:25 PM 2,1709764378,pears,bus,Wed Mar 06 2024 04:32:58 PM 3,1709875892,orange,truck,Thu Mar 07 2024 11:31:32 PM Obviously you could add error checking and such to make it more robust, but if you're going to use awk anyway, oguz ismail's is better. The same general idea in a more prosaic loop - $: echo "$time" | while IFS=, read -ra line; do printf %s, "${line[@]}" ; date +"%a %b %d %Y %r" -d "@${line[1]}"; done 1,1708746085,apples,cars,Fri Feb 23 2024 09:41:25 PM 2,1709764378,pears,bus,Wed Mar 06 2024 04:32:58 PM 3,1709875892,orange,truck,Thu Mar 07 2024 11:31:32 PM
score: 2
has comment: http://stackoverflow.com/comment/137824558
has comment: http://stackoverflow.com/comment/137815444
has comment: http://stackoverflow.com/comment/137811988

http://stackoverflow.com/comment/137939118
comment on: http://stackoverflow.com/a/78242017
type: Comment
type: AnswerComment
score: 0
has text: If you got it, that is worth an upvote.

http://stackoverflow.com/comment/137903116
type: Comment
comment on: http://stackoverflow.com/q/78218663
score: 0
has text: When printing diagnostic messages, make sure the message ends with a newline. The `printf("111111111111111111");` output may not appear until another message outputs a newline. If the standard output is going to a file, it may not appear until the buffer is full. Some systems may produce the output as if the standard output was unbuffered, but it is unwise to rely on that. Besides, debugging messages should usually be more helpful than a string of ones.
type: QuestionComment

http://stackoverflow.com/q/78195387
tagged with: node.js
has comment: http://stackoverflow.com/comment/137856105
tagged with: bash
has title: How to add dependencies into package.json with jq
has body: I want to add package dependencies to the package.json file by bash script using jq. Add new element to existing JSON array with jq Here is the test script with 5 steps: #!/bin/bash add_element_with_jq() { # step 1: Add a new root element "{}" first echo "============= step 1 ================" echo "{}" > "package.json" # step 2: Add a "dependencies" sub element to the root element "{}" echo "============= step 2 ================" # step 3: Add a "foo" package with version "1.1.1" to the "dependencies" echo "============= step 3 ================" jq '. += dependencies { "foo": "1.1.1" }' "package.json" echo "=========== step 3 output ==================" cat "package.json" # step 4: Add a "bar" package with version "2.2.2" to the "dependencies" echo "============= step 4 ================" jq '.dependencies += "bar": "2.2.2" ' "package.json" # step 5: If the "foo" package already existed, then update to the latest version. Otherwise, add the "foo" package to the dependencies. echo "============= step 5 ================" jq '.dependencies += "foo": "3.3.3" ' "package.json" echo "=========== final output ==================" cat "package.json" } add_element_with_jq Here is the error: ============= step 1 ================ ============= step 2 ================ ============= step 3 ================ jq: error: syntax error, unexpected '{', expecting $end (Unix shell quoting issues?) at <top-level>, line 1: . += dependencies { jq: 1 compile error =========== step 3 output ================== {} ============= step 4 ================ jq: error: syntax error, unexpected ':', expecting $end (Unix shell quoting issues?) at <top-level>, line 2: "bar": "2.2.2" jq: 1 compile error ============= step 5 ================ jq: error: syntax error, unexpected ':', expecting $end (Unix shell quoting issues?) at <top-level>, line 2: "foo": "3.3.3" jq: 1 compile error =========== final output ================== {} Here is the expected output: =========== step 3 output ================== { "dep…
favorite count: 0
has answer: http://stackoverflow.com/a/78195996
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137856003
possible better answer: http://stackoverflow.com/a/78195834
has comment: http://stackoverflow.com/comment/137856559
accepted answer: http://stackoverflow.com/a/78195996
has comment: http://stackoverflow.com/comment/137856898
answer count: 2
has comment: http://stackoverflow.com/comment/137856513
type: Question
tagged with: ubuntu
downvote count: 0
has answer: http://stackoverflow.com/a/78195834
score: 1
linked to: http://stackoverflow.com/q/42245288
tagged with: jq
tagged with: package.json
upvote count: 1
has comment: http://stackoverflow.com/comment/137856028

http://stackoverflow.com/a/78195834
answers question: http://stackoverflow.com/q/78195387
has body: The syntax being used (. += dependencies) seems incorrect. To add or modify a key in dependencies, use the following syntax: jq '.dependencies["foo"]="1.1.1"' "package.json" This will output the edited contents. Since we cannot pipe back into the file (it is open for reading while jq is being executed), we have to pipe it to a new file and rename it (use the mv command for this). jq '.dependencies["foo"]="1.1.1"' "package.json" > package.json.new \ && mv package.json.new package.json
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/137856814
upvote count: 1
type: Answer

http://stackoverflow.com/comment/137855885
has text: Or if you really do want an array, `readarray -t interfaces < <(basename -a /sys/class/net/* | awk '/eth/{print $1}')`, but I really hate to advise that command -- it's needlessly inefficient to fork off several subprocesses (a subshell, a copy of the `basename` executable, and a copy of the `awk` executable) for something the shell could do itself built-in with no forking at all.
score: 0
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment
type: Comment

parameters
type: Tag
tag name: parameters
tags question: http://stackoverflow.com/q/78195964

http://stackoverflow.com/comment/137865703
type: QuestionComment
comment on: http://stackoverflow.com/q/78196837
type: Comment
has text: @Bohemian I'm mostly concerned with timestamps between 12am and 2am of the starting/ending date for DST. I'm writing a bash script that takes that date as input
score: 0

http://stackoverflow.com/comment/137999447
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78276574
has text: Does this answer your question? [Parsing variables from config file in Bash](https://stackoverflow.com/questions/16571739/parsing-variables-from-config-file-in-bash)
type: Comment

http://stackoverflow.com/comment/137866193
score: 0
type: Comment
has text: I have tried setting it before `date`, and I have tried `export`. In both cases, the change did not take, and the system still returned `UTC`. I don't remember if I tried `env`, but doing some research pointed at the possibility of the time zone actually being set to read-only and unchangeable, so that is my best guess at this time. It still doesn't explain the new 5h difference...
comment on: http://stackoverflow.com/q/78200396
type: QuestionComment

http://stackoverflow.com/comment/137893198
type: Comment
has text: How to tell Textadept the right path to the file? %f will be replaced by the current script file name, but the current working directory gets lost on the way to the target script ...
comment on: http://stackoverflow.com/a/78216128
type: AnswerComment
score: 0

http://stackoverflow.com/q/78291764
has comment: http://stackoverflow.com/comment/138026029
has comment: http://stackoverflow.com/comment/138026743
has comment: http://stackoverflow.com/comment/138026058
has comment: http://stackoverflow.com/comment/138025579
has comment: http://stackoverflow.com/comment/138026013
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138025604
type: UnansweredQuestion
has body: echo ~/"foo" Works as expected - you get /home/<username>/foo However, if the forward slash is moved inside the quoted area echo ~"/foo" expansion does not work anymore. You get ~/foo What is the rule that is controlling such behaviour?
has comment: http://stackoverflow.com/comment/138025766
has comment: http://stackoverflow.com/comment/138026024
linked to: http://stackoverflow.com/q/32276909
has comment: http://stackoverflow.com/comment/138026797
has title: Bash tilde expansion not working when attached to a quoted string
tagged with: bash
duplicate of: http://stackoverflow.com/q/32276909

http://stackoverflow.com/comment/138048750
has text: Your comment looks like you are still using quotes around the variable. It should be `:user1`, not `:'user1'` or `:"user1"`, right?
comment on: http://stackoverflow.com/a/78302726
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/q/78170444
score: 2
has title: Convert unix time human readable loop
has comment: http://stackoverflow.com/comment/137813771
has comment: http://stackoverflow.com/comment/137811895
linked to: http://stackoverflow.com/q/10067266
upvote count: 2
has body: I have a variable called $time that contains 1,1708746085,apples,cars 2,1709764378,pears,bus 3,1709875892,orange,truck I'm trying to iterate over the variable and convert the time 2nd column from unix time to human readable var=`echo $time |awk -F &quot;,&quot;' '{print $2}'` for secs in $var do date -d @$secs done But it only seems to convert the 1st occurrence and not all of them. Suggestion? At the end of the day I'm hoping to append the converted times to the end of items as the 5th column like 1,170874608,apples,cars,Fri Mar 15 2024 7:37:39 PM
tagged with: bash
answer count: 5
accepted answer: http://stackoverflow.com/a/78170533
has comment: http://stackoverflow.com/comment/137811742
has answer: http://stackoverflow.com/a/78170706
has answer: http://stackoverflow.com/a/78172263
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137813744
has answer: http://stackoverflow.com/a/78171801
has comment: http://stackoverflow.com/comment/137813010
possible better answer: http://stackoverflow.com/a/78171801
type: Question
has answer: http://stackoverflow.com/a/78170533
downvote count: 0
has comment: http://stackoverflow.com/comment/137813778
has answer: http://stackoverflow.com/a/78170836

http://stackoverflow.com/comment/137787469
type: Comment
has text: `at` writes that summary to standard error, not standard output.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78156630

http://stackoverflow.com/q/78186259
has comment: http://stackoverflow.com/comment/137839454
has answer: http://stackoverflow.com/a/78187523
answer count: 2
score: -1
type: Question
upvote count: 0
has comment: http://stackoverflow.com/comment/137840578
type: UnansweredQuestion
has body: I'm trying to understand how (ba)sh works "under the hood". I noticed one problems that bothers me. Most of parameters such as @, ? or even * can be treated as readonly variables. They can be assigned to variables that will have exactly the same "value" (e.g. STAR_VAR=$*). @ is different, especially when used as "$@". It's more like array (let's call it SET), which can be accessed with special non-array syntax, e.g. "$@" instead of "${SET[@]}". You can learn how and when to use it, but still - is's quite confusing way of accessing "numbered" parameters (it's more like array but you're accessing with non-array syntax). Bash was improved a lot to replace legacy constructs like `` with more "clean" syntax like $(). I wonder why this aspect was not cleaned up to make bash syntax less tricky, eg. adding to shell's or function's environment array variable (e.g. SET) with "numbered" parameters inside (with option to use legacy syntax of course)?
favorite count: 0
has answer: http://stackoverflow.com/a/78186982
tagged with: syntax
tagged with: bash
has comment: http://stackoverflow.com/comment/137840351
has title: Bash @ parameter - "special" array? What is it exactly?
downvote count: 1

variables
tags question: http://stackoverflow.com/q/78200217
type: Tag
tags question: http://stackoverflow.com/q/78146405
tag name: variables
tags question: http://stackoverflow.com/q/78302587
tags question: http://stackoverflow.com/q/78409604
tags question: http://stackoverflow.com/q/78477621
tags question: http://stackoverflow.com/q/78649419
tags question: http://stackoverflow.com/q/78707385
tags question: http://stackoverflow.com/q/78891591
tags question: http://stackoverflow.com/q/78946487
tags question: http://stackoverflow.com/q/79025069
tags question: http://stackoverflow.com/q/78950801
tags question: http://stackoverflow.com/q/79068201
tags question: http://stackoverflow.com/q/79050654
tags question: http://stackoverflow.com/q/78975082
tags question: http://stackoverflow.com/q/79178079
tags question: http://stackoverflow.com/q/79261597
tags question: http://stackoverflow.com/q/79327490
tags question: http://stackoverflow.com/q/79277246

github-codespaces
type: Tag
tags question: http://stackoverflow.com/q/78294007
tag name: github-codespaces

http://stackoverflow.com/comment/137769573
score: 0
has text: @pjh thank you ever so much. This has been invaluable. Looks like I was doing several things wrong, mainly incorrect assignment of the variable. Thank you!
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78146405

http://stackoverflow.com/comment/137858097
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78196374
has text: do you want to *truncate* the long lines or break them into 60-char chunks on separate lines (ie, wrap)?
score: 1

http://stackoverflow.com/q/78147406
has comment: http://stackoverflow.com/comment/137771469
tagged with: http://stackoverflow.com/tag/r
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137771151
has body: I have a bash script where I use singularity exec to run a program from inside the container. I want to call this script in R using the system() function. Everything works fine until it reaches the line containing singularity exec, where I get the error : &quot;./script.sh: line 22: singularity: command not found &quot; The bash script works well when I call it directly in command line. How could I make it work? Thank you.
has comment: http://stackoverflow.com/comment/137771125
type: UnansweredQuestion
tagged with: bash
tagged with: singularity-container
has title: Call singularity exec from a shell script in R
tagged with: shell

http://stackoverflow.com/comment/137842568
score: 0
comment on: http://stackoverflow.com/q/78187590
type: QuestionComment
type: Comment
has text: @Rubberducky, ...to be a little more explicit, `\w` is PCRE syntax. `grep` supports BRE or ERE; only with nonstandard extensions can it support PCRE, and even then on the GNU version compiled with the optional library dependency adding that support there's an extra argument needed to turn it on.

http://stackoverflow.com/a/78196739
downvote count: 0
upvote count: 1
answers question: http://stackoverflow.com/q/78196593
type: Answer
has body: Setup: sMABzAlert='FirstField|SecondField|INTFARE.D240319.T1100 INTFARE.D240319.T1101|FourthField' Append a character on the end of our data, a character that does not show up in the data (eg, %): $ echo "${sMABzAlert}" FirstField|SecondField|INTFARE.D240319.T1100 INTFARE.D240319.T1101|FourthField $ echo "${sMABzAlert}%" # add '%' on the end of string FirstField|SecondField|INTFARE.D240319.T1100 INTFARE.D240319.T1101|FourthField% # output terminated by a '%' Tell read to read until the first % it comes to (-d'%'): IFS='|' read -r -d'%' sFirstField sSecondField sThirdFieldTwoLines sFourthField <<< "${sMABzAlert}%" The results: $ typeset -p sFirstField sSecondField sThirdFieldTwoLines sFourthField declare -- sFirstField="FirstField" declare -- sSecondField="SecondField" declare -- sThirdFieldTwoLines=$'INTFARE.D240319.T1100\nINTFARE.D240319.T1101' declare -- sFourthField="FourthField" Running OP's last 4 echo calls generates: sFirstField:[FirstField] sSecondField:[SecondField] sThirdFieldTwoLines:[INTFARE.D240319.T1100 INTFARE.D240319.T1101] sFourthField:[FourthField]
score: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78196593
has comment: http://stackoverflow.com/comment/137869380

http://stackoverflow.com/comment/138031578
has text: I found the linked quesiton when I googled "bash empty array nounset". It has a link to the relevant release note.
comment on: http://stackoverflow.com/q/78294975
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137822924
type: AnswerComment
comment on: http://stackoverflow.com/a/78176299
has text: This produced a blank result.
type: Comment
score: 0

http://stackoverflow.com/comment/138024013
type: Comment
comment on: http://stackoverflow.com/q/78290808
score: 1
has text: This sounds like a job for systemd-timer or cron.
type: QuestionComment

http://stackoverflow.com/comment/137791341
type: QuestionComment
score: 0
has text: why `0777` rather than `0666` ?
type: Comment
comment on: http://stackoverflow.com/q/78158725

http://stackoverflow.com/q/78224990
has body: #! /usr/bin/env bash Wallpaper_Dir="~/.config/hypr/Wallpapers/" #using full path in my code chosen=$(ls $Wallpaper_Dir --ignore='Best Wallpapers.md' | rofi -dmenu -i) swww img "$Wallpaper_Dir'$chosen'" # I added the extra quotes so that if the image name contains a space it is still able to work this code returns this error: Error: "failed to open image: No such file or directory (os error 2)" in terms of bug testing I have tried to echo: swww img "$Wallpaper_Dir'$chosen'" and it returns swww img ~/.config/hypr/Wallpapers/'Chill Study.jpg' which looks fine, note that I use the full path not ~ in my code, wondering if anyone could shed some light as to why
type: Question
duplicate of: http://stackoverflow.com/q/67117575
has comment: http://stackoverflow.com/comment/137908423
tagged with: nixos
has title: "No such file or dir" when using bash to automate wallpaper selection - NixOS
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/67117575
has comment: http://stackoverflow.com/comment/137908346
has comment: http://stackoverflow.com/comment/137912885
has comment: http://stackoverflow.com/comment/137908357
score: -1
upvote count: 0
has comment: http://stackoverflow.com/comment/137908417
has comment: http://stackoverflow.com/comment/137909113
tagged with: bash
duplicate of: http://stackoverflow.com/q/32276909
answer count: 1
has comment: http://stackoverflow.com/comment/137908369
favorite count: 0
has answer: http://stackoverflow.com/a/78227319
downvote count: 1
has comment: http://stackoverflow.com/comment/137908391

http://stackoverflow.com/comment/138038970
type: Comment
score: 0
type: QuestionComment
has text: _nod_, both those results tell us bash is doing the right thing. (The PR against cjdb _actually fixes_ cjdb, right? If bash wasn't passing the environment variable to the application, it wouldn't be in `os.environ` so the PR wouldn't work).
comment on: http://stackoverflow.com/q/78298036

node.js
tags question: http://stackoverflow.com/q/78177847
tag name: node.js
type: Tag
tags question: http://stackoverflow.com/q/78307692
tags question: http://stackoverflow.com/q/78195387
tags question: http://stackoverflow.com/q/78164579
tags question: http://stackoverflow.com/q/78385537
tags question: http://stackoverflow.com/q/78831728
tags question: http://stackoverflow.com/q/78981695
tags question: http://stackoverflow.com/q/79022536
tags question: http://stackoverflow.com/q/79057828
tags question: http://stackoverflow.com/q/79155445
tags question: http://stackoverflow.com/q/79201229
tags question: http://stackoverflow.com/q/79328848
tags question: http://stackoverflow.com/q/79383675
tags question: http://stackoverflow.com/q/79460476
tags question: http://stackoverflow.com/q/79443511
tags question: http://stackoverflow.com/q/79498895

http://stackoverflow.com/comment/137858156
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78196593
type: Comment
has text: The quoted IFS is needed because i am using "|" as IFS, but we can probably have an off topic discussion for it.

http://stackoverflow.com/a/78162277
type: Answer
score: 5
upvote count: 5
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78161552
accepted answer of: http://stackoverflow.com/q/78161552
has body: In the end it was a syntax problem. To fix this issue I needed to change the -h to -H. After fixing the initial issue I also had to wrap the data object in double quotes e.g. "$mergedTest". The script then worked as desired. Docs showing '-H' required syntactically: https://ec.haxx.se/http/post/content-type.html In regards to the lack of double quotes around my $mergedTest variable. To quote Charles Duffy "you risk the contents of mergedTest being split on whitespace, having those individidual components expanded as globs, and then being sent to curl as several separate, smaller arguments". Previously asked question showing why double quotes should be used: I just assigned a variable, but echo $variable shows something else
downvote count: 0
has comment: http://stackoverflow.com/comment/137810146

http://stackoverflow.com/comment/137825968
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78178702
has text: The `tee` command is your friend. [Documentation](https://www.man7.org/linux/man-pages/man2/tee.2.html). Additionally, refer to [this Unix & Linux SE question](https://unix.stackexchange.com/q/80707).
score: 0

http://stackoverflow.com/comment/137908196
score: 0
has text: I think @oguz is the correct answer (You should post it below). You should also make sure that the file is in the same working directory as the script.
type: QuestionComment
comment on: http://stackoverflow.com/q/78224799
type: Comment

http://stackoverflow.com/comment/137770238
comment on: http://stackoverflow.com/q/78146721
score: 0
has text: Please [edit] your question to provide all of the missing information on the kind of pattern matching you want to do so we can help you. Oh, and your code does `grep -v '^#' "$MANIFEST_FILE"` which suggest you have some lines in your manifest that contain `#`s that you want to ignore so make sure your example includes such lines.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/137871454
comment on: http://stackoverflow.com/q/78203871
type: QuestionComment
type: Comment
has text: I believe so-- I have added an additional testcase to account for the possibility it does not, (`test3.sh`), and that also does not output "How do i get here".
score: 0

http://stackoverflow.com/comment/137855498
type: Comment
score: 0
has text: (btw, in a real-world case I'd proabably want to add some logic to the loop to use `continue` to skip things that _aren't_ valid names corresponding with interfaces you want to handle in this way; not sure this logic is correct for `lo`, for example, so `$interface = lo* && continue` might be called for -- but this all depends very much on details that haven't been added into evidence here)
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973

http://stackoverflow.com/comment/137957166
type: Comment
has text: @Philippe i think it would be a good idea. Earlier i thought it would be simpler with cli commands.
score: 0
comment on: http://stackoverflow.com/q/78252129
type: QuestionComment

http://stackoverflow.com/a/78188212
has comment: http://stackoverflow.com/comment/137850096
has comment: http://stackoverflow.com/comment/137860913
has comment: http://stackoverflow.com/comment/137864291
has comment: http://stackoverflow.com/comment/137853490
score: 0
has body: The normal approach would be to create an array of the entries, easily doable with mapfile (or readarray - a synonym of mapfile); in this case we'll also use process substitution to feed the fold results to mapfile, eg: $ string=1234567898765432 $ mapfile -t arr < <(fold -w4 <<< "${string}") $ typeset -p arr declare -a arr=([0]="1234" [1]="5678" [2]="9876" [3]="5432") The chatGPT answer is working it's just that the final line of the script (declare -p | grep -E ...) needs some tweaking. Alternatives for the last line: $ declare -p | grep 'var_' declare -- var_1="1234" declare -- var_2="5678" declare -- var_3="9876" declare -- var_4="5432" declare -- var_name="var_4" # probably don't want to see this one $ declare -p | grep '^declare -- var_[0-9]*=' declare -- var_1="1234" declare -- var_2="5678" declare -- var_3="9876" declare -- var_4="5432" $ declare -p | grep -E ' var_[0-9]+=' declare -- var_1="1234" declare -- var_2="5678" declare -- var_3="9876" declare -- var_4="5432"
type: Answer
has comment: http://stackoverflow.com/comment/137843785
answers question: http://stackoverflow.com/q/78187590

http://stackoverflow.com/a/78272332
type: Answer
accepted answer of: http://stackoverflow.com/q/78272291
score: 2
upvote count: 2
has body: Trying to print non-numbers with %.3f format prints 0.000. The awk script should leave the first line alone by testing NR Instead of piping to sed to convert spaces to tabs, just set the awk variable OFS. awk -v OFS='\t' 'NR == 1 {print; next} { for (i=4; i<=NF; ++i) $i=sprintf("%.3f", $i); print }' TestAllScore.tsv > TestAllScore2.tsv
downvote count: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78272291

http://stackoverflow.com/comment/137886641
has text: Why are you using Bash + Python instead of just Python? Python has JSON parsing in its standard library, and Bash is a terrible language for anything more complicated than gluing other programs together (and it’s not very good at that either).
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78212759

http://stackoverflow.com/comment/138050738
type: Comment
comment on: http://stackoverflow.com/q/78305587
has text: Or better yet, change it into a standalone script so you don't need to separately enable interactive features when your use case is clearly a noninteractive one.
score: 3
type: QuestionComment

http://stackoverflow.com/comment/138031430
score: 0
has text: Or `{ ps -p "$apid"; echo; } >>pslog.txt` to only open the output file once -- using a grouping that way is more efficient than putting `>>pslog.txt` on each of two separate commands. (Note that the syntax used there is very deliberate -- the `;` before the last `}` is essential when running this as a one-liner; so is the space after the `{`)
comment on: http://stackoverflow.com/q/78295010
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78199516
score: 0
answers question: http://stackoverflow.com/q/78195172
has body: If, as is common on PC keyboards, when you hit the Backspace key on your keyboard it generates the Del character (ASCII dec 127, hex 177, Control-?), rather than the backspace character (ASCII 8, Control-H), then all you need is: $ cat tst.sh #!/usr/bin/env bash while true; do IFS= read -r -p 'Continue (y/n): ' yn case $yn in [yY] ) echo 'Yes - Continuing...' break;; [nN] ) echo 'No - Exiting...' exit;; * ) echo 'Invalid response!';; esac done because the read will complete when you hit Enter to generate a newline, then the case will check for the 1 char before that newline being y or n. Unless you put your terminal into "raw" mode your terminal buffers the keypresses until you hit Enter so the terminal, not your script, is what interprets that backspace keypress and deletes the preceding character from the input buffer before your script sees it. So if you type n backspace y your script will just read y, same as if you hadn't hit n backspace first. See https://unix.stackexchange.com/a/414171/133219 for more information. Unfortunately the whole "Backspace" vs "Delete" area is a bit of a mess with Macs having a Delete key generating the Del character where the PC Backspace key is that generates Del character on some OSes and the BS character on others, and then Macs not having a Backspace key but instead requiring key combinations to generate BS, and PCs having a Delete key that generates something that isn't an ASCII character, etc. hence the "If your keyboard generates Del when Backspace is hit" caveat at the top of this answer.
type: Answer

http://stackoverflow.com/q/78227591
has title: stringify bash array to json string
has comment: http://stackoverflow.com/comment/137913404
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137913430
has body: I'm new to bash and I have a bash script with a variable that is an array called 'output' I'd like to convert the bash array to a JSON string. for example: original array: output = ['one', 'two'] desired output: '["one","two"]' I have tried the following: "$(jq -c -n '$ARGS.positional' --args "${output[@]}")" but that seems to wrap the array inside another set of square brackets: '["[\"one\",\"two\"]"]' which is not what I want. also, I'd like to assign the JSON string to a variable. I also saw that I can do this: echo '{"foo" : "bar"}' | jq -R . but I dont know how to use my variable 'output' instead of the hard-coded object. Also, not sure how to assign the result of that to a variable EDIT here's the bash script: service_list_json="$(jq -c -n '$ARGS.positional' --args "${output[@]}")" EDIT 2 ok, I think I might be seeing where the issue is. the original array looks like this: '["one","two"]' i'm guessing the extra set of quotes around the array are causing it to be treated like a string?
has comment: http://stackoverflow.com/comment/137913409
has comment: http://stackoverflow.com/comment/137913440
has comment: http://stackoverflow.com/comment/137913476
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/137913419
accepted answer: http://stackoverflow.com/a/78227637
has comment: http://stackoverflow.com/comment/137913464
has answer: http://stackoverflow.com/a/78227637
has comment: http://stackoverflow.com/comment/137913398
has comment: http://stackoverflow.com/comment/137913393
answer count: 1
tagged with: jq
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137913396
has comment: http://stackoverflow.com/comment/137913738
score: 0

http://stackoverflow.com/comment/137847061
comment on: http://stackoverflow.com/q/78190193
type: QuestionComment
has text: That said, I'm surprised that you're better off running an external copy of awk piping to sqlite rather than a separate Python process using sqlite through the relevant module -- using a prepared statement is generally going to be more efficient than any interface that requires starting the parsing from the beginning for every piece of input, and prepared statements _require_ a level of integration you can't get with the command line tool and stdin.
score: 2
type: Comment

http://stackoverflow.com/comment/137910515
comment on: http://stackoverflow.com/q/78224942
type: QuestionComment
has text: Please remove the bash tag. There is nothing related to bash in your question.
type: Comment
score: 0

http://stackoverflow.com/q/78177405
downvote count: 0
tagged with: bash
answer count: 5
has comment: http://stackoverflow.com/comment/137823625
has answer: http://stackoverflow.com/a/78177590
has answer: http://stackoverflow.com/a/78177763
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78177452
has answer: http://stackoverflow.com/a/78177437
tagged with: sh
has answer: http://stackoverflow.com/a/78177452
type: Question
tagged with: shell
score: 1
upvote count: 1
favorite count: 0
has title: Capturing first line from shell command output and continue processing rest
has body: I'm trying to capture and "store away" (preferably in a variable) the first line of a command output and forward the remainder of the output back to stdin of the next command in a pipe. As an FYI, the purpose is to capture and store the cursor reference of a redis-cli SCAN invocation, while processing the data returned. This is what I came up with: command | { read first_line ; cat ; } | process_rest echo $first_line This seems to work as intended in zsh, but not in Bourne Shell ("/bin/sh") or bash. It appears that piping to the command grouping causes a subshell in sh/bash, "swallowing" the first_line variable. What is the best way to achieve what I'm trying to do? Will I need to "pipe" the first line through a file or fifo instead of trying to set a variable? I also tried using a while read line ; do construct to filter out the first line and continue processing the rest, but it appears it has the same effect (any variable changes within the do/done block are not reflected in the outer scope).
has answer: http://stackoverflow.com/a/78177473
possible better answer: http://stackoverflow.com/a/78177763

http://stackoverflow.com/comment/137851314
has text: @choroba yes, it should be.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78192804

http://stackoverflow.com/a/78199624
downvote count: 0
score: 1
upvote count: 1
has body: Try this Shellcheck-clean Bash code: #! /bin/bash -p for r1 in sample*_R1.fastq; do base=${r1%_R1.fastq} r2=${base}_R2.fastq -f $r2 || continue num=${base#sample} motus profile -f "$r1" -r "$r2" -t 4 > "taxon${num}.txt" done See Removing part of a string (BashFAQ/100 (How do I do string manipulation in bash?)) for an explanation of ${r1%_R1.fastq} and ${base#sample}.
type: Answer
answers question: http://stackoverflow.com/q/78199142
has comment: http://stackoverflow.com/comment/137863085

http://stackoverflow.com/a/78422669
answers question: http://stackoverflow.com/q/78240309
downvote count: 0
score: 1
upvote count: 1
has body: Thanks to the comment from Caldazar, I realized my question was based on a confusion of the concepts of profiles and accounts. It seems that profiles, like SSO sessions are local and can be linked to any account. So instead of trying to retrieve an automatically generated profile id from the aws command, it is better to just provide a profile id via command line argument or as an exported environment variable. Also instead of running aws configure sso each time to log in, we only need to do it once for each profile to set up the profiles locally: aws configure sso --profile prefix-dev aws configure sso --profile prefix-qa aws configure sso --profile prefix-prod Then inside the script we first determine the correct profile and then run aws sso login. My use case is to retrieve an rds password. So the relevant part of my script looks like this: export AWS_PROFILE="prefix-$env" DB_PASSWORD=$(aws rds generate-db-auth-token --hostname $DB_HOST --port 5432 --username $SERVICE) while [ $? != 0 ]; do aws sso login DB_PASSWORD=$(aws rds generate-db-auth-token --hostname $DB_HOST --port 5432 --username $SERVICE) done This has the added benefit that we don't have to manually choose a matching account and only have to interact with the script once a day to refresh the sso credentials.
type: Answer

http://stackoverflow.com/comment/137855971
has text: Assuming you're using the array approach, did you maybe use `$interfaces` instead of `"${interfaces[@]}"`? That would make it only do the first.
type: Comment
comment on: http://stackoverflow.com/q/78194973
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138031388
has text: You mean a blank line between commands? `echo >>pslog.txt` should do it.
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78295010

http://stackoverflow.com/comment/137872877
has text: _is there a more efficient way to do_ : Since your script is probably broken (unless `input_name` happens to be an environment variable, which was set in the parent process - but you didn't mention this ), pretty much any correct script is "more efficient" than this one.
comment on: http://stackoverflow.com/q/78203880
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/137866852
score: 0
has text: @looks like truth. When i'll go on work, i try use `grep -w`
type: QuestionComment
comment on: http://stackoverflow.com/q/78201574
type: Comment

http://stackoverflow.com/q/78203880
has comment: http://stackoverflow.com/comment/137871770
has answer: http://stackoverflow.com/a/78203898
has body: im trying to write a script that asks a user for a file/directory name, determines its type (regular file, directory, or another type) then outputs a message saying its type. it is necessary to check if the file exists first in this instance. is there a more efficient way to do what im trying to? #!/bin/bash if [ ! -e "$input_name" ]; then echo "Error: '$input_name' does not exist." exit 1 fi echo “Enter the path” read input if [ -f “$input” ] then echo “$input is a regular file” elif [ -d “$input” ] then echo “$input is a directory” else echo “$input is not a regular file or directory” fi
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137872877
type: UnansweredQuestion
answer count: 2
has answer: http://stackoverflow.com/a/78203971
tagged with: bash
has title: a script that outputs the type of file, is it necessary to check if the file exists first
has comment: http://stackoverflow.com/comment/137872849
has comment: http://stackoverflow.com/comment/137871809

http://stackoverflow.com/q/78202378
tagged with: php
upvote count: 1
tagged with: python
has body: I have this XML with multiple products and I want to add a new element with the values of other elements. I want to add a new element to each titled . This should include the values of ProductOption, PurchaseOption, Quantity. Example should look like price-each-an-order-250-499 . I am open to different technologies, like command line sed, bash etc.., php, python, javascript. Input XML 82508 <Title>Product Title description Price Each An Order 250-499 250 499 1.09 Price Each An Order 500-999 500 999 0.95 Price Each An Order 1000-2499 1000 2499 0.93 Price Each An Order 2500-4999 2500 4999 0.87 Price Each An Order 5000 5000 0.84 Price Each A Quote 0.00 Price Each A Sample 1 1 1 0.00 Expected Output 82508 <Title>Product Title description Price Each An Order 250-499 250 499 1.09 price-each-an-order-250-499 Price Each An Order 500-999 500 999 0.95 price-each-an-order-500-999 Price Each An Order 1000-2499 1000 2499 0.93 price-each-an-order-1000-2499 Price Each An Order 2500-4999 2500 4999 0.87 price-each-an-order-2500-4999 Price Each An Order 5000 5000 0.84 price-each-an-order-5000 Price Each A Quote 0.00 price-each-a-quote Price Each A Sample 1 1 1 0.00 price-each-a-sample-1 Not sure what to use to accomplish this. Any examples or tutorials would be helpful.
tagged with: command-line
score: 0
type: Question
tagged with: javascript
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137868466
answer count: 1
has comment: http://stackoverflow.com/comment/137868461
has title: Copy values from XML element to create a new element with combined new value
favorite count: 0
downvote count: 1
has answer: http://stackoverflow.com/a/78204513
tagged with: bash

zsh
tags question: http://stackoverflow.com/q/78207181
tags question: http://stackoverflow.com/q/78274299
type: Tag
tag name: zsh
tags question: http://stackoverflow.com/q/78204849
tags question: http://stackoverflow.com/q/78402822
tags question: http://stackoverflow.com/q/78325081
tags question: http://stackoverflow.com/q/78437863
tags question: http://stackoverflow.com/q/78399997
tags question: http://stackoverflow.com/q/78539085
tags question: http://stackoverflow.com/q/78558314
tags question: http://stackoverflow.com/q/78581308
tags question: http://stackoverflow.com/q/78474106
tags question: http://stackoverflow.com/q/78491259
tags question: http://stackoverflow.com/q/78503442
tags question: http://stackoverflow.com/q/78644539
tags question: http://stackoverflow.com/q/78597052
tags question: http://stackoverflow.com/q/78842937
tags question: http://stackoverflow.com/q/78811543
tags question: http://stackoverflow.com/q/78988601
tags question: http://stackoverflow.com/q/78950820
tags question: http://stackoverflow.com/q/79043659
tags question: http://stackoverflow.com/q/78949650
tags question: http://stackoverflow.com/q/79034879
tags question: http://stackoverflow.com/q/79105138
tags question: http://stackoverflow.com/q/79107325
tags question: http://stackoverflow.com/q/79135245
tags question: http://stackoverflow.com/q/79141629
tags question: http://stackoverflow.com/q/79238784
tags question: http://stackoverflow.com/q/79277670
tags question: http://stackoverflow.com/q/79361411
tags question: http://stackoverflow.com/q/79403981
tags question: http://stackoverflow.com/q/79441992
tags question: http://stackoverflow.com/q/79467011
tags question: http://stackoverflow.com/q/79475099
tags question: http://stackoverflow.com/q/79438491
tags question: http://stackoverflow.com/q/79465116
tags question: http://stackoverflow.com/q/79509411

http://stackoverflow.com/q/78241462
has title: How to write function in bash for reuse shell commands inside using osascript?
has comment: http://stackoverflow.com/comment/137937992
tagged with: osascript
score: 0
has comment: http://stackoverflow.com/comment/137938001
tagged with: function
type: Question
has body: I want to get rid of duplicates, but get the errors: 178:186: syntax error: A “"” can’t go after this identifier. (-2740) 133:134: syntax error: Expected expression but found unknown token. (-2741) execute_commands() { local command = "$1" osascript <<EOF tell application "iTerm" to \ tell the last session of current tab of current window to \ write text $command EOF } # function call execute_commands "cd \"$PROJECT_PATH\"/frontend && npm run dev" I tried to fix it in different ways, nothing works.
tagged with: shell
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137938142
tagged with: terminal
answer count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137937989

http://stackoverflow.com/comment/137822150
has text: It's not clear what you're trying to do. Is `file.txt` supposed to be `number.txt`? How does the value of the shell variable `number` relate to your awk script comparing the 1st and 8th fields from `number.txt` to the hard-coded numbers `200` and `800`? What does `Trying to extract numbers between 200 and 400 and then print the whole line` actually mean? Once we know what it is you're really trying to do then we can best help you. And please don't just keep repeating `text` in your example - show some truly representative values.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78176347
score: 0

http://stackoverflow.com/comment/137922684
type: AnswerComment
comment on: http://stackoverflow.com/a/78232840
has text: You're a godsend. I would not have guessed this by myself. And here's your question-answered-checkmark :)
score: 0
type: Comment

http://stackoverflow.com/comment/137934312
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78239545
has text: Try `declare -a ARGS=("$@")` or use `$1,$2, $3` and/or `$@` directly.

http://stackoverflow.com/comment/138014672
type: QuestionComment
type: Comment
has text: _Exactly_ what surprises you about it? You might look into how shebangs work.
score: 0
comment on: http://stackoverflow.com/q/78285382

http://stackoverflow.com/comment/138001816
type: QuestionComment
has text: Did you try `grep -Eo`? Otherwise the plus won't work without being escaped https://www.gnu.org/software/grep/manual/html_node/Basic-vs-Extended.html
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78278018

http://stackoverflow.com/a/78196086
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/137857321
has comment: http://stackoverflow.com/comment/137857693
type: Answer
answers question: http://stackoverflow.com/q/78195964
has body: I presented two options, a solution to your problem and in addition a more proper way of hanlding input arguments. To Answer your question Looking at this little bit of code, we exclude the argument options from the values by comparing each value to our arg_options array. Hence anything define in arg_options will not be in the final results. The script loops over every input option, then runs another check (loop) to look for any matches in our arg options, if it's found we mark it as a value we don't want and we move on. declare -a arg_options=( aaa bbb ccc ddd ) for each in "$@"; do found=0 for opt in "${arg_options[@]}"; do if [ "$each" = "$opt" ]; then found=1 break fi done if [ $found -ne 1 ]; then echo $each # store to an array etc. here fi done To expand on your question Take this example 'script.sh' with command line options: Script.sh -mode active -count 10 Here's the code, and the nice part is that it will properly handle the inputs no matter what order they are passed to the script: typeset mode='inactive' typeset count get_user_input_options() { while [[ $# > 0 ]] ;do key="$1" case ${key,,} in -m|--mode) mode="$2" shift ;; -c|--count) count="$2" shift ;; *) echo "ERROR: Unknown option $key given." exit 1 ;; esac shift done } get_user_input_options "$@" # handle user inputs (if any) What are we doing in the script, we are defining a function to read in the options and set the global variables get_user_input_options. Look at how it is being called, it is taking in all of the command line inputs for handling with the "$@" option. Note: if you don't want it to be a script just remove the function line and it's closing bracket. Then it is using a while loop to step over every option, but when it finds a match for an option it sets the value and shifts forward as that had the value of the option. It continues to step through the inputs until completed. You will also notice that I set the global variable 'mode' to something so if the script is called without tha…

http://stackoverflow.com/a/78196849
type: Answer
has comment: http://stackoverflow.com/comment/137866028
has comment: http://stackoverflow.com/comment/137865387
has body: You're replacement string specifically says to add a newline after every 0 to 60 chars so that's what sed is doing and then it's printing a terminating newline at the end of all of it's output as it always does and that's what's causing a blank line to appear. It's easier to see with smaller input and a smaller range: $ echo '1234' | sed 's/.\{0,2\}/<&>\n/g' <12> <34> $ $ echo '12345' | sed 's/.\{0,2\}/<&>\n/g' <12> <34> <5> $ There's various ways to solve the problem but you seem to be trying to wrap (aka fold) lines rather than truncate them, so try this instead: fold -s -w60 | sed "s/^/${esc}[35m║ /" Here it is using what I think your original output of sudo apt upgrade 2>&1 >&1 probably looked like as input: $ cat file WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. $ cat file | fmt -s -w60 | sed "s/^/${esc}[35m║ /" ║ WARNING: apt does not have a stable CLI interface. Use ║ with caution in scripts. ║ ║ Reading package lists... ║ Building dependency tree... ║ Reading state information... ║ Calculating upgrade... ║ 0 upgraded, 0 newly installed, 0 to remove and 0 not ║ upgraded. Note that fold is splitting the input at white space (when it can), whereas your sed command would chop lines mid-word which would create messier output.
score: 1
has comment: http://stackoverflow.com/comment/137866346
has comment: http://stackoverflow.com/comment/137865899
answers question: http://stackoverflow.com/q/78196374
downvote count: 0
has comment: http://stackoverflow.com/comment/137865180
upvote count: 1

http://stackoverflow.com/q/78278018
has comment: http://stackoverflow.com/comment/138004626
has body: I'm using npm ls -a which gives the following ouput: └─┬ cors@2.8.5 ├── object-assign@4.1.1 └── vary@1.1.2 I'm trying to extract all the dependencies and store it in a file with the following command: npm ls -a | grep -o "\S+@\S+" >> deps.txt" Which gives nothing. I'm using macOS with bash shell. According my understanding \S catch any non space character + is used to match one or more of such occurrence then match for @ and again for one or more occurrence of non space characters. example dependencies text from which information have to be extracted: According to me grep -o "\S+@\S+" should have given the result i.e all the package names along with the version information but it does not. Interestingly when i try with using grep -o "\S*@\S*" it gives the required information. Extracted information I want to know why the + does not works as according to me it should work as * means it would match for 0 or more occurrences while + means it would match for one or more occurrences of non space characters (\S+) so + should be more secure
tagged with: grep
has comment: http://stackoverflow.com/comment/138002349
answer count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138009717
upvote count: 1
favorite count: 0
downvote count: 1
linked to: http://stackoverflow.com/q/18514135
has comment: http://stackoverflow.com/comment/138001927
has title: Confused about why the regex pattern does not works
tagged with: regex
linked to: http://stackoverflow.com/q/4377480
has comment: http://stackoverflow.com/comment/138001816
score: 0
duplicate of: http://stackoverflow.com/q/18514135
type: Question
has comment: http://stackoverflow.com/comment/138004642
tagged with: shell
type: UnansweredQuestion

http://stackoverflow.com/q/78228745
has comment: http://stackoverflow.com/comment/137919149
tagged with: linux
tagged with: bash
has title: how to deal with multipart form data in bash?
has body: Backend running on thttpd using cgi. Decide to add file upload feature. then the part thats reading stdin and writing to a file if [ "$REQUEST_METHOD" == "POST" ]; then while IFS= read -r line; do printf "%s" "$line" >> encoded_file done fi I have no issues with text based files the only issue is with binary data i.e. png file in my case using hexedit to view the file: 00000000 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D ------------------------ 00000018 2D 2D 2D 2D 2D 31 36 39 33 34 34 35 39 32 39 31 34 35 30 36 31 30 30 36 -----1693445929145061006 00000030 35 34 31 34 31 35 32 32 31 32 0D 43 6F 6E 74 65 6E 74 2D 44 69 73 70 6F 5414152212.Content-Dispo 00000048 73 69 74 69 6F 6E 3A 20 66 6F 72 6D 2D 64 61 74 61 3B 20 6E 61 6D 65 3D sition: form-data; name= 00000060 22 66 69 6C 65 54 6F 55 70 6C 6F 61 64 22 3B 20 66 69 6C 65 6E 61 6D 65 "fileToUpload"; filename 00000078 3D 22 49 4D 47 5F 37 30 39 37 2E 50 4E 47 22 0D 43 6F 6E 74 65 6E 74 2D ="IMG_7097.PNG".Content- 00000090 54 79 70 65 3A 20 69 6D 61 67 65 2F 70 6E 67 0D 0D 89 50 4E 47 0D 1A 0D Type: image/png...PNG... 000000A8 49 48 44 52 01 7B 03 93 08 06 5E B6 A3 CD 01 73 52 47 42 AE CE 1C E9 38 IHDR.{....^....sRGB....8 000000C0 65 58 49 66 4D 4D 2A 08 01 87 69 04 01 1A 02 A0 02 04 01 01 7B A0 03 04 eXIfMM*...i.........{... 000000D8 01 03 93 4E 72 1E D1 40 49 44 41 54 78 01 EC BD 07 94 5E C7 75 E7 F9 BE ...Nr..@IDATx.....^.u... passing thru uudeview to get rid of boundaries and header 00000000 89 50 4E 47 0A 1A 0A 49 48 44 52 01 7B 03 93 08 06 5E B6 A3 CD 01 73 52 .PNG...IHDR.{....^....sR 00000018 47 42 AE CE 1C E9 38 65 58 49 66 4D 4D 2A 08 01 87 69 04 01 1A 02 A0 02 GB....8eXIfMM*...i...... 00000030 04 01 01 7B A0 03 04 01 03 93 4E 72 1E D1 40 49 44 41 54 78 01 EC BD 07 ...{......Nr..@IDATx.... 00000048 94 5E C7 75 E7 F9 BE 9C FA EB 1C D0 88 4D 10 19 CC 99 14 65 CB E3 75 D8 .^.u.........M.....e..u. 00000060 B1 C7 B3 92 C7 E3 73 BC 5A 7B 25 79 EC B5 CE D9 D9 9D B4 3E 67 45 EE CC .....…
has comment: http://stackoverflow.com/comment/137916344
has comment: http://stackoverflow.com/comment/137919631
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137917196
answer count: 0
has comment: http://stackoverflow.com/comment/137915816
tagged with: ubuntu
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137919426
tagged with: content-type

http://stackoverflow.com/q/78261247
has answer: http://stackoverflow.com/a/78272045
tagged with: grep
upvote count: 4
tagged with: bash
score: 3
favorite count: 0
has comment: http://stackoverflow.com/comment/137973422
tagged with: awk
tagged with: sed
possible better answer: http://stackoverflow.com/a/78261401
has answer: http://stackoverflow.com/a/78262533
has title: How to Extract Clusters with Multiple Rows Using Bash Commands?
answer count: 5
type: Question
accepted answer: http://stackoverflow.com/a/78261291
has answer: http://stackoverflow.com/a/78262545
type: AnsweredQuestion
downvote count: 1
has answer: http://stackoverflow.com/a/78261401
has body: I'm trying to extract clusters from a text file using Bash commands. Each cluster is delineated by a line starting with &gt;Cluster. I want to extract only those clusters with more than one data row within them. Here's a simplified example of my input file: &gt;Cluster 199 0 2599aa, &gt;CAD5117741.1... * &gt;Cluster 200 0 2579aa, &gt;CAD5112262.1... * &gt;Cluster 201 0 2578aa, &gt;CAD5116287.1... * &gt;Cluster 202 0 2578aa, &gt;CAD5122864.1... * 1 1867aa, &gt;CAD5122865.1... at 100.00% 2 2369aa, &gt;CAD5122866.1... at 100.00% &gt;Cluster 203 0 2573aa, &gt;CAD5110750.1... * &gt;Cluster 204 0 2571aa, &gt;CAD5116249.1... * &gt;Cluster 205 0 2558aa, &gt;CAD5122682.1... * &gt;Cluster 206 0 2553aa, &gt;CAD5126525.1... * &gt;Cluster 207 0 2551aa, &gt;CAD5115834.1... * In this example, I want to extract only Cluster 202 because it has more than one row of data within it. The desired output would be: &gt;Cluster 202 0 2578aa, &gt;CAD5122864.1... * 1 1867aa, &gt;CAD5122865.1... at 100.00% 2 2369aa, &gt;CAD5122866.1... at 100.00% I'm currently using awk to process the file but struggling to figure out how to extract these clusters properly. Can someone guide me in accomplishing this task efficiently using Bash commands? I attempted to use the following awk command: awk '/^&gt;Cluster/ {cluster=$0; count=0; next} {count++} count &gt; 1 {print cluster; print} count == 0 {print cluster}' When applied to the provided data, it produced the following output: &gt;Cluster 202 2 2369aa, &gt;CAD5122866.1... at 100.00% This output is incomplete, as it should include all lines within Cluster 202.
has answer: http://stackoverflow.com/a/78261291
has comment: http://stackoverflow.com/comment/137973374

http://stackoverflow.com/comment/138026307
type: AnswerComment
has text: @DavidWong Just run `git blame on the file` and you'll see that each line has a prefix with some meta information like commit id, date, author etc, including at the very end the line number. So you can filter that out either with sed/perl/python or with cut+rev+awk line in my answer.
score: 0
comment on: http://stackoverflow.com/a/78276584
type: Comment

http://stackoverflow.com/comment/137913476
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591
type: Comment
has text: @AbdulAhmad Yeah, that isn't a bash array. Is the string actually that value, or does it look like that in the bash source? If it looks like that in the source, then the actual value is a string, `["one","two"]`. But it looks like that string is the output you want, so there's nothing you need to do. :-)

http://stackoverflow.com/comment/137999494
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78276617
has text: To clean up afterwards: `$ source <(grep 'x=' hg.ini); echo "$x" ; unset x`
score: 1

http://stackoverflow.com/a/78215334
score: -1
has body: One option might be to utilize grep and cut to extract the colors for a chosen scheme into an array and then access the individual array elements for the colors. #!/bin/bash read -rp "Select color scheme: " scheme printf "SCHEME: \n\t%s\nCOLORS: \n" "$scheme" read -ra colors <<<"$(grep "$scheme" schemes.txt | cut -d= -f2)" printf '\t%s\n' "${colors[@]}" # Access the individual array elements as ${colors[0]}, ${colors[1]}, etc. printf "First color: %s\n" "${colors[0]}" Example: $ ./script Select color scheme: sch-001 SCHEME: sch-001 COLORS: red blue white First color: red
upvote count: 0
answers question: http://stackoverflow.com/q/78214961
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78214961
type: Answer
downvote count: 1

http://stackoverflow.com/comment/137958934
type: Comment
score: 0
has text: Yes, it's undefined from `process.env.API_KEY`
type: QuestionComment
comment on: http://stackoverflow.com/q/78252063

http://stackoverflow.com/comment/137867343
type: AnswerComment
has text: Thanks for your help. I was able to figure it out. Github requires that you use their naming convention. See my post below.
comment on: http://stackoverflow.com/a/78183320
type: Comment
score: 0

http://stackoverflow.com/q/78260557
tagged with: gnome-terminal
has title: howto gnome-terminal source some env variable and alias statement
has comment: http://stackoverflow.com/comment/137982234
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138025122
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137991946
has body: i want to set up my work environment for different terminal tabs quickly. For that I have some statements in a script e.g.: gnome-terminal --title "A TITLE" --tab --profile Red-White -- bash -c "source ~./envs/setEnv.sh; exec bash" cat setENVS.sh: echo Hallo there alias instdir='cd /local0/biologics/instances/instsp-T8/' complete -C complete-ant-cmd.pl ant export incarnation='INCARN1' export instsp='TEST123' export port='41201' PS1="$PS1-- INSTANCE=${_magenta}\${incarnation-<unset>}-\${instsp-<unset>}:\${port-<unset>}${_coloff}\n" How ever this does not work. The "PS1" and the "alias" are not set. Export variables is working. On so does this sourceing, meaning the script works: . setENVS.sh Does anybody have a solution for this? Thanks.
score: 0
answer count: 0
has comment: http://stackoverflow.com/comment/138002255
has comment: http://stackoverflow.com/comment/138002377

http://stackoverflow.com/a/78242017
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78241761
score: 5
accepted answer of: http://stackoverflow.com/q/78241761
upvote count: 5
type: Answer
has body: Although @oguz-ismail's answer would work with the sample output provided, it seems that actual equery output becomes garbled when it is fed into a pipe. This convoluted commandline seems to work around the problems: &lt;/dev/null script -B /dev/null -f -q -c ' eix-installed -a | xargs equery depends ' | tr -d '\r' | grep -v '^---' | awk '!/\n/' RS= script makes equery believe it is writing to a terminal redirecting script's stdin from /dev/null avoids some display oddities (cf. re-enable on-screen carriage return behaviour without including them in the data stream) tr strips the carriage returns added by script grep filters some non-dependency info (per @konsolebox comment) awk splits on empty lines and filters out multi-line records
has comment: http://stackoverflow.com/comment/137939118
has comment: http://stackoverflow.com/comment/137939133
downvote count: 0

http://stackoverflow.com/a/78241862
upvote count: 2
has comment: http://stackoverflow.com/comment/137939115
has body: I think you would need something a bit longer. Something that stores lines ending in ':' and then checks, in some way, that the line that follows is empty (with awk simply checking NF works). You also need a trigger to indicate no output is waiting. Setting the variable holding the saved line to empty works. There are many ways to do this, but you can translate the above into: awk '/:$/ {last=$0; next} NF==0 && length(last) { print last } { last="" } END { if (length(last)) print }' Example Use/Output Using a heredoc to feed data (you can just pipe to it as you are doing), and making sure you catch a final line of interest in the END rule, you can do: $ awk '/:$/ {last=$0; next} NF==0 && length(last) { print last } { last="" } END { if (length(last)) print }' << eof > * These packages depend on app-portage/gentoolkit-0.6.5: > > * These packages depend on app-portage/getuto-1.11: > sys-apps/portage-3.0.63 (!build ? app-portage/getuto) > > * These packages depend on app-portage/portage-utils-0.96.1: > app-admin/perl-cleaner-2.31 (!pkgcore ? app-portage/portage-utils) > > * These packages depend on app-portage/cockatoolkit-0.6.5: > eof * These packages depend on app-portage/gentoolkit-0.6.5: * These packages depend on app-portage/cockatoolkit-0.6.5: ("cockatoolkit" was just made up for the example...) Look things over and let me know if you have problems.
answers question: http://stackoverflow.com/q/78241761
has comment: http://stackoverflow.com/comment/137938910
has comment: http://stackoverflow.com/comment/137938831
downvote count: 0
has comment: http://stackoverflow.com/comment/137953435
has comment: http://stackoverflow.com/comment/137951556
has comment: http://stackoverflow.com/comment/137938892
has comment: http://stackoverflow.com/comment/137938849
type: Answer
score: 2

http://stackoverflow.com/q/78307692
has comment: http://stackoverflow.com/comment/138054281
has comment: http://stackoverflow.com/comment/138054303
has body: There is a shell command that is used to copy all HTML files from one directory to another while preserving the directory structure: find ./src -name '*.html' -exec sh -c 'mkdir -p "./dist/$(dirname "{}")" && cp "{}" "./dist/{}"' \; The goal is to include this command in the npm scripts entry in package.json. However, it's unclear how to properly escape the command to make it work. Here's what has been tried: "scripts": { "copy-html": "find ./src -name '*.html' -exec sh -c 'mkdir -p \"./dist/$(dirname \"{}\")\" && cp \"{}\" \"./dist/{}\"' \\;" } When running npm run copy-html, the following error occurs: find: missing argument to `-exec' What is the correct way to include this command in the npm scripts entry and resolve this error? Note: Currently, user is using git bash to run this. User already gets around this by creating a separate bash file and calling that from npm script. User wants to find a solution to properly escape because this command is just an example and there are numerous other commands user would like to escape/use without having to create bash files for each command.
score: 0
type: Question
tagged with: shell
answer count: 0
tagged with: npm
type: UnansweredQuestion
tagged with: node.js
tagged with: bash
has title: How to Include a Shell Command in npm Scripts Entry?

http://stackoverflow.com/comment/137919149
type: Comment
comment on: http://stackoverflow.com/q/78228745
score: 0
has text: @pjh reading with cat indeed made a difference null bytes are preserved. Now im stuck at how to deal with header and boundary. Uudeview is inducing new bytes and not preserving null bytes.
type: QuestionComment

http://stackoverflow.com/a/78147252
accepted answer of: http://stackoverflow.com/q/78146405
has comment: http://stackoverflow.com/comment/137771159
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78146405
has body: As others have mentioned, there is no subshell in your code. I think you probably saw code like num=27; seq 3 | while IFS= read -r line; do num="$line"; echo "inside: $num"; done; echo "outside: $num" which would output 1, 2, 3, 27 and misunderstood why that outputs 27 instead of 3 at the end. It's not because loops run in a subshell, but because the commands on both sides of a pipe (|) run in a subshell. That's why you'd use command substitution (<(command)) to write num=27; while IFS= read -r line; do num="$line"; echo "inside: $num"; done < <(seq 3); echo "outside: $num" which would output 1, 2, 3, 3 instead. See mywiki.wooledge.org/BashFAQ/024. Regarding the code in your question, FWIW I'd write it as: $ cat tst.sh #!/usr/bin/env bash Guessing_Game() { local keepPlaying theNumber userGuess echo 'Guessing Game!' theNumber=$(shuf -n 1 -i 1-10) until [[ "$keepPlaying" =~ [nN] ]]; do echo "$keepPlaying" IFS= read -r -p 'Guess a number between 1 and 10: ' userGuess if (( userGuess == theNumber )); then echo "Well done! You win." else echo "Incorrect guess." fi IFS= read -r -p 'Would you like to play again? ([y]/n)' keepPlaying done } Guessing_Game The changes I made were: Added a shebang to find the first bash in the callers PATH. Added the call to the function. Used local variables. Used arithmetic operators ((...)) for numeric comparisons. Used IFS= and -r on the reads as you always should unless you have a specific need to remove either of them, see why-is-using-a-shell-loop-to-process-text-considered-bad-practice. Quoted the variables as you always should unless you have a specific need to remove them, see https://mywiki.wooledge.org/Quotes. Got rid of loopSwitch as it meant almost exactly the same thing as playAgain and then renamed playAgain to keepPlaying so it made slightly more sense for the first loop iteration too. Defined a variable to hold the target number instead of hard-coding it in the comparison for ease of future maintenance/enhancements (e.g. if y…
type: Answer
score: 0

http://stackoverflow.com/comment/137845195
type: QuestionComment
comment on: http://stackoverflow.com/q/78188914
type: Comment
has text: See [Bash Pitfalls #35 (if \[\[ $foo =~ 'some RE' \]\])](https://mywiki.wooledge.org/BashPitfalls#if_.5B.5B_.24foo_.3D.2BAH4_.27some_RE.27_.5D.5D) and [bash regex with quotes?](https://stackoverflow.com/q/218156/4154375).
score: 0

http://stackoverflow.com/comment/137854787
type: QuestionComment
type: Comment
has text: Copy/paste your code into https://shellcheck.net and fix any flagged errors. If that doesn't resolve your problem, then update your question and indicate "approved by shellcheck" or similar. If it DOES resolve your problem, then delete your qusetion as it was really just a typo. Good luck.
comment on: http://stackoverflow.com/q/78192103
score: 0

http://stackoverflow.com/comment/137957638
score: 0
has text: Since `errexit` can easily, and even accidentally, be disabled for code where it was previously working, it can't be depended on for dealing with errors, ever. Code that is truly reliable and robust needs to check explicitly for errors. `if cmd; then ...` is sometimes the best way to do it. In the common case where you want to exit the program immediately after detecting an error it's very useful to have a "die" utility function. (See [BashFAQ/101 - Common utility functions (warn, die)](https://mywiki.wooledge.org/BashFAQ/101).) You can then write code like `cmd || die "cmd failed ..."`.
comment on: http://stackoverflow.com/q/78252458
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137843785
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78188212
has text: Another Bash alternative for the last line using parameter expansion: `declare -p "${!var_@}"`

http://stackoverflow.com/q/78240155
has title: How to use a loop to chain piped commands together?
type: Question
has comment: http://stackoverflow.com/comment/137937128
has answer: http://stackoverflow.com/a/78241429
score: 1
linked to: http://stackoverflow.com/q/18125731
favorite count: 0
has answer: http://stackoverflow.com/a/78242889
linked to: http://stackoverflow.com/q/17529220
has answer: http://stackoverflow.com/a/78240193
accepted answer: http://stackoverflow.com/a/78241429
linked to: http://stackoverflow.com/q/9898939
possible better answer: http://stackoverflow.com/a/78240193
downvote count: 0
tagged with: bash
has body: I would like to write a function with a loop to construct the command: cat example.txt | sed ′s/A/1//' | sed ′s/B/2//' | sed ′s/C/3//' | sed ′s/D/4//' ... while taking in a string of A B C D. example.txt A B C D Here is what I have come up with so far but I do not know the syntax to chain piped commands together. I was thinking that I could use echo to construct the string version of the command and then execute it that way but I am wondering if there is a better way to do this. elements="A B C D" n=1 for i in $elements ; do cat example.txt | sed "s/$i/$n/g" n=$(($n+1)) done The output makes sense given the commands that I have generated: cat example.txt | sed "s/A/1/g" cat example.txt | sed "s/B/2/g" cat example.txt | sed "s/C/3/g" cat example.txt | sed "s/D/4/g" but as stated above I would like to "chain" pipe them together.
upvote count: 1
type: AnsweredQuestion
answer count: 3
tagged with: sed
has comment: http://stackoverflow.com/comment/137935584

http://stackoverflow.com/q/78192206
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137851090
tagged with: shell
has comment: http://stackoverflow.com/comment/137850808
linked to: http://stackoverflow.com/q/3765304
has comment: http://stackoverflow.com/comment/137850918
has answer: http://stackoverflow.com/a/78193474
answer count: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/137851159
has comment: http://stackoverflow.com/comment/137851034
has title: How do I use the Linux PAM module in a custom script?
has comment: http://stackoverflow.com/comment/137851944
has body: I'm working on a program that would value from using the built in PAM module of linux, for authentication and verifying user entered credentials. I've been trying to research how it's implemented, however much documentation I find is old and usually deleted, and I have trouble finding many examples of it being used in a casual script. Can someone help me understand how PAM would be used with a custom script, specifically to pass a username and password for authentication, and maybe point me to documentation on how to use it?
tagged with: linux
tagged with: pam
tagged with: bash
favorite count: 0
downvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137852293
accepted answer: http://stackoverflow.com/a/78193474

http://stackoverflow.com/comment/137886811
comment on: http://stackoverflow.com/q/78212759
has text: Bash (and similar languages) and cybersecurity are not compatible things. Almost all Bash programs start with a line that means the caller can make them do anything by just setting an environment variable, and then get worse from there. It is very difficult to write shell programs that will not do something bad when they encounter slightly unusual inputs. Explicit `eval` is bad, but Bash has at least 10 features that `eval` input data internally. Writing shell programs that cannot be subverted by knowledgeable users (co-workers, fellow students, attackers, ...) is effectively impossible.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137821750
score: 1
type: QuestionComment
has text: `awk $1 ...` - that `$1` will be the first argument to the _bash_ function you are in and not the first column in `numbers.txt`.
type: Comment
comment on: http://stackoverflow.com/q/78176347

http://stackoverflow.com/comment/137853607
has text: following you suggestion, @EdMorton, i concatenated down but when i run it, i get an `Unterminated quoted string` error. here's the snippet: `commandSQL = "sqlite3 -noheader -separator \" \" " /path/to/db " \"update pulseCount set pulses=\"" if (DIN1 == "1") system(commandSQL ++TICKCOUNT "\";")`
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193
type: Comment

http://stackoverflow.com/a/78225303
downvote count: 0
score: 3
type: AcceptedAnswer
upvote count: 3
answers question: http://stackoverflow.com/q/78225038
has body: If you run with strace: $ strace -fe execve bash -c 'exec -a fake ./test.sh' execve("/usr/bin/bash", ["bash", "-c", "exec -a fake ./test.sh"], 0x7ffd9c557aa0 /* 56 vars */) = 0 execve("/home/xxx/test.sh", ["fake"], 0x58fc3a91a130 /* 56 vars */) = 0 # /home/xxx/test.sh # you will notice that "fake" is passed as zeroth argument, it's just shell overrides $0 with script name indeed, as @oguz pointed out, this is the special case of interpreter scripts handling by exec commands. Compare with the same shell script but without #!/bin/bash : $ strace -fe execve bash -c 'exec -a fake ./test.sh' execve("/usr/bin/ksh", ["ksh", "-c", "exec -a fake ./test.sh"], 0x7fff79964a40 /* 56 vars */) = 0 execve("/home/xxx/test.sh", ["fake"], 0x5fbe079d0b08 /* 57 vars */) = -1 ENOEXEC (Exec format error) # fake #
has comment: http://stackoverflow.com/comment/137908835
has comment: http://stackoverflow.com/comment/137909178
has comment: http://stackoverflow.com/comment/137908964
type: Answer
has comment: http://stackoverflow.com/comment/137909060
accepted answer of: http://stackoverflow.com/q/78225038

http://stackoverflow.com/comment/137935584
type: Comment
comment on: http://stackoverflow.com/q/78240155
has text: BTW, it's very deliberate that my answer isn't using `cat`. Using `cat file` results in the component to the right of it in a pipeline getting a FIFO that it can only read once, front-to-back. For some programs this forces them to be _very_ inefficient compared to getting a real file descriptor -- for example, if you give `sort` a real FD it can split up into threads and have each one process a piece of the file in parallel; if you give `tail` a real FD it can skip straight to the end no matter how long it is, etc
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137777374
type: Comment
comment on: http://stackoverflow.com/q/78150653
has text: Personally, I'd probably fix this by passing options to `more` through the environment. For example, `MORE=e` tells it not to wait for the user to press `q` after it hit end-of-file, `LINES` can be set to tell it how long to treat the terminal as being, &c.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138038527
score: 1
comment on: http://stackoverflow.com/q/78298936
has text: https://stackoverflow.com/questions/60626955/why-bash-background-task-ignores-sigint wow
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78301325
accepted answer: http://stackoverflow.com/a/78301430
linked to: http://stackoverflow.com/q/50340829
score: 1
upvote count: 1
answer count: 1
favorite count: 0
tagged with: http://stackoverflow.com/tag/csv
tagged with: gnu
type: AnsweredQuestion
downvote count: 0
tagged with: gnuplot
tagged with: bash
has body: I want to adjust the x axis format whilst using a csv file to load my data. The script below does not work with the associated data. min_example.csv 12-03 17:40:54,6 12-03 18:40:54,5 12-03 19:40:54,9 set datafile separator "," set xdata time set timefmt "%d-%m %H:%M:%S" set format x "%d %H" plot 'min_example.csv' using 1:2:xtic(1) The output is still in the "%d-%m %H:%M:%S" format. Many thanks! When using a dataset with more data (e.g., 12/4) it still sorts correctly by date and time, but I can't modify anything else. The xtics are an explicit list. I already checked that the "space" character is not a \t; it is definietly a space.
type: Question
has title: Cannot change date format in gnuplot
has answer: http://stackoverflow.com/a/78301430

http://stackoverflow.com/comment/137804709
type: QuestionComment
score: 2
type: Comment
has text: The `find` variant would fail on files with linefeeds in their name. Why not simply `for file in *"${filter}"* ; do gunzip "${file}" ; done`?
comment on: http://stackoverflow.com/q/78166538

http://stackoverflow.com/a/78279493
score: 1
upvote count: 1
type: Answer
has body: You can Put this into .bashrc: alias myclip="xsel -b" and write this example command: ls | myclip
answers question: http://stackoverflow.com/q/78278159
downvote count: 0

http://stackoverflow.com/a/78155222
downvote count: 0
type: AcceptedAnswer
has body: I know a trick $ unset x $ echo &quot;${x:-${_/*/~}}&quot; /home/oguz but you should just use $HOME.
has comment: http://stackoverflow.com/comment/137785042
answers question: http://stackoverflow.com/q/78154583
has comment: http://stackoverflow.com/comment/137789551
has comment: http://stackoverflow.com/comment/137784938
type: Answer
has comment: http://stackoverflow.com/comment/137789705
score: 3
accepted answer of: http://stackoverflow.com/q/78154583
upvote count: 3

http://stackoverflow.com/a/78214709
score: 0
has body: Firstly, I must note that working with JSON objects like so grep $1 /file/path/courses.jsonl | awk -F ',' '{print $1}' | awk -F ':' '{print $2}' is extremely fragile and happens to work due to order inside JSON object, meanwhile according to RFC 8259 An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array. therefore following two {"id":123,"name":"somename"} {"name":"somename","id":123} are equivalent but would give different result if you would shove it into | awk -F ',' '{print $1}' | awk -F ':' '{print $2}' You might use tools for dealing with JSON like jq to lessen fragility, consider that echo -e '{"id":123,"name":"somename"} {"name":"somename","id":123}' | jq '.id' gives output 123 123 Now you have one id per line, your mmid.py might be altered to take ids from standard input following way import struct import hashlib import hmac import sys for line in sys.stdin: idno = int(line) key = hashlib.md5(b"9f2b4678").digest() data = struct.pack("<Q", idno) checksum = hmac.HMAC(key, data, 'md5').digest() checksum = checksum[3:1:-1].hex().upper() idstring = str.upper(hex(idno))[2:] for y in range(8 - len(idstring)): idstring = '0' + str(idstring) code = str(checksum) + '0000' + str(idstring) print(code) and then you might assemble whole thing as follows, let courses.jsonl content be {"id":69558108,"retrieval_date":"2021-06-05T08:04:59.154776Z","url":"https://d2sno3mhmk1ekx.cloudfront.net/10.WUP_AMAJ_datastore/ds/1/data/00069558108-00001?Expires=1625472299&Signature=BqxLU18d~4rV4FeHNN-Sm2dbKqKyLhS5qX2liHPqr3MN9Y0Fgt5GCYCXrseFt-tinj4LVjrtMIWZW4G1ijj4FSHQyXN9OoW3PfyZbSuatl9~aNHLPtCCBfMDm7HmF~Njry1pvFjvmeMTJf4ZlUTrKIJF00gfA~2Mu2K1qjIR4yqSQCyxsxG61J~KG3CQMVJUKnbdGupeHN5-nigDqZ3EbT3-odEmjJsq04wb8K98iNMVHKINg8MZwuWHtEtECGWWqvhAvkdRDj6ZZQxAPW1fwxkLJBY4PSRW28A20T-lcq0CDDeU4yFUzeeE6GqFV0xvwj2IOFrlWVOo3McmE21HqA__&Key-Pair-Id=APKAJUYKVK3BE6ZPNZBQ","stars":1,"course_name":"hell…
answers question: http://stackoverflow.com/q/78212116
type: Answer

http://stackoverflow.com/comment/137997530
score: 1
type: Comment
comment on: http://stackoverflow.com/a/78275140
type: AnswerComment
has text: In replacement only `&` has special meaning but in the search regex there can be many like `., *, +, [, ], (, )` etc

http://stackoverflow.com/comment/137988092
type: Comment
comment on: http://stackoverflow.com/q/78269359
has text: Your "shell expansion pattern" is conventionally spelled *pattern* or *shell pattern* or *glob*. The last is probably clearest, but the first is the one used in the specifcations for the POSIX shell language. "globstar" is the name of a Bash (and maybe other-shell) option that affects glob semantics.
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137908346
comment on: http://stackoverflow.com/q/78224990
type: QuestionComment
score: 0
type: Comment
has text: I'm hardly an expert, but have you made sure that the path `"$Wallpaper_Dir'$chosen'"` actually does exist and point to an image? Cause I can imagine that `"~/.config/hypr/Wallpapers/'Wallpaper.png'"` might be kinda hard to find. Try getting rid of the single quotes around `$chosen` and see if that helps.

autotools
tag name: autotools
tags question: http://stackoverflow.com/q/78274675
type: Tag
tags question: http://stackoverflow.com/q/78276793

http://stackoverflow.com/comment/138052431
score: 2
type: Comment
type: QuestionComment
has text: If the carriage returns are actually coming from `jq` (not something else, like the script itself), *and* you are actually using bash (not some other shell), you can use `while IFS=$'\r' read cratePath...` (see my answer [here](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings/67611850#67611850)). Also, be sure to double-quote all variable references (e.g. `echo "$input"` instead of `echo $input`) -- [shellcheck.net](https://www.shellcheck.net) is good at spotting common mistakes like this.
comment on: http://stackoverflow.com/q/78306525

http://stackoverflow.com/comment/137804681
comment on: http://stackoverflow.com/q/78166538
type: QuestionComment
score: 2
has text: The first pipes the filename to `gunzip`’s STDIN, the second gives it as an argument. Why _would_ they do the same? Also, [don’t use `ls` like that](http://mywiki.wooledge.org/ParsingLs) .
type: Comment

http://stackoverflow.com/comment/137822527
type: Comment
comment on: http://stackoverflow.com/q/78176347
has text: @Ed Morton so would you know of the right solution will call awk once to do all of the calculations and text manipulation. if it helps the file numbers could be anything I guess as long as the terminal sends back the full line(s) with the number that are less than or equal to user input between 200 and 400
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137864498
score: 1
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78200064
has text: Alternatively `[[ $file =~ .*/([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2}) ]]` to just prepend the regexp with `.*/` to match the directory path.

http://stackoverflow.com/comment/137959477
type: Comment
comment on: http://stackoverflow.com/q/78253800
score: 4
type: QuestionComment
has text: Why are you escaping the `$` (i.e `\$container_name`) ?

http://stackoverflow.com/comment/137773000
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78148060
has text: @gambarimas87, my bad on the `awk` command. The original version used incorrect quoting. I have replaced it with a corrected (but necessarily uglier) version.
type: Comment

http://stackoverflow.com/comment/137803138
comment on: http://stackoverflow.com/q/78163062
type: QuestionComment
type: Comment
score: 0
has text: So basically you are looking for files with the same name in two directories? If you can guarantee that you never have files where the name contains a newline character, you could create two sorted text files holding the names in thos two directories, and then use `comm` to find the common entries. See _man comm_.

http://stackoverflow.com/comment/137931117
type: Comment
has text: Didn't try it myself, but from https://en.wikipedia.org/wiki/ANSI_escape_code, I would conclude that _ESC [ m_ would turn off colouring. See the section about "SGR parameters" in that wiki.
comment on: http://stackoverflow.com/q/78235520
score: 0
type: QuestionComment

http://stackoverflow.com/a/78173289
has comment: http://stackoverflow.com/comment/137816535
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137816516
accepted answer of: http://stackoverflow.com/q/78173269
has body: you can use the printf function using the parameter "%c" that treats the input as a single character. Easy solution: Pipe the output to the inverse function. echo "hello" | od -An -td1 -v -w1 | awk '{ printf "%c", $1 }' awk receives the piped information in the first column with ASCII value and sends it as input for the print function.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78173269

http://stackoverflow.com/a/78254659
score: -1
has comment: http://stackoverflow.com/comment/137960777
downvote count: 1
answers question: http://stackoverflow.com/q/78254419
upvote count: 0
has body: this is my small attempt and it may not be effective. I omitted some errors, just hoping for reference value. package main import ( "bufio" "fmt" "os" "os/exec" "sync" "time" ) func main() { // Initialize the ticker to trigger every minute ticker := time.NewTicker(time.Minute / 10) defer ticker.Stop() // Create a channel to receive ticker events tickerCh := ticker.C logFolderPath := "./log/" tmpFile, _ := os.CreateTemp("", "tmp_example") defer tmpFile.Close() // Commands to execute sequentially cmd := exec.Command("sh", "-c", "./ledplayer") cmd.Stdout = tmpFile cmd.Stderr = tmpFile // Start the command err := cmd.Start() if err != nil { fmt.Println("Error:", err) return } cmdStopCh := make(chan int) wg := sync.WaitGroup{} wg.Add(2) go func() { defer wg.Done() // Wait for the command to finish before exiting err = cmd.Wait() if err != nil { fmt.Println("Error waiting for command to finish:", err) } // Notification End cmdStopCh <- 1 }() scanner := bufio.NewScanner(tmpFile) go func() { defer wg.Done() for { // Create new log file filename := generateFilename() logFile, err := os.OpenFile(logFolderPath+filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { fmt.Println("Error opening log file:", err) return } // Read from scanner and write to logFile for scanner.Scan() { logFile.WriteString(scanner.Text() + "\n") select { case <-tickerCh: // switch to new log file break case <-cmdStopCh: // cmd is exited logFile.Close() return default: } } logFile.Close() } }() wg.Wait() } func generateFilename() string { // Generate filename with the current date and time return time.Now().Format("2006-01-02_15-04_05") + "_ledplayer.log" }
type: Answer

http://stackoverflow.com/q/78261051
answer count: 1
upvote count: 1
score: -1
has answer: http://stackoverflow.com/a/78261076
has body: I am writing a bash script and I wrote a if clause to check the existence of multiple files. The clause I used is - if -f /home/step/certs/root_ca.crt &amp;&amp; -f /home/step/certs/intermediate_ca.crt &amp;&amp; -f /home/step/secrets/root_ca_key &amp;&amp; -f /home/step/secrets/intermediate_ca_key &amp;&amp; -f /home/step/config/ca.json &amp;&amp; -f /home/step/config/defaults.json; then echo 'Existing Certificate Authority found!\nUsing the existing certificate authority...' It is giving this error - syntax error in conditional expression: unexpected token `;' I tried removing the ; and got another syntax error - syntax error in conditional expression What is the correct syntax for checking if multiple files exist?
tagged with: linux
tagged with: bash
accepted answer: http://stackoverflow.com/a/78261076
favorite count: 0
linked to: http://stackoverflow.com/q/9581064
type: AnsweredQuestion
downvote count: 2
type: Question
has comment: http://stackoverflow.com/comment/137975346
tagged with: shell
has title: What is the mistake in this shell script using if block?

http://stackoverflow.com/comment/137847078
score: 1
has text: (The other advantage of Go in this context is that it builds static executables; as long as you compile your code without CGo, you'll have no problem targeting an embedded device even if it doesn't use glibc; see https://github.com/glebarez/go-sqlite for a pure-Go sqlite library that doesn't require CGo)
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193
type: Comment

http://stackoverflow.com/a/78157136
has comment: http://stackoverflow.com/comment/137790564
type: Answer
has comment: http://stackoverflow.com/comment/137790462
downvote count: 0
has comment: http://stackoverflow.com/comment/137790317
has comment: http://stackoverflow.com/comment/137790130
answers question: http://stackoverflow.com/q/78154583
has comment: http://stackoverflow.com/comment/137789555
score: 2
has body: This seems to be portable across all the POSIX shells I can get my hands on: $ HOME="tilde expansion is protected against splitting" $ unset x $ echo "${x:-$(printf '%s' ~/)}" tilde expansion is protected against splitting/ but you should just use $HOME.
upvote count: 2

http://stackoverflow.com/a/78166645
has comment: http://stackoverflow.com/comment/137813112
downvote count: 1
answers question: http://stackoverflow.com/q/78166553
score: 0
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/137810615
has body: You can use the --build-arg argument with docker build export RELEASE_TAG=$(git describe --tags --always) docker build --build-arg RELEASE_TAG=$RELEASE_TAG -t your_image_name . And inside your Dockerfile: FROM node:20-alpine ARG RELEASE_TAG That way, RELEASE_TAG will now have the value of git describe --tags --always output.

http://stackoverflow.com/comment/137865577
type: QuestionComment
type: Comment
has text: It seems like the part you say you're not sure of is the whole point of the exercise.
score: 0
comment on: http://stackoverflow.com/q/78200978

http://stackoverflow.com/comment/137858143
has text: @pmf This doesn't work because it should remove all b's etc. from the results.. Also you do not account for location of the input ... anyway this must be a homework assignment it seems like a useless way to handle input args lol
type: AnswerComment
comment on: http://stackoverflow.com/a/78196126
score: 0
type: Comment

http://stackoverflow.com/a/78212599
type: Answer
accepted answer of: http://stackoverflow.com/q/78212116
score: 3
type: AcceptedAnswer
upvote count: 3
answers question: http://stackoverflow.com/q/78212116
downvote count: 0
has body: Do it entirely within python: EDIT: Now with matching course_name import hashlib import hmac import jsonlines import re import struct import sys course_name = str(sys.argv[1]) idno = -1 reader = jsonlines.Reader(sys.stdin) for obj in reader: if re.search(course_name, obj["course_name"]): idno = int(obj["id"]) break if idno > -1: key = hashlib.md5(b"9f2b4678").digest() data = struct.pack("<Q", idno) checksum = hmac.HMAC(key, data, "md5").digest() checksum = checksum[3:1:-1].hex().upper() idstring = str.upper(hex(idno))[2:] for y in range(8 - len(idstring)): idstring = "0" + str(idstring) code = str(checksum) + "0000" + str(idstring) print(code) else: print("Cannot match course_name: %s\n" % course_name) Usage example: $ ./bin/python3 ./mmid.py kitty < ./courses.jsonl 7AC9000004255F5C

http://stackoverflow.com/comment/137860913
type: AnswerComment
has text: @markp-fuso, not 100% sure what you mean here. Sorry.... rather than see var_1="1234", var_2="5678", var_3="9876" etc etc it returns as var_1="2345", var_2="2345", var_3="2345"... The 'list' will always be constructed from a string which is made up of multiples of 4 characters. My need is to assign each block of 4 characters to a variable, then these variables can be used further along in the script in order to convert the blocks from hex to decimal for the users to check..
comment on: http://stackoverflow.com/a/78188212
type: Comment
score: 0

http://stackoverflow.com/comment/137813010
type: Comment
comment on: http://stackoverflow.com/q/78170444
score: 0
has text: `awk -F, '{print $2}' <<< "$time" | while read secs; do date -d @$secs; done`
type: QuestionComment

http://stackoverflow.com/q/78231603
score: 0
has answer: http://stackoverflow.com/a/78231634
has body: In my .bashrc file I have the following: export USER_HOME1='/home/$(id -nu)/' export USER_HOME2='/home/'$(id -nu)'/' export USER_HOME3=&quot;/home/$(id -nu)/&quot; export USER_HOME4=&quot;/home/\$(id -nu)/&quot; Command substitution only works for USER_HOME2 and USER_HOME3. How does it work for USER_HOME2? Within single quotes, the '$' is treated as a literal character instead of taking on any special meaning. Within double quotes, certain characters take on special meaning and require escaping if we need to use them literally. This would explain why command substitution works in USER_HOME3 but not in USER_HOME1 and USER_HOME4. How does USER_HOME2 work? How does the shell know how to pair up the single quotes? Does it effectively concatenate three strings: '/home/', the output of $(id -nu), and '/'? In which case, we can rewrite USER_HOME2 as export USER_HOME2=/home/$(id -nu)/
type: Question
has title: Why does command substitution work in these ways?
tagged with: shell
answer count: 1
tagged with: command-line
has comment: http://stackoverflow.com/comment/137920361
tagged with: bash
accepted answer: http://stackoverflow.com/a/78231634
has comment: http://stackoverflow.com/comment/137920497
type: AnsweredQuestion

http://stackoverflow.com/a/78290274
score: 0
has body: Working version: copyclip(){ cmd=$(history 1 | sed 's/^ *[0-9]* *//' | sed 's/|.*//'); output=$(cat); echo "\$ "$cmd$'\n'"$output" | xclip -sel clipboard; echo "$output"; }
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78278159
accepted answer of: http://stackoverflow.com/q/78278159
type: Answer

http://stackoverflow.com/comment/137829950
type: Comment
comment on: http://stackoverflow.com/q/78180816
score: 0
has text: @topsail I know what conda is and what Python virtual environments are. I will remove the python venv altogether. I'm just looking to understanding the behaviour.
type: QuestionComment

http://stackoverflow.com/q/78238193
answer count: 1
tagged with: bitbucket-pipelines
tagged with: sh
score: 0
tagged with: bitbucket
tagged with: bash
has body: This is a part of my Bitbucket pipeline: npm_audit: &npm_audit echo "Running npm audit..." npm_audit_output=$(npm audit --audit-level=critical) if [ $? -ne 0 ]; then echo "Critical vulnerabilities found. They must be fixed manually:" exit 1 fi npm_audit_output=$(npm audit) if [ $? -ne 0 ]; then echo "Non-critical vulnerabilities found." echo "$npm_audit_output" echo "Attempting to fix..." npm audit fix else echo "No vulnerabilities found." fi later called like: - step: ... script: - *npm_audit BB returns: + echo "Running npm audit..." npm_audit_output=$(npm audit --audit-level=critical) if [ $? -ne 0 ]; then echo "Critical vulnerabilities found. They must be fixed manually:" exit 1 fi npm_audit_output=$(npm audit) if [ $? -ne 0 ]; then echo "Non-critical vulnerabilities found." echo "$npm_audit_output" echo "Attempting to fix..." npm audit fix else echo "No vulnerabilities found." fi bash: bashScript5261110360543614450.sh: line 5: syntax error near unexpected token `then' Why is there a syntax error? ShellCheck is green And why is the whole script echoed instead of just strings I asked for?
has comment: http://stackoverflow.com/comment/137931788
accepted answer: http://stackoverflow.com/a/78239876
has title: Syntax error in Bash script inlined in YAML anchor for Bitbucket Pipelines
type: Question
has answer: http://stackoverflow.com/a/78239876
type: AnsweredQuestion

loops
tag name: loops
tags question: http://stackoverflow.com/q/78241899
type: Tag
tags question: http://stackoverflow.com/q/78200978
tags question: http://stackoverflow.com/q/78422072
tags question: http://stackoverflow.com/q/78371799
tags question: http://stackoverflow.com/q/78579093
tags question: http://stackoverflow.com/q/78462933
tags question: http://stackoverflow.com/q/78479842
tags question: http://stackoverflow.com/q/78687148
tags question: http://stackoverflow.com/q/78591583
tags question: http://stackoverflow.com/q/78626809
tags question: http://stackoverflow.com/q/78731380
tags question: http://stackoverflow.com/q/78759826
tags question: http://stackoverflow.com/q/78777635
tags question: http://stackoverflow.com/q/78957162
tags question: http://stackoverflow.com/q/79048675
tags question: http://stackoverflow.com/q/78975695
tags question: http://stackoverflow.com/q/78948987
tags question: http://stackoverflow.com/q/78958663
tags question: http://stackoverflow.com/q/78952087
tags question: http://stackoverflow.com/q/79111022
tags question: http://stackoverflow.com/q/79224627
tags question: http://stackoverflow.com/q/79151092
tags question: http://stackoverflow.com/q/79301328
tags question: http://stackoverflow.com/q/79299247
tags question: http://stackoverflow.com/q/79374871
tags question: http://stackoverflow.com/q/79507705
tags question: http://stackoverflow.com/q/79526480
tags question: http://stackoverflow.com/q/79492218

http://stackoverflow.com/comment/137784366
type: QuestionComment
score: 0
has text: @jhnc Clever. But again, I'm sorry for my amnesia. I meant "without introducing temporary variables".
type: Comment
comment on: http://stackoverflow.com/q/78154583

http://stackoverflow.com/comment/138038649
has text: @CharlesDuffy i do get: `declare -x PGPASSWORD="postgrespw"`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78298036
score: 1

http://stackoverflow.com/a/78288077
upvote count: 3
score: 3
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78274675
has body: All those error messages are generated by the shell code in configure which AC_OUTPUT expands to. There is nothing you can get wrong about writing AC_OUTPUT on a line by itself, so there is something wrong in the macros which happen before AC_OUTPUT and which set up things for AC_OUTPUT, both in the sh and in the m4 realm. As a general remark, the configure.ac uses an uncommon sequence of events, and is a bit weird in other ways as well. The specific weirdness which breaks things for you turns out to be the multiple lines in configure.ac which contain LT_INIT, some of which have the win32-dll argument some do not: The LT_INIT macro is only expanded into shell code the first time it appears in configure.ac and all subsequent LT_INIT macro invocations are substituted by no shell code at all. So unless the first LT_INIT in the first case branch runs, no libtool related shell variables will be set, and the libtool shell code produced by AC_OUTPUT which relies on those variables will fail. The fix on your side is easy: Just put one LT_INIT([win32-dll]) inside configure.ac, outside of all if or case conditionals. On libtool's side, they could have LT_INIT produce an autoreconf time error message instead of expanding LT_INIT to an empty string, but that does not help you right now. Here is OP's github issue for this question, and my github pull request with a fix. How did I find this? I put a bunch of echo AAAAAAAAAAAAAA and echo BBBBBBBBBBB lines into multiple places in configure.ac. The problem happened after the line which I put just before AC_OUTPUT and before the line which I put after AC_OUTPUT. I restored configure.ac using git and I commented out AC_OUTPUT by adding dnl at the beginning of the AC_OUTPUT line. That confirmed the location where the problem occurred. I restored configure.ac using git and commented out just about everything after AC_CANONICAL_HOST and before AC_OUTPUT with the exception of the AM_CONDITIONAL lines. This got rid of the problem. I then s…
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/78274675

http://stackoverflow.com/comment/137832840
comment on: http://stackoverflow.com/q/78182539
score: 0
has text: What encoding does your text file and your shell script use? We can’t tell you the correct encoding without seeing (a representative, ideally small sample of) the actual contents of the data in an unambiguous representation; a hex dump of the problematic byte(s) with a few bytes of context on each side is often enough, especially if you can tell us what you think those bytes are supposed to represent. See also https://meta.stackoverflow.com/questions/379403/problematic-questions-about-decoding-errors
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137912334
has text: @GillesQuénot I added an 'x' to the first line just to make sure that the ELSE was working.
type: QuestionComment
comment on: http://stackoverflow.com/q/78216881
type: Comment
score: 1

http://stackoverflow.com/comment/137888142
comment on: http://stackoverflow.com/q/78212724
type: QuestionComment
type: Comment
score: 1
has text: You're using the wrong tool. Using a Bash script to parse and modify HTML is guaranteed to produce incorrect results other than for trivial cases. Beyond that observation, your question is incoherent -- even allowing for the fact that English is obviously not your native language.

http://stackoverflow.com/comment/137921693
score: 0
type: QuestionComment
has text: You also don't need to use `rm`. Simply open `temp.txt` for writing in the `while` command body using a specific file descriptor and then use `echo ... >&<the_file_descriptor>`. Also look for topics about it.
type: Comment
comment on: http://stackoverflow.com/q/78232246

http://stackoverflow.com/a/78147054
answers question: http://stackoverflow.com/q/78146721
score: 0
type: Answer
has body: This presumes to work: while IFS= read -r pattern; do # Check if the filename matches the pattern using fnmatch if "$(basename "$filename1")" == $pattern ; then included=true echo "Filename $(basename "$filename1") matched pattern $pattern in MANIFEST" break fi done < <(grep -v '^#' "$MANIFEST_FILE") Simply by using "==" but I don't understand why. Does UNIX automatically compares string with globs? UPDATE/EXPLANATION The == operator in Bash's conditional expressions ([[ ... ]]) supports pattern matching, including glob patterns. This is not native to Unix but is a feature provided by Bash itself. When you use == within [[ ... ]], Bash treats the right-hand side of the comparison as a pattern if it contains wildcard characters like * or ?. This behavior allows you to perform pattern matching directly in conditional expressions without needing additional commands or functions. In your case, when you compare $(basename "$filename1") with $pattern using ==, Bash recognizes $pattern as a glob pattern due to the presence of the * character, and it performs pattern matching accordingly. This allows you to match filenames against glob patterns directly in your script without needing to resort to external tools or functions.

http://stackoverflow.com/a/78299434
type: Answer
answers question: http://stackoverflow.com/q/78299332
has comment: http://stackoverflow.com/comment/138039534
score: 2
has body: Answering my own question. The solution provided here also covers my example. So wrapper.sh would look like this: #!/usr/bin/env bash if (( $# == 0 )); then python3 -m example -h else python3 -m example &quot;$@&quot; fi
upvote count: 2
downvote count: 0

http://stackoverflow.com/a/78261291
answers question: http://stackoverflow.com/q/78261247
has comment: http://stackoverflow.com/comment/137972372
type: Answer
has body: Here is a simple working script (just tested and without awk): #!/bin/bash function process_cluster { input_file=$1 current_cluster="" data_rows=0 while read -r line; do if [[ $line == ">Cluster "* ]]; then if $data_rows -gt 1 ; then echo -e "$current_cluster" fi current_cluster="$line" data_rows=0 else ((data_rows++)) current_cluster="$current_cluster\n$line" fi done < $input_file if $data_rows -gt 1 ; then echo -e "$current_cluster" fi } process_cluster clusters.txt > output.txt Remember to save your input data into a file named clusters.txt or change it into the above script.
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/137972055
accepted answer of: http://stackoverflow.com/q/78261247
downvote count: 0
type: AcceptedAnswer

http://stackoverflow.com/comment/137876674
has text: Are the flutter and dart binaries present in /usr/sbin/flutter/bin?
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78207181

http://stackoverflow.com/comment/137876648
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78204135
score: 0
has text: @pjh shopt and variables shouldn't stay set. it's a subshell

http://stackoverflow.com/q/78203984
has comment: http://stackoverflow.com/comment/137875130
has comment: http://stackoverflow.com/comment/137872821
downvote count: 3
has answer: http://stackoverflow.com/a/78204135
has comment: http://stackoverflow.com/comment/137871204
has title: Write a shell script that has a function that displays the number of files in the present working directory, but not subdirectories
tagged with: function
score: -3
tagged with: bash
has body: Write a shell script that consists of a function that displays the number of files in the present working directory, but not subdirectories # Function to count files in the pwd excluding sub directories files_in_pwd() { num_files=$(ls -l | wc -l) | -maxdepth 1 echo "Number of files in the pwd: $num_files" } # Call the function files_in_pwd
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78203990
favorite count: 0
tagged with: subdirectory
answer count: 2
type: Question
upvote count: 0
has comment: http://stackoverflow.com/comment/137875167

http://stackoverflow.com/comment/137908202
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78224799
has text: @oguzismail Thank you so much! This fixed the problem and the code now works. In hindsight it was such a simple oversight, but that seems to be how coding works.

http://stackoverflow.com/comment/137787675
type: AnswerComment
comment on: http://stackoverflow.com/a/78148060
score: 0
has text: `system("./doit.sh '"'"'" $0 "'"'"'")` = `system("./doit.sh \047" $0 "\047")` which IMO is a bit easier on the eyes. Starting a new subshell to call `doit.sh` once per input line would be a pretty slow process though since awk isn't designed to sequence calls to other tools (that's what a shell is for).
type: Comment

http://stackoverflow.com/comment/137975925
comment on: http://stackoverflow.com/q/78261786
score: 0
has text: @frans - you can also show the output to the user by doing program args 2>&1 | tee program.out. This will redirect the output to terminal and also to the file program.out. Also you can redirect the std err/out to different files. You can always write a wrapper where at the end you would ask user to clean up the log file and remove it based on input. e.g in case of error user might want to look at the output. and for normal runs might delete the file.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137938892
comment on: http://stackoverflow.com/a/78241862
has text: I'd vote for @oguz-ismail's answer because it too looks like it should work. Strange issue.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/a/78276584
answers question: http://stackoverflow.com/q/78267465
score: 0
has comment: http://stackoverflow.com/comment/138026307
type: Answer
has comment: http://stackoverflow.com/comment/138141857
has body: Preface You first ask for modifications for a single commit while the question later asks comparing against a remote branch which can be anything from zero to unlimited number of commits. Also you ask about changed lines, however this is impossible for any computer program to determine. Solution With that said, here is what I think you are asking for. If it had been just changes in a single commit you could use git blame $THE_COMMIT -- filename and then filter out only the lines with $THE_COMMIT's sha value. The blame lines contains a line number directly so the next step is just to extract that. For comparing multiple commits then git blame does not work, however there exists a git diff-blame tool that does what the name suggest and could be used in the same way, although you want to use the downstream branch of my fork to have it not print ansi colour formatting in pipes and to support diffing individual files. # NB, the -- before the file name is mandatory. git diff-blame HEAD origin/develop -- .gitlab-ci.yml \ | grep '^ [+-]' \ | cut -d ')' -f1 \ | rev \ | awk '{print $1}' \ | rev # Assuming no &quot;)&quot; in the author name.
has comment: http://stackoverflow.com/comment/138026257

http://stackoverflow.com/q/78192103
type: Question
has title: Bash script that goes trough folder and uses dd
downvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/78192118
upvote count: 1
tagged with: sh
has comment: http://stackoverflow.com/comment/137854787
tagged with: linux
tagged with: bash
type: UnansweredQuestion
score: 1
has body: Hi I am looking to create a script in bash/sh that can do the following Go in to a folder Cycles trough a set of img.xz files and if it finds one of the secified ones uses that to invoke unxz -c (img.xzfile) | dd of=/dev/mmcblk0 bs=4096 status=progress The folder will at least contain 3-5 img.xz What I have now #!bin/bash $img.xz $img.xz2 cd /img/ if ./20240317-1928-postmarketOS-edge-i3wm-0.5-microsoft-surface-rt.img.xz --&gt;$img.xz then unxz -c $img.xz | dd of=/dev/mmcblk0 bs=4096 status=progress else ./20240317-1346-postmarketOS-edge-mate-7-microsoft-surface-rt.img.xz --&gt; $img.xz2 then unxz -c $img.xz2 | dd of=/dev/mmcblk0 bs=4096 status=progress I don't know if this works, hence the question for something like this that can work, or even lists all images in the folder and asks witch one to use by selecting option 1-5 put that in the variable and use the variable in the unxz -c $variable | dd of=/dev/mmcblk0 bs=4096 status=progress to image the to a emmc module build in a device. This script will be run from a USB booted live Linux image with the images in the /img/ folder
favorite count: 0
tagged with: dd

http://stackoverflow.com/comment/137791330
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78158852
has text: Reading your question, I think you may be interested by reading [This answer to *Is bash a programming language?*](https://stackoverflow.com/a/67498861/1765658)
type: QuestionComment

http://stackoverflow.com/comment/137904357
comment on: http://stackoverflow.com/q/78222483
type: Comment
score: 1
has text: What's the script code? Questions must provide a [mcve].
type: QuestionComment

http://stackoverflow.com/comment/138007769
comment on: http://stackoverflow.com/a/78276969
type: Comment
type: AnswerComment
has text: I had never heard of this Decorate-sort-undecorate idiom before. Thanks so much for that great explanation.
score: 1

http://stackoverflow.com/comment/137855911
type: Comment
comment on: http://stackoverflow.com/q/78194973
score: 0
has text: When I said `for interface in /sys/class/net/*; do interface=${interface##*/}; interface = eth* || continue; ...; done`, I meant **exactly** that. No `interfaces=` anything, no `$()` anything; when you go that route, you don't _need_ an interfaces array at all.
type: QuestionComment

http://stackoverflow.com/comment/137975671
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78263189
type: QuestionComment
has text: The standard term for your "EOF multiline string" is *here document* or *heredoc*. Your term is misleading because the "EOF" part is only a convention. You can use any shell word in its place.

git-add
tags question: http://stackoverflow.com/q/78244513
type: Tag
tag name: git-add

http://stackoverflow.com/a/78175811
answers question: http://stackoverflow.com/q/78175779
type: AcceptedAnswer
upvote count: 3
score: 3
type: Answer
accepted answer of: http://stackoverflow.com/q/78175779
downvote count: 0
has body: Refer to the bash manual description of here strings: 3.6.7 Here Strings A variant of here documents, the format is: [n]<<< word The word undergoes tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal. Filename expansion and word splitting are not performed. The result is supplied as a single string, with a newline appended, to the command on its standard input (or file descriptor n if n is specified). Note "with a newline appended". Even if your string starts out empty, it ends up containing at least a newline when used in this fashion. A string or file containing just a newline will be interpreted as one blank line by the while read loop.

http://stackoverflow.com/comment/137822230
type: Comment
has text: do both numbers (1st field, 8th field) have to be between 200 and 400?
comment on: http://stackoverflow.com/q/78176347
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137877830
comment on: http://stackoverflow.com/q/78207789
has text: (also, avoid `seq` -- it's nonstandard, you pay a performance cost to start it, and the shell has builtins that are just as capable as long as you're dealing with integers -- and if you _aren't_ dealing with integers you can't trust seq to behave in a reliable/portable way anyhow, since not all implementations support floating point values)
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137885750
comment on: http://stackoverflow.com/q/78212116
type: Comment
score: 0
has text: i am able to edit mmid.py yes, i will post the current version of it in the post
type: QuestionComment

http://stackoverflow.com/a/78250534
type: AcceptedAnswer
has body: The shell expands the commands before executing them. There are 7 consecutive expansions: brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, word splitting, and pathname expansion (see this section of the bash manual). In your case brace expansion, tilde expansion and arithmetic expansion have no effect because you do not use these features. Before the for loop is executed command substitution replaces the find command with ./? ./*. Because it is enclosed in double quotes the word splitting does not split ./? ./* and filename expansion is skipped. The for command is thus not further transformed before execution. The loop iterates only once with value ./? ./* of variable f. In echo "$f" $f is expanded (parameter expansion) and replaced with the value of variable f. Again, because of the double quotes, word splitting and filename expansion are skipped, the result is printed without further modifications, and you see ./? ./*. In echo $f, $f is also expanded and replaced with the value of f but the expansion continues with word splitting and pathname expansion. Word splitting separates the two words ./? and ./* such that they are treated separately in the next steps. Pathname expansion replaces ./? with the list of all single-character file names in current directory (in your case ./? and ./*) and ./* is replaced with the list of all file names in current directory (in your case ./? and ./*). So, finally what is echoed is ./? ./* ./? ./*.
has comment: http://stackoverflow.com/comment/137953894
downvote count: 0
has comment: http://stackoverflow.com/comment/137953984
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78250385
score: 1
accepted answer of: http://stackoverflow.com/q/78250385

http://stackoverflow.com/comment/137956473
score: 1
type: QuestionComment
has text: @markp-fuso I've edited my question dear markp-fuso, your suggestion was the path to the final solution, I verified it twice, and posted the final and working script at the end of the question. Bravo.
comment on: http://stackoverflow.com/q/78252038
type: Comment

http://stackoverflow.com/comment/137899742
comment on: http://stackoverflow.com/a/78217506
type: Comment
has text: (reposted after minor edit) : Good stuff! But one quibble, In regards to the `:-Nothing..}`, I think "assign" is too strong a word. There is also a syntax of `var=${BITBUCKET_TAG:=Nothing to see here}` which will truly assign that "default" value to the variable. In the case for the O.P. the assignment still happens to `$var`, but `$BITBUCKET_TAG` by itself is still has no value. Look at what happens with just a bare variable, `unset z; echo X${z:-tempDefault}X ; echo X${z}X; echo ${z:=permanentDefault} ; echo X${z}X` ; Good luck to all.
type: AnswerComment
score: 1

http://stackoverflow.com/comment/137872987
score: 0
has text: Do you **need** the exit code of `example`? I would be surprised that a program with such a bizarre behaviour as _example_ would actually set a meaningful exitcode.
comment on: http://stackoverflow.com/q/78203871
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78281380
has body: You can pass it as an environment variable. $ bash_var='dir\t\010\out' $ bash_var=$bash_var awk 'BEGIN { awk_var = ENVIRON["bash_var"]; print awk_var }' dir\t\010\out
answers question: http://stackoverflow.com/q/78281234
has comment: http://stackoverflow.com/comment/138007552
score: 4
upvote count: 4
downvote count: 0
type: Answer

recursive-descent
tags question: http://stackoverflow.com/q/78223744
tag name: recursive-descent
type: Tag

http://stackoverflow.com/comment/137969613
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78255091
has text: Your question is uncler. You write in the title _multiple if condition_, but your `if` has as argument only a signe `[[ ... ]]` statiement, and even this does not make sense. For instance you never execute any `grep` command in your code (as you can see, when you run your script with `set -x` turned on.
score: 0

windows-subsystem-for-linux
tags question: http://stackoverflow.com/q/78146600
type: Tag
tags question: http://stackoverflow.com/q/78146724
tag name: windows-subsystem-for-linux
tags question: http://stackoverflow.com/q/78535188
tags question: http://stackoverflow.com/q/78558314
tags question: http://stackoverflow.com/q/78652215
tags question: http://stackoverflow.com/q/78730034
tags question: http://stackoverflow.com/q/78731726
tags question: http://stackoverflow.com/q/79176541
tags question: http://stackoverflow.com/q/79238784
tags question: http://stackoverflow.com/q/79076493
tags question: http://stackoverflow.com/q/79137206
tags question: http://stackoverflow.com/q/79144100
tags question: http://stackoverflow.com/q/79400353

rtmp
tag name: rtmp
tags question: http://stackoverflow.com/q/78181450
type: Tag

http://stackoverflow.com/a/78272045
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/78261247
has comment: http://stackoverflow.com/comment/138057304
downvote count: 0
has body: With your shown samples Only, please try following in GNU awk. awk -v RS='(^|\n)&gt;' 'RT &amp;&amp; num=split($0,arr,ORS)&gt;2' Input_file
type: Answer

http://stackoverflow.com/comment/137839509
score: 0
has text: @user88888888 Is that because of [my comment](https://stackoverflow.com/questions/78176347/using-awk-how-do-i-find-numbers-in-a-file-between-200-and-400/78176886?noredirect=1#comment137822166_78176634)? That was about `substr()` outputting a string and then trying to use it in a numeric comparison. There's nothing wrong with using `substr()` but if you want to do a numeric comparison on it's output then you have to convert it's output to a number first, e.g. by adding `0`. See https://www.gnu.org/software/gawk/manual/gawk.html#Variable-Typing for types in awk.
comment on: http://stackoverflow.com/a/78176886
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78252129
type: UnansweredQuestion
tagged with: ripgrep
answer count: 1
tagged with: jq
has answer: http://stackoverflow.com/a/78252525
score: -1
upvote count: 0
has title: Run an external command within jq to manipulate each values of a particular key
tagged with: bash
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/137957014
has body: I have a json like [ { &quot;url&quot;: &quot;https://drive.google.com/file/d/1tO-qVknlH0PLK9CblQsyd568ZiptdKff/view?usp=share_link&quot;, &quot;title&quot;: &quot;&amp;#8211; Flexibility&quot; }, { &quot;url&quot;: &quot;https://drive.google.com/open?id=11_sR8X13lmPcvlT3POfMW3044f3wZdra&quot;, &quot;title&quot;: &quot;&amp;#8211; Pronouns&quot; } ] I got it using curl -Lfs &quot;https://motivatedsisters.com/2019/07/08/arabic-review-sr-rahat-basit/&quot; | rg -o '&lt;li&gt;.*?href=&quot;(.*?)&quot;.*?&lt;/a&gt; (.*?)&lt;\/li&gt;' -r '{&quot;url&quot;: &quot;$1&quot;, &quot;title&quot;: &quot;$2&quot;}' | jq -s '.'. I have a command in my machine named unescape_html, a python scipt to unescape the html (replace – with appropriate character). How can I apply this function on each of the titles using jq. For example: I want to run: unescape_html &quot;&amp;#8211; Flexibility&quot; unescape_html &quot;&amp;#8211; Pronouns&quot; The expected output is: [ { &quot;url&quot;: &quot;https://drive.google.com/file/d/1tO-qVknlH0PLK9CblQsyd568ZiptdKff/view?usp=share_link&quot;, &quot;title&quot;: &quot;– Flexibility&quot; }, { &quot;url&quot;: &quot;https://drive.google.com/open?id=11_sR8X13lmPcvlT3POfMW3044f3wZdra&quot;, &quot;title&quot;: &quot;– Pronouns&quot; } ] Update 1: If jq doesn't have that feature, then i am also fine that the command is applied on rg. I mean, can i run unescape_html on $2 on the line: rg -o '&lt;li&gt;.*?href=&quot;(.*?)&quot;.*?&lt;/a&gt; (.*?)&lt;\/li&gt;' -r '{&quot;url&quot;: &quot;$1&quot;, &quot;title&quot;: &quot;$2&quot;}' Any other bash approach to solve this problem is also fine. The point is, i need to run unescape_html on title, so that i get the expected output. Update 2: The following command: curl -Lfs &quot;https://motivatedsisters.com/2019/07/08/arabic-review-sr-rahat-basit/&quot; | rg -o '&lt;li&gt;.*?href=&quot;(.*?)&quot;.*?&lt;/a&gt; (.*?)&lt;\/li&gt;' -r '{&quot;url&quot;: &quot;$1&quot;, &quot;title&quot;: &quot;$2&quot;}' | jq…
has comment: http://stackoverflow.com/comment/137957190
has comment: http://stackoverflow.com/comment/137957166
type: Question

http://stackoverflow.com/comment/137914482
type: QuestionComment
type: Comment
has text: What's the point of "in the background" when you want sequential?
score: 2
comment on: http://stackoverflow.com/q/78228111

http://stackoverflow.com/comment/137939115
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78241862
has text: I'll investigate further. Without sample data, I'm not sure how to adjust.
type: Comment

http://stackoverflow.com/a/78178940
type: Answer
score: 0
has body: You can use a bash function: run() { echo &quot;$@&quot; &quot;$@&quot; } run ls -l /directory/to/check/exists &gt;&gt; validation.log It has the advantage to let you format the command as you like, eg echo &quot;&gt;&gt; $@&quot;.
answers question: http://stackoverflow.com/q/78178702

http://stackoverflow.com/comment/138038587
score: 0
type: QuestionComment
has text: @tjm3772 that was my own PR for my problem. but now that i have the same problem again with Martin, i kind of doubt that its their problem, but rather my problem ;)
type: Comment
comment on: http://stackoverflow.com/q/78298036

http://stackoverflow.com/comment/137784265
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78154583
has text: @jhnc (I previously answered to jhnc that his answer does not count due to being not a simple command). I forgot to mention that the solution must be within one _simple command_.
type: QuestionComment

http://stackoverflow.com/comment/137791200
comment on: http://stackoverflow.com/q/78158725
type: QuestionComment
has text: simple fix: make a subdirectory inside `/tmp` and put the fifo inside that
type: Comment
score: 0

http://stackoverflow.com/comment/137918989
type: QuestionComment
comment on: http://stackoverflow.com/q/78229406
has text: I don't understand your question at all. From what you say: You do a `hello.txt`, but the output you see is different from the output you expect. However, I don't see how you create the file hello.txt, so your question is meaningless - at least to me.
score: 0
type: Comment

http://stackoverflow.com/q/78251094
has comment: http://stackoverflow.com/comment/137954578
has body: I have the following input-file (p) ($inputFile) PING 8.8.8.8 (8.8.8.8): 56 data bytes 11:36:27.996138 64 bytes from 8.8.8.8: icmp_seq=1 ttl=109 time=48.066 ms 11:36:28.991554 64 bytes from 8.8.8.8: icmp_seq=2 ttl=109 time=39.374 ms Request timeout for icmp_seq 3 11:36:31.000927 64 bytes from 8.8.8.8: icmp_seq=4 ttl=109 time=41.830 ms --- 8.8.8.8 ping statistics --- 4 packets transmitted, 3 packets received, 25.0% packet loss round-trip min/avg/max/stddev = 30.542/40.064/54.798/6.720 ms I want another file ($outputFile), based on the input-file, which should have this structure: write 0 if the line contains the word "bytes" write 1 if the line contains the word "timeout" this should give me this 0 0 1 0 I use this bash function-fragment to achieve this while read p; do if echo "$p" | grep 'bytes from'; then echo 0 elif echo "$p" | grep 'timeout'; then echo 1 fi done <$inputFile >>$outputFile What I really get in the $outputFile is 11:36:27.996138 64 bytes from 8.8.8.8: icmp_seq=1 ttl=109 time=48.066 ms 0 11:36:28.991554 64 bytes from 8.8.8.8: icmp_seq=2 ttl=109 time=39.374 ms 0 Request timeout for icmp_seq 3 1 11:36:31.000927 64 bytes from 8.8.8.8: icmp_seq=4 ttl=109 time=41.830 ms 0 How do I get rid of the original lines in the output-file ($outputFile)?
tagged with: macos
has title: MacOS Bash-Script: while read p and echo
score: 0
linked to: http://stackoverflow.com/q/23088439
type: Question
answer count: 0
type: UnansweredQuestion
tagged with: bash
duplicate of: http://stackoverflow.com/q/23088439
upvote count: 1
favorite count: 0
downvote count: 1

http://stackoverflow.com/comment/137832541
comment on: http://stackoverflow.com/q/78182030
type: QuestionComment
score: 0
type: Comment
has text: If it really, really, has to be aliases and not functions, define `alias time="time "` and use that. See https://unix.stackexchange.com/a/25329/187122 for more information.

http://stackoverflow.com/comment/137802667
comment on: http://stackoverflow.com/q/78165163
score: 0
type: QuestionComment
type: Comment
has text: What is desired output for shown input?

http://stackoverflow.com/a/78272713
has body: The simplest approach is to wrap the code in a function and use the local builtin. (Bash uses dynamic local scope, so this has exactly the behavior you describe, of saving the original variable and then restoring it.) If that's not an option for some reason, then: To test if a variable named SOMEVAR is set, you can write e.g. ${SOMEVAR+yes}, which expands to yes if it's set and otherwise to the empty string. (You can save that in a variable named was_SOMEVAR_set, and later write if "$was_SOMEVAR_set" .) If it is set, then of course you can save its value in another variable to restore from later. If it's not set, then you'll use the unset builtin to restore that once you're done.
upvote count: 2
downvote count: 0
type: Answer
score: 2
answers question: http://stackoverflow.com/q/78272610

http://stackoverflow.com/comment/137881298
comment on: http://stackoverflow.com/q/78209376
type: Comment
score: 0
type: QuestionComment
has text: @pjh Thank you! That was a _HUGE_ improvement (< 1 sec, compared to dozens of seconds)!

http://stackoverflow.com/comment/137803089
type: Comment
has text: Write the value you want to pass to the parent process to a file, and read the file in the parent process. I suggest that the parent process passes the file name to your script via an environment variable, so that you avoid concurrency problems.
comment on: http://stackoverflow.com/q/78163771
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137872811
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78204923
has text: It's the same output in bash and zsh. And in fact this are just users; it relates to the content of /etc/passwd. Thanks a lot!
score: 0

http://stackoverflow.com/comment/137939133
score: 1
type: Comment
type: AnswerComment
has text: `equery` unfortunately sends error messages after an empty package entry like this: `* These packages depend on x/y: --- Unmatched removal atom(s) in /etc/portage/profile/package.mask: ...`; causing such packages to also be not included.
comment on: http://stackoverflow.com/a/78242017

http://stackoverflow.com/comment/138031935
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78295010
has text: `{ ps -p "$apid"; echo; } >>pslog.txt` worked! Thanks! Is the lack of space between `>>` and `pslog.txt` also deliberate?
type: QuestionComment

http://stackoverflow.com/comment/137855917
score: 0
has text: where would i add "readarray -t interfaces < <(basename -a /sys/class/net/* | awk '/eth/{print $1}')"
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
type: Comment

http://stackoverflow.com/comment/137854913
comment on: http://stackoverflow.com/q/78194866
type: QuestionComment
type: Comment
score: 0
has text: Hmmm, it stripped out the line breaks making it a lot harder to read

http://stackoverflow.com/q/78158852
has comment: http://stackoverflow.com/comment/137791330
duplicate of: http://stackoverflow.com/q/7950268
tagged with: shell
linked to: http://stackoverflow.com/q/7950268
upvote count: 2
has comment: http://stackoverflow.com/comment/137791467
tagged with: bash
type: UnansweredQuestion
score: 1
answer count: 1
favorite count: 0
tagged with: calculator
downvote count: 1
has body: I saw a code like this that could be run on the bash prompt: bc fibonacci.bc <<< "fibonacci(1)" A function fibonacci(n)is defined in the file fibonacci.bc. The syntax of the function follows bc syntax rules. The redirection symbol <<< looks new to me. Can somebody throw some light on it?
tagged with: bc
has title: Triple input redirection symbol in bash script
has answer: http://stackoverflow.com/a/78158865
linked to: http://stackoverflow.com/q/28693737
type: Question

http://stackoverflow.com/comment/137807878
has text: Hmm, well, and I'm sure you figured this out, I had 'xdd' instead of 'xxd' (I fixed it above). Also, I should have provided the -c 0 option, so the output would be all one line, otherwise the 'sed' might not match if it happened to fall between line breaks. Finally, looks like I also should have provided the -p option to the xxd -r command, otherwise it doesn't output anything. I updated the script above, let me know if you still have the problem.
score: 1
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78155511

http://stackoverflow.com/q/78276793
upvote count: 4
has answer: http://stackoverflow.com/a/78280733
tagged with: autotools
score: 3
answer count: 1
favorite count: 0
has title: How to trace which `configure.ac` m4 macro expands to a specific bash code block in `configure`?
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78280733
linked to: http://stackoverflow.com/q/78274675
tagged with: configure
tagged with: autoconf
tagged with: m4
tagged with: bash
type: Question
downvote count: 1
has body: Following this question, I am working on debugging a legacy build system and need to understand how a specific section of the generated configure script is produced from its configure.ac m4 source. Specifically, I'm trying to trace back the source of the following bash code block in the configure script: _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 As described here. From here, here, and here, I've learned that autoconf and autom4te have a --trace option that could potentially be used to figure out which part of the configure.ac file leads to this generated script section. However, I'm unsure how to effectively use this --trace option for this purpose. Can someone guide me on using the --trace option (or any other method) to pinpoint which m4 macro(s) in configure.ac expand to generate this specific bash code block in the configure script? Any help or insight into this would be greatly appreciated, as it would help me understand and potentially modify the build configuration for this project.

http://stackoverflow.com/comment/137871822
comment on: http://stackoverflow.com/q/78203871
type: QuestionComment
type: Comment
has text: Doesn't sound like a good idea. Try `./example </dev/null && whatever` then.
score: 0

http://stackoverflow.com/comment/137856003
has text: Where is step 2?
comment on: http://stackoverflow.com/q/78195387
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137810228
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78169487
has text: Furthermore, you don't need to know the absolute directory; you can simply use `.` for the current directory. See also [What exactly is current working directory?](https://stackoverflow.com/questions/45591428/what-exactly-is-current-working-directory/66860904)
type: Comment

systemd
tag name: systemd
tags question: http://stackoverflow.com/q/78290118
type: Tag
tags question: http://stackoverflow.com/q/78540680
tags question: http://stackoverflow.com/q/79372220
tags question: http://stackoverflow.com/q/79525280
tags question: http://stackoverflow.com/q/79546408

http://stackoverflow.com/q/78187590
type: Question
has title: creating variables from data after using the fold command
downvote count: 0
type: UnansweredQuestion
tagged with: fold
has comment: http://stackoverflow.com/comment/137842549
has body: My main goal is to set up variables which are taken from a string which can be of various lengths. Each variable must contain 4 digits from the string (ie var_1 = digits 1-4, var_2 = digits 5-8 etc). By using the fold -w4 command I can get the string into blocks of 4. For example: string = 1234567898765432 fold -w4: 1234 5678 9876 5432 Rather than manually create the variables by copying the data, can anyone suggest how I can get Bash to automatically create variables for each block of 4 that is created? I have searched Google and even tried ChatGPT. The suggestion given doesn't seem to work: # Get the length of the input string length=${#input_string} # Loop through the string in steps of 4 characters for (( i=0; i<$length; i+=4 )); do # Extract 4 characters starting from position i substring="${input_string:i:4}" # Create a variable with the extracted substring var_name="var_$((i/4 + 1))" declare "$var_name=$substring" done # Print the created variables echo "Created variables:" declare -p | grep -E '^declare -\w+ var_[0-9]+=' All that happens is I get the "Created variables" written to the terminal.
score: 2
upvote count: 2
tagged with: bash
has comment: http://stackoverflow.com/comment/137842568
has comment: http://stackoverflow.com/comment/137849565
favorite count: 0
has comment: http://stackoverflow.com/comment/137842312
has answer: http://stackoverflow.com/a/78188637
has comment: http://stackoverflow.com/comment/137842542
has comment: http://stackoverflow.com/comment/137842079
has answer: http://stackoverflow.com/a/78188212
answer count: 2

http://stackoverflow.com/a/78235578
accepted answer of: http://stackoverflow.com/q/78235520
downvote count: 0
answers question: http://stackoverflow.com/q/78235520
type: AcceptedAnswer
has body: Try this: printf '%b\033[m%s\n' "$a" "$b"
score: 4
has comment: http://stackoverflow.com/comment/137927591
upvote count: 4
has comment: http://stackoverflow.com/comment/137927586
has comment: http://stackoverflow.com/comment/137927647
type: Answer

http://stackoverflow.com/comment/138025604
has text: (The word "unquoted" is right there in the "If a word begins with an unquoted tilde character" at the beginning of the _Tilde Expansion_ section of the manual).
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78291764

http://stackoverflow.com/comment/137860499
comment on: http://stackoverflow.com/q/78197884
type: QuestionComment
has text: Please explain, why this https://stackoverflow.com/a/532161/7733418 (one of the answers in the proposed duplicate) does not explain what you need to know. I.e. why do you doubt that environment variables are not stored in files, are instead stored in process-specific memory, can be visualised in (virtual) file system in different ways and can be made persistent by resetting them after each restart/reset in automatically executed scripts, like in `~/.bashrc` or `~/.bash_profile`. I am afraid that otherwise (even if this gets reopened) this question will quickly be closed again.
type: Comment
score: 0

http://stackoverflow.com/comment/138002377
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78260557
has text: The concept of "window" doesn't matter here at all. You explicitly ask one bash to define some aliases and then to `exec` another bash. I explained why it doesn't work. In the mean time I believe KamilCuk's solution should work, have you tried that?
type: QuestionComment

http://stackoverflow.com/comment/137953984
score: 0
has text: Because there is only one iteration of the loop, with `f=./? ./*`. So `echo` is executed only once with `"./? ./*"` or `./? ./*`. If you remove the double quotes around the `find` command the command substitution and the pathname expansions will replace it with `./? ./* ./? ./*`, there will be 4 iterations and 4 `echo`. You will see 4 lines with either 1 token each (`echo "$f"`) or 2 tokens each (`echo $f`).
comment on: http://stackoverflow.com/a/78250534
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78212787
downvote count: 0
type: Answer
has body: What I would do using jq: jq -r '"ID: \(.id) Course name: \(.course_name) Creator name: \(.creator.nnid)"' file.json Yields: ID: 66782542 Course name: go Creator name: Khanna1974
upvote count: 2
answers question: http://stackoverflow.com/q/78212759
score: 2

http://stackoverflow.com/comment/137854432
type: Comment
comment on: http://stackoverflow.com/a/78194502
type: AnswerComment
score: 0
has text: @CharlesDuffy: Why surprised? That's what `source` does, runs the command in the context of the current shell.

http://stackoverflow.com/comment/137901425
type: Comment
comment on: http://stackoverflow.com/a/78217506
has text: I've tried to explain with more details.
type: AnswerComment
score: 1

http://stackoverflow.com/comment/137856632
type: Comment
type: AnswerComment
score: 0
has text: The `-o` output specifier is not included in the [BSD version](https://man.freebsd.org/cgi/man.cgi?query=column&sektion=1) of `column`
comment on: http://stackoverflow.com/a/78193436

http://stackoverflow.com/comment/137817829
comment on: http://stackoverflow.com/a/78171801
has text: Dumb question, can that get evaluated directly in the printf like? printf %s,%s,%s,"$((utime/1000))" $first"$utime" "$rest" "$utime" done <<<"$time"
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137956363
type: QuestionComment
score: 0
has text: please update the question with *a)* the output from `typeset -p TOKEN` and *b)* the results of the 2nd `curl` call (error? no output? wrong output? hangs?)
type: Comment
comment on: http://stackoverflow.com/q/78252038

http://stackoverflow.com/comment/138038090
comment on: http://stackoverflow.com/q/78298036
score: 1
type: QuestionComment
type: Comment
has text: Of course, you can also run `declare -p PGPASSWORD` in the same shell you're subsequently going to start cjdb from (if you're not starting it from a shell at all but using a GUI, that points to a completely different problem); if you get a response starting with `declare --` that tells us the variable isn't exported, if you get one starting with `declare -x` it means it is, if you get an error saying the variable isn't set at all, of course, that means what it says.

http://stackoverflow.com/comment/137842079
comment on: http://stackoverflow.com/q/78187590
score: 1
type: QuestionComment
has text: How will you access the variables? Why not an array?
type: Comment

http://stackoverflow.com/q/78154096
type: Question
tagged with: audit
tagged with: tcsh
has title: Force tcsh to check whether command exist in the path before attempting to execute it
tagged with: linux
downvote count: 0
has body: I've noticed that tcsh, regardless of whether "-f" flag is passed on the shebang line, will iterate through $PATH, and try to execute the command from that path until the command is found. Whereas bash first checks whether the command is present in that location. This tcsh behaviour leads to a lot of failed entries in the audit logs as our audit has been configured to capture execve system calls. For instance when sleep is called from within a tcsh script, one of the failed audit entries shows it tried to run sleep with absolute path: "/usr/local/bin/sleep". type=SYSCALL msg=audit(1710330471.326:37838): arch=c000003e syscall=59 success=no exit=-2 a0=2601590 a1=261e010 a2=261d110 a3=7ffdc4a409e0 items=1 ppid=8930 pid=8938 auid=1011478343 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts1 ses=863 comm="csh_test.sh" exe="/usr/bin/tcsh" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="non_sys_execs" type=CWD msg=audit(1710330471.326:37838): cwd="/tmp" type=PATH msg=audit(1710330471.326:37838): item=0 name="/usr/local/bin/sleep" objtype=UNKNOWN cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0 type=PROCTITLE msg=audit(1710330471.326:37838): proctitle=2F62696E2F637368002E2F6373685F746573742E7368 Strace shows bash stats first, before attempting an access: stat("/usr/local/bin/sleep", 0x7ffdd8de5630) = -1 ENOENT (No such file or directory) stat("/usr/local/sbin/sleep", 0x7ffdd8de5630) = -1 ENOENT (No such file or directory) stat("/sbin/sleep", 0x7ffdd8de5630) = -1 ENOENT (No such file or directory) stat("/bin/sleep", {st_mode=S_IFREG|0755, st_size=33128, ...}) = 0 The order in which it traverses the paths matches the order the paths are defined in $PATH. Unfortunately changing the order around on all our servers will not be possible, also it's unclear what the implications would be of putting /bin/ ahead of /usr/local/bin etc. Whilst, I doubt it, but just in case, is there perhaps some runtime or install configuration to force …
type: UnansweredQuestion
score: 1
tagged with: bash
upvote count: 1
favorite count: 0
answer count: 0
tagged with: shell

http://stackoverflow.com/a/78193474
type: AcceptedAnswer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78192206
upvote count: 1
type: Answer
has body: You could use sudo to check the password. printf "%s" "$password" | sudo -n -S -u "$username" true
accepted answer of: http://stackoverflow.com/q/78192206
has comment: http://stackoverflow.com/comment/137856244

http://stackoverflow.com/comment/137864389
has text: You set a variable `dest_dir=/Users/myuser/photo-archive` but then on the next line hard-code the directory path again `for file in /Users/myuser/photo-archive/Blackhole/*.jpg; do`. Use your variable - `for file in "$dest_dir"/Blackhole/*.jpg; do`
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78199979

npm
tags question: http://stackoverflow.com/q/78166360
tag name: npm
type: Tag
tags question: http://stackoverflow.com/q/78307692
tags question: http://stackoverflow.com/q/78175570
tags question: http://stackoverflow.com/q/78472033
tags question: http://stackoverflow.com/q/78469350
tags question: http://stackoverflow.com/q/79022536
tags question: http://stackoverflow.com/q/79460476

http://stackoverflow.com/comment/137997085
type: Comment
comment on: http://stackoverflow.com/a/78275140
type: AnswerComment
has text: It works! By the way, are there any other symbols to look out for?
score: 1

http://stackoverflow.com/comment/137959484
has text: Try `grep` with multiple templates: `grep -E ''TLS handshake failed|Connection reset by peer|Failed to release a message"`
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78253800

http://stackoverflow.com/q/78228111
answer count: 2
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137938365
has comment: http://stackoverflow.com/comment/137914699
has body: I'm writing a bash script to execute a python program with different values of parameters 'H' and 'K'. What I would like to happen is that only one instance of 'program.py' runs at a time and subsequent jobs are not started until the previous one finishes. Here's what I tried - #!/bin/bash H="1 10 100" K="0.01 0.1" for H_val in ${H} do for K_val in ${K} do { nohup python program.py $H_val $K_val; } & done done However, this just loops over all the parameter values without waiting for any one job to finish. Conversely, if I modify the above slightly by taking off the ampersand, I can run each job individually - but not in the background. Any ideas on how to proceed?
upvote count: 1
type: AnsweredQuestion
has title: Run Jobs Sequentially, in the Background, in Bash
accepted answer: http://stackoverflow.com/a/78228153
has comment: http://stackoverflow.com/comment/137914482
has comment: http://stackoverflow.com/comment/137914493
has answer: http://stackoverflow.com/a/78239469
type: Question
has answer: http://stackoverflow.com/a/78228153
tagged with: background-process
possible better answer: http://stackoverflow.com/a/78239469
score: 1
favorite count: 0

http://stackoverflow.com/a/78264387
type: Answer
score: 0
has body: It seems this is what I was looking for (this is bash/CLI; I'm giving a one-liner again because this is what I'll be actually using): ppmmake white "${CANVAS_WIDTH}" "${CANVAS_HEIGHT}" | pamcomp -xoff="${x1}" -yoff="${y1}" "${OVERLAY_PNM_IMAGE}" - | pamtopng -transparent=white | pngquant --speed 1 --posterize 4 --strip - | img2pdf - | pdftk - multibackground "${IMAGE%.pnm}_ocr.pdf" output "def.pdf" The following is a MWE to test on the fly, with ad hoc generated files. pngquant is removed here: CANVAS_W=4800; CANVAS_H=3450; W=1000; H=1000; x1=500; x2=500; \ ppmmake blue "${W}" "${H}" > overlay_img.pnm; \ ppmmake orange "${CANVAS_W}" "${CANVAS_H}" | ppmtojpeg | img2pdf - > pdf_file.pdf; ppmmake red "${CANVAS_W}" "${CANVAS_H}" | pamcomp -xoff="${x1}" -yoff="${y1}" "overlay_img.pnm" - | pamtopng -transparent=red | img2pdf - | pdftk - multibackground "pdf_file.pdf" output "def.pdf" If I'm not wrong, the key point here is to make sure the colour of the canvas made with the ppmmake command is the same as the one specified in the pamtopng command. I thought there was some 'geometrical' info (i.e. coordinates to define areas and related stuff) to be stored/embedded in the .png file to tell the software not to modify the specified areas/pixels, but it seems the whole business amounts to tell the utility converting from .pnm to .png to interpret as the 'transparent' colour the one formerly specified when generating the image that will be used as the 'canvas'. NOTE: in my working scenario (grayscale), I choose white because picking an actual colour to absolutely avoid inteference with grayscale images (i.e., using an extraneous colour, red for instance, makes you sure you won't be messing up with existing colours and then can behave as 'transparent', as a reference for transparency, so to say), produced an undesired effect when the final .pdf file was viewed in okular: a very thin red-coloured frame (or grey, if piped through pngquant) could be clearly perceived. Thus, as the …
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78261118
accepted answer of: http://stackoverflow.com/q/78261118

dockerfile
tags question: http://stackoverflow.com/q/78166553
tag name: dockerfile
type: Tag
tags question: http://stackoverflow.com/q/78292636
tags question: http://stackoverflow.com/q/78388698
tags question: http://stackoverflow.com/q/78416125
tags question: http://stackoverflow.com/q/78332428
tags question: http://stackoverflow.com/q/78506946
tags question: http://stackoverflow.com/q/78458917
tags question: http://stackoverflow.com/q/78518786
tags question: http://stackoverflow.com/q/78675262
tags question: http://stackoverflow.com/q/78802037
tags question: http://stackoverflow.com/q/78755032
tags question: http://stackoverflow.com/q/78812372
tags question: http://stackoverflow.com/q/79050490
tags question: http://stackoverflow.com/q/79163801
tags question: http://stackoverflow.com/q/79547103
tags question: http://stackoverflow.com/q/79530284
tags question: http://stackoverflow.com/q/79421113

http://stackoverflow.com/comment/137833698
score: 0
has text: either solution works on either `awk` (except the specified edge cases) i just wrote it like that to showcase the code is portable.
comment on: http://stackoverflow.com/a/78177038
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78236202
answers question: http://stackoverflow.com/q/78235520
type: Answer
has body: I'm using this for color printing. Here is how it works, color codes stored in variables: red='\e[91m' #Red grn='\e[92m' #Green blu='\e[94m' #Blue DEF='\e[0m' #Default color and effects ... To print something with color simple add some color var before the text you wish to print in color: printf "${red}R${grn}G${blu}B${DEF}no color" Note the use of $DEF code without it this will be printed:
score: 0

http://stackoverflow.com/comment/137938142
has text: @Barmar Thank you! All your comments help to solve the problem
score: 0
comment on: http://stackoverflow.com/q/78241462
type: Comment
type: QuestionComment

http://stackoverflow.com/q/78255091
upvote count: 0
tagged with: shell
has title: Multiple if conditions in shell script
has comment: http://stackoverflow.com/comment/137961171
accepted answer: http://stackoverflow.com/a/78255128
answer count: 1
score: -1
has answer: http://stackoverflow.com/a/78255128
linked to: http://stackoverflow.com/q/36371221
type: Question
has comment: http://stackoverflow.com/comment/137961702
tagged with: bash
has comment: http://stackoverflow.com/comment/137963260
favorite count: 0
duplicate of: http://stackoverflow.com/q/36371221
downvote count: 1
type: AnsweredQuestion
tagged with: sh
has body: I am using shell script and trying below where I searching for two strings in a file if they are passing then I need to print "PASS" as shown in below code but getting issue when executing below code. #!/bin/bash if (grep -q "Build of target from_sms.compfiles.xf : PASS" failed.log) && (grep -q "All tests fine" test.log) ; then echo "PASS" fi
duplicate of: http://stackoverflow.com/q/8934012
has comment: http://stackoverflow.com/comment/137969613

http://stackoverflow.com/q/78232246
has comment: http://stackoverflow.com/comment/137921629
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/137922830
duplicate of: http://stackoverflow.com/q/36584391
type: UnansweredQuestion
has body: I'm trying to split video by chapters by reading chapter details from text file, storing each values in a variable and passing those to ffmpeg. After splitting some chapters, start time and end time gets mixed with chapter title. Below is the script #1 /bin/bash file=$(echo "$1" | awk -F '.' '{print $(NF-1)}') ext=$(echo "$1" | awk -F '.' '{print $(NF)}') ffprobe -show_chapters "$1" | grep -i 'id=\|start_time\|end_time\|title' > chapters.txt rm temp.txt while read chapter_id; do read start_time read end_time read chapter_title id=$(echo "$chapter_id" | awk -F '=' '{print $(NF)}') st=$(echo "$start_time" | awk -F '=' '{print $(NF)}') en=$(echo "$end_time" | awk -F '=' '{print $(NF)}') title=$(echo "$chapter_title" | awk -F '=' '{print $(NF)}') echo "id=$id" >> temp.txt echo "start=$id" >> temp.txt echo "end=$en" >> temp.txt echo "title=$title" >> temp.txt echo "------" >> temp.txt ffmpeg -ss "$st" -to "$en" -y -i "$1" -c copy "$file-$id-$title.$ext" done < chapters.txt
has comment: http://stackoverflow.com/comment/137921693
has comment: http://stackoverflow.com/comment/137922446
linked to: http://stackoverflow.com/q/36584391
has title: Bash Scripting: when trying to read 3 lines at a time, input line gets skipped in between
has comment: http://stackoverflow.com/comment/137922015
has comment: http://stackoverflow.com/comment/137922794
has comment: http://stackoverflow.com/comment/137921473
score: 0
has comment: http://stackoverflow.com/comment/137922461
tagged with: shell
tagged with: linux
tagged with: bash

http://stackoverflow.com/a/78278695
has body: (this answer should have been a comment, but I am not yet allowed to write them) from my tests the issue seems to be that the script is acting as if &quot;$@&quot; contains the whole command before the pipe, but, it does not work this way and performing this task in a clean and robust way can be tricky (see this post from more than 5 years ago) the solution I have found is ugly and also I am afraid that it is far from being robust the function m() { ( echo &quot;$( history 1 | head -n 1 | cut -c 26- | cut -d\| -f 1 )&quot; ; cat ) | xclip -i ; } (it works by echoing the command from history and then appending stdin to stdout) here is the test in bash (running from a ssh with putty) /tmp $ /tmp $ m() { ( echo &quot;$( history 1 | head -n 1 | cut -c 26- | cut -d\| -f 1 )&quot; ; cat ) | xclip -i ; } /tmp $ /tmp $ ls -1 foo bar baz /tmp $ /tmp $ /tmp $ ls -1 foo |m /tmp $ cat &gt;/dev/null this is the content of the clipboard when I paste it with shift-insert: ls -1 foo bar baz /tmp $
has comment: http://stackoverflow.com/comment/138004065
type: Answer
answers question: http://stackoverflow.com/q/78278159
has comment: http://stackoverflow.com/comment/138005632
score: 0
has comment: http://stackoverflow.com/comment/138004000
has comment: http://stackoverflow.com/comment/138003085

http://stackoverflow.com/comment/137927560
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78235520
type: QuestionComment
has text: Are you looking for this? `printf "%b\n%b\n" "$a" "$b"`

http://stackoverflow.com/comment/138002306
type: Comment
comment on: http://stackoverflow.com/q/78278159
score: 0
has text: You don't have an `alias` in the code you posted. BTW, read _man xclip_. It describes how stdin is placed into the clipboard.
type: QuestionComment

http://stackoverflow.com/comment/137802523
type: QuestionComment
type: Comment
score: 0
has text: Usually when you use both `awk` and `sed` there is a way to simplify and use only one. Example with just `sed`: `sed -i '/^EEEEEEEEE$/,/^$/d' file`.
comment on: http://stackoverflow.com/q/78165163

http://stackoverflow.com/comment/137907855
score: 0
has text: It works perfectly! Thank you so much! So many months trying to make it work and finally I can organise it. A couple of questions: - If I add duplicates, which one it keeps? (older, newer of creation..) - Would it be easy to add one more level? YYYYMM and inside that level the days as it is? Just wondering...
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78200064

http://stackoverflow.com/q/78254419
type: UnansweredQuestion
favorite count: 0
tagged with: go
has answer: http://stackoverflow.com/a/78277290
has comment: http://stackoverflow.com/comment/137960443
has comment: http://stackoverflow.com/comment/137960478
answer count: 2
downvote count: 0
score: 1
tagged with: bash
upvote count: 1
tagged with: file
has body: I have go application which takes log from another binary application which is also go application. I want to write log in new file per 10 seconds. But the problem is still writing in first log file no matter how many log files are created. package main import ( "fmt" "log" "os" "os/exec" "time" ) func main() { // Initialize the ticker to trigger every minute ticker := time.NewTicker(time.Minute / 10) defer ticker.Stop() // Create a channel to receive ticker events tickerCh := ticker.C logFolderPath := "./log/" // Initialize the first log file filename := generateFilename() logFile, err := os.OpenFile(logFolderPath+filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { fmt.Println("Error opening log file:", err) return } defer logFile.Close() // Commands to execute sequentially cmd := exec.Command("sh", "-c", "./ledplayer") // Connect command's stdout and stderr to pipes cmd.Stdout = logFile cmd.Stderr = logFile // Start the command err = cmd.Start() if err != nil { fmt.Println("Error:", err) return } fmt.Println("Command started successfully. Log stored in", filename) // Loop to handle ticker events for range tickerCh { // Close the current log file err := logFile.Close() if err != nil { fmt.Println("Error closing log file:", err) return } log.Printf("%#v\n", logFile) // Generate a new filename for the next minute filename := generateFilename() // Open the new log file logFile, err = os.OpenFile(logFolderPath+filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { fmt.Println("Error opening log file:", err) return } // Print the new log file name fmt.Println("Log file switched to", filename) // Update command's stdout and stderr to write to the new log file cmd.Stdout = logFile cmd.Stderr = logFile } // Wait for the command to finish before exiting err = cmd.Wait() if err != nil { fmt.Println("Error waiting for command to finish:", err) } } func generateFilename() string { // Generate filename with the current date and time return time.No…
has answer: http://stackoverflow.com/a/78254659
tagged with: logging
type: Question
has title: write log into new file per 10 seconds while getting log from another application

http://stackoverflow.com/comment/137893885
comment on: http://stackoverflow.com/a/78214419
type: Comment
has text: So parsing `JSON` with `awk` or `bash` is a good practice for you? No better way?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138061941
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78274675
has text: Did you have any luck resolving this?
score: 0

http://stackoverflow.com/comment/137982688
has text: I see the point. So the, what about redirecting the output into a file? Afterwards, you can decide, whether, how and for how long you show the file. Of course you need to think of whether you really want to hide all output. What if there are error message in the output?
comment on: http://stackoverflow.com/q/78261786
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137982665
type: QuestionComment
has text: @user1934428: `clear` clears _everything_ - the main reason why I don't want to keep useless stuff on the terminal is to make the rest more readable. If I didn't care about the terminal content I wouldn't have to keep it tidy in the first place or produce any output at all.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78261786

http://stackoverflow.com/comment/137886361
score: 0
comment on: http://stackoverflow.com/a/78211596
type: Comment
type: AnswerComment
has text: You show your whole script but not the one thing we really need to help you which is the output of the 2 commands you're trying to parse the output of - `ip addr show` and `ip -6 addr show scope global`. "got it to work" is relative. You're doing a few things that don't make sense, e.g. those case statements, some that are buggy, e.g. not escaping `.`s in your regexp, and some that are well known anti-patterns, e.g. storing code in variables, this could be a good opportunity for you to learn a bit more about bash programming.

git-for-windows
tags question: http://stackoverflow.com/q/78204675
type: Tag
tag name: git-for-windows
tags question: http://stackoverflow.com/q/78520208
tags question: http://stackoverflow.com/q/78485242

http://stackoverflow.com/comment/137988499
has text: But just to be clear, this is the command that'll do it (use rsync, not sync, and for neatness just append R to the end of the flags that are already there): `rsync -ahvR targetvolume/targetdir/./**/my_folder/ ./outputdir`
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78270269

http://stackoverflow.com/a/78200064
has comment: http://stackoverflow.com/comment/137864344
has comment: http://stackoverflow.com/comment/137869933
has comment: http://stackoverflow.com/comment/137866576
has comment: http://stackoverflow.com/comment/137864498
type: Answer
has comment: http://stackoverflow.com/comment/137864154
has comment: http://stackoverflow.com/comment/137907855
answers question: http://stackoverflow.com/q/78199979
score: 2
upvote count: 2
has body: You're forgetting that file contains the full path. The regex ^([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2}) won't match a string starting with /Users/myuser/photo-archive/Blackhole/. Change that conditional to this and it'll work. [[ ${file##*/} =~ ^([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2}) ]]
downvote count: 0

http://stackoverflow.com/comment/137908821
comment on: http://stackoverflow.com/q/78224942
score: 0
has text: [Shellcheck](https://www.shellcheck.net/) finds a serious problem in the code (missing spaces). The report that it produces includes a link to more information about the problem and how to fix it. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78231634
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78231603
type: AcceptedAnswer
upvote count: 1
score: 1
has body: How does USER_HOME2 work? How does the shell know how to pair up the single quotes? Does it effectively concatenate three strings: '/home/', the output of $(id -nu), and '/'? In which case, we can rewrite USER_HOME2 as Yes, that's exactly what's happening. The following strings are all identical from the viewpoint of the shell: abc 'abc' "abc" 'a'b'c' "a"b"c" ''abc'' 'ab''c' 'ab'"c" Command substitution must be double quoted, otherwise field splitting and glob expansion will be applied to the result (unless when it appears on the right hand side of the parameter assignment; in that case no further expansions will be applied)
type: Answer
answers question: http://stackoverflow.com/q/78231603

http://stackoverflow.com/comment/138013602
has text: please update the question with expected outputs where `number=3` and `number=4`; it's not clear (to me) how you can create a diamond with an even number of stars .... unless 'number' refers to something else (other than the max number of stars to be displayed in the center line)
comment on: http://stackoverflow.com/q/78283701
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/q/78211182
tagged with: shell
answer count: 1
favorite count: 0
has body: I have a simple bash script that listens to SIGUSR{1,2} like this: #!/usr/bin/env bash trigger() { echo "receiving signal" } echo $$ trap trigger USR1 USR2 sleep inf So I ran the script and then ran: kill -USR1 -$PID # where $PID is the PID printed by the script receiving signal is printed, but then the script just dies afterwards. Is there a way to prevent this, so that the script can keep on listening to SIGUSR{1,2} signals?
has title: Script dies after receiving SIGUSR1/SIGUSR2
score: -1
tagged with: bash
type: Question
upvote count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/137884119
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78212713

http://stackoverflow.com/comment/137871175
has text: Yes, you can implement other cases, like `video` and so on. `*)` is a catch all for not listed cases
comment on: http://stackoverflow.com/a/78203898
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137865688
has text: @Nic3500 those characters are in the data file
type: Comment
comment on: http://stackoverflow.com/q/78196837
type: QuestionComment
score: 0

http://stackoverflow.com/comment/137908152
has text: Inside a function `$1` refers to the first of arguments the function is called with. You're calling `Domain_Lookup_Func` with no arguments and `filename` ends up empty. Try `Domain_Lookup_Func "$initialInput"`.
score: 2
comment on: http://stackoverflow.com/q/78224799
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137813744
comment on: http://stackoverflow.com/q/78170444
score: 0
type: QuestionComment
type: Comment
has text: Try this: very quick as this run `date` only once: `sed < file.csv 's/^[0-9]*,\([0-9]\+\),.*/@\1/'|LANG=C date -f -| paste -d, file.csv -`

http://stackoverflow.com/comment/137790134
score: 1
has text: `x` is just a string, not an array, so the `+=` is only a literal, not adding anything. Why can't you just `rm $line`?
comment on: http://stackoverflow.com/q/78158123
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137823864
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78177473
score: 0
has text: `mkfifo for-consumer; producer >for-consumer & { rm for-consumer; read first_line; consumer; } <for-consumer`

http://stackoverflow.com/comment/137913738
type: Comment
comment on: http://stackoverflow.com/q/78227591
score: 1
type: QuestionComment
has text: Is the input a _Bash array_ or a _string_ resulting from unescaping the string `'["one","two"]'` or the input is the _string_ with the literal exact value `'["one","two"]'`? `original array: output = ['one', 'two']` presents an invalid bash code, resulting in `output: command not found` error. If the `${output[@]}` contains your input, please post the output of `declare -p output`.

http://stackoverflow.com/comment/137894367
comment on: http://stackoverflow.com/a/78217017
score: 0
has text: Thanks! I knew that it was something simple (dooooh!).
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78275140
has comment: http://stackoverflow.com/comment/137997085
type: Answer
accepted answer of: http://stackoverflow.com/q/78274893
upvote count: 2
has comment: http://stackoverflow.com/comment/137997791
type: AcceptedAnswer
score: 2
has body: You may use awk like this with a bash replacement: key="KEY" value="- & -" awk -v s="$key" -v r="${value//&/\\\\&}" '{sub(s,r)}1' <<< 'AAA KEY AAA' AAA - & - AAA Here "${value//&/\\\\&}" will replace & with \\&.
downvote count: 0
has comment: http://stackoverflow.com/comment/137997530
answers question: http://stackoverflow.com/q/78274893

http://stackoverflow.com/q/78178090
linked to: http://stackoverflow.com/q/76122906
has comment: http://stackoverflow.com/comment/137826042
tagged with: bash
duplicate of: http://stackoverflow.com/q/5725296
has title: Why am I getting a bash error when I use vared or read command?
answer count: 0
has comment: http://stackoverflow.com/comment/137853145
has comment: http://stackoverflow.com/comment/137831420
tagged with: unix
has comment: http://stackoverflow.com/comment/137849577
has comment: http://stackoverflow.com/comment/137829991
has comment: http://stackoverflow.com/comment/137827515
has comment: http://stackoverflow.com/comment/137824896
score: 0
has comment: http://stackoverflow.com/comment/137824887
has comment: http://stackoverflow.com/comment/137835054
type: Question
has body: I am attempting to make a small bash script to remind me to drink water at a random time (roughly 30-45mins let's say). When the timer reaches to the magic random number, it will trigger the voice and remind me to drink water. In order to exit, useThis is something fun and silly to get back into coding a little bit and rewire myself a bit. I had this project for a while. Anyways, while looking at it and trying to make it functional, I attempted to write a read input in the code, but it displays me an error for line 37: vared: command not found or line 37: read: command not found I'm slightly confused as to why exactly the issue is in here. I ran it separately with varead and read, and they are fine outside of the shell file. This question sole purpose is not knowing the difference between zsh and bash altogether. Instead, it is to know why the script that I'm executing is not running it properly (even with the small tweaks suggested in the comments) Idea This script only runs when I open the terminal. So, I have a dotfile that executes this shell on my profile like this: #Drink water reminder script chmod +x Water-Reminder/drinkwater.sh ./drinkwater.sh and inside of drinkwater.sh is the code. Code #!/bin/zsh start_reminder() { while : do input='' sleep_duration=$(((RANDOM % 10) + 15)) # Random number for the seconds for testing it out. sleep $sleep_duration printf "DRINK WATER YOU DINGUS\n" say DRINK WATER YOU DINGUS vared -p "Are you going to drink water? [y/n]: " -c input if | $input == 'y' || $input == "yes" || $input == "YES" || $input == "Yes" ; then printf "okay :^) I will trust you\n" else echo "uwotm8?" fi done } start_reminder & If it helps, I'm mainly using zsh. I tried to test it on bash too, but not doing the trick to my problem.
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137868430
linked to: http://stackoverflow.com/q/5725296
has comment: http://stackoverflow.com/comment/137831899
has comment: http://stackoverflow.com/comment/137831472

http://stackoverflow.com/comment/138045689
has text: I am getting the same error by using no quotes or double quotes :') Error: psql:helper_scripts/datenbank/initialize_postgres.sql:188: ERROR: syntax error at or near ":" LINE 5: UPDATE ON ALL TABLES IN SCHEMA public TO :"user1"; ^ psql:helper_scripts/datenbank/initialize_postgres.sql:191: ERROR: syntax error at or near ":" LINE 2: SELECT ON ALL SEQUENCES IN SCHEMA public to :"user1"; ^
type: Comment
score: 0
comment on: http://stackoverflow.com/a/78302726
type: AnswerComment

http://stackoverflow.com/comment/137831472
comment on: http://stackoverflow.com/q/78178090
type: Comment
score: 0
type: QuestionComment
has text: There is no shortcut which allows you to ignore the differences between these three incompatible shells, other than not using the other two at all and concentrating exclusively on learning only one of them. Even then, if the one you choose is not `sh`, you will need to understand the differences between `sh` and your preferred shell eventually.

http://stackoverflow.com/comment/137778286
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78146724
type: QuestionComment
has text: @markp-fuso test_01.py should give me a single print statement, something asinine i put there just to test the shell script. test_02 is a print statement inside a 'for x in range' loop. but when run through bash, i get the test_01 print statement executed, then the test_01 statement again, then test_02.

http://stackoverflow.com/comment/137863404
type: AnswerComment
has text: Yes, it is just for a single git invoke.
score: 0
comment on: http://stackoverflow.com/a/78199112
type: Comment

http://stackoverflow.com/comment/137988209
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78270350
has text: _nod_; see also [BashFAQ #48](https://mywiki.wooledge.org/BashFAQ/048) if otherwise feeling tempted to use `eval`.

http://stackoverflow.com/comment/137891609
type: Comment
score: 0
has text: Mind, stdout and stderr have different buffering behaviors by default (when both are redirected to a TTY), so stderr being flushed more quickly than stdout would be normal in a lot of languages, but a call to `echo` in bash flushes when it completes, so that's not the case here.
comment on: http://stackoverflow.com/q/78215669
type: QuestionComment

http://stackoverflow.com/comment/137871568
comment on: http://stackoverflow.com/q/78201574
score: 0
has text: @CharlesDuffy that i had, when i enter `declare -- computer_name="ws-pa-sius-l002" declare -- group_members="pan-sgg-dalas:*:1941423615:ws-pa-test-l001\$,ws-pa-jeu-l004\$,ws-pa-ukg-ktr\$,ws-pa-arm-kszi\$,ws-pa-ds-dis1\$,ws-pa-ds-dis2\$"`
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78148131
type: Answer
has comment: http://stackoverflow.com/comment/137773351
has body: Just use the variable. env=stage && AWS_REGION="us-west-2" AWS_PROFILE="$env" mvn clean test "-Dtest=KarateRunner#$env" -DargLine="-Dkarate.env=$env"
has comment: http://stackoverflow.com/comment/137772871
answers question: http://stackoverflow.com/q/78148102
score: 0

http://stackoverflow.com/comment/137827399
comment on: http://stackoverflow.com/q/78178759
has text: @oguzismail I edited the question. Feel free to review the solution :)
score: 0
type: QuestionComment
type: Comment

kali-linux
tag name: kali-linux
type: Tag
tags question: http://stackoverflow.com/q/78270350

http://stackoverflow.com/comment/137939085
type: QuestionComment
has text: @jhnc Like what things? If you worry about other possible errors that may cause nonerror exit code I agree, but this should suffice for immediate use.
type: Comment
comment on: http://stackoverflow.com/q/78241761
score: 0

http://stackoverflow.com/comment/137960636
type: QuestionComment
comment on: http://stackoverflow.com/q/78253195
type: Comment
has text: ... When I try to convert to bash array I only get the first instance of array: '2' in this case. Same with string value (only the first word): 'Breezy'. Ex: arr=($(echo $drp | jq -r '.[]')) Same with mapfile, same with regular exp. I have modified post to include full json. Thank you so much.
score: 0

http://stackoverflow.com/comment/137885581
comment on: http://stackoverflow.com/a/78211545
type: Comment
type: AnswerComment
has text: Yep, I did something wrong, my bad. I used the `-n` syntax which kills the whole process group apparently. Also thanks for going out of your way to test it on NixOS.
score: 1

http://stackoverflow.com/comment/137876402
has text: Lots of things don't work well when filenames have newlines. It's really hard to deal with them in shell scripts. There are tricks like that for particular cases. But unless you're in a context where screw cases like this will cause a problem, I'm happy to ignore it.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78203990
score: 0

http://stackoverflow.com/a/78297254
score: 1
upvote count: 1
type: Answer
has body: Perl and Time::Piece to the rescue! <test.log perl -MTime::Piece -lne ' /\[(.+)\] \{(.+)\}/; print Time::Piece->strptime($1, "%a %b %d %H:%M:%S %Y") ->strftime("%F %T"), " $2"' -n reads the input line by line, runs the code for each line; -l removes newlines from input and adds them to print; /\[(.+)\] \{(.+)\}/ matches the input line and remembers the timestamp and command in $1 and $2; strptime parses the timestamp and strftime formats it to the desired format. It doesn't give the expected output, though. The last line has the time 03:35:51, not 03:33:42 - but so does the input, so I guess it's a typo.
downvote count: 0
answers question: http://stackoverflow.com/q/78297014

http://stackoverflow.com/comment/137850826
type: QuestionComment
type: Comment
has text: Assuming pnpm/npm does something that makes it different
score: 0
comment on: http://stackoverflow.com/q/78166360

http://stackoverflow.com/comment/137926822
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78235101
has text: also variables are assumed global unless `local` or `declare` in a function is used
type: Comment

nixos
tag name: nixos
tags question: http://stackoverflow.com/q/78224990
type: Tag

http://stackoverflow.com/comment/137908391
type: QuestionComment
comment on: http://stackoverflow.com/q/78224990
type: Comment
has text: yeah exactly like this: swww img ~/.config/hypr/Wallpapers/'Chill Study.jpg' bear in mind I am using ~ instead of my actual home path, but when I did it I used the actual path
score: 0

http://stackoverflow.com/comment/137855008
has text: @chenzhang, same process, new stack frame within that process -- just the same as how a shell function runs in the same process as its caller, but has its own local variables (if in fact it uses `local` or `declare`), its own argument list, &c. To be clear, it's the same stack (not a completely new one like it would be after an `exec()` or even a copy-on-write instance that can't modify the original like it would be with a `fork()`), just a new _frame_ added to that existing stack, and removed when the context exits.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78194467

ruby
type: Tag
tags question: http://stackoverflow.com/q/78203871
tag name: ruby
tags question: http://stackoverflow.com/q/78984023

http://stackoverflow.com/a/78156004
type: AcceptedAnswer
has body: function! PrependLine() &quot; Save the current file to avoid problems with switching buffers update &quot; Copy the current line to the default register yank &quot; Open a new buffer or switch to exiting one edit myfile.md &quot; Paste content of the default register before the 1st line 1put! &quot; Save the file update &quot; Return to the previous file edit # endfunction map &lt;leader&gt;i :call PrependLine()&lt;CR&gt; The only problem is — the filename is fixed. Vim macros don't have parameters. Functions do have.
accepted answer of: http://stackoverflow.com/q/78155628
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/137787551
answers question: http://stackoverflow.com/q/78155628
type: Answer
has comment: http://stackoverflow.com/comment/137786997
has comment: http://stackoverflow.com/comment/137792245
downvote count: 0
has comment: http://stackoverflow.com/comment/137793031

http://stackoverflow.com/comment/138022420
type: Comment
comment on: http://stackoverflow.com/q/78284887
has text: What do you mean by "handready"? Requests for people to find or recommend off-site resources are categorically off-topic.
score: 0
type: QuestionComment

http://stackoverflow.com/a/78156732
answers question: http://stackoverflow.com/q/78156679
type: Answer
has comment: http://stackoverflow.com/comment/137787832
upvote count: 4
has body: While there may be a way to use indirect references with arrays (it's going to be a bit convoluted) I find namerefs are much simpler to use ... With bash 4.3+ you can use a nameref to cycle through the different arrays. One bash approach: myArray1=("userList1" "emailList1" "valueList1") myArray2=("userList2" "emailList2" "valueList2") myArrayN=("userListN" "emailListN" "valueListN") active_lists=("myArray1" "myArray2" "myArrayN") for arr_name in "${active_lists[@]}" do printf "\n####### ${arr_name}\n\n" declare -n _arr="${arr_name}" # nameref for i in "${!_arr[@]}" # loop through indices of nameref'd array "_arr[]" (ie, indices of the current "arr_name" array] do echo "${arr_name}[$i] = ${_arr[i]}" done done NOTES: ${arr_name}[$i] is not an array reference but rather 4 strings appended together (${arr_name} + [ + $i + ]) for display purposes ${_arr[i]} is an array reference and due to the nameref will display the ith element of the current arr_name array This generates: ####### myArray1 myArray1[0] = userList1 myArray1[1] = emailList1 myArray1[2] = valueList1 ####### myArray2 myArray2[0] = userList2 myArray2[1] = emailList2 myArray2[2] = valueList2 ####### myArrayN myArrayN[0] = userListN myArrayN[1] = emailListN myArrayN[2] = valueListN
score: 4
downvote count: 0

http://stackoverflow.com/comment/137836613
comment on: http://stackoverflow.com/a/78183320
score: 0
type: Comment
type: AnswerComment
has text: Re: uppercase variables, see also [Correct Bash and shell script variable capitalization](https://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization)

http://stackoverflow.com/q/78160050
tagged with: bash
answer count: 1
favorite count: 0
has title: How is subshell called from sed replacement part? There is some deep magic going on
has body: I need to call subcommand from sed replacement part to transform data. I didn't expect it to work at all, but it does, yet for very specific invocation there is some escaping problem or smth. I totally don't understand it, can someone advice? Lets start with function definition: $ function add() { echo "<${1}>"; } $ export -f add $ add a easy. Now some replacements, proving that it works. $ echo 'aaa bbb' | sed "s/\(.*\) \(.*\)/\1 $(add \\2)/" aaa <bbb> $ echo -e 'aaa bbb\nccc ddd' | sed "s/\(.*\) \(.*\)/\1 $(add \\2)/" aaa <bbb> ccc <ddd> so in this replacement ^^ we consumed entire line, took 2 capturing groups, first printed as is, and called function with 2nd one. Works as expected. But what if we use builtin instead of function? echo -e 'aaa bbb\nccc ddd' | sed "s/\(.*\) \(.*\)/\1 $(echo \<\\2\>)/" aaa <bbb> ccc <ddd> work as well. So what about custom script? $cat<<EOF > /tmp/e #!/bin/bash echo "<\${1}>"; EOF $ chmod u+x /tmp/e $ echo -e 'aaa bbb\nccc ddd' | sed "s/\(.*\) \(.*\)/\1 $(/tmp/e \\2)/" aaa <bbb> ccc <ddd> Works! This is awesome. So lets move to some actual data: $ isoDurationToMillis 0h:00m:00s.089 89 This ^^ is custom script, invoked as this it works. So we can finally call sed with this: $ echo 'aaa 0h:00m:00s.089' | sed "s/\(.*\) \(.*\)/\1 $(isoDurationToMillis \\2)/" date: invalid date ‘1970-01-01 \\2’ (standard_in) 1: syntax error aaa so in this case the invocation does NOT work. BUT it's not that 0h:00m:00s.089 ins't passed into script. It is, if I do echo $1 it will be printed, but the invocation of that script is somewhat funny, and in another part of that script, where I actually need value of $1 the \2 is substituted instead. Can someone explain?
linked to: http://stackoverflow.com/q/7917018
score: 0
type: Question
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/137793448
downvote count: 1
has answer: http://stackoverflow.com/a/78160193
tagged with: sed

http://stackoverflow.com/a/78225000
answers question: http://stackoverflow.com/q/78224942
upvote count: 0
has body: Please use quote ("") around the variables and space after '[', ']'. Code: #!/bin/sh echo "arg 0=" $0 echo "arg 1=" $1 echo "arg 2=" $2 if [ "$#" -eq 1 ]; then cal "$1" elif [ "$#" -eq 2 ]; then cal "$1" "$2" else echo "Incorrect amount of arguments used" fi Output: Command => $ ./test.sh 5 2020 arg 0= ./test.sh arg 1= 5 arg 2= 2020 May 2020 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
accepted answer of: http://stackoverflow.com/q/78224942
type: AcceptedAnswer
score: -1
has comment: http://stackoverflow.com/comment/137908604
downvote count: 1
type: Answer

http://stackoverflow.com/comment/137925222
type: Comment
type: AnswerComment
has text: To be slightly more specific, `$'...'` is an [ANSI-C quoted string](https://www.gnu.org/software/bash/manual/bash.html#ANSI_002dC-Quoting).
comment on: http://stackoverflow.com/a/78234256
score: 1

http://stackoverflow.com/comment/137888750
score: 0
comment on: http://stackoverflow.com/q/78211761
type: QuestionComment
has text: Then you may want to respond to the comments there so we can make progress in trying to help you.
type: Comment

http://stackoverflow.com/comment/137772908
type: Comment
type: AnswerComment
score: 0
has text: Thank you! This is what I was looking for. Thanks also for pointing out that the proper command for what I want to do is actually `xargs`. I didn't know it. Just one thing, the `awk` command you posted is not working as expected, it just returns the string "3 bash" three times, in separated lines. And I'm sorry for the rudimentary and full of gotchas script example I posted. I meant it only as an example of an "arbitrary function".
comment on: http://stackoverflow.com/a/78148060

http://stackoverflow.com/comment/137837127
has text: Helpful, thanks Mark. However this is Intel Mac and first in PATH is indeed /usr/local/bin, same in my interactive and in the batch file (I echo'd it out to check) so I expect the same sqlite to get invoked by the same command - but NO, not what we saw. If I delete the alias in interactive shell that also then gets the old version... BUT looking at links in /usr/local/bin is instructive... amending my answer and awarding you for the pointer...
comment on: http://stackoverflow.com/a/78183157
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/137802434
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78151708
has text: @PawełSelen Is it binary data, or is it an executable? If it is just binary data, do you know what application produced the files? What application are they used with?
score: 0

http://stackoverflow.com/q/78298936
tagged with: sh
linked to: http://stackoverflow.com/q/60626955
has title: Sending SIGINT to background process does not stop it
has body: Given following script (work.sh) #! /bin/bash must_stop="" function sigint_handler() { echo "SIGINT" must_stop="1" } trap sigint_handler SIGINT COUNTER=0 while [ -z "${must_stop}" ] do ((COUNTER+=1)) echo "#${COUNTER} Working..." sleep 1 done I have executed it as a background process: $ sh -c "work.sh &" Now,I wanted to stop it with SIGINT (simulating Ctrl+C when running in foreground), for that I did: $ ps PID TTY TIME CMD 14125 pts/3 00:00:00 tcsh 27717 pts/3 00:00:00 work.sh 28288 pts/3 00:00:00 sleep 28605 pts/3 00:00:00 ps $ kill -INT 27717 but it continues printing counter (no echo "SIGINT" and no stop), why? What is the right way to stop it with SIGINT (not SIGTERM/SIGKILL)?
score: 3
upvote count: 3
linked to: http://stackoverflow.com/q/27694818
type: Question
tagged with: tcsh
has comment: http://stackoverflow.com/comment/138038527
downvote count: 0
type: UnansweredQuestion
tagged with: bash
tagged with: tty
has answer: http://stackoverflow.com/a/78299289
has comment: http://stackoverflow.com/comment/138038401
has comment: http://stackoverflow.com/comment/138038446
answer count: 1
has comment: http://stackoverflow.com/comment/138038385
favorite count: 0
has comment: http://stackoverflow.com/comment/138038665
has comment: http://stackoverflow.com/comment/138038650

http://stackoverflow.com/comment/137788192
type: Comment
has text: Sorry for my bad English, and being such a noob ^_^ By the way, what i'm trying to do is avoid to write "*.txt" and make that script working reading only *.txt
comment on: http://stackoverflow.com/q/78156916
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137780879
score: 0
has text: There should be nothing in bash which explains the differences, but most likely you are running different `nc` executables. Do a `which nc` (and for the safe side a `which sleep`) before entering the loop.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78152355

http://stackoverflow.com/comment/138047628
comment on: http://stackoverflow.com/q/78298728
has text: Have you tried a Taskfile? It's much easier to handle a lot of things. https://taskfile.dev/usage/#environment-variables
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137949844
has text: @larsks I know that there are other ways to send a signal. What I'm trying to do is exactly force the user to use different ways to do that as an exercise (in C, python, ASM, etc).
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78248223
score: 0

http://stackoverflow.com/comment/137824204
type: Comment
has text: Thanks for all the excellent input. I'm trying the same approach to convert byes to mb like this below but maybe my approach is not so correct MB=`while IFS= read -r line ; do 'numfmt --to=iec'; done <<< "$bytes`
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78170533

http://stackoverflow.com/a/78261401
score: 3
upvote count: 3
type: Answer
answers question: http://stackoverflow.com/q/78261247
downvote count: 0
has body: Using any awk in 1 pass of reading the input and only storing 1 ^&gt;-separated record at a time in memory: awk ' /^&gt;/ { prt(); rec=$0; next } { rec = rec ORS $0 } END { prt() } function prt() { if (gsub(ORS,&quot;&amp;&quot;,rec)&gt;1) print rec } ' file &gt;Cluster 202 0 2578aa, &gt;CAD5122864.1... * 1 1867aa, &gt;CAD5122865.1... at 100.00% 2 2369aa, &gt;CAD5122866.1... at 100.00%

http://stackoverflow.com/comment/137804050
has text: Not entirely sure what’s going on there but note that it a mistake to parse the output of `ls`, and will give erroneous results for valid file names. You should use `find dir -maxdepth 1 -name "*${subdir}*" -type d -print0` instead (and replace `read -r target` with `IFS='' read -r -d '' target`). This will also make the `-d` test unnecessary.
score: 4
comment on: http://stackoverflow.com/q/78166124
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137866817
score: 2
has text: Note that this use of `grep` may not be safe. If your computer name is `abc`, and the computer `xabcy` is in the group, your grep will be successful. You should use `grep -w` so it matches whole words.
type: Comment
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment

http://stackoverflow.com/comment/137981966
comment on: http://stackoverflow.com/q/78261314
type: Comment
score: 0
has text: The error message just says that there is no command named `if[`. The syntax is `if COMMAND` and not `ifCOMMAND`. Aside from this, you didn't say how you executed your script. Unless you run it explicitly by `bash SCRIPTNAME`, it is not executed by bash, and your _bash_ tag does not make sense.
type: QuestionComment

http://stackoverflow.com/comment/137939680
type: Comment
comment on: http://stackoverflow.com/q/78242340
has text: for bigger files, second is more efficient as `awk '{print length}' inputfile` (or `length+1`)
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137865180
type: Comment
type: AnswerComment
score: 0
has text: Hi @Ed Morton, I really appreciate your response here, and breaking things down for me. However, I've elaborated on my initial question providing some further details. Essentially, your solution works for `apt upgrade`, but not when I'm executing a python script. I'm assuming that python output is something outside of `STDOUT` or `STDERR`?
comment on: http://stackoverflow.com/a/78196849

http://stackoverflow.com/comment/137963959
has text: it would all work inline with the if condition. Although It would be much less readable and the intention much less obvious than offloading it into a dedicated function with a meaningful name.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78255939

http://stackoverflow.com/a/78182345
has body: It sounds like you're using aliases when you should be using functions and have a few other issues such as calling eval for no apparent reason. I THINK this is what you're trying to do: $ cat tst.sh #!/usr/bin/env bash myTask1() { sleep 3; } myTask2() { sleep 5; } timertest() { local begSecs endSecs printf -v begSecs '%(%s)T' printf '%s Started at %d = %(%Y-%m-%d %H:%M:%S)T\n' "$*" "$begSecs" >&2 "$@" printf -v endSecs '%(%s)T' printf '%s Finished at %d = %(%Y-%m-%d %H:%M:%S)T\n' "$*" "$endSecs" >&2 printf '=========== %s Complete, took %d ==================\n' "$*" "$(( endSecs - begSecs ))" >&2 } timertest myTask1 timertest myTask2 $ ./tst.sh myTask1 Started at 1710787312 = 2024-03-18 13:41:52 myTask1 Finished at 1710787315 = 2024-03-18 13:41:55 =========== myTask1 Complete, took 3 ================== myTask2 Started at 1710787315 = 2024-03-18 13:41:55 myTask2 Finished at 1710787320 = 2024-03-18 13:42:00 =========== myTask2 Complete, took 5 ==================
downvote count: 0
score: 1
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/78182030

http://stackoverflow.com/comment/137855854
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78194973
type: Comment
has text: (please _ask questions_ about suggestions you don't understand or that look like they wouldn't work, instead of just ignoring them!)

http://stackoverflow.com/comment/137829991
type: Comment
has text: Sorry if my question sounds confusing, but regardless to what I'm trying to do (either in bash or zsh), I'm still encountering the same issue. What do you recommend me to do @user1934428 ?
comment on: http://stackoverflow.com/q/78178090
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138016059
has text: See here for the conversion https://stackoverflow.com/questions/4614775/converting-hex-to-decimal-in-awk-or-sed
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78286124
score: 0

http://stackoverflow.com/comment/138024159
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78290808
has text: Use `cron` or `at` (see _man at_) for starting the script. See `timeout` (_man timeout_) for ensuring that the script terminates 2 hours later.

http://stackoverflow.com/comment/137934308
type: Comment
comment on: http://stackoverflow.com/q/78239545
score: 0
has text: Have you tried putting `ARGS+=("$@")` after the declare command?
type: QuestionComment

http://stackoverflow.com/comment/137875331
type: Comment
comment on: http://stackoverflow.com/a/78203990
type: AnswerComment
score: 0
has text: As @jhnc showed, this does not work correctly when files have newlines in their names. A standard trick for working around this is: `find .//. -maxdepth 1 -type f | grep -c //`

http://stackoverflow.com/comment/137786997
comment on: http://stackoverflow.com/a/78156004
score: 0
type: Comment
type: AnswerComment
has text: I'd recommend to get in the habit of using `:nnoremap` by default. And `:tabedit` might enable you to open the second file without having to `:update` first.

http://stackoverflow.com/comment/137892382
has text: _Should every shell script start with `exec 2>&1` to avoid problems...?_ -- I wouldn't recommend that. `2>&1` (redirecting stderr to stdout) papers over the differences between stderr and stdout in a way that does damage when you _need_ those differences -- for example, when you're writing content that should go through a pipeline or into a data file / output file to stdout, and content that should be presented directly to the user to stderr.
comment on: http://stackoverflow.com/q/78215669
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/137844600
comment on: http://stackoverflow.com/a/78188933
score: 1
has text: I suggest you edit the question and provide example code there otherwise it is not possible to read from comment
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137777392
type: Comment
has text: ...okay, [POSIX says](https://man7.org/linux/man-pages/man1/more.1p.html) that `more` should read commands from stderr when it's a terminal, and _may_ fall back to `/dev/tty` otherwise. Which... I'd take to mean that this answer probably wouldn't work with a strictly compliant implementation.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78150663

http://stackoverflow.com/comment/137927586
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78235578
has text: oh wow, that works. But why did that work?

http://stackoverflow.com/a/78242889
answers question: http://stackoverflow.com/q/78240155
has body: This might work for you (GNU sed &amp; parallel): parallel echo 's/{1}/{2}/g' ::: $elements :::+ {1..999} | sed -f - file Use parallel to build up the sed commands into a file which is imported using the -f option on a piped invocation of sed. N.B. If there are more than 999 elements, then increase the argument. Beware of overlapping patterns!
score: 1
upvote count: 1
downvote count: 0
type: Answer

http://stackoverflow.com/comment/137935444
has text: (honestly, I find it suspicious that they're trying to obfuscate the script at all; usually that's done by people who are either super incompetent about key management - which isn't obviously the case here - or people trying to bypass anti-malware measures; if the place they download packages from is on security tools' radar as a source of malicious code, you don't want that fact to be getting past scanners).
comment on: http://stackoverflow.com/q/78239018
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137854448
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78194502
has text: (`source` behaves like functions in other respects as well -- see `return`'s behavior f/e)

http://stackoverflow.com/comment/137801035
has text: It seems to work, but when it starts writing the file again: `xxd -r ${FILE}.tmp2 > $FILE` the final file grows endlessly to several dozen gigabytes (the original file is over 20 megabytes). And the MaxRagDollCount value itself does not change.
score: 0
comment on: http://stackoverflow.com/a/78155511
type: Comment
type: AnswerComment

gnome-terminal
type: Tag
tags question: http://stackoverflow.com/q/78260557
tag name: gnome-terminal
tags question: http://stackoverflow.com/q/78436977
tags question: http://stackoverflow.com/q/79404066

http://stackoverflow.com/comment/137787935
type: QuestionComment
type: Comment
has text: http://shellcheck.net/ will flag these problems for you automatically.
score: 1
comment on: http://stackoverflow.com/q/78156916

pnpm
type: Tag
tags question: http://stackoverflow.com/q/78166360
tag name: pnpm

http://stackoverflow.com/comment/138019733
score: 0
comment on: http://stackoverflow.com/a/78281278
has text: @Philippe This error message is from the POSIX awk of Solaris; but it's not the only one, I get similar errors on macOS, FreeBSD and AIX
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137903377
type: QuestionComment
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
comment on: http://stackoverflow.com/q/78221728
type: Comment
score: 0

http://stackoverflow.com/comment/137891864
score: 0
type: QuestionComment
has text: Wow! It works ... may you provide an answer and explain in detail how does it make a difference and why? What is the impact of `exec 2>&1` causing the right order of outputs in Textadept and how did it come that it was not in the right order in first place? Should every shell script start with `exec 2>&1` to avoid problems with running it from some IDE environment?
type: Comment
comment on: http://stackoverflow.com/q/78215669

http://stackoverflow.com/comment/137847066
type: Comment
score: 3
has text: Anyhow, bottom line, if you really want the fastest possible way to run a bunch of tiny sqlite statements quickly, I'd probably use an entirely different stack -- most likely Go. The Python interpreter has overhead, parsing SQL queries as strings has overhead; if you really want to optimize for spending as much time as possible in sqlite itself and as little in anything else, neither Python _nor_ awk _nor_ the command-line sqlite client is ideal.
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193

http://stackoverflow.com/tag/json
tags question: http://stackoverflow.com/q/78221337
tags question: http://stackoverflow.com/q/78227591
tags question: http://stackoverflow.com/q/78253195
tag name: json
type: Tag
tags question: http://stackoverflow.com/q/78239630
tags question: http://stackoverflow.com/q/78175570
tags question: http://stackoverflow.com/q/78212759
tags question: http://stackoverflow.com/q/78423157
tags question: http://stackoverflow.com/q/78411838
tags question: http://stackoverflow.com/q/78422524
tags question: http://stackoverflow.com/q/78456512
tags question: http://stackoverflow.com/q/78490743
tags question: http://stackoverflow.com/q/78561876
tags question: http://stackoverflow.com/q/78491313
tags question: http://stackoverflow.com/q/78592653
tags question: http://stackoverflow.com/q/78691133
tags question: http://stackoverflow.com/q/78742408
tags question: http://stackoverflow.com/q/78647980
tags question: http://stackoverflow.com/q/78604131
tags question: http://stackoverflow.com/q/78608644
tags question: http://stackoverflow.com/q/78736348
tags question: http://stackoverflow.com/q/78797043
tags question: http://stackoverflow.com/q/78765364
tags question: http://stackoverflow.com/q/78810394
tags question: http://stackoverflow.com/q/78870424
tags question: http://stackoverflow.com/q/78886723
tags question: http://stackoverflow.com/q/78962905
tags question: http://stackoverflow.com/q/78977238
tags question: http://stackoverflow.com/q/79009319
tags question: http://stackoverflow.com/q/78946376
tags question: http://stackoverflow.com/q/79038230
tags question: http://stackoverflow.com/q/79008215
tags question: http://stackoverflow.com/q/79065379
tags question: http://stackoverflow.com/q/78946487
tags question: http://stackoverflow.com/q/79134868
tags question: http://stackoverflow.com/q/79084052
tags question: http://stackoverflow.com/q/79311905
tags question: http://stackoverflow.com/q/79362025
tags question: http://stackoverflow.com/q/79286312
tags question: http://stackoverflow.com/q/79440815
tags question: http://stackoverflow.com/q/79423387
tags question: http://stackoverflow.com/q/79469366
tags question: http://stackoverflow.com/q/79524158

http://stackoverflow.com/comment/137922830
type: Comment
has text: ...you could also get rid of `chapters.txt`, replacing `<chapters.txt` with `< <(ffmpeg -show_chapters "$1" | grep ...)`. I'd think seriously about doing something similar to eliminate `temp.txt` as well outright, though we'd need to know what you're using it for to figure out details.
type: QuestionComment
comment on: http://stackoverflow.com/q/78232246
score: 0

http://stackoverflow.com/comment/138026024
has text: (if you look up the docs I quoted from, you'll see that a few words past the end of the quote it refers to "the first unquoted slash"; thus it's also black-letter documentation that the slash needs to be unquoted as well).
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78291764
score: 0

http://stackoverflow.com/comment/138027424
type: Comment
has text: please update the question with a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) that demonstrates the issue; if the 1st `for` loop is 'working' then replace it with the output from `typeset -p args`; the 2nd 'for' loop should be cut down to just enough code to demonstrate the issue (ie, we don't need to see 76 lines of static html code) .... it looks like the 2nd 'for' loop is merely generating a set of output files where `$day` is used to build the file name (so consider something simple like `echo abc > new_file_$day_name`)
comment on: http://stackoverflow.com/q/78292693
score: 1
type: QuestionComment

zshrc
tag name: zshrc
type: Tag
tags question: http://stackoverflow.com/q/78274299

http://stackoverflow.com/comment/138023062
type: Comment
has text: Keep in mind that `daemon-reload` does not start or enable your service. It only loads the service file so that you *can* start or enable your service. Can you clarify whether you've tried starting/enabling your service?
comment on: http://stackoverflow.com/q/78290118
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137806763
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78166553
type: Comment
has text: Are there any pariticular reasons you want to do this instead of doing it on the `docker build` command line ?

http://stackoverflow.com/comment/137813112
has text: I don't want to pass this info via `docker build` command as I do not have control over how `docker build` is invoked. That's why I am seeking the way to do this inside the Dockerfile itself.
comment on: http://stackoverflow.com/a/78166645
score: 2
type: Comment
type: AnswerComment

4g
type: Tag
tag name: 4g
tags question: http://stackoverflow.com/q/78252038

http://stackoverflow.com/a/78211545
type: Answer
answers question: http://stackoverflow.com/q/78211450
downvote count: 0
has comment: http://stackoverflow.com/comment/137884590
accepted answer of: http://stackoverflow.com/q/78211450
has comment: http://stackoverflow.com/comment/137884574
has comment: http://stackoverflow.com/comment/137885581
has comment: http://stackoverflow.com/comment/137884582
score: 3
has comment: http://stackoverflow.com/comment/137884567
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/137884537
has comment: http://stackoverflow.com/comment/137884786
has body: Wait using wait trap 'echo hello' USR1 USR2 gnome-calculator &gt;/dev/null 2&gt;&amp;1 &amp; echo $$ until wait; do : done and send the signal like so kill -USR1 123

http://stackoverflow.com/q/78209376
tagged with: slackware
downvote count: 0
score: 1
accepted answer: http://stackoverflow.com/a/78209490
tagged with: bash
has title: Optimizing GNU find command with many "-o" (Boolean ∨) statements
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137880750
has comment: http://stackoverflow.com/comment/137881298
tagged with: gnu-findutils
tagged with: optimization
tagged with: gnu-parallel
type: Question
has body: I have the following find command that's run on source directories in Slackware SlackBuild scripts: find -L . \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ -o -perm 511 \) -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; But it can be very slow for projects with many source files. I tried speeding it up with GNU Parallel, but it didn't seem any faster: find -L . \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ -o -perm 511 \) | parallel --bar chmod 755 find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) | parallel --bar chmod 644 Is there a way to optimize this find command better?
has answer: http://stackoverflow.com/a/78209490

http://stackoverflow.com/q/78284887
has comment: http://stackoverflow.com/comment/138013831
tagged with: function
type: Question
upvote count: 0
has body: I wrote a function working quite fine using ANSI escape sequences for terminals like VT100 (normally managed by Linux/Unix terminal emulators). I reported below the Bash code. #!/bin/bash # Returns the line number if <= 255; otherwais 255. function getCurPos() { local CURPOS local -i lineNumb echo -e "\E[6n"; read -sdR CURPOS; CURPOS=${CURPOS#*[} CURPOS=(${CURPOS//;/ }) #echo ${CURPOS[*]} lineNumb=${CURPOS[0]} if [ $lineNumb -gt 255 ]; then return 255 fi return $lineNumb } # $1: text with "echo -e" interpreted syntax ('\n' means "return") function messagetBox() { local oldIFS=IFS unset IFS if [ -z $1 ]; then exit 0; fi local text=$1 local -i maxLineLenght=0 local -i lineLenght=0 local -i lineNumb=0 local -i count local -i line #echo -e "\033[1;31m" echo while read i; do echo -e "| $i "; lineLenght=${#i} lineLenght+=4 if [ $lineLenght -gt $maxLineLenght ]; then maxLineLenght=$lineLenght fi lineNumb+=1 done < <(echo -e $text) count=$maxLineLenght while [ $count -gt 0 ]; do echo -en "-" count+=-1 done #echo -en "\033[u" echo -en "\033[$((lineNumb+2))A\n" count=$maxLineLenght while [ $count -gt 0 ]; do echo -en "-" count+=-1 done echo -en "\033[1B" count=$lineNumb while [ $count -gt 0 ]; do getCurPos line=$? echo -e "\033[${line};${maxLineLenght}H|" count+=-1 done echo -en "\033[${lineNumb}B" echo -e "\033[0m" IFS=$localIFS } ~$ source ./sample.sh ~$ messagetBox "Hello\nMy name is Lorenzo, I was born in Italy." -------------------------------------------- | Hello | | My name is Lorenzo, I was born in Italy. | -------------------------------------------- ~$ The problem is that for text lines longer than the screen column's number, new lines before the first side line unshape the box: ~$ messagetBox "Hello. My name is Lorenzo, I was born in Italy. Hello. My name is Lorenzo, I was born in Italy." | Hello. My name is Lorenzo, I was born in Italy. Hello. My name is Loren------------------------------------------------------------ ---------------------------------------------…
score: -3
has comment: http://stackoverflow.com/comment/138019938
tagged with: text
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/78289713
downvote count: 3
has title: There's a way to show boxed text messages using pure Bash script?
has answer: http://stackoverflow.com/a/78289713
tagged with: messagebox
tagged with: bash
has comment: http://stackoverflow.com/comment/138022420
type: AnsweredQuestion

http://stackoverflow.com/comment/137880492
type: Comment
has text: I do need the exit code of `example`, yes, and I cannot edit it.
score: 0
comment on: http://stackoverflow.com/q/78203871
type: QuestionComment

http://stackoverflow.com/comment/137912820
type: QuestionComment
has text: @CharlesDuffy it's reopened now if you were considering posting an answer.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78226499

http://stackoverflow.com/comment/138039117
comment on: http://stackoverflow.com/q/78299332
has text: Glad it helped. FWIW, `python example.py "$@"` seems to work fine.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137813520
has text: @philippe, like this: `RUN npm run build -- --version=$RELEASE_TAG` and `RUN npm run upload-sourcemaps -- --version=$RELEASE_TAG`. And, then one more command at the bottom that uses same **variable**.
score: 0
comment on: http://stackoverflow.com/q/78166553
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138001927
has text: I don't use Mac, but `grep` matches with BRE (basic regex expressions) by default. You can modify that behavior with `-E` (use ERE - extended regex expressions0 or `-p` (perl compatible regex) All provide different features. For `\S` (or negated whitespace) See [What does the regex \S mean in JavaScript?](https://stackoverflow.com/q/4377480/3422102)
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78278018
type: QuestionComment

http://stackoverflow.com/a/78196477
type: Answer
has comment: http://stackoverflow.com/comment/137864728
answers question: http://stackoverflow.com/q/78196374
score: 1
has comment: http://stackoverflow.com/comment/137865395
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78196374
upvote count: 1
has body: You need to replace the whole line with its first 60 characters. sed -e 's/^\(.\{0,60\}\).*/'"$esc"'[35m║ \1/' # ~~ ~~^^ ~~ # 1 1 2 3 1 remembers the first 60 characters, 2 matches the rest, 3 outputs the remembered part.
has comment: http://stackoverflow.com/comment/137865880
downvote count: 0

http://stackoverflow.com/comment/137995369
score: 4
type: QuestionComment
type: Comment
has text: People here are making simplifying assumptions, because without them processing CSVs using the likes of `sed` is a notoriously annoying problem. It's notorious enough that the [gawk manual](https://www.gnu.org/software/gawk/manual/html_node/Comma-Separated-Fields.html) has a section on how to process CSVs correctly. So I suggest you just use that.
comment on: http://stackoverflow.com/q/78274285

http://stackoverflow.com/comment/137897158
score: 1
has text: Well, what's the difference between your two examples? `wc` reads from stdin, while `cat fichier.txt` does not. So probably `wc` is trying to read from stdin, and it's waiting (it never gets EOF). Try to debug that.
comment on: http://stackoverflow.com/q/78218663
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137957003
type: QuestionComment
type: Comment
has text: Best guess for the cause of the spurious `false` results is that `grep` stops reading input as soon as it finds a match, `dpkg` continues writing and eventually fails to write and gets a `SIGPIPE` error. `dpgk` then exits with a non-zero exit status and that is the exit status of the pipeline (because of `pipefail`). See "Bash Pitfalls #60" (referenced in my previous comment) for more information. You can work around the problem by changing the `grep` invocation so it reads to to the end of its input (and various other ways), but you should consider stopping using `pipefail`.
comment on: http://stackoverflow.com/q/78252458
score: 2

http://stackoverflow.com/comment/137787832
has text: Many thanks, mate! I appreciate you helping me understand this. I had tried all sorts of wrong options, quite blindly I'll admit, cause I don't really understand referencing in BASH. Some of my failed attempts included: `for arr_name in "${active_lists[@]}"; do ` `config_array="${arr_name}[@]"` `config_array="${arr_name[@]}"` `config_array="${($arr_name)[@]}"` `done` You've clarified all this for me now. Much obliged, sir!
score: 0
comment on: http://stackoverflow.com/a/78156732
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78217017
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78216881
score: 3
type: AcceptedAnswer
upvote count: 3
answers question: http://stackoverflow.com/q/78216881
has body: You want if $BITBUCKET_TAG ; then varr="$BITBUCKET_TAG" else varr="Nothing to see here" fi echo "$varr" Note that I've moved your echo to outside of the else block. (I've converted your one liner to something that is legible even in mobile views. The ; are correct for one liners). You're misusing the "dereference" operator (${!var}). Note what you get if you just execute echo "${!BITBUCKET_TAG}" bash: 2.2.2: invalid variable name ${!BITBUCKET_TAG} is expecting another variable name and 2.2.2 can't be used as a variable name AND there is no value assigned to it. Learn to use set -x to see how your code is executing. The line preceded + is showing your code with all env-var, parameter expansions complete. Learn to check you code at https://shellcheck.net and fix any issues flagged before posting code here. Include a note like "Shellcheck validated" # --------- just FYI -------------- Vars with strings including spaces will be "normalized" with single quotes, that is X="2. 2.2" + X='2 2.2' echo "$X" + echo '2 2.2' 2 2.2
type: Answer
has comment: http://stackoverflow.com/comment/137894367

http://stackoverflow.com/q/78175570
score: 0
answer count: 2
tagged with: linux
accepted answer: http://stackoverflow.com/a/78175977
has title: Using Bash to edit VS Code Settings
tagged with: npm
linked to: http://stackoverflow.com/q/73867739
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78175961
possible better answer: http://stackoverflow.com/a/78175961
tagged with: bash
has answer: http://stackoverflow.com/a/78175977
type: Question
tagged with: visual-studio-code
tagged with: http://stackoverflow.com/tag/json
has body: I am trying to use the npm package.json to edit the VS Code settings from a bash script. I found How to change VS Code settings from terminal (bash) which has helped me to almost achieve what I wanted. I am trying to change the color theme of the workbench. My settings.json currently looks like this and is located under HOME/.config/Code/User/ (Linux): { "workbench.colorTheme": "Default Dark Modern" } My bash script looks as follows: #! /usr/bin/bash json -I -f $HOME/.config/Code/User/settings.json -e 'this.workbench.colorTheme="Default Dark Modern"' and I get the following error: undefined:3 this.workbench.colorTheme="Default Dark Modern" ^ TypeError: Cannot set properties of undefined (setting 'colorTheme') at Object.eval (eval at main (/usr/lib/node_modules/json/lib/json.js:1365:27), <anonymous>:3:26) at parseChunk (/usr/lib/node_modules/json/lib/json.js:1569:29) at /usr/lib/node_modules/json/lib/json.js:1426:13 at getInput (/usr/lib/node_modules/json/lib/json.js:738:17) at main (/usr/lib/node_modules/json/lib/json.js:1396:9) at Object.<anonymous> (/usr/lib/node_modules/json/lib/json.js:1764:5) at Module._compile (node:internal/modules/cjs/loader:1368:14) at Module._extensions..js (node:internal/modules/cjs/loader:1426:10) at Module.load (node:internal/modules/cjs/loader:1205:32) at Module._load (node:internal/modules/cjs/loader:1021:12) Node.js v21.7.1 I think it has something to do with that the key "workbench.colorTheme" is separated by a dot, but I unfortunately cannot find anything to fix this issue. I have already tried switching out the " " with ' ' and accessing the key in different ways, for example this[workbench.colorTheme] or this.workbench[colorTheme]

http://stackoverflow.com/comment/138045651
type: QuestionComment
comment on: http://stackoverflow.com/q/78302587
type: Comment
score: 0
has text: Use double-quotes around your variables: `psql -U "$DB_USER" -d "$DB_NAME" -v "user1=$DB_USER" -f initialize_postgres.sql` Have a look at [Store mysql result in a bash array variable](https://stackoverflow.com/a/35276157/1765658), there are sample of variable use in both way. (Maybe you could be interested by my *`shell-connector.sh`*.)

http://stackoverflow.com/q/78208548
answer count: 1
has body: I`m trying to create a docker with rails project: Here`s my dockerfile: FROM ruby:3.1.2-slim RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ build-essential \ gnupg2 \ less \ git \ libpq-dev \ postgresql-client \ libvips42 \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ENV LANG=C.UTF-8 \ BUNDLE_JOBS=4 \ BUNDLE_RETRY=3 RUN gem update --system && gem install bundler WORKDIR /usr/src/app ENTRYPOINT ["sh", "./entrypoint.sh"] EXPOSE 3001 CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"] And here is my entrypoint.sh #!/bin/bash set -e # Remove a potentially pre-existing server.pid for Rails. rm -f /usr/src/app/tmp/pids/server.pid echo "bundle install..." bundle check || bundle install --jobs 4 # Then exec the container's main process (what's set as CMD in the Dockerfile). exec "$@" I`ve also added the rights permissions -rwxr-xr-x 1 vitat staff 274 22 Mar 16:02 entrypoint.sh When I run: docker-compose up -d I got this error: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./entrypoint.sh": stat ./entrypoint.sh: no such file or directory: unknown What I doing wrong?
tagged with: bash
tagged with: ruby-on-rails
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78208750
has title: Docker Rails entrypoint.sh failure
accepted answer: http://stackoverflow.com/a/78208750
tagged with: docker
score: 0
type: Question

http://stackoverflow.com/comment/138029771
type: Comment
score: 0
has text: I have added the relevant files.
comment on: http://stackoverflow.com/q/78294007
type: QuestionComment

http://stackoverflow.com/comment/137815022
comment on: http://stackoverflow.com/a/78171975
score: 0
has text: You can use "seesaw quoting", like ```'single-quoted string with literal `backticks` and $dollar signs adjacent to a '"double-quoted $string where 'they' are `echo "interpolated"`.```
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78249608
score: 2
upvote count: 2
has body: Finally I could make it work and I want to share important steps that should help to get it done or make it into the scripts and wiki of the project: install Cygwin and add wget command in the process to download some package manager download and install apt-cyg for easier tool install without using setup.exe: $ wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg $ install apt-cyg /bin make the internal script-os-check in postbank_pdf2csv*.sh run under Cygwin by adding some code here: old: if [ "$(uname -o)" = "FreeBSD" ] || [ "$(uname -o)" = "Darwin" ] ; then new: if [ "$(uname -o)" = "FreeBSD" ] || [ "$(uname -o)" = "Darwin" ] || [ "$(uname -o)" = "Cygwin" ] ; then in some history version scripts there is some test code that causes some early exit of the script which can be fixed by outcommenting (#) those lines, e.g.: #echo 'hallo' #exit README.md says to install some required tools and we do it like this: $ apt-cyg install ghostscript poppler pstotext different errors arise because of still missing libraries so in summary I fixed it like this: the typical error is C:/cygwin64/bin/pdftotext.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory to determine the missing libraries you could check iteratively the missing ones running cygcheck on it, e.g.: $ cygcheck /usr/bin/pdftotext.exe which may result in e.g.: C:\cygwin64\bin\pdftotext.exe C:\cygwin64\bin\cygpoppler-106.dll C:\cygwin64\bin\cygwin1.dll C:\Windows\system32\KERNEL32.dll C:\Program Files\Eclipse Adoptium\jdk-17.0.2.8-hotspot\bin\api-ms-win-core-rtlsupport-l1-1-0.dll C:\Windows\system32\ntdll.dll C:\Windows\system32\KERNELBASE.dll ... C:\cygwin64\bin\cygssh2-1.dll C:\cygwin64\bin\cygcrypto-1.1.dll C:\cygwin64\bin\cygzstd-1.dll cygcheck: track_down: could not find cygfontconfig-1.dll cygcheck: track_down: could not find cygfreetype-6.dll cygcheck: track_down: could not find cygjpeg-8.dll cygcheck: track_down: could not find cyglcms2-2.dll cygcheck: tr…
downvote count: 0
answers question: http://stackoverflow.com/q/78249607
type: Answer

http://stackoverflow.com/comment/138057304
comment on: http://stackoverflow.com/a/78272045
type: Comment
type: AnswerComment
has text: Probably you don't need to do `num=` here
score: 1

http://stackoverflow.com/comment/137822961
score: 0
has text: I haven't tried the gawk solution you provided yet, but the mawk one above did. I didn't even know mawk was a thing. Thanks.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78177038

audit
tags question: http://stackoverflow.com/q/78154096
tag name: audit
type: Tag

http://stackoverflow.com/comment/137919426
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78228745
has text: `still doesnt work with uudeview` how are you using it? What "doesn't work"? What happens, what does not happen? What are the stderr logs?
type: Comment

http://stackoverflow.com/comment/137922794
has text: (similarly, `file=${1%.*}` and `ext=${1##*.}`; mind, you might want to check for and handle the case where the filename has no dots in it at all).
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78232246
score: 0

http://stackoverflow.com/q/78298036
downvote count: 0
has comment: http://stackoverflow.com/comment/138038970
score: 1
tagged with: environment-variables
has comment: http://stackoverflow.com/comment/138039014
answer count: 1
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78301560
has title: Environment Variables are not seen in Bash Applications
accepted answer: http://stackoverflow.com/a/78301560
tagged with: bash
type: Question
has body: I am trying to pass a password to a Postgres db in bash on Ubuntu 22.04. like so: export PGPASSWORD=postgrespw when I am trying to use them in applications like so: (for example cjdb, a program handling uploading to a PostgreSQL database, https://github.com/cityjson/cjdb: The password can be specified in the PGPASSWORD environment variable. If not specified, the app will prompt for the password. ) cjdb import -H localhost -U postgres -d test -s cjdb -f src/cjdb/LoD2_326625712.jsonl or like this: (martin, a program also handling some database function on PostgreSQL db) martin --config config.yaml I always get "missing password". using psql directly strangely works: psql -U postgres testcjdb -h localhost both of the mentioned programs clearly state that they support the use of the env variable PGPASSWORD How can I figure out if it's the programs fault (which I kind of don't believe), or if something is off with my bash terminal?
has comment: http://stackoverflow.com/comment/138038587
has comment: http://stackoverflow.com/comment/138038059
tagged with: postgresql
has comment: http://stackoverflow.com/comment/138038649
has comment: http://stackoverflow.com/comment/138038691
has comment: http://stackoverflow.com/comment/138037956
upvote count: 1
has comment: http://stackoverflow.com/comment/138038090

http://stackoverflow.com/comment/138041958
score: 0
comment on: http://stackoverflow.com/q/78298728
type: QuestionComment
has text: just to have a short command typing in terminal
type: Comment

http://stackoverflow.com/comment/137882177
type: QuestionComment
type: Comment
has text: Proper security lies server-side, not client-side
comment on: http://stackoverflow.com/q/78210154
score: 0

http://stackoverflow.com/comment/137891768
type: Comment
has text: I have checked it in a Terminal shell ... and I can't reproduce this behavior in the xfce4-terminal Terminal running bash either, so I have edited the question to give further details about the observed behavior.
score: 0
comment on: http://stackoverflow.com/q/78215669
type: QuestionComment

http://stackoverflow.com/a/78299289
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78298936
type: Answer
has body: As it was mentioned by KamilCuk, according to signal(7) manual both SIGINT and SIGQUIT are from keyboard. So it makes sense to ignore them in detached processes. We need to use another signal (e.g. SIGUSR1) #! /bin/bash must_stop="" function sigint_handler() { echo "SIGUSR1" must_stop="1" exit 1 } trap sigint_handler SIGUSR1 COUNTER=0 while [ -z "${must_stop}" ] do ((COUNTER+=1)) echo "#${COUNTER} Working..." sleep 1 & wait $! done

http://stackoverflow.com/q/78188141
has body: Having a testenv in a tox.ini file, how do we execute bash commands? [testenv:testenv_name] description = testenv_description. commands = export ABC="123" echo $ABC
tagged with: bash
has title: How to run bash commands in a tox.ini command
has answer: http://stackoverflow.com/a/78188142
tagged with: tox
downvote count: 2
type: Question
upvote count: 0
type: UnansweredQuestion
answer count: 1
favorite count: 0
score: -2

http://stackoverflow.com/comment/137854339
score: 0
comment on: http://stackoverflow.com/q/78190193
has text: I'd say if you're stuck using shell to call awk to call shell to call sqlite3 then get rid of the "to call awk to call shell" part and just call `sqlite3` directly from the shell script that's currently calling awk , but whether that's reasonable or not depends on what "# more proprietary code that reads the mux and dumps value to DIN variable" is doing and whether or not that could be implemented differently if necessary.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/137876950
type: Comment
comment on: http://stackoverflow.com/q/78207181
has text: Don't use /usr/sbin, prefer /usr/bin or even /home/yourUsername
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137866707
score: 0
has text: What part of it isn't working correctly? If you run the individual commands by hand, do they get the expected results? If not, you should ask about those commands on [unix.se].
type: QuestionComment
comment on: http://stackoverflow.com/q/78201574
type: Comment

http://stackoverflow.com/comment/137927647
type: Comment
type: AnswerComment
has text: @BobbyOcean `help printf`
score: 0
comment on: http://stackoverflow.com/a/78235578

http://stackoverflow.com/q/78287441
has answer: http://stackoverflow.com/a/78287610
type: Question
has comment: http://stackoverflow.com/comment/138021751
type: UnansweredQuestion
has body: As far as I know, command sed precesses its input line by line. Thus, the following command successfully outputs only the directories in the current directory: $ ls -p -1 | sed -n '/\/$/p' Here option -1 to ls makes its output appear in a column, so sed can process it line by line. However, if I remove option -1 this command still works. Why? Without option -1 the output of ls is not a set of separated lines. EDIT I posted the question here in the Unix &amp; Linux forum, just to get it also closed soon after because it's a duplicate. Anyway, I got the answer reading the question referenced by duplicate highlight there. Thanks.
upvote count: 1
tagged with: sed
score: 0
tagged with: linux
tagged with: bash
linked to: http://stackoverflow.com/q/36258224
answer count: 1
favorite count: 0
tagged with: ls
downvote count: 1
has title: Non-column output of `ls` piped to `sed`
has comment: http://stackoverflow.com/comment/138018442
has comment: http://stackoverflow.com/comment/138018224
tagged with: unix
has comment: http://stackoverflow.com/comment/138017990

http://stackoverflow.com/comment/137867714
type: Comment
comment on: http://stackoverflow.com/q/78202033
score: 1
has text: You're overriding the container command. So, the broker isn't running at the time you're trying to create topics
type: QuestionComment

http://stackoverflow.com/comment/137855232
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78194973
has text: Note that to be on-topic here, questions need to be about narrow, specific problems. While I closed it as duplicative of three separate smaller problems with answers that combine to address your larger issue, it also could have been closed as "too broad" since it isn't focused on a specific issue and is instead an open-ended "help me refactor this code" request.
type: QuestionComment

printf
tag name: printf
tags question: http://stackoverflow.com/q/78297320
tags question: http://stackoverflow.com/q/78283701
type: Tag
tags question: http://stackoverflow.com/q/78219094
tags question: http://stackoverflow.com/q/78173269
tags question: http://stackoverflow.com/q/78360964
tags question: http://stackoverflow.com/q/78538377
tags question: http://stackoverflow.com/q/78642423
tags question: http://stackoverflow.com/q/78657687
tags question: http://stackoverflow.com/q/79066953
tags question: http://stackoverflow.com/q/78955277
tags question: http://stackoverflow.com/q/79125428
tags question: http://stackoverflow.com/q/79395000
tags question: http://stackoverflow.com/q/79315347
tags question: http://stackoverflow.com/q/79490250
tags question: http://stackoverflow.com/q/79514807
tags question: http://stackoverflow.com/q/79514950

http://stackoverflow.com/comment/137831899
has text: I already have the shebang initially, but I still yet don't understand why is not properly `varead` or `read` input in the first place when I want it to lol. It executes fine, but it does not even attempt to read the input
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78178090

http://stackoverflow.com/q/78235101
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/137926865
has title: Initialization of an empty Bash indexed array
has comment: http://stackoverflow.com/comment/137926809
has body: I’ve read some of the related questions on the subject but didn’t find the precise one I have in mind. I hope it’s not because it is too stupid. In Bash 5 (5.2.15 if that matters), does it make any difference declaring an array like: declare -a foo compared with: declare -a foo=() I wonder if the first declaration does ensure the creation of an empty array, or only the second one guarantees that? You may ask, what the point in initializing an empty array? Why not initializing it only when it’s needed storing a first element? Well, I don’t know, maybe? Then another question arises, would it be safe to initialize the array only when storing the first element with the append operator? Like: bar+=('baz') (bar here being not defined before this first element is appended) it seems not to be a problem, even if option nounset is set, but doing so, am I assured 'baz' will always be the first element in the array? Is it safe to do that? Also, in the case I’d need to change the default scope of the variable, I guess I couldn’t avoid using declare (or local), and it seems wrong to call declare or local every times I append an element (while it seems to work though). Sorry if it’s a stupid question or is badly worded. Have a nice day.
upvote count: 3
tagged with: initialization
tagged with: arrays
type: Question
has comment: http://stackoverflow.com/comment/137927044
downvote count: 0
has comment: http://stackoverflow.com/comment/137926912
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78235206
has comment: http://stackoverflow.com/comment/137926822
has comment: http://stackoverflow.com/comment/137926834
accepted answer: http://stackoverflow.com/a/78235206
tagged with: bash
has comment: http://stackoverflow.com/comment/137926914
has comment: http://stackoverflow.com/comment/137927006

http://stackoverflow.com/comment/138006135
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78274675
has text: You say you are running `autoreconf`. Is that necessary? The usage model around which the Autotools are designed calls for software distributions to include AT-generated artifacts, in which case those just building the software on a supported platform ***should not*** run `autoreconf` or the other Autotools. However, you might indeed need to do, because it has become common for projects to ignore that usage model. But if you don't need to `autoreconf`, then don't do it.
type: Comment

http://stackoverflow.com/comment/137817749
type: Comment
comment on: http://stackoverflow.com/q/78173589
has text: You don't need process substitutions for that, `<(cat)` can be replaced with `-`.
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137827515
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78178090
has text: You are tagging the question _bash_ **AND** _zsh_, but then run it as _sh_. Please make up your mind first which shell you are going to use, before complaining what does not work.
type: QuestionComment

http://stackoverflow.com/comment/137849577
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78178090
has text: @ZeidTisnes Background processes are paused if they try to read from the terminal; see ["Why do backgrounded processes sometimes stop spontaneously?"](https://unix.stackexchange.com/questions/25024/why-do-backgrounded-processes-sometimes-stop-spontaneously)

http://stackoverflow.com/q/78274285
has body: Good morning everyone, I have a csv and want to replace all delimiter "," with the delimiter ";", but I have to maintain the "," if it is in a string (in csv field): Current csv "001","User,Super","04/04/2024" Expected csv "001";"User,Super";"04/04/2024" Is there a way to exclude the check if it is between a string? I would like to do this in bash with a couple of commands without the need of writing a custom loop to check every character and check the position I tried the following command but with no success: sed -r 's/("*,*")|,/\;/g' test.csv
type: Question
answer count: 4
has comment: http://stackoverflow.com/comment/137995589
tagged with: linux
accepted answer: http://stackoverflow.com/a/78276869
linked to: http://stackoverflow.com/q/1560393
has answer: http://stackoverflow.com/a/78276869
has title: Using sed to replace a character but not if it is in a string in bash csv file
tagged with: sed
possible better answer: http://stackoverflow.com/a/78274313
upvote count: 2
tagged with: bash
score: 1
has comment: http://stackoverflow.com/comment/137996780
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78274313
has answer: http://stackoverflow.com/a/78275673
downvote count: 1
has comment: http://stackoverflow.com/comment/137995369
has answer: http://stackoverflow.com/a/78274409

http://stackoverflow.com/a/78276949
type: Answer
has body: Solutions that use eval are potentially dangerous because they can lead to unwanted code being run. For instance, if you make a mistake editing hg.ini (or somebody else edits it with mischievous or malicious intent) and end up with these contents [hello goodbye] x=hello who y=goodbye.cruel.cruel.world z=I.dont.know.why.you.say.goodbye.I.say.hello then simple code that uses eval may run the who command (generating information about the users logged in on the system) and not set x at all (because it is set only temporarily while the who command is running). See Why should eval be avoided in Bash, and what should I use instead? and BashFAQ/048 (Eval command and security issues). Using source is just as dangerous because source FILE is equivalent to eval "$(cat FILE)". A simple solution that uses source may also run who and not set x. This Shellcheck-clean Bash code will always set x and will never run any code contained in the hg.ini file: #! /bin/bash -p xass=$(grep x= hg.ini) x=${xass#x=} declare -p x When run with the bad hg.ini file above this program outputs declare -- x="hello who" (showing that x is a scalar string variable containing the string hello who). ${xass#x=} expands to the value of xass (hopefully a line from hg.ini) with leading x= removed. See Removing part of a string (BashFAQ/100 (How do I do string manipulation in bash?)). declare -p x prints the value of x in an unambiguous way that may reveal invisible characters or unexpected variable properties. echo "$x" is not a reliable way to print the value of a variable. See Bash Pitfalls #14 (echo $foo). printf '%s\n' "$x" is safe, but will not reveal invisible characters (e.g. trailing spaces) or variable properties.
answers question: http://stackoverflow.com/q/78276574
upvote count: 1
downvote count: 0
score: 1

http://stackoverflow.com/comment/137858187
has text: It's not going to have any effect unless there are single quote characters in the data you're parsing, so it's probably not related to the problem you're having.
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78196593

http://stackoverflow.com/comment/137811988
score: 1
has text: it may be safer to do `"date ... -d @"$2 | getline s; print $0,s` so there is no opportunity for injection issues (and assuming `$2` has also been sanitised)
type: Comment
comment on: http://stackoverflow.com/a/78170533
type: AnswerComment

http://stackoverflow.com/comment/137891642
has text: (see https://stackoverflow.com/questions/45760692/separately-redirecting-and-recombining-stderr-stdout-without-losing-ordering for discussion of the case where someone _is_ splitting and recombining the streams)
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78215669
type: Comment

http://stackoverflow.com/comment/137998883
comment on: http://stackoverflow.com/q/78272610
type: Comment
has text: @WilliamPursell: yeah I don't think `export` affects the question at all; just happened that my use case needs `export`.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137888081
comment on: http://stackoverflow.com/q/78213645
type: Comment
type: QuestionComment
score: 0
has text: https://www.gnu.org/software/bash/manual/bash.html#index-_005b_005b

http://stackoverflow.com/comment/138016117
has text: what do you mean by `bigger tables`? more rows? more columns? something else? how does this code 'no longer work'? error? wrong answer? hangs? something else?
score: 3
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78286060

http://stackoverflow.com/q/78272610
has body: This is almost the same (BUT NOT THE SAME!) as this question. I want to save and restore a single environment variable, and leave it unset if it was unset. But unlike that question I don't have the option of using a subshell because the "middle" command sets some other environment variables I want to keep. I.e. $ cat ./myenv.sh export SOME_VAR=1 export OTHER_VAR=1 $ save SOME_VAR $ source ./myenv.sh $ restore SOME_VAR After this SOME_VAR should be unset and OTHER_VAR should be 1. How can I do this?
type: UnansweredQuestion
score: 1
tagged with: bash
has answer: http://stackoverflow.com/a/78272868
has title: Restore previous value or unset environment variable without subshell
has comment: http://stackoverflow.com/comment/137998879
linked to: http://stackoverflow.com/q/40190736
has comment: http://stackoverflow.com/comment/137993441
has comment: http://stackoverflow.com/comment/137992273
has comment: http://stackoverflow.com/comment/137998875
has answer: http://stackoverflow.com/a/78273432
has comment: http://stackoverflow.com/comment/137998883
has comment: http://stackoverflow.com/comment/137992287
has comment: http://stackoverflow.com/comment/137993787
type: Question
has comment: http://stackoverflow.com/comment/137992732
downvote count: 0
has comment: http://stackoverflow.com/comment/137993875
has answer: http://stackoverflow.com/a/78272713
tagged with: environment-variables
answer count: 3
upvote count: 1
favorite count: 0

http://stackoverflow.com/a/78167823
has comment: http://stackoverflow.com/comment/137807129
score: 1
has body: Using GNU awk for arrays of arrays and length(array): $ cat ./tst.sh #!/usr/bin/env bash arr=(test,meta my,amazon test,amazon this,meta test,google my,google hello,microsoft) printf '%s\n' "${arr[@]}" | awk -F',' ' { vals_locs[$1][$2] } END { for ( val in vals_locs ) { out = length(vals_locs[val]) " " val ": " sep = "" for ( loc in vals_locs[val] ) { out = out sep loc sep = ", " } print out } } ' $ ./tst.sh 1 hello: microsoft 1 this: meta 2 my: google, amazon 3 test: google, amazon, meta
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78167734
downvote count: 0

http://stackoverflow.com/comment/137797340
has text: Thanks Charles, I did fix this after fixing the initial issue.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78161552
score: 0

http://stackoverflow.com/comment/137892105
type: QuestionComment
type: Comment
has text: Textadept for the GUI version rely on Qt's or Gtk's process spawning features, and for the Terminal version polls manually (the easiest maintenance-wise for the maintainer of the project ). SciTE output buffer works OK like Terminals do.
comment on: http://stackoverflow.com/q/78215669
score: 0

http://stackoverflow.com/comment/137988456
comment on: http://stackoverflow.com/q/78270350
score: 0
type: QuestionComment
has text: (As a completely different, language-agnostic piece of advice -- try to get out of the habit of treating recursion as if it were a GOTO; that's a habit that tends to bite people, either by way of running out of stack, or unintended side effects of the unwinding process; typically the cases where this is done are situations where an explicit state machine or a top-level function that calls children in turn will make more sense).
type: Comment

http://stackoverflow.com/comment/137854341
comment on: http://stackoverflow.com/a/78194502
score: 0
has text: (That is to say: If the OP didn't have "using the source command" in the question, we could just close it as a duplicate with one of our many preexisting questions on the topic having answers that tell people to use `set --` for this purpose and be done).
type: Comment
type: AnswerComment

serial-port
tags question: http://stackoverflow.com/q/78183685
type: Tag
tag name: serial-port

http://stackoverflow.com/comment/137838243
has text: @Nic3500 wen I check the system log file I got this 'Mar 19 10:08:44 MacBook-de-Kevin login[41784]: DEAD_PROCESS: 41784 ttys002 Mar 19 10:13:11 MacBook-de-Kevin syslogd[127]: ASL Sender Statistics Mar 19 10:24:18 MacBook-de-Kevin syslogd[127]: ASL Sender Statistics Mar 19 10:34:43 MacBook-de-Kevin syslogd[127]: ASL Sender Statistics Mar 19 10:44:43 MacBook-de-Kevin syslogd[127]: ASL Sender Statistics Mar 19 10:45:18 MacBook-de-Kevin login[47962]: USER_PROCESS: 47962 ttys002' There is no log related to cron ! is it normal ?
comment on: http://stackoverflow.com/q/78183354
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/a/78196299
answers question: http://stackoverflow.com/q/78195964
downvote count: 0
score: 3
has body: Try this Shellcheck-clean Bash code: #! /bin/bash -p args=() for a in "$@"; do $a == b || args+=( "$a" ) done set -- "${args[@]}" (( $# > 0 )) && printf '%s\n' "$@" When run with arguments 'a 1' b 'c 2' it produces output a 1 c 2 When run with arguments -x "a'1" b 'c 2' "'\$(echo REBOOTING >&2)'" it produces output -x a'1 c 2 '$(echo REBOOTING >&2)' The -- argument to set prevents subsequent arguments (e.g. -x) being treated as options.
type: Answer
upvote count: 3

http://stackoverflow.com/q/78212724
tagged with: http://stackoverflow.com/tag/html
score: 0
has comment: http://stackoverflow.com/comment/137887468
type: Question
type: UnansweredQuestion
tagged with: css
has comment: http://stackoverflow.com/comment/137888142
has comment: http://stackoverflow.com/comment/137889856
answer count: 2
has answer: http://stackoverflow.com/a/78214277
tagged with: bash
upvote count: 1
favorite count: 0
has body: i made this #Swatch(https://codepen.io/ricoThaka/pen/YzMVdXj?editors=1100 <~) i want to expand it to a flexible layout that can contain unlimited colors for the swatch ` .swatch div:nth-child(1) { background: DeepPink;} .swatch div:nth-child(2) { background: cyan;} .swatch div:nth-child(3) { background: GreenYellow;} .swatch div:nth-child(4) { background: CornflowerBlue;} .swatch div:nth-child(5) { background: Coral;} ` Thats the values that i want to exponentially increment and manipulate in a nice #CSSGRid that kinda spider webs to my wife phone screen, thats how we talk @normani ` i=1 until [ $i -gt 8 ]; do echo ".swatch div:nth-child($i){ background: ;}" ((i=i+1)) done .swatch div:nth-child(1){ background: ;} .swatch div:nth-child(2){ background: ;} .swatch div:nth-child(3){ background: ;} .swatch div:nth-child(4){ background: ;} .swatch div:nth-child(5){ background: ;} .swatch div:nth-child(6){ background: ;} .swatch div:nth-child(7){ background: ;} .swatch div:nth-child(8){ background: ;} ` how do i get the background hex values loaded? im storing them in a file ~> ` ``` for i in `cat colorvalues.csv`; do echo "$i"; done ``` #9acd32 #efcc00 #ffd300 #ffae42 #ffef00 #fefe33 #0014a8 #2c1608... like i want to feed that list like this .swatch div:nth-child(1){ background: #xxxxxx ;} .swatch div:nth-child(2){ background: #xxxxxx ;} .swatch div:nth-child(3){ background: #xxxxxx ;} .swatch div:nth-child(4){ background: #xxxxxx ;} ` #BASH_iNTERPETER = https://www.onlinegdb.com/edit/0LXwgPkFV its supposed to create a bunch of divs i just paste into my css file the divs in the html r empty enter image description here ` i=1 until [ $i -gt 8 ]; do echo ".swatch div:nth-child($i){ background: ;}" ((i=i+1)) done .swatch div:nth-child(1){ background: ;} .swatch div:nth-child(2){ background: ;} .swatch div:nth-child(3){ background: ;} .swatch div:nth-child(4){ background: ;} .swatch div:nth-child(5){ background: ;} .swatch div:nth-child(6){ background: ;} .swatch div:nth-chil…
downvote count: 1
has title: I want to increment a number and insert $i values from a csv array #confused
has answer: http://stackoverflow.com/a/78214785

http://stackoverflow.com/comment/137938836
has text: What's the language? Please add the language tag.
comment on: http://stackoverflow.com/q/78241899
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137804210
comment on: http://stackoverflow.com/q/78166124
score: 0
type: QuestionComment
type: Comment
has text: Yes, both `find dir -maxdepth 1 -name "*${subdir}*" -type d` and `for i in "${dir}"/*"${subdir}"*/` work, interestingly. It's just the output of `ls` which is somehow funked up. Weird. I just can't let it go. Why is it different specifically?

http://stackoverflow.com/comment/137791596
score: 0
type: QuestionComment
type: Comment
has text: Since the code you posted, is syntactically not correct, we can't discuss it. Please make code free of errors before posting. As for setting your variable, the simplest way would be `MY_SPECIAL_FILE=$PWD/hello.txt`.
comment on: http://stackoverflow.com/q/78157779

http://stackoverflow.com/a/78204135
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78203984
type: Answer
has comment: http://stackoverflow.com/comment/137871580
has comment: http://stackoverflow.com/comment/137875405
has comment: http://stackoverflow.com/comment/137876852
has comment: http://stackoverflow.com/comment/137876648
has body: files_in_pwd()( shopt -s nullglob dotglob any=( * ) dirs=( */ ) notdir_count=$(( ${#any[@]} - ${#dirs[@]} )) echo "Number of files in the pwd: $notdir_count" ) files_in_pwd()( shopt -s nullglob dotglob n=0 for e in *; do # add appropriate extra tests if ! -d $e ; then (( n++ )) fi done echo "Number of files in the pwd: $n" )
has comment: http://stackoverflow.com/comment/137877409
upvote count: 1
has comment: http://stackoverflow.com/comment/137876825

http://stackoverflow.com/q/78163771
tagged with: fastlane
type: Question
answer count: 0
has title: Set and pass environment variable from Fastlane to calling bash script
type: UnansweredQuestion
has body: I am wanting to set an environment variable in Fastlane, and pass it back to a calling Bash script. Just as a simple example, I run this Bash script: #!/bin/sh fastlane beta echo $DELIVER_USER Somewhere in my lane code I have: sh(command: 'export DELIVER_USER=joe') But the echo in the calling script does not show "joe", it doesn't show anything. Is there a way that I can do this? Or some other way to be able to pass a value from Fastlane back to the calling Bash script?
has comment: http://stackoverflow.com/comment/137800046
score: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/137800553
has comment: http://stackoverflow.com/comment/137803089

http://stackoverflow.com/comment/137826816
has text: You don't have to retrieve it as an artifact. `gdb -batch -ex bt ./test /path/to/coredump` should work.
comment on: http://stackoverflow.com/q/78178759
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78188914
has title: Bash regex: Do you have to escape a backtick with a character class?
accepted answer: http://stackoverflow.com/a/78188933
score: 1
has comment: http://stackoverflow.com/comment/137845063
upvote count: 1
linked to: http://stackoverflow.com/q/218156
favorite count: 0
type: AnsweredQuestion
has body: I've found in a regex I have that if the string I'm testing has a backtick in it, I can only get it to match is if I escape the backtick while enclosed in brackets > [\`]. Regularly escaping the character like you would an asterisk \* does not work, nor does just keeping the backtick in brackets. In fact, the formatting of this post gets screwed up with these backticks. What is it with backticks that causes such mayhem? I know they have a special function in bash, but matching them is much more complicated than other characters. EDIT: @anubhava has an example that works, but I still see in my particular regex that the backtick MUST be escaped. Example below, the backtick is right before the capturing parentheses. pattern="symbolic[[:space:]]link[[:space:]]to[[:space:]][\`]([^[[:space:]]+)'" This should match to some text like this: z1.gz: symbolic link to `zip1.gz' This is a simple file command return, but could apply to anything else.
possible better answer: http://stackoverflow.com/a/78189875
answer count: 2
downvote count: 0
tagged with: bash
type: Question
has answer: http://stackoverflow.com/a/78189875
tagged with: regex
has comment: http://stackoverflow.com/comment/137845195
has answer: http://stackoverflow.com/a/78188933

http://stackoverflow.com/a/78167873
accepted answer of: http://stackoverflow.com/q/78167734
has body: You may consider this solution that would with any version of awk: printf '%s\n' &quot;${arr[@]}&quot; | awk -F, ' { row[$1] = (fq[$1]++ ? row[$1] &quot;, &quot; : &quot;&quot;) $2 } END { for (k in fq) print fq[k], k &quot;:&quot;, row[k] }' | sort -rn -k1 3 test: meta, amazon, google 2 my: amazon, google 1 this: meta 1 hello: microsoft Note that, I have used sort to get output as per your shown expected output. If you don't care about ordering that you can remove sort command.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137812365
has comment: http://stackoverflow.com/comment/137807081
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/137807124
score: 2
answers question: http://stackoverflow.com/q/78167734
downvote count: 0

http://stackoverflow.com/comment/137911643
comment on: http://stackoverflow.com/q/78226499
type: QuestionComment
has text: so, if I understand correctly, when i capture SIGINT and override it, I also have to explicitely write in my script to exit (if I want it to) ? And if i don't, my captured SIGINT is just gonna do some other stuff without actually killing my script?
type: Comment
score: 0

http://stackoverflow.com/comment/137831411
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78175689
type: Comment
has text: This does work, and does solve my issue, but, I'm having some issues running other commands. I'm trying to run a `git clone`, but when I do, I simply get no output at all. `{git clone https://github.com/repo $SITE_DIR} 2> >(sed 's/^/E:/') > >(sed 's/^/S:/')` Otherwise, this works. Is there something different about the output of `git clone`?

http://stackoverflow.com/comment/137871748
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78203871
score: 0
has text: But what's the point?

http://stackoverflow.com/comment/137837688
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78185284
has text: What is the `\n`? Is it two characters a backslash and a `n` or is it a single LF character? Sed see whole lines so should not see the end-of-line (or line separation) characters.

http://stackoverflow.com/comment/138034690
type: QuestionComment
has text: Then, if I go to the server vía ssh session and exec "sudo systemctl stop myService.service", then "sudo systemctl daemon-reload" and lastly "sudo systemctl start myService.service", the changes made to file myService.service when executing the script are applied to the new running. So, it seems a problem when doing the daemon reload throught ssh -i "/myssh.key" myuser@host "sudo systemctl daemon-reload"
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78290118

http://stackoverflow.com/comment/137856028
has text: maybe add_element_with_jq() is have an syntax using function keyword?
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78195387

http://stackoverflow.com/comment/137871115
score: 0
has text: just to clarify, does *) echo to_add ;; cover removing the if statement so?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78203898

http://stackoverflow.com/comment/138007448
type: Comment
score: 0
type: AnswerComment
has text: @Barmar That's right; `bash_var` comes from an argument to the script.
comment on: http://stackoverflow.com/a/78281278

http://stackoverflow.com/comment/137778325
type: Comment
has text: test_02.py is definitely not calling test_01.py, i've already checked that.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78147099

http://stackoverflow.com/comment/138039045
score: 1
type: QuestionComment
type: Comment
has text: Aren't all arguments positional arguments?
comment on: http://stackoverflow.com/q/78299332

terminal
tags question: http://stackoverflow.com/q/78246449
tags question: http://stackoverflow.com/q/78261786
tag name: terminal
tags question: http://stackoverflow.com/q/78245937
tags question: http://stackoverflow.com/q/78241462
tags question: http://stackoverflow.com/q/78294007
type: Tag
tags question: http://stackoverflow.com/q/78353017
tags question: http://stackoverflow.com/q/78316829
tags question: http://stackoverflow.com/q/78324472
tags question: http://stackoverflow.com/q/78444401
tags question: http://stackoverflow.com/q/78402822
tags question: http://stackoverflow.com/q/78503442
tags question: http://stackoverflow.com/q/78570634
tags question: http://stackoverflow.com/q/78576313
tags question: http://stackoverflow.com/q/78572680
tags question: http://stackoverflow.com/q/78654909
tags question: http://stackoverflow.com/q/78617693
tags question: http://stackoverflow.com/q/78665352
tags question: http://stackoverflow.com/q/78617714
tags question: http://stackoverflow.com/q/78636388
tags question: http://stackoverflow.com/q/78605457
tags question: http://stackoverflow.com/q/78885332
tags question: http://stackoverflow.com/q/78752438
tags question: http://stackoverflow.com/q/78983275
tags question: http://stackoverflow.com/q/78998999
tags question: http://stackoverflow.com/q/79234977
tags question: http://stackoverflow.com/q/79192025
tags question: http://stackoverflow.com/q/79412418
tags question: http://stackoverflow.com/q/79327606
tags question: http://stackoverflow.com/q/79403981
tags question: http://stackoverflow.com/q/79546833
tags question: http://stackoverflow.com/q/79465297
tags question: http://stackoverflow.com/q/79447335

http://stackoverflow.com/comment/137855913
comment on: http://stackoverflow.com/q/78194991
type: QuestionComment
has text: If you're killing a mixture of processes, some owned background jobs of the current shell and others not, then you might want to suppress `disown`'s error output and ignore failures: `disown "$PROCESS_ID" 2>/dev/null || :`.
type: Comment
score: 1

http://stackoverflow.com/q/78260874
score: 0
tagged with: bash
tagged with: optimization
tagged with: mpi
has body: I created a file with molecule coordinates that I wanted to optimize, but when i end the file with esc :wq, and execute the command qsub -pe mpi 8 [name of file], I only get errors. my file What am I doing wrong? (I am a beginner)
has title: qsub -pe mpi doesn't want to run
type: Question
answer count: 0
tagged with: qsub
has comment: http://stackoverflow.com/comment/137971750
type: UnansweredQuestion

http://stackoverflow.com/comment/137866346
comment on: http://stackoverflow.com/a/78196849
score: 0
type: Comment
has text: The sed solution doesn't actually work though, right? The one in the accepted answer will truncate each line, not wrap it as you want. Even if you got a sed solution that wrapped instead of truncated and the fold solution did end up being slightly slower - unless you write a very complicated and probably non-portable and slow sed script (I wouldn't even consider attempting it) the `fold` solution works much better by finding spaces to split at rather than just cutting lines mid-word. `fold` may run faster if you remove that `-s` option so it doesn't have to do that work if you don't want it.
type: AnswerComment

http://stackoverflow.com/comment/137937128
type: QuestionComment
score: 0
type: Comment
has text: Also see [BashFAQ/119 - What's the difference between "cmd < file" and "cat file | cmd"? What is a UUOC?](https://mywiki.wooledge.org/BashFAQ/119).
comment on: http://stackoverflow.com/q/78240155

http://stackoverflow.com/comment/137821130
type: Comment
comment on: http://stackoverflow.com/q/78175779
has text: See [How can I stop a here string (<<<) from adding a line break or new lines?](https://stackoverflow.com/q/37728699/4154375) and [Why does Bash always add a newline when expanding here strings?](https://stackoverflow.com/q/33245568/4154375).
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137842923
comment on: http://stackoverflow.com/a/78186982
has text: `why it was not appended` It is sometimes hard to answer why something is not there. There might not be a specific reason, it's not there, because no one did it. People are used to `$@` since ages. There are some examples in POSIX https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/xrat/V4_xcu_chap02.html
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78172263
answers question: http://stackoverflow.com/q/78170444
score: 0
has body: Here is a Ruby to do that: #!/bin/bash time='1,1708746085,apples,cars 2,1709764378,pears,bus 3,1709875892,orange,truck' echo "$time" | ruby -F, -r "time" -lane ' puts "#{$F.join(",")},#{Time.at($F[1].to_i).strftime("%c")}"' (The strftime("%c") formats to the preferred local time output and is OS configuration dependent.) Prints: 1,1708746085,apples,cars,Fri Feb 23 22:41:25 2024 2,1709764378,pears,bus,Wed Mar 6 17:32:58 2024 3,1709875892,orange,truck,Fri Mar 8 00:31:32 2024 Notice that each answer here has a different time in the example output. Epoch time is 'naive' meaning that the OS local time zone is assumed. You will need to add time zone info if you want that to be the same across different time zones...
type: Answer

http://stackoverflow.com/comment/138038755
type: Comment
comment on: http://stackoverflow.com/q/78292693
has text: @Allan, how quick is it really when trying to do it with the shell gets you in enough trouble that you need to get third-party troubleshooting assistance? Choosing an appropriate language for the task will make development easier and bugs less likely. I like the shell, and I do a fair amount of shell programming, but I would have reached for Python here for a quick and *clean* alternative. Your particular language repertoire might incline you in another direction, but if the shell is the best you've got for this task then you should consider expanding your expertise.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137869173
score: 1
has text: @semmelbroesel, what you now describe does not match what I observe on my own system. It's difficult to say whether it is `TZ` or `date` or `env`, or all of the above, that is being restricted on your server, but I'm prepared at this point to say that `date` is not going to do for you the job that you want it to do. Unless you're prepared to manually adjust for DST twice a year, this is were we come to the "explore alternatives" part of the answer.
type: Comment
comment on: http://stackoverflow.com/a/78201679
type: AnswerComment

http://stackoverflow.com/comment/137871526
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78203990
has text: `( d=$(mktemp -d); cd "$d"; touch "$(printf "a\nb\nc")"; files_in_pwd; rm -r "$d" )`

http://stackoverflow.com/comment/137867814
type: Comment
comment on: http://stackoverflow.com/q/78202033
score: 0
has text: It also looks like Kafka is set to auo creating topics, so when the other services start the topics are created on connection. Supposedly that is set in /etc/kafka/server.properties, but I am not able to find the setting in there. So manually creating the topics is redundant (though I would prefer a manual rather than an auto). So that appears to be a hang-up along with the kafka start.
type: QuestionComment

http://stackoverflow.com/comment/138027370
score: 1
type: QuestionComment
type: Comment
has text: ***fails to generate the html pages.*** - fails how? error msg? wrong output? no output? script hangs?
comment on: http://stackoverflow.com/q/78292693

http://stackoverflow.com/comment/137780875
has text: @EdMorton Sorry, I added some more information. shellcheck did not have problems with the while loop itself.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78152355

http://stackoverflow.com/comment/137792245
has text: Moving the comments on the line above the commands would help with legibility.
score: 2
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78156004

http://stackoverflow.com/comment/138061966
type: QuestionComment
has text: @shellter there have been some good progress. Feel free to check [here](https://github.com/JModelica/JModelica/issues/7) and [here](https://github.com/JModelica/JModelica/commit/078d150ed85bbe63943248be9cffd7aa86578990).
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78274675

http://stackoverflow.com/comment/137987735
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78261786
has text: @user1934428, ...indeed, that's a SO duplicate for what I was previously linking to [unix.se] for; good find, thank you!
type: Comment

http://stackoverflow.com/a/78160457
type: Answer
has comment: http://stackoverflow.com/comment/137800872
downvote count: 0
has body: You can assign values to your variables in the CI/CD settings (see screenshot below). Then you can use those variables in your .gitlab-ci.yml like this: image: docker:latest stages: - build variables: SMTP_USERNAME: ${SMTP_USERNAME} SMTP_PASSWORD: ${SMTP_PASSWORD} build: stage: build script: - ./email.sh I prefer this approach because it means that the environment variable values are not hard-coded into a file and are easy changed via the GitLab UI.
accepted answer of: http://stackoverflow.com/q/78157839
score: 3
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/137801505
answers question: http://stackoverflow.com/q/78157839

http://stackoverflow.com/comment/137922739
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78232840
has text: Glad to help. BTW, if you didn't already have aliases defined you were trying to use, I would suggest using functions instead -- a function is an actual first-class citizen with its own stack frame, argument list, local variables, &c; unlike aliases, they can be exported to subprocesses through the environment, they work in shells compiled with interactive extensions completely disabled, and they're much less likely to result in disapproving stares from old-timers. :P

http://stackoverflow.com/comment/137827456
comment on: http://stackoverflow.com/q/78177875
type: QuestionComment
type: Comment
score: 0
has text: `awk '{s+=$1} END {print s}'` will output a blank line for an empty input file when you probably want `0` instead - do `awk '{s+=$1} END {print s+0}'` to solve that problem.

http://stackoverflow.com/q/78194442
has title: Github Actions base64 encoding masking only one specific string
has body: I am facing a weird issue with github action. I am simply trying to do base64 encoding over some text but the same is throwing an error when I implement it as a step. What's more weird is that this failure of base64 encoding is just for this value: '{"alg":"HS256","typ":"JWT"}' as I am able to successfully encode other values. I have tried the same code on my local machine as well and it works perfectly fine. Code Snippet: header='{"alg":"HS256","typ":"JWT"}' encoded_header=$(echo -n "$header" | base64 | tr -d '=' | tr -d '\n' | tr '+/' '-_') echo $encoded_header Expected output: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 Actual Output: *** Any help with this will be really awesome! Code Snippet for reproduction: header='{"alg":"HS256","typ":"JWT"}' encoded_header=$(echo -n "$header" | base64 | tr -d '=' | tr -d '\n' | tr '+/' '-_') echo $encoded_header Expected output: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 Actual Output: *** Things that I have tried Storing the variable as configuration variable. Same result Storing the variable as environment variable and then encoding. Same result. Adding leading and trailing spaces. This does generate an encoded value but not what I need.
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137854609
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137854181
answer count: 0
tagged with: bash
tagged with: github-actions

gitlab
type: Tag
tags question: http://stackoverflow.com/q/78157839
tag name: gitlab
tags question: http://stackoverflow.com/q/78379828
tags question: http://stackoverflow.com/q/78361550
tags question: http://stackoverflow.com/q/78560700
tags question: http://stackoverflow.com/q/78561559
tags question: http://stackoverflow.com/q/78808824
tags question: http://stackoverflow.com/q/79017951
tags question: http://stackoverflow.com/q/79539054

http://stackoverflow.com/comment/137819111
type: Comment
comment on: http://stackoverflow.com/a/78173611
type: AnswerComment
has text: Same issue here, as with peak's answer if one of the JSON files does not have an outer object container but is a stand-alone array.
score: 0

http://stackoverflow.com/a/78157339
score: 5
upvote count: 5
accepted answer of: http://stackoverflow.com/q/78157184
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/78157184
downvote count: 0
has comment: http://stackoverflow.com/comment/137789935
has body: These build-with-just-one-tool conceits might make fun puzzles, but the fact is Git's one tool in a very capable toolbox. git log --pretty= --name-status | awk -F$'\t' '!seen[$2]++ && $1=="A"' will find all files that haven't been touched since being added.

http://stackoverflow.com/comment/137822467
comment on: http://stackoverflow.com/q/78176347
type: QuestionComment
type: Comment
score: 0
has text: yes file.txt is supposed to be numbers.txt i want the to enter any number between 200 and 400. if i enter 200 I want the terminal to print out all lines where it says 200 or less, so 500 text1 text1 text1 text1 text1 text1 (200) 200 text2 text2 text2 text2 text2 text2 if 400 is entered I understand that the whole file will print yes the numbers must be between 200 and 400 @Ed Morton , why definitely do not do that?

http://stackoverflow.com/comment/137872715
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78204675
has text: `mydir=$( dirname "$BASH_SOURCE" )`
score: 0

http://stackoverflow.com/q/78207789
has comment: http://stackoverflow.com/comment/137877830
score: 0
has title: How to "make" a variable that contains another variable value?
tagged with: ping
answer count: 0
tagged with: shell
has comment: http://stackoverflow.com/comment/137878420
upvote count: 1
favorite count: 0
has body: I'm back to (very modest) scripting after 20+ years outside of that domain. I'd like to write a small script that pings some IP addresses (some internal and wired, some internal over CPL, some external) to troubleshoot the instability of my network connectivity. I do a single ping to each host, and if it's down, it adds a line to a file named host_.txt I don't need alerting, just logging. I've read many posts here, and my current script was leaning towards the below. As you can see, I'm storing 2 (stupid and fake for now) IPs in variables $IP1 and $IP2. I don't want to duplicate the code for each ping, so I basically wanted to encapsulate it in a "for" loop and use the value of the "i" counter to point to the correct variable ( IP$i would then give me IP1, IP2, ...). My problems/questions: If I concatenate "IP" with $i, I end up with the name of my variable: IP1, IP2, ... but how can I refer to the value of this variable? More in general, is this "while true" a good method to have the script running continuously, as "ping" would do without its "-c" parameter? Won't it use too much resources on my small Raspberry Pi? Would it be better to consider building a list or a table of IPs, and go through that list without requiring the storage of IPs into separate variables? Any other recommendations are most welcome! Many thanks #!/bin/bash IP1=127.0.0.1 IP2=127.0.0.2 while true do stamp=$(date +"%Y%m%d-%T") for i in $(seq 1 2) do target=IP$i ping -c1 -W10 $target if [ $? -ne 0 ]; then echo $target "KO at" $stamp > host_$IP$i.txt ; else echo $IP$i "OK > at" $stamp ; fi done sleep 1 done For info, I also tried this, without success.. #!/bin/bash IP1="127.0.0.1" i=1 echo IP$i echo $(echo "IP";echo $i) EDIT: For the sake of documentation, with focus on the initial issue: "If I concatenate "IP" with $i, I end up with the name of my variable: IP1, IP2, ... but how can I refer to the value of this variable?" This technique is called "indirect" and is documented in stackoverflow.c…
tagged with: scripting
has comment: http://stackoverflow.com/comment/137877810
linked to: http://stackoverflow.com/q/16553089
has comment: http://stackoverflow.com/comment/137878102
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/137877802
has comment: http://stackoverflow.com/comment/137877843
downvote count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137881965
duplicate of: http://stackoverflow.com/q/16553089
duplicate of: http://stackoverflow.com/q/10757380

http://stackoverflow.com/a/78148123
type: Answer
has comment: http://stackoverflow.com/comment/137772687
score: 4
has body: You need: env=stage; AWS_REGION="us-west-2" AWS_PROFILE="$env" mvn clean test -Dtest="KarateRunner#$env" -DargLine="-Dkarate.env=$env" You don't need testing boolean shell assignation: env=stage && [...] It will always return true as far of you assign a string or don't use a sub-command returning false.
has comment: http://stackoverflow.com/comment/137773325
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78148102
has comment: http://stackoverflow.com/comment/137773350
upvote count: 4
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78148102

http://stackoverflow.com/comment/137860896
type: Comment
has text: @Yunnosch thanks for your comments, I updated the question. Let me know if now it is more clear.
comment on: http://stackoverflow.com/q/78197884
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137912359
has text: Thanks, I wasn't familiar with this notation. It's cleaner than my if/else statement too.
comment on: http://stackoverflow.com/a/78217506
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137833564
type: Comment
comment on: http://stackoverflow.com/q/78182867
has text: (I should say, programming language rather than program.)
score: 1
type: QuestionComment

docker
tags question: http://stackoverflow.com/q/78202033
tags question: http://stackoverflow.com/q/78166553
type: Tag
tags question: http://stackoverflow.com/q/78208548
tags question: http://stackoverflow.com/q/78248223
tags question: http://stackoverflow.com/q/78157839
tags question: http://stackoverflow.com/q/78292636
tag name: docker
tags question: http://stackoverflow.com/q/78388698
tags question: http://stackoverflow.com/q/78416125
tags question: http://stackoverflow.com/q/78374366
tags question: http://stackoverflow.com/q/78405506
tags question: http://stackoverflow.com/q/78332428
tags question: http://stackoverflow.com/q/78349366
tags question: http://stackoverflow.com/q/78538995
tags question: http://stackoverflow.com/q/78588025
tags question: http://stackoverflow.com/q/78506946
tags question: http://stackoverflow.com/q/78479103
tags question: http://stackoverflow.com/q/78458917
tags question: http://stackoverflow.com/q/78481642
tags question: http://stackoverflow.com/q/78518786
tags question: http://stackoverflow.com/q/78535188
tags question: http://stackoverflow.com/q/78590486
tags question: http://stackoverflow.com/q/78706727
tags question: http://stackoverflow.com/q/78683353
tags question: http://stackoverflow.com/q/78675262
tags question: http://stackoverflow.com/q/78727571
tags question: http://stackoverflow.com/q/78695386
tags question: http://stackoverflow.com/q/78663492
tags question: http://stackoverflow.com/q/78901178
tags question: http://stackoverflow.com/q/78840846
tags question: http://stackoverflow.com/q/78854738
tags question: http://stackoverflow.com/q/78785884
tags question: http://stackoverflow.com/q/78802037
tags question: http://stackoverflow.com/q/78755032
tags question: http://stackoverflow.com/q/78810394
tags question: http://stackoverflow.com/q/78812372
tags question: http://stackoverflow.com/q/78956213
tags question: http://stackoverflow.com/q/79000979
tags question: http://stackoverflow.com/q/78928577
tags question: http://stackoverflow.com/q/78987363
tags question: http://stackoverflow.com/q/79050490
tags question: http://stackoverflow.com/q/79109633
tags question: http://stackoverflow.com/q/79237461
tags question: http://stackoverflow.com/q/79139077
tags question: http://stackoverflow.com/q/79091421
tags question: http://stackoverflow.com/q/79157218
tags question: http://stackoverflow.com/q/79163801
tags question: http://stackoverflow.com/q/79238116
tags question: http://stackoverflow.com/q/79100587
tags question: http://stackoverflow.com/q/79306910
tags question: http://stackoverflow.com/q/79310007
tags question: http://stackoverflow.com/q/79401075
tags question: http://stackoverflow.com/q/79291946
tags question: http://stackoverflow.com/q/79252604
tags question: http://stackoverflow.com/q/79386064
tags question: http://stackoverflow.com/q/79364353
tags question: http://stackoverflow.com/q/79421113
tags question: http://stackoverflow.com/q/79530470
tags question: http://stackoverflow.com/q/79466429
tags question: http://stackoverflow.com/q/79443511

http://stackoverflow.com/a/78272868
answers question: http://stackoverflow.com/q/78272610
has body: I think this is correct. It requires Bash 4.2 (which is very old). It also clobbers SAVED_SOME_VAR but I think that's unavoidable and not likely to be an issue. if -v SOME_VAR ; then SAVED_SOME_VAR="$SOME_VAR" else unset SAVED_SOME_VAR fi ... if -v SAVED_SOME_VAR ; then export SOME_VAR="$SAVED_SOME_VAR" unset SAVED_SOME_VAR else unset SOME_VAR fi
has comment: http://stackoverflow.com/comment/137993841
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/137993389

http://stackoverflow.com/comment/137787932
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78156916
has text: Quotes, quotes everywhere. `find "$directory"`, and `./a.sh 20 /home/user "*.txt"`

http://stackoverflow.com/comment/138031353
type: QuestionComment
comment on: http://stackoverflow.com/q/78294975
type: Comment
score: 0
has text: This is apparently a bug that has been fixed in later versions. So either upgrade or don't use `set -o nounset`

http://stackoverflow.com/comment/137843227
has text: Sure. You have to get used to many other not so trivial features of sh (like the fact that `(` is metacharacter and control operator, wheras `{` is just reserved word). The best approach seems to be - don't try to understand why some things are in bash as they are, just learn it and use properly.
score: 0
comment on: http://stackoverflow.com/a/78186982
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137866939
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment
has text: To be clear, `grep -w` would stop this from saying your computer is in the group when it isn't, but I understand the problem this question is about to be the opposite of that -- grep saying the computer _isn't_ in the group when it is. You _do_ want `grep -w`, but I'm not at all convinced that it's the whole of the issue at hand; again, to be able to propose a solution with any confidence we'd really want specific examples of the output of the various commands, emitted in such a way that things like whitespace, nonprinting characters, &c are shown.

parameter-passing
tags question: http://stackoverflow.com/q/78299332
tag name: parameter-passing
type: Tag
tags question: http://stackoverflow.com/q/78582237
tags question: http://stackoverflow.com/q/79192378
tags question: http://stackoverflow.com/q/79514950

http://stackoverflow.com/comment/138012831
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78283701
has text: Hmmm... Consider `printf -v stars '%*s' $number;stars="${stars// /*}";echo "$stars"`

http://stackoverflow.com/comment/137998879
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78272610
has text: @Ivan: Not a bad idea but in my case I want the variable to remain mutable.

http://stackoverflow.com/comment/138019938
comment on: http://stackoverflow.com/q/78284887
type: QuestionComment
type: Comment
has text: You might be interested by "tput": https://linux.die.net/man/1/tput
score: 0

http://stackoverflow.com/comment/137866758
type: Comment
has text: @Barmar i think isn't correctly part `grep -q "$computer_name"`
score: 0
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment

http://stackoverflow.com/comment/137820566
type: QuestionComment
type: Comment
has text: You may enclose commands without parenthesis, by using any other kind of grouping (`if...then...else`,`case... esac`,`for...;do done`: try this: `if :;then ls -ld /t{mp,nt};ls -ld /t{mp,nt};fi 2> >(sed 's/^/E:/') > >(sed 's/^/S:/')`
comment on: http://stackoverflow.com/q/78175689
score: 0

http://stackoverflow.com/comment/137886594
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78212459
score: 1
has text: `grep $1 /file/path/courses.jsonl` is extremely fragile as it's using an unquoted argument and so that'll undergo globbing, word splitting, and file name expansion courtesy of the shell before `grep` even sees it and then `grep` is doing a whole line regexp match with it's argument(s) when you want a literal string full-field match on one specific input field. The net result is you'll get matches that you don't expect and not get matches that you do expect.

http://stackoverflow.com/comment/137957190
score: 0
has text: Also there is no reliable way to parse markup languages such as HTML with shell. HTML is the worst to parse because of its permissive evasive syntax. You'd better ask the site to have access to its data source via an API rather than trying to parse. HTML pages are for rendering only, they cannot convey data for processing.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78252129

extglob
tags question: http://stackoverflow.com/q/78232634
tag name: extglob
type: Tag

http://stackoverflow.com/comment/137886440
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78211596
has text: And we can definitely get rid of the 2 extra calls to awk at the end of your script once we know what the input looks like. (I'm saying "we" as many people posting here can help you once you provide the missing input, not just me).

http://stackoverflow.com/comment/137988204
comment on: http://stackoverflow.com/q/78270350
type: QuestionComment
has text: Also see ["Why does shell ignore quoting characters in arguments passed to it through variables?"](https://stackoverflow.com/questions/12136948/why-does-shell-ignore-quotes-in-arguments-passed-to-it-through-variables) In general, if you need to build a command (or list of command arguments), use an array rather than a plain string (and avoid the temptation to use `eval` -- it is a massive bug magnet).
score: 0
type: Comment

http://stackoverflow.com/a/78276456
type: Answer
has body: Tweaking OP's current awk code to use gsub() to count the number of non white space characters: awk '{ x=$0; print gsub(/[^[:space:]]/,&quot;&quot;,x), $0 }' file.txt | sort Where: x=$0 - make copy of current line; we'll modify the copy while leaving the current line alone gsub(...,x) - run gsub() against x (copy of $0) NOTE - this will also ignore tabs; if OP wants to count tabs then replace /[^[:space:]]/ with /[^ ]/ (a single space) We'll also need to make a tweak to allow sort to work properly when the count could be a variable number of digits. Sample input: $ cat file.txt a b c abcde ab cd ef abcdefg a a b asdfasdfasdfas as asdfasfdasdf # that's a single tab (\t) between the 2nd and 3rd strings Running with sort: $ awk '{ x=$0; print gsub(/[^[:space:]]/,&quot;&quot;,x), $0 }' file.txt | sort 1 a 2 a b 28 asdfasdfasdfas as asdfasfdasdf # wrong; lexicographic/alphabetic ordering 3 a b c 5 abcde 6 ab cd ef 7 abcdefg Running with sort -n: $ awk '{ x=$0; print gsub(/[^[:space:]]/,&quot;&quot;,x), $0 }' file.txt | sort -n 1 a 2 a b 3 a b c 5 abcde 6 ab cd ef 7 abcdefg 28 asdfasdfasdfas as asdfasfdasdf # right; numeric ordering Counting tabs: $ awk '{ x=$0; print gsub(/[^ ]/,&quot;&quot;,x), $0 }' file.txt | sort -n 1 a 2 a b 3 a b c 5 abcde 6 ab cd ef 7 abcdefg 29 asdfasdfasdfas as asdfasfdasdf # +1 since we're counting the tab between 2nd and 3rd strings
answers question: http://stackoverflow.com/q/78276360
downvote count: 0
score: 2
upvote count: 2

http://stackoverflow.com/comment/137790515
comment on: http://stackoverflow.com/q/78158123
type: QuestionComment
has text: The error message tells you where the problem lies. The path you are trying to remove is `(arr+=(/vol4/backups/forms_02_24_2024.tar.gz))`. Do you not realize that is from the third line of your program? Why do you even have a `arr()` array since yo¨don't use it? Just `rm "$line"`.
type: Comment
score: 0

http://stackoverflow.com/a/78202297
answers question: http://stackoverflow.com/q/78186846
has comment: http://stackoverflow.com/comment/137870259
type: Answer
accepted answer of: http://stackoverflow.com/q/78186846
has body: Similar to this question, is it possible to use the predefined replacement string as input for my replacement or do I need to create the full replacement from the original input? You need to create the full replacement from the original input. You can find the definition in man parallel under --rpl: --rpl '{/} s:.*/::' So: ... | parallel --rpl '{mybasename} s:.*/::; s:_non-important.txt::' echo {mybasename} Remember that --rpl definitions can be put in ~/.parallel/config
type: AcceptedAnswer
score: 0

for-loop
type: Tag
tags question: http://stackoverflow.com/q/78263189
tags question: http://stackoverflow.com/q/78212116
tags question: http://stackoverflow.com/q/78244372
tag name: for-loop
tags question: http://stackoverflow.com/q/78199142
tags question: http://stackoverflow.com/q/78496979
tags question: http://stackoverflow.com/q/78505054
tags question: http://stackoverflow.com/q/78583045
tags question: http://stackoverflow.com/q/78639369
tags question: http://stackoverflow.com/q/78759826
tags question: http://stackoverflow.com/q/78811543
tags question: http://stackoverflow.com/q/78839494
tags question: http://stackoverflow.com/q/78958663
tags question: http://stackoverflow.com/q/79076493
tags question: http://stackoverflow.com/q/79216406
tags question: http://stackoverflow.com/q/79193786
tags question: http://stackoverflow.com/q/79327490
tags question: http://stackoverflow.com/q/79301328
tags question: http://stackoverflow.com/q/79492218
tags question: http://stackoverflow.com/q/79530052
tags question: http://stackoverflow.com/q/79440348

http://stackoverflow.com/comment/137838950
type: Comment
type: AnswerComment
score: 0
has text: I thought I was to avoid substr?
comment on: http://stackoverflow.com/a/78176886

http://stackoverflow.com/comment/137856864
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78194973
has text: (Pardon the long delay -- I was afk for lunch; taking a look now)

http://stackoverflow.com/comment/138039014
comment on: http://stackoverflow.com/q/78298036
score: 1
has text: BTW, consider `PGPASSWORD='secure' application arg1 arg2 ...` instead of `export PGPASSWORD='secure'; application arg1 arg2 ...` -- the former way still exports the variable, but only for the one application, without leaving it in the environment for everything else later started by the same shell.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137832745
score: 1
has text: What results are you expecting, and what are you getting? You told us you tried, but not what happened.
comment on: http://stackoverflow.com/q/78182539
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137856513
score: 0
comment on: http://stackoverflow.com/q/78195387
has text: `dependencies` without quotes and a colon is not valid JSON. I'm guessing you mean `"dependencies": { ... }` but we obviously can't know for sure what you actually hoped it would do.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/78246449
tagged with: bash
tagged with: visual-studio-code
has comment: http://stackoverflow.com/comment/137946768
duplicate of: http://stackoverflow.com/q/54887987
has title: I am using the bash terminal in VS Code, I am new to coding, and the terminal displays very differently, how do I get them to match?
linked to: http://stackoverflow.com/q/54887987
tagged with: settings
tagged with: format
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137971026
has body: here is what it looks like on the course Here is what it looks like for me How do I get it to not show the line "dayne@DESKTOP-323EO95 MINGW64 ~"? Also, it would help if I could get an explanation as to why it displays this way. Thanks. I tried looking through the settings on VSCode, and on the bash terminal settings, but couldn't find it. I could be easily just missing it though. I also searched the internet for solutions, but couldn't find any, since I'm not really sure on the terminology I need to use to find my problem.
type: UnansweredQuestion
tagged with: terminal
answer count: 1
has answer: http://stackoverflow.com/a/78246478

http://stackoverflow.com/q/78177847
has comment: http://stackoverflow.com/comment/137826001
tagged with: node.js
tagged with: amazon-web-services
tagged with: bash
type: UnansweredQuestion
tagged with: amazon-ec2
answer count: 1
has body: I have an EC2 instance Linux/UNIX, t2.micro. Al there is in there is a NodeJs Express server. If I cd ./project-folder-name and then run "npm run server" it starts a server which can accept API requests. I use this server only 15 minutes a day so I am thinking to have it in a schedule to stop/start only for 1 hour. I got the code that starts and stops it but I don't know how to make the EC2 to start the Express server (go to the path and run "npm run server") after the EC2 is restarted. Note: No need to worry about pulling the project from gitlab or updating dependencies (npm install or any other command). Literally, all I want it is to get to the folder and run "npm run server", which is a script on my package.json file I appreciate if someone can give me some instructions on how to do that.
linked to: http://stackoverflow.com/q/4903570
score: 0
type: Question
has title: How to automatically start a NodeJs Express server when EC2 starts
tagged with: ec2-userdata
has answer: http://stackoverflow.com/a/78220190
has comment: http://stackoverflow.com/comment/137876672

http://stackoverflow.com/comment/138004626
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78278018
type: QuestionComment
has text: @DavidC.Rankin i did tried with -P it throwed me an error that it is not a valid argument/ flag.

http://stackoverflow.com/comment/137830151
has text: Regrading "to run it sequentially the data is very huge so it is taking a lot of time." - I'm not saying that's the permanent solution to your problem, I'm saying do it one time to find out if the issue is parallelism or not so you can focus on fixing that parallelism problem or move on to investigating what else might be the problem.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78177875

http://stackoverflow.com/comment/137963661
has text: The best resource for this is the bash manual itself (`man bash`). You can also read [this page of the `bash` guide](https://mywiki.wooledge.org/BashGuide/Patterns).
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78254812
score: 0

http://stackoverflow.com/comment/137787841
has text: inside the loop add `_arr+=('added in loop')`; after the loop run `typeset -p myArray1 myArray2 myArrayN` and you'll see that all 3 arrays now have an extra entry of `[3]="added in loop"`; net result: changes made to the nameref (`sublist` in your case) flow through to the underlying array
score: 1
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78156830

http://stackoverflow.com/comment/137913430
has text: @AbdulAhmad Please add a _complete_ snippet, including the initialization of `output` and the command that outputs the incorrectly escaped output. In the snippet you add, if I run that and then `echo "$service_list_json"`, I get `["one","two"]`. There's clearly something else going on for you, but I don't know what.
score: 1
comment on: http://stackoverflow.com/q/78227591
type: Comment
type: QuestionComment

http://stackoverflow.com/q/78272291
has answer: http://stackoverflow.com/a/78273234
possible better answer: http://stackoverflow.com/a/78273234
answer count: 2
has title: How can I limit values to three decimal places while keeping the header intact in a table?
tagged with: bash
type: AnsweredQuestion
has body: I have a tab-separated file with multiple columns, the first three of which are chr,start, and end. Other columns contain different samples with a specific score. My primary goal here is to limit values to three decimal places for all samples. grep -v 'NA' TestAllScore.tsv | head -n 10 chr start end EE85756 EE85757 EE85770 EE85775 chr1 9900 10000 0.370534858784818 0.506262316364967 0.249866030926826 0.663009952219704 chr1 10000 10100 214.786706475599 313.545127935369 250.865495050533 335.980293287335 chr1 10100 10200 511.214593503454 684.63540583089 540.710090925652 713.895966052567 chr1 10200 10300 516.525593146036 630.296583874384 465.875214663067 545.822943164872 chr1 10300 10400 297.539491604209 396.572147819224 346.689117910971 339.295343048434 chr1 10400 10500 142.161874153775 272.537880309807 238.372193504192 255.093079116531 chr1 10500 10600 191.072475513371 295.150930440776 246.118040462924 277.635417492001 chr1 10600 10700 237.142309622283 345.102145655452 308.459615179167 306.310597925503 chr1 10700 10800 239.859565253372 270.512831044347 294.342184431801 272.497090362299 I used the script below to accomplish this, but it looks like the output is missing a header. awk '{ for (i=4; i<=NF; ++i) $i=sprintf("%.3f", $i); print }' TestAllScore.tsv | sed 's/ /\t/g' > TestAllScore2.tsv grep -v '0.00' 11jHL.win.nucocc6.txt | head -n 10 chr1 11000 11100 177.486 211.955 240.996 249.955 chr1 11100 11200 136.480 218.874 242.620 236.529 chr1 11200 11300 106.714 251.444 252.240 225.921 chr1 11300 11400 172.422 274.900 305.336 211.997 chr1 11400 11500 178.104 301.732 303.087 196.085 chr1 11500 11600 192.431 272.875 252.864 219.954 chr1 11600 11700 256.287 271.863 219.507 267.690 chr1 11700 11800 190.084 231.024 198.144 229.733 chr1 11800 11900 162.047 218.705 221.881 183.156 chr1 11900 12000 180.203 228.156 241.745 147.520 I would like to know how to restrict values to three decimal places while keeping the header intact.
tagged with: awk
has answer: http://stackoverflow.com/a/78272332
has comment: http://stackoverflow.com/comment/137993621
accepted answer: http://stackoverflow.com/a/78272332
score: 0
type: Question

http://stackoverflow.com/comment/137772892
type: Comment
has text: many cmds can read from std-in and `grep` (thankfully) is one of them. The `-q` means ***quiet**, so the only thing it will do is return true (`0`) if the search target it found and false (`1`) if not.
score: 0
comment on: http://stackoverflow.com/q/78147838
type: QuestionComment

http://stackoverflow.com/comment/137999703
comment on: http://stackoverflow.com/q/78274675
has text: @konsolebox that is a valid point, so I asked a follow-up question [here](https://stackoverflow.com/q/78276793/4999991)
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137789747
type: Comment
score: 1
has text: the code you show is broken, so we don't know what you actually mean
comment on: http://stackoverflow.com/q/78157779
type: QuestionComment

http://stackoverflow.com/comment/137922461
has text: This is also [BashFAQ #89](https://mywiki.wooledge.org/BashFAQ/089).
type: QuestionComment
comment on: http://stackoverflow.com/q/78232246
type: Comment
score: 0

http://stackoverflow.com/comment/137886346
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78211596
has text: @Cordux As I mentioned, I'm just guessing at what you need since you didn't show us the output of your `ip` commands. Whatever is wrong in the awk script will be trivial to correct if you edit your question to show that information.
score: 0

http://stackoverflow.com/comment/138026013
score: 0
comment on: http://stackoverflow.com/q/78291764
type: QuestionComment
has text: Still, you understand the actual behavior so you don't have a question with an answer expected to change how you go about the practice of software development.
type: Comment

http://stackoverflow.com/comment/137884119
comment on: http://stackoverflow.com/q/78211182
score: 0
type: QuestionComment
type: Comment
has text: ? That's not really the problem. But I managed to solved it by using `trap 'trigger && sleep inf' USR1 USR2`. It seems that the `sleep inf` at the bottom gets terminated when trap runs. Someone more knowledgeable can feel free to expand on this as an answer.

http://stackoverflow.com/comment/137865907
has text: What methods have you tried for (re)defining the `TZ` variable in the environment of your `date` command? Have you tried setting it as a prefix on the `date` command line? Have you set it *and `export`ed it* in the host shell? Have you tried using the `env` command for the purpose?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78200396
score: 0

http://stackoverflow.com/comment/137773256
type: Comment
score: 0
has text: `grep` [defaults to reading stdin](https://man7.org/linux/man-pages/man1/grep.1.html) if no file argument is given (unless it's a recursive search). If you want to be explicit, use a filename of `-`. You could also write this as `grep -q gzip <(file $filename)` in `bash`, if your stdin was otherwise being used in, say, a loop.
comment on: http://stackoverflow.com/q/78147838
type: QuestionComment

http://stackoverflow.com/a/78276969
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/138007769
has comment: http://stackoverflow.com/comment/138008190
answers question: http://stackoverflow.com/q/78276360
score: 3
has body: Applying the Decorate-Sort-Undecorate idiom with any awk: $ awk -v OFS='\t' '{print length() - gsub(/[[:space:]]/,&quot;&amp;&quot;), NR, $0}' file | sort -n -k1,1 -k2,2 | cut -f3- a a b a b c abcde ab cd ef abcdefg The above is doing: Decorate with awk: The awk command is decorating the input file by adding the number of non-blank chars and then the input line number before the original input line. I'm separating the awk output fields with tabs as that's a default separator value for both of the subsequent commands in the pipeline, sort and cut. Sort with sort - I'm sorting using the number of non-spaces first and then the original line number second so that if 2 lines have the same number of characters they retain their input order in the output Undecorate with cut - I'm just printing from the 3rd tab-separated field on, which takes us back to the original input line. To see how that works, just add the commands one at a time: $ cat file a b c abcde ab cd ef abcdefg a a b $ awk -v OFS='\t' '{print length() - gsub(/[[:space:]]/,&quot;&amp;&quot;), NR, $0}' file 3 1 a b c 5 2 abcde 6 3 ab cd ef 7 4 abcdefg 1 5 a 2 6 a b $ awk -v OFS='\t' '{print length() - gsub(/[[:space:]]/,&quot;&amp;&quot;), NR, $0}' file | sort -n -k1,1 -k2,2 1 5 a 2 6 a b 3 1 a b c 5 2 abcde 6 3 ab cd ef 7 4 abcdefg $ awk -v OFS='\t' '{print length() - gsub(/[[:space:]]/,&quot;&amp;&quot;), NR, $0}' file | sort -n -k1,1 -k2,2 | cut -f3- a a b a b c abcde ab cd ef abcdefg
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78276360

gnu-parallel
tags question: http://stackoverflow.com/q/78209376
tags question: http://stackoverflow.com/q/78186846
tag name: gnu-parallel
type: Tag
tags question: http://stackoverflow.com/q/78678279
tags question: http://stackoverflow.com/q/78702712
tags question: http://stackoverflow.com/q/78761415
tags question: http://stackoverflow.com/q/78822595
tags question: http://stackoverflow.com/q/79188455
tags question: http://stackoverflow.com/q/79338351

http://stackoverflow.com/comment/137855964
type: Comment
score: 0
has text: Thanks - that does it but only finds the first network interface eth0 not eth1
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment

http://stackoverflow.com/a/78199180
score: 5
downvote count: 0
has body: You can use the environment variable GIT_CONFIG_GLOBAL to tell git where to load the global configuration from. If you tell it to load it from something like /dev/null it will basically not load anything. $ GIT_CONFIG_GLOBAL=/dev/null git config --global --list $ This shows that this way the global configuration will contain nothing.
type: Answer
answers question: http://stackoverflow.com/q/78199094
upvote count: 5
accepted answer of: http://stackoverflow.com/q/78199094
type: AcceptedAnswer

http://stackoverflow.com/comment/137866828
has text: i just need set that code in startup script. and when computer run, that he must detect, is his hostname belongs group pan-sgg-dalas or not. If not he must set time shutdown in 22:00.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78201574
type: QuestionComment

http://stackoverflow.com/a/78220190
has body: You can make use of custom systemd service. Creating a custom systemd service in Ubuntu enables users to start, stop, and manage custom background processes effectively. create a bash script file with the required commands to run your node application. in my_node_app.sh #!/bin/bash # Custom script to node application cd /path/to/node/app/folder npm install npm run server make the script executable chmod +x /path/to/script/my_node_app.sh Create a new unit file at /etc/systemd/system/my_node_app.service [Unit] Description=My Custom Service [Service] Type=simple ExecStart=/path/to/script/my_node_app.sh [Install] WantedBy=multi-user.target Execute the following commands to reload, enable and start the service systemctl daemon-reload systemctl enable my_node_app.service systemctl start my_node_app.service After starting the services every time instance reboot this service will run the script.
type: Answer
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78177847

http://stackoverflow.com/comment/137858284
has text: I changed it to use read -r -d '', and it only added a newline at the end of $sFourthField but still removed the newlines from $sThirdFieldTwoLines
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78196593

http://stackoverflow.com/comment/137969773
score: 0
comment on: http://stackoverflow.com/q/78254632
type: QuestionComment
type: Comment
has text: Silly question: Why don't you want to use a regex? Is this a programming exercise, or why do you want to do it the hard way, when bash comes with a useful extended regex matching builtin?

http://stackoverflow.com/comment/137873434
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78202789
has text: Just in terms of Python syntax, though: your `awk` parameter is a single-quoted string, but you have that inside a single-quoted Python string. If you change the quotes around the first parameter to double quotes, `"kubectl ... | awk '...' ..."`, you'll avoid the Python SyntaxError.

http://stackoverflow.com/comment/137955014
comment on: http://stackoverflow.com/q/78250385
type: QuestionComment
has text: See [Bash Pitfalls #1 (for f in $(ls *.mp3))](https://mywiki.wooledge.org/BashPitfalls#for_f_in_.24.28ls_.2A.mp3.29).
type: Comment
score: 0

http://stackoverflow.com/comment/137908655
comment on: http://stackoverflow.com/q/78225038
has text: Remove the shebang line and it'll work.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137898078
score: 0
comment on: http://stackoverflow.com/q/78218663
type: QuestionComment
has text: The remark "*it doesn't redirect the output of `'ls | wc'` to this file*" suggests a possible misconception that may be relevant. Although it's true that `ls | wc > a` should redirect the output of the pipeline to file `a`, that's because the output of the pipeline is the output of the last command in it. You should achieve the desired effect by redirecting specifically the output of the `wc` command. That needs to be your conception of the problem, else you risk solving the *wrong* problem.
type: Comment

config
tag name: config
type: Tag
tags question: http://stackoverflow.com/q/78298728
tags question: http://stackoverflow.com/q/78480370
tags question: http://stackoverflow.com/q/78669939
tags question: http://stackoverflow.com/q/79099208
tags question: http://stackoverflow.com/q/79305356

http://stackoverflow.com/comment/137943281
has text: Ok those are good points, though when I try to think on way, I keep getting into thought rabbit-hole, would this be correct: `git add *[Ll]ivewire/*String1[?s]` ? I am not so well-versed with regex that much, that's why I wanna know if anyone can come up with a way or partial way. I don't wanna end up adding incorrectly.
type: QuestionComment
comment on: http://stackoverflow.com/q/78244513
type: Comment
score: 0

http://stackoverflow.com/q/78233301
tagged with: bash
linked to: http://stackoverflow.com/q/23848294
has answer: http://stackoverflow.com/a/78233340
has comment: http://stackoverflow.com/comment/137923619
answer count: 1
has body: I'd like the reverse of this How can I print a newline as \n in Bash? Basically I have a JSON with a stack trace embedded as string and I want to see it without the control characters I tried cat -e and echo -e to no avail. Note I am asking for both \n and \t
has comment: http://stackoverflow.com/comment/137924160
score: -1
type: Question
has comment: http://stackoverflow.com/comment/137923469
upvote count: 0
type: UnansweredQuestion
favorite count: 0
has comment: http://stackoverflow.com/comment/137923546
has title: How do I render escape characters .e.g \n and \t as new line and spaces in bash?
downvote count: 1
linked to: http://stackoverflow.com/q/32715008

http://stackoverflow.com/a/78210478
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/78210405
accepted answer of: http://stackoverflow.com/q/78210405
type: AcceptedAnswer
has body: [audioWithGain] is interpreted as a character class and matched. There's a file or directory named t which matches it. That's because variable expansion happens before pathname expansion (see EXPANSION in man bash). Double quote the variable to prevent it: echo "$x" Otherwise, what bash runs is echo -map [audioWithGain]
score: 2
downvote count: 0

http://stackoverflow.com/comment/138012200
score: 1
type: QuestionComment
has text: `out= ; for i in {4..1} {1..4};{ printf -v var '%*s%*s%-*s' $i '*' $[(4-i)*2] '' $i '*' ; out+=$var$'\n';}; echo "$out" `
type: Comment
comment on: http://stackoverflow.com/q/78283701

http://stackoverflow.com/comment/137787564
comment on: http://stackoverflow.com/q/78156630
has text: (Lots more things are "diagnostic" in that sense than someone might intuit -- for example, shell prompts are written to stderr, because they're there to tell the operator when the shell is ready for them to type a new command; diagnostic content not going to stdout is generally a Good Thing -- if you're writing `curl http://example.com/foo.csv > foo.csv`, f/e, you want curl's progress bar to be displayed to the user, not mixed into the CSV file's contents).
score: 1
type: QuestionComment
type: Comment

ec2-userdata
tags question: http://stackoverflow.com/q/78177847
type: Tag
tag name: ec2-userdata

http://stackoverflow.com/comment/137922015
type: Comment
comment on: http://stackoverflow.com/q/78232246
has text: `while read chapter_id; do read start_time read end_time read chapter_title` that's 4 reads `sample chapters.txt file` Please edit your post and add the sample to the post.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137836103
comment on: http://stackoverflow.com/q/78184175
type: Comment
type: QuestionComment
has text: 1. what does `help source` tell you it does? 2. please define "returns" and "result"
score: 0

javascript
type: Tag
tag name: javascript
tags question: http://stackoverflow.com/q/78202378
tags question: http://stackoverflow.com/q/78252063
tags question: http://stackoverflow.com/q/78164579
tags question: http://stackoverflow.com/q/78518299
tags question: http://stackoverflow.com/q/79057828

http://stackoverflow.com/comment/137816098
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78173029
has text: That does work for any amount of subdirectories. To be sure, just tested this and it does go 5 levels down (that's the max folder depth I have in my project).

http://stackoverflow.com/comment/138038691
type: QuestionComment
type: Comment
has text: @CharlesDuffy thanks for your first comment too! i do get this tho: ```tr '\0' '\n' </proc/1957428/environ | grep -e PGPASSWORD PGPASSWORD=postgrespw``` so i guess it could actually use the env variable.
comment on: http://stackoverflow.com/q/78298036
score: 0

http://stackoverflow.com/comment/137913464
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591
type: Comment
has text: @yshavit ok so I have added the original array, which looks like its wrapped by an extra set of quotes that I didnt notice originally. could that be the cause?
score: 0

http://stackoverflow.com/comment/137970114
has text: As you can conclude from the error message, the script does check your operating system, and the author of the script did not check for the presence of Cygwin. Well, what would you expect from Postbank, after the desaster with the change in their IT last year.....
type: QuestionComment
comment on: http://stackoverflow.com/q/78249607
type: Comment
score: 0

http://stackoverflow.com/a/78274517
type: Answer
has body: When you do export PATH="$PATH:/opt/homebrew/Cellar/bash/5.2.26/bin" you're making your new directory the LAST place to look for an instance of bash, you should have done export PATH="/opt/homebrew/Cellar/bash/5.2.26/bin:$PATH" to make it the first directory instead, otherwise some existing version of bash will be picked up by anything looking down your PATH. Also, make sure in your script you have a shebang of #!/usr/bin/env bash at the top of your script: #!/usr/bin/env bash echo "$BASH_VERSION" >&2 # just so you can see which version is used ... so it actually looks in your PATH for bash.
upvote count: 2
answers question: http://stackoverflow.com/q/78274299
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78274299
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137996395
score: 2

http://stackoverflow.com/a/78176299
type: Answer
has comment: http://stackoverflow.com/comment/137822924
has comment: http://stackoverflow.com/comment/137823995
has body: Using custom field separator in awk you can simplify your awk commands into just a single one like this: awk -F '="|",' '$1 == "appid" {print $2}' "$filename" myapp
score: 0
answers question: http://stackoverflow.com/q/78176143

http://stackoverflow.com/comment/137777331
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78150653
score: 3
has text: as an aside, don't follow the practices you see in that script. `[ x$foo = x ]` is an artifact of the 1970s (and buggy if the user enters, say, `*`, or `1\ =\ x1\ -o\ x` -- the backslashes prevent `read` from splitting content into `leftover`, since `-r` wasn't used); in any shell that's even a _tiny_ bit modern (read: from the 90s or later), `[ -z "$foo" ]` or `[ ! -n "$foo" ]` is preferred.

timezone
tag name: timezone
tags question: http://stackoverflow.com/q/78200396
type: Tag
tags question: http://stackoverflow.com/q/79377185

http://stackoverflow.com/comment/137973672
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78261786
has text: @JonSG: as written in the last line, no, I don't want to kill the whole terminal history. The goal is to make it more readable by not cluttering it with useless info, while still keeping the user informed about what's going on. (imaging a compile process which I'm not interested in if everything is going well)
type: Comment

http://stackoverflow.com/comment/137959067
comment on: http://stackoverflow.com/a/78240810
has text: Thanks, that really helps a lot. How can I do this for the `cask` packages?
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137971750
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78260874
type: QuestionComment
has text: Please provide enough code so others can better understand or reproduce the problem.

http://stackoverflow.com/comment/137988099
type: QuestionComment
has text: rsync doesn't have any way of knowing which directories were written out by hand and which resulted from shell globs -- that expansion is fully complete before the shell invokes it at all.
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78269359

http://stackoverflow.com/comment/137896156
has text: Deos https://unix.stackexchange.com/questions/5093/how-does-one-atomically-change-a-symlink-to-a-directory-in-busybox answer your quesiton? You want to replace symlink with directory or symlink with different symlink? First one is not possible atomically, second one is.
score: 4
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78218123

http://stackoverflow.com/comment/137988271
score: 0
comment on: http://stackoverflow.com/a/78270269
has text: Thanks for all the community support! Indeed option 1 provided by @ikkachu works well for me and is succinct.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137918935
type: Comment
score: 1
type: QuestionComment
has text: Does this answer your question? [I just assigned a variable, but echo $variable shows something else](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else)
comment on: http://stackoverflow.com/q/78229406

http://stackoverflow.com/a/78195996
score: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/78195387
has comment: http://stackoverflow.com/comment/137887426
downvote count: 0
answers question: http://stackoverflow.com/q/78195387
type: AcceptedAnswer
upvote count: 1
has body: First of all, all you need is this: cat <<'.' >package.json { "dependencies": { "foo": "3.3.3", "bar": "2.2.2" } } . But let's assume you have a reason to break it down into steps. The linked answer is about adding to an array. You are not trying to add to an array. To add a key and value to an object, you can simply use .object["key"] = value Therefore, doing one addition at a time, the program would look like the following: { } | .dependencies = { } | .dependencies[ "foo" ] = "3.3.3" | .dependencies[ "bar" ] = "2.2.2" Demo on jqplay. As separate calls to jq, we get the following: printf '{ }\n' | jq '.dependencies = { }' | jq '.dependencies[ "foo" ] = "3.3.3"' | jq '.dependencies[ "bar" ] = "2.2.2"' >package.json As a single pipeline, these commands are still entangled. To separate them, we will need a temporary file or the sponge command-line utility. printf '{ }\n' >package.tmp1.json jq '.dependencies = { }' package.tmp1.json >package.tmp2.json jq '.dependencies[ "foo" ] = "3.3.3"' package.tmp2.json >package.tmp3.json jq '.dependencies[ "bar" ] = "2.2.2"' package.tmp3.json >package.tmp4.json mv package.tmp4.json package.json rm package.tmp{1,2,3}.json What if you wanted to add .dependencies only if it didn't already exist? Replace .dependencies = { } with .dependencies //= { }

http://stackoverflow.com/comment/137905341
comment on: http://stackoverflow.com/q/78222483
has text: Consider asking in [UNIX & Linux](https://unix.stackexchange.com) with the `systemd` and `journaltctl` tags added.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137820292
type: Comment
type: AnswerComment
score: 0
has text: @bobmonty, it's generally not a good idea to put variable expansions in the `printf` format string, and [Shellcheck](https://www.shellcheck.net/) will normally complain if you do it. I'd go with `printf '%s,%s,%s,%(%c)T\n' "$first" "$utime" "$rest" "$((utime/1000))"`
comment on: http://stackoverflow.com/a/78171801

http://stackoverflow.com/comment/137873071
type: Comment
type: AnswerComment
has text: @jhnc not according to shellcheck
comment on: http://stackoverflow.com/a/78199319
score: 0

http://stackoverflow.com/comment/137798903
type: Comment
has text: `diff -r` compares the content (recursively).
comment on: http://stackoverflow.com/q/78163062
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137833868
type: Comment
has text: `eval "$response"` -- note the quotes, they're important (simple code can appear to work without them, but complex code can fail in surprising ways)
comment on: http://stackoverflow.com/q/78183119
score: 0
type: QuestionComment

conda
tags question: http://stackoverflow.com/q/78180816
type: Tag
tag name: conda
tags question: http://stackoverflow.com/q/78356154
tags question: http://stackoverflow.com/q/78527966
tags question: http://stackoverflow.com/q/78811660
tags question: http://stackoverflow.com/q/78879439
tags question: http://stackoverflow.com/q/78924081
tags question: http://stackoverflow.com/q/79058251
tags question: http://stackoverflow.com/q/78927392

http://stackoverflow.com/comment/137924150
type: Comment
type: AnswerComment
score: 0
has text: I'm not trying to make JSON, I am extracting the content that is in JSON.
comment on: http://stackoverflow.com/a/78233340

http://stackoverflow.com/a/78204923
downvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78204849
score: 1
answers question: http://stackoverflow.com/q/78204849
type: Answer
has body: ~&lt;TAB&gt; completes a username. ~string navigates to user string home directory. So this looks like some pre-configured list of ?shortcuts?. It is not, these are usernames. Can this be configured? You tagged both bash and zsh, I do not know which one of them are you using. I know bash. In bash, you can modify the bash-completion functions, depending on the version they are installed. See ex. https://github.com/scop/bash-completion/blob/4f9ad009487452cb5896cd129a7c87ac4196cb21/bash_completion#L272 . Why are there suggestions that doesn't work (no such file or directory: /nonexistent)? There are users with not existent home directories, because they are system or batch users, or there are users with home directories to which your user does not have permissions to navigate to. cd ~[TAB] doesn't behave as expected That is true. In such situations, you could consider adjusting your expectation. ~string is the standard way to reference some user home directory, there are also less known ~+ ~- ~5. See https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html /
has comment: http://stackoverflow.com/comment/137872811
upvote count: 2

http://stackoverflow.com/q/78294975
linked to: http://stackoverflow.com/q/7577052
has comment: http://stackoverflow.com/comment/138031581
has title: How can I declare an empty array in bash 3.2 without unbound variable warnings when referencing it?
has comment: http://stackoverflow.com/comment/138031558
has body: Bash version: GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23) Copyright (C) 2007 Free Software Foundation, Inc. Consider the following script: #!/bin/bash set -o nounset HELLO_ARRAY=() # HELLO_ARRAY=( hi hi ) echo &quot;${HELLO_ARRAY[@]}&quot; With line 6 commented out, I get the output: ./MWE.sh: line 7: HELLO_ARRAY[@]: unbound variable With line 6 uncommented, I get the output: hi hi Is it possible to modify the declaration on line 5 to avoid the unbound variable warning? I've already tried declare -a HELLO_ARRAY=() but I get the same warning.
has comment: http://stackoverflow.com/comment/138031578
score: 0
duplicate of: http://stackoverflow.com/q/7577052
answer count: 0
has comment: http://stackoverflow.com/comment/138031358
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138031663
has comment: http://stackoverflow.com/comment/138031353
type: Question

http://stackoverflow.com/comment/137830122
comment on: http://stackoverflow.com/q/78177875
type: QuestionComment
type: Comment
score: 0
has text: I understand that with the version of the sed variant you ran you got the count you wanted but it's **undefined behavior** and so you may get different results with other sed variants or other versions of your current one and/or other tools you want to run on the files and so a better solution would be to fix the files that have the problem by fixing whatever's creating them to always provide the terminating `\n` required for a valid POSIX text file.

http://stackoverflow.com/comment/138013992
type: Comment
score: 3
has text: One possible cause is that `(bash "$mkvdts2ac3_path"/mkvdts2ac3.sh -f -t $track_id -v $merged_file)` consumed standard input, throwing away all the data from the second line onwards.
comment on: http://stackoverflow.com/q/78284934
type: QuestionComment

http://stackoverflow.com/comment/137870407
has text: Try `subprocess.run("command ...".split(), ...) the `split` is key since you need a list of the command's components. But probably this is a duplicate question if that's your issue..
type: QuestionComment
comment on: http://stackoverflow.com/q/78202789
type: Comment
score: 0

http://stackoverflow.com/comment/137857614
type: QuestionComment
type: Comment
has text: (since you got it working, I assume you either added `| head -n 1` to the pipeline setting `gateway`, or did some equivalent?)
comment on: http://stackoverflow.com/q/78194973
score: 0

http://stackoverflow.com/comment/137772406
has text: `"%env%"` this is not bash syntax. `"${env}"` or `"$env"` would be bash syntax.
type: QuestionComment
comment on: http://stackoverflow.com/q/78148102
type: Comment
score: 2

http://stackoverflow.com/comment/137874989
has text: Thank you for your input, what do you mean by "I prefer test over file"?
comment on: http://stackoverflow.com/a/78203971
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137896031
comment on: http://stackoverflow.com/q/78218123
type: QuestionComment
has text: Seems like your goal is to avoid a network hop, so could you just use `ln -sf 2023.tmp 2023`?
type: Comment
score: 0

http://stackoverflow.com/comment/137822933
score: 0
comment on: http://stackoverflow.com/a/78176733
type: Comment
has text: This is also the only answer so far that has produced a result.
type: AnswerComment

http://stackoverflow.com/comment/137863337
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78195172
type: Comment
has text: Which character is generated by your backspace key? If you do `printf '<control-v><backspace>' | od -c` does it output `177` or `8` or something else?

http://stackoverflow.com/comment/137775890
type: QuestionComment
comment on: http://stackoverflow.com/q/78149866
has text: @GillesQuénot I think. So you can embed another if/else inside like that?
type: Comment
score: 0

http://stackoverflow.com/comment/137913396
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591
type: Comment
has text: afaik bash doesn't have a built-in json parser. I would suggest creating a small php script or something that has built-in json parsing and just pass it to the php script to return it for your bash script
score: 0

http://stackoverflow.com/comment/137784938
comment on: http://stackoverflow.com/a/78155222
has text: Wow. How did you know that?
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137868461
type: Comment
score: 1
has text: Asking for tutorials is generally frowned upon for this site, as well as just listing a bunch of languages and hoping someone will write this for you. Instead we'd ask you to try something, preferably in a language you are comfortable with, and once you get stuck post a question here.
type: QuestionComment
comment on: http://stackoverflow.com/q/78202378

http://stackoverflow.com/comment/137814238
score: 1
has text: Given the minimal parsing needed, I think this is a case where it's better to let the shell split the line than to try to safely embed a shell command into an `awk` script.
type: Comment
comment on: http://stackoverflow.com/a/78170533
type: AnswerComment

http://stackoverflow.com/comment/137996784
has text: @WilliamPursell thank you! I just tested it and the output is correct. However, my real world case's value is taken from another file, I can't manually modify it to escape. So I just tried `raw_value="- & -" && value="$(echo "$raw_value" | sed -e 's/&/\&/g')"`, but it doesn't work. I'll try more tmr, or do you have any suggestions?
score: 0
comment on: http://stackoverflow.com/q/78274893
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137769478
type: QuestionComment
type: Comment
has text: cf [Looping Constructs](https://www.gnu.org/software/bash/manual/bash.html#Looping-Constructs) - note that `test-commands` is plural, only the exit status of the final one matters
comment on: http://stackoverflow.com/q/78146405
score: 0

clipboard
tags question: http://stackoverflow.com/q/78278159
type: Tag
tag name: clipboard
tags question: http://stackoverflow.com/q/79014791
tags question: http://stackoverflow.com/q/79543504

http://stackoverflow.com/comment/137886737
comment on: http://stackoverflow.com/q/78212759
score: 2
type: Comment
type: QuestionComment
has text: If you're learning bash as part of a cybersecurity class then you REALLY need to focus on the details to avoid potential security issues. Regarding "So far i have tried using a loop and appending the data to a new array, and using eval to do basically the same thing." - that's not necessary even if you were to do this part in bash and it's likely to introduce a code injection vulnerability, see https://mywiki.wooledge.org/BashFAQ/048.

http://stackoverflow.com/comment/138007608
type: Comment
has text: See also: https://stackoverflow.com/questions/13808909/should-awk-expand-escape-sequences-in-command-line-assigned-variables
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78281234

format
type: Tag
tags question: http://stackoverflow.com/q/78219094
tag name: format
tags question: http://stackoverflow.com/q/78246449
tags question: http://stackoverflow.com/q/78954892

http://stackoverflow.com/comment/137947721
type: QuestionComment
comment on: http://stackoverflow.com/q/78239018
score: 0
has text: How do you see the file content? I got some error installing that bash on a test server and they gave me different file https://pastebin.com/Fue33Wu7 , what's inside this one?
type: Comment

http://stackoverflow.com/a/78158163
answers question: http://stackoverflow.com/q/78158123
type: Answer
score: -1
has body: Before rm, we can check for the file's existence. As a one-liner: while read line; do [ -f ${line} ] &amp;&amp; rm ${line}; done &lt; ./old_backups.txt Here, [ -f ${line} ] check if file exists, and if and only if, the next instruction (rm ${line}) executes as enforced by the &amp;&amp; operator.
has comment: http://stackoverflow.com/comment/137807322
upvote count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/137820358
has comment: http://stackoverflow.com/comment/137807567

http://stackoverflow.com/a/78248577
type: Answer
has body: As I mentioned in the comments on your question, I think the only way to do this effectively (that is, in a way that isn't easy for someone to re-enable the kill command) is to build a custom bash binary with the kill command disabled. Here's one option for that; we replace the kill builtin with a modified command that reports The kill command is not available in this shell. when someone runs kill. This is a multi-stage Dockerfile -- we perform the custom build in the first stage, and then copy just the bash binary into the final image. FROM docker.io/debian:bookworm AS builder RUN apt update RUN DEBIAN_FRONTEND=noninteractive && apt-get -y install gcc make autoconf automake libtool git WORKDIR /src/bash RUN git clone https://git.savannah.gnu.org/git/bash.git . COPY <<'EOF' ./builtins/kill.def $PRODUCES kill.c $BUILTIN kill $FUNCTION kill_builtin $SHORT_DOC kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] The kill command is not available in this shell. $END #include <config.h> #include <stdio.h> #include <signal.h> #include "../shell.h" int kill_builtin (list) WORD_LIST *list; { fprintf(stderr, "The kill command is not available in this shell.\n"); return (EXECUTION_FAILURE); } EOF RUN ./configure --prefix=/usr RUN make RUN mkdir -p /tmp/bash && make install DESTDIR=/tmp/bash FROM docker.io/debian:bookworm COPY --from=builder /tmp/bash/usr/bin/bash /usr/bin/bash CMD ["/usr/bin/bash"] Using this looks like: $ podman run -it --rm bash-nokill bash-5.2# kill The kill command is not available in this shell. bash-5.2# help kill kill: kill (disabled) The kill command is not available in this shell. bash-5.2#
answers question: http://stackoverflow.com/q/78248223
score: 0

http://stackoverflow.com/comment/138039506
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78290118
has text: Thanks for clarifying. I wonder if you're running into a race condition between daemon-reload and start. Can you add a `sleep 10` to your script after daemon-reload to test this idea?
score: 0

http://stackoverflow.com/comment/137830640
comment on: http://stackoverflow.com/q/78181239
type: Comment
type: QuestionComment
has text: You have an executable in a `PATH` directoty **and** another executable linked to by an alias. They are different. This is nothing special to sqlite, you just have more than one version of the same program. And executing them of course yields different results.
score: 0

gentoo
tags question: http://stackoverflow.com/q/78241761
type: Tag
tag name: gentoo

http://stackoverflow.com/comment/137855649
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78195172
type: Comment
has text: Hmm, it seems that simply changing `[yY]* )` "from the example linked" into `[yY] )` seems to restrict it to one single `y` character + `enter` allowing the user to continue.

http://stackoverflow.com/comment/138023943
score: 5
has text: Can't you set up a cron job instead?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78290808

http://stackoverflow.com/comment/137820711
comment on: http://stackoverflow.com/a/78175828
type: Comment
type: AnswerComment
score: 1
has text: Thank you for these precise answers. Still I have accepted Kensters answer, because it highlights the behaviour of the "here string", which I did not expect.

http://stackoverflow.com/a/78273432
downvote count: 0
upvote count: 3
has comment: http://stackoverflow.com/comment/137998848
type: Answer
has body: This may do what you want: SOME_VAR='' source ./myenv.sh The SOME_VAR environment variable is set (to empty) just for the source command. Previous settings of SOME_VAR (including being unset) are restored after the source command completes.
score: 3
answers question: http://stackoverflow.com/q/78272610

http://stackoverflow.com/comment/137961702
comment on: http://stackoverflow.com/q/78255091
score: 3
has text: Stop thinking of "conditions". The syntax of the shell is *not* `if condition`, it is `if command`. eg `if grep ... && grep ....`
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138006456
has text: I opted for using gawk since it gives me more flexibility in the following parsing but this command get the job done. Again, thanks everyone!
comment on: http://stackoverflow.com/a/78276869
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137909178
comment on: http://stackoverflow.com/a/78225303
type: Comment
score: 0
has text: @oguzismail thanks, didn't know that, not so obvious as I thought
type: AnswerComment

http://stackoverflow.com/comment/137820516
comment on: http://stackoverflow.com/a/78173029
score: 0
has text: @WalterA did those in series and the first ls showed the wav file. So obviously globstar is working, just not in the executable. Thanks for that troubleshooting tip. So now I need to figure out why it isn't working in the code
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78218663
has comment: http://stackoverflow.com/comment/137902935
tagged with: http://stackoverflow.com/tag/c
tagged with: bash
has body: interesting screen lldb I encounter an issue with my implementation of pipes and output redirection. It works fine individually, but when I try 'ls | wc > a', it doesn't function as in real Bash. It creates the file 'a', but it doesn't redirect the output of 'ls | wc' to this file and creat infinite loop It waits for the pid, but I have the loop to wait for all the function at the end, I made a mistake, but I don't know where ? I have a function for creating my pipes and their execution and the same for redirection I can't find the solution i my probleme why my 'ls | wc > file' is not redirected from my file pipeline.c void create_pipe(int pipe_fd[2], int i, int last) { if (i < (last - 1)) { if (pipe(pipe_fd) == -1) { perror("pipe"); exit(EXIT_FAILURE); } } } void close_pipes_in_parent(int i, t_data *data, int *input_fd) { if (i != data->first) close(*input_fd); if (i < data->last) { close(data->pipe_fd[1]); *input_fd = data->pipe_fd[0]; } } pid_t fork_process_pipe(int i, int input_fd, t_data *data, t_Token *curr, char **envp, t_Token *lst_tok) { pid_t pid = fork(); if (pid == 0) { printf("111111111111111111"); if (i != data->first) { dup2(input_fd, STDIN_FILENO); close(input_fd); } if (i < data->last) { dup2(data->pipe_fd[1], STDOUT_FILENO); close(data->pipe_fd[0]); close(data->pipe_fd[1]); } data->path_exe = ft_get_reading(data, curr, envp); if(!data->path_exe) { printf("Bash : command not found : %s\n", data->cmd[0]); ft_free_tabtab(data->cmd); free_token(lst_tok); exit(EXIT_FAILURE); } if (execve(data->path_exe, data->cmd, envp) == -1) { ft_free_tabtab(data->cmd); free(data->path_exe); exit(EXIT_FAILURE); } free(curr->Token_str); free(curr); } return (pid); } redir.c int *creat_fd_out(t_data *data, t_Token *curr, int *output_fd) { int i; i = 0; while(i < data->nb_file) { output_fd[i] = open(curr->next->next->Token_str, O_CREAT | O_WRONLY | O_TRUNC, 0644); if (output_fd[i] == -1) exit(EXIT_FAILURE); i++; curr = curr->next->next ; } return(output_fd); } void close…
has comment: http://stackoverflow.com/comment/137903116
tagged with: wait
answer count: 1
accepted answer: http://stackoverflow.com/a/78225807
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137897158
has comment: http://stackoverflow.com/comment/137898078
has comment: http://stackoverflow.com/comment/137898125
has title: Implementation Bash pipes and redirections in c
tagged with: waitpid
tagged with: fork
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137906469
has answer: http://stackoverflow.com/a/78225807
has comment: http://stackoverflow.com/comment/137901910

http://stackoverflow.com/a/78216523
answers question: http://stackoverflow.com/q/78216460
upvote count: 3
accepted answer of: http://stackoverflow.com/q/78216460
downvote count: 0
has comment: http://stackoverflow.com/comment/137893382
type: Answer
has body: Use script to keep color : script -qec "systemd status weechat" /dev/null |grep Active
score: 3
type: AcceptedAnswer

http://stackoverflow.com/a/78217506
has comment: http://stackoverflow.com/comment/137912359
answers question: http://stackoverflow.com/q/78216881
score: 4
has comment: http://stackoverflow.com/comment/137901224
downvote count: 0
has body: When you copying data from some variable to another variable and there is a chance that there is no data to copy. And you need to workaround this somehow by adding some default value for example. There is special bash syntax for this: var=${BITBUCKET_TAG:-Nothing to see here} $ echo $var Nothing to see here BITBUCKET_TAG=2.2.2 var=${BITBUCKET_TAG:-Nothing to see here} $ echo $var 2.2.2
has comment: http://stackoverflow.com/comment/137899742
type: Answer
has comment: http://stackoverflow.com/comment/137901425
upvote count: 4

http://stackoverflow.com/comment/137908845
type: Comment
comment on: http://stackoverflow.com/q/78224942
type: QuestionComment
score: 0
has text: Note that the code in the question is not a Bash program. See [Difference between sh and Bash](https://stackoverflow.com/q/5725296/4154375).

http://stackoverflow.com/comment/137856330
score: 0
type: QuestionComment
type: Comment
has text: @charles-duffy - ps thank you so much for your help so far. i have fixed the broadcast - getting the multiple interfaces still "ip route add 0.0.0.0/23 dev eth0 eth1 table vrack"
comment on: http://stackoverflow.com/q/78194973

http://stackoverflow.com/comment/137922498
comment on: http://stackoverflow.com/q/78232787
type: QuestionComment
score: 2
type: Comment
has text: Also, think about testing the contents of `[[ ${BASH_ALIASES[testcommand]} ]]` if you want to know if something is _specifically_ an alias, as opposed to whether it's defined.

http://stackoverflow.com/comment/137913393
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591
type: Comment
has text: `output=(one two); echo "$(jq -c -n '$ARGS.positional' --args "${output[@]}")"` results in `["one","two"]` for me. I'm not sure where you're getting your escaped brackets from. Can you post a complete bash snippet (it should be just a few lines)?
score: 2

http://stackoverflow.com/comment/137855835
has text: Think about `for interface in /sys/class/net/*; do interface=${interface##*/}; interface = eth* || continue; ...; done` for your loop.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment

od
type: Tag
tags question: http://stackoverflow.com/q/78173269
tag name: od

http://stackoverflow.com/a/78301072
type: Answer
has comment: http://stackoverflow.com/comment/138042577
has body: Given: $ cat file [Tue Apr 9 03:32:21 2024] {cmd1} [Tue Apr 9 03:33:42 2024] {cmd2} [Tue Apr 9 03:35:51 2024] {cmd3} [Tue Apr 999 03:35:51 2024] {bad time} nonsense line Here is a Ruby: ruby -r time -lne ' m=/^\[([^\]]+)\]\s+\{([^}]+)\}/.match($_) t=Time.parse($1) rescue nil puts &quot;#{t} #{$2}&quot; if m &amp;&amp; t ' file Prints: 2024-04-09 03:32:21 -0400 cmd1 2024-04-09 03:33:42 -0400 cmd2 2024-04-09 03:35:51 -0400 cmd3 Online demo
score: 0
answers question: http://stackoverflow.com/q/78297014

http://stackoverflow.com/comment/138007497
has text: @Barmar, @pjh, The referenced solution processes the whole file rather than specific lines chosen by grep. The section header `[hello goodbye]` may execute as a bash command, but probably doesn't do what you want.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78276574
type: QuestionComment

http://stackoverflow.com/comment/137886356
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78211681
has text: I pointed that out and included the fix for it and a few other things in my answer posted an hour earlier.
score: 0

http://stackoverflow.com/comment/137847150
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193
type: Comment
has text: as already mentioned ... open a connection to the database once and then keep open (plus code to (re)connect if you get disconnected - which hopefully isn't very often); minimize the number of times you need to parse-n-compile the `update` (prepared statements==great; stored proc==good)

http://stackoverflow.com/comment/137791598
has text: I would generally be hesitant to link to the ABS.
comment on: http://stackoverflow.com/a/78158865
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138018442
score: 0
type: QuestionComment
type: Comment
has text: Regarding your edit, that's *why* questions get closed as duplicates: to redirect you to an existing question that already answers yours. It doesn't mean go post the same question on a different site.
comment on: http://stackoverflow.com/q/78287441

http://stackoverflow.com/comment/137886319
comment on: http://stackoverflow.com/q/78211473
type: QuestionComment
type: Comment
has text: pjh: It seems to be the same, but I can't understand that code or how it is formed. But thanks. And Thanks for the link to spellcheck. Didn't know about it. I am quite new to Bash-programming.
score: 0

http://stackoverflow.com/comment/137816291
has text: You need to run `shopt -s globstar` first or `**/*.wav` is equivalent to `*/*.wav`.
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78173029

http://stackoverflow.com/a/78203990
answers question: http://stackoverflow.com/q/78203984
downvote count: 1
has comment: http://stackoverflow.com/comment/137871526
has body: Use find with the -type f option to count only regular files, and -maxdepth 1 to prevent going into subdirectories. files_in_pwd() { num_files=$(find . -maxdepth 1 -type f | wc -l) echo "Number of files in the pwd: $num_files" }
has comment: http://stackoverflow.com/comment/137876402
has comment: http://stackoverflow.com/comment/137875331
score: 0
upvote count: 1
type: Answer

http://stackoverflow.com/a/78167906
type: Answer
upvote count: 2
has body: With bash only: arr=(test,meta my,amazon test,amazon this,meta test,google my,google hello,microsoft) declare -Ai count declare -A locations for pair in "${arr[@]}"; do value=${pair%%,*} location=${pair#*,} count[$value]+=1 locations[$value]+="$location, " done for value in "${!locations[@]}"; do printf '%d %s: %s\n' ${count[$value]} "$value" "${locations[$value]%, }" done
score: 2
answers question: http://stackoverflow.com/q/78167734
downvote count: 0

http://stackoverflow.com/a/78188637
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/78187590
has body: This Shellcheck-clean pure Bash code demonstrates one way to populate an array with the 4-character blocks extracted from the input string: #! /bin/bash -p input_string=1234567898765432 blocks=() for ((i=0; i&lt;${#input_string}; i+=4)); do blocks+=( &quot;${input_string:i:4}&quot; ) done declare -p blocks This should work with any version of Bash since 2.0 (released in 1996). It will work for input_string containing any possible characters (including spaces, newlines, and glob characters).
upvote count: 1

http://stackoverflow.com/comment/138031558
has text: Is that bug referenced somewhere?
type: QuestionComment
comment on: http://stackoverflow.com/q/78294975
score: 0
type: Comment

http://stackoverflow.com/comment/137854311
has text: Each stack frame has its own arguments. When the scope is exited, the stack frame goes away.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78194467

http://stackoverflow.com/comment/137799253
type: QuestionComment
type: Comment
has text: When I use diff PROD/Today/ PROD/Yesterday > PROD/Changes/delta.txt, my output is: Only in PROD/Today/: <each individual filename>.cfg with a line for each individual file. So its comparing the file itself, not the contents of each file.
comment on: http://stackoverflow.com/q/78163062
score: 0

http://stackoverflow.com/comment/137988253
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78269359
score: 0
has text: @JohnBollinger, thanks for the nomenclature clarification! and RE: what I mean by "filtering": I am referring to the --filter flag and/or the --include --exclude flags

http://stackoverflow.com/comment/137886692
score: 1
type: QuestionComment
type: Comment
has text: you got a point yea. i think ill see if i get a better answer on the other question, or see if the python answer gets a little clarified so i can understand what im looking at. but thank you for all the help!
comment on: http://stackoverflow.com/q/78212759

http://stackoverflow.com/comment/138017084
score: 0
type: QuestionComment
has text: You not only want to add the score a a new column after each name. You also apparently want to suppress leading blanks in the name fields: in your example `2.csv` there is a space before `Bob` in `Alice, Bob,`, but there is no space in your expected result. And you apparently also want to suppress empty fields at the end of each record in `2.csv`: in `Alice, Bob,` and `Michel,` there is a trailing comma, but not in your expected output. Please edit your question and add the missing specifications (or fix your examples).
type: Comment
comment on: http://stackoverflow.com/q/78286060

http://stackoverflow.com/comment/137988655
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78270350
has text: Thx @GordonDavisson, I used "bash -c" and it worked, thank u so much bro
score: 0

http://stackoverflow.com/comment/137865158
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78196374
type: QuestionComment
has text: Essentially yes, "wrapping" the line around after ~60 characters, and appending a prefix in front of each line. My apologizes, I couldn't think of the correct term "wrap" and went with "truncating".

http://stackoverflow.com/comment/138016043
type: Comment
score: 4
type: QuestionComment
comment on: http://stackoverflow.com/q/78286124
has text: Do you want to use csv file 1 2 or 3?

http://stackoverflow.com/comment/137855363
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78194973
has text: ... `ip route | awk 'NR==2 {print $1}'` could be wrong! Try this *pure [tag:bash]*: `while read iface dest gate _{,,,} mask _;do case $dest$mask in 0000000000000000 ) defIface=$iface defRoute=$gate;;* ) printf -v iface_$iface %s/%s $dest $mask ;;esac;done < /proc/net/route ;declare -n defGate=iface_${defIface};printf '%s: %d.%d.%d.%d / %d.%d.%d.%d via %d.%d.%d.%d\n' $defIface 0x${defGate:6:2} 0x${defGate:4:2} 0x${defGate:2:2} 0x${defGate::2} 0x${defGate: -2} 0x${defGate: -4:2} 0x${defGate: -6:2} 0x${defGate: -8:2} 0x${defRoute:6:2} 0x${defRoute:4:2} 0x${defRoute:2:2} 0x${defRoute::2}`

http://stackoverflow.com/comment/137912318
has text: @user1934428 The statement is part of a larger build pipeline. The reason why I need two variables is because BITBUCKET_TAG is an environment variable that is set by our build pipeline, but I want to guarantee that it is not an empty string for a grep statement later in the pipeline (not shown here). When it's an empty string, the grep would pass but I want it to fail, so I replace it with a random string. I guess that I could have overwritten the env variable when it was empty, but I preferred to not mess with it.
type: Comment
comment on: http://stackoverflow.com/q/78216881
score: 0
type: QuestionComment

http://stackoverflow.com/a/78262533
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78261247
has body: This might work for you (GNU sed): sed -n '/^&gt;Cluster/{:a;x;s/\n/&amp;/2p;x;h;d};H;$ba' file Turn off implicit printing -n. If a line begins &gt;Cluster, then: Check to see if the hold space contains 3 or more lines and if so print them. Make a copy of the current cluster header in the hold space and delete that line. Otherwise, append a copy of the current line to the hold space and perform no further processing. Unless the current line is the last line, then proceed as if a cluster header has been accepted.
downvote count: 0

http://stackoverflow.com/comment/137831493
score: 0
has text: I have tidied up my question in light of clarifications. Still confused why batch file does not behave the same!
type: QuestionComment
comment on: http://stackoverflow.com/q/78181239
type: Comment

http://stackoverflow.com/comment/137771151
comment on: http://stackoverflow.com/q/78147406
has text: @user1934428 It's "./script.sh: line 22: singularity: command not found"
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137954139
has text: Please read https://mywiki.wooledge.org/BashFAQ/001#Input_source_selection, https://stackoverflow.com/q/4708549/1745001, https://mywiki.wooledge.org/Quotes and, as the [tag:bash] tag you used instructs, always copy/paste your code into http://shellcheck.net before posting a question as it'll detect and explain some of the issues in your code.
type: QuestionComment
comment on: http://stackoverflow.com/q/78250385
score: 2
type: Comment

http://stackoverflow.com/comment/137941100
type: Comment
has text: Which language is this? Unix is not a language. You tagged the question _shell_, which means POSIX shell or unix sh, but both shells don't have arrays, so your question does not make sense.
type: QuestionComment
comment on: http://stackoverflow.com/q/78241899
score: 0

http://stackoverflow.com/comment/137832085
comment on: http://stackoverflow.com/q/78182030
score: 3
type: QuestionComment
has text: if using `bash 3.1+` consider replacing the subprocess calls to `date` with `printf -v secs '%(%s)T'` (replace `x=$(date +%s)`) and `printf -v dt '%(%Y-%m-%d %H:%M:%S)T' "${secs}"` (replace `y=$(date -d$timerend1)`)
type: Comment

http://stackoverflow.com/comment/137865846
score: 0
has text: I should have looked at the man page a little better. Didn't realize sed also had -E for regex! Your changes solved my problem. Thanks!
comment on: http://stackoverflow.com/a/78196863
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78177473
has body: I think I found a way that works: first_line=$(command | { read first_line ; echo $first_line ; process_rest }) echo $first_line This will capture the first line while processing the remainder of the data. The main drawback of this approach is that I cannot easily redirect stdout of process_rest as part of the whole construct anymore. E.g. get_data() { first_line=$(command | { read first_line ; echo $first_line ; process_rest }) echo 2&gt;&amp;1 $first_line } get_data | do_something_else # derp One possible solution to this might be to use a fifo: get_data() { FIFO=$(mktemp -u) mkfifo $FIFO first_line=$(cat | { read first_line ; echo $first_line ; process_rest &gt; $FIFO}) echo 2&gt;&amp;1 first_line cat $FIFO rm $FIFO } get_data | do_something_else
has comment: http://stackoverflow.com/comment/137823938
type: Answer
has comment: http://stackoverflow.com/comment/137823729
has comment: http://stackoverflow.com/comment/137823864
answers question: http://stackoverflow.com/q/78177405
has comment: http://stackoverflow.com/comment/137823732
score: 0
has comment: http://stackoverflow.com/comment/137823724
has comment: http://stackoverflow.com/comment/137823753

http://stackoverflow.com/comment/137856559
comment on: http://stackoverflow.com/q/78195387
type: QuestionComment
type: Comment
has text: `jq` doesn't modify its input in-place; you would have to write the output of each command back to `package.json`.
score: 0

uniq
tag name: uniq
type: Tag
tags question: http://stackoverflow.com/q/78167734

http://stackoverflow.com/comment/137804595
has text: @KonradRudolph I'm willing to credit you as The Answer here but I think I can't if you just leave as a comment. If you submit as an answer I'll validate it. Else I'll quote you for the answer. Cheers
comment on: http://stackoverflow.com/q/78166124
score: 0
type: QuestionComment
type: Comment

steam
type: Tag
tag name: steam
tags question: http://stackoverflow.com/q/78233393

http://stackoverflow.com/comment/137896039
score: 0
type: QuestionComment
has text: @cmbuckley It is and I thought about this, but ain't it ugly! haha
type: Comment
comment on: http://stackoverflow.com/q/78218123

http://stackoverflow.com/comment/137857736
score: 0
comment on: http://stackoverflow.com/q/78196374
has text: From my understanding... `${esc}[35m║ &\n` adds the purple `║ ` prefix, then the `&` takes the remainder of the string, beyond the `60 characters`, and and prints it out, after the `\n` (even though the `&` comes before the `\n`. Essentially, this was the closest I could get to my desired output, but with this extra new line appearing.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/137908291
has text: @CharlesDuffy I will be honest, I don't know. As stated, this is my first experience with Bash. I only done it this way to ensure the file contents (google.com etc) were properly piped into the nslookup. It works as it is, and considering my circumstances with this uni assignment (I need to redo this code in DOS and some other research stuff) I'm leaving the 'making it fancy and neat' part until last, where I might have extra time. Could you explain the 'xargs' example you gave? (If that sort of discussion isn't allowed here then no worries!)
comment on: http://stackoverflow.com/q/78224799
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137851282
has text: Where does the link come from? Should it be hardcoded?
comment on: http://stackoverflow.com/q/78192804
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138005497
score: 0
type: QuestionComment
has text: just the first character of each row?
type: Comment
comment on: http://stackoverflow.com/q/78280175

http://stackoverflow.com/a/78182177
answers question: http://stackoverflow.com/q/78181978
has comment: http://stackoverflow.com/comment/137833925
has comment: http://stackoverflow.com/comment/137833579
has comment: http://stackoverflow.com/comment/137834247
downvote count: 0
has comment: http://stackoverflow.com/comment/137833728
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/137840296
type: Answer
has body: You can do this all in one shot by using elif and else in the callback, as demonstrated in the git-filter-repo documentation examples, like this: -------------------------------------------------- git-filter-repo --filename-callback ' if commit.author_email == b"incorrect1@email" # change it elif commit.author_email == b"incorrect2@email" # change it else: # put default here ' -------------------------------------------------- Add additional swaps in elif blocks and the default in the else block. Side Note: In the example in your question, you are setting both the Author and Committer based on the Author alone. Perhaps they are always the same in your repo in which case it doesn't matter. If they do ever differ though, you may wish to handle them separately.

http://stackoverflow.com/comment/137975346
score: 0
comment on: http://stackoverflow.com/q/78261051
type: QuestionComment
type: Comment
has text: Does this answer your question? [Why should there be spaces around '\[' and '\]' in Bash?](https://stackoverflow.com/questions/9581064/why-should-there-be-spaces-around-and-in-bash)

http://stackoverflow.com/q/78178702
has comment: http://stackoverflow.com/comment/137826210
score: 0
type: Question
tagged with: shell
has comment: http://stackoverflow.com/comment/137826057
has title: In shell script how to print command to file and show the command as well?
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/78119052
answer count: 1
duplicate of: http://stackoverflow.com/q/2853803
linked to: http://stackoverflow.com/q/876239
tagged with: unix
linked to: http://stackoverflow.com/q/2853803
linked to: http://stackoverflow.com/q/22713667
has body: I have multiple ls -l commands in my shell script and i want each line to append it's output to text file so i run it like this: ls -l /directory/to/check/exists &gt;&gt; validation.log The file will show only the output but I also want it to show the command that was executed. How can I have this without adding both command and echo of same command to avoid multiple lines? Thank you
has comment: http://stackoverflow.com/comment/137825968
has comment: http://stackoverflow.com/comment/137826649
has answer: http://stackoverflow.com/a/78178940
has comment: http://stackoverflow.com/comment/137826189
has comment: http://stackoverflow.com/comment/137826172
duplicate of: http://stackoverflow.com/q/876239
tagged with: bash
has comment: http://stackoverflow.com/comment/137826134

http://stackoverflow.com/comment/137855863
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78194973
score: 0
has text: @Charles Duffy Bit confused on what the actual command would be

http://stackoverflow.com/comment/137901910
type: QuestionComment
comment on: http://stackoverflow.com/q/78218663
has text: Side note: In this context, "Bash" is the name of a *specific* shell. It is not a generic term. It is inappropriate for your shell to identify itself as "Bash".
score: 0
type: Comment

http://stackoverflow.com/comment/137823753
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78177473
score: 0
has text: @CharlesDuffy Thank you. Edited the post. I was always under the impression that the `$()` syntax was bash specific and not portable. I guess that information is wildly outdated.

http://stackoverflow.com/comment/137807567
comment on: http://stackoverflow.com/a/78158163
type: Comment
type: AnswerComment
score: 0
has text: Yes, that worked like a charm, but any chance you can direct me to any white paper on why. On first glance, the likes look identical, so I'm missing the way? Thank you again, but if you don't mind, the why.

http://stackoverflow.com/comment/137926912
score: 1
comment on: http://stackoverflow.com/q/78235101
type: QuestionComment
type: Comment
has text: you declare the array, not the elements. if you want global, don't use `declare`. but read the manul re dynamic scoping

http://stackoverflow.com/comment/137872587
score: 1
type: QuestionComment
type: Comment
has text: If you use GNU sed then `sed '200s/.*/df -h/e' file` is suffice.
comment on: http://stackoverflow.com/q/78200217

http://stackoverflow.com/comment/137823724
score: 0
comment on: http://stackoverflow.com/a/78177473
type: Comment
type: AnswerComment
has text: I wonder if there's some exec FD redirection magic one can do to avoid having to create a FIFO for the last scenario, too.

http://stackoverflow.com/comment/137945903
type: QuestionComment
type: Comment
has text: you are right about tee. in some occurrences the file was empty indeed
comment on: http://stackoverflow.com/q/78245937
score: 0

http://stackoverflow.com/comment/137804165
score: 3
type: QuestionComment
has text: but why not `for i in "${dir}"/*"${subdir}"*/`? Even `arr=("${dir}"/*"${subdir}"*/); if (( ${#arr[@]} )); then return 0; fi`
type: Comment
comment on: http://stackoverflow.com/q/78166124

http://stackoverflow.com/a/78173611
upvote count: 1
has body: You can do it with a single call to jq like this : jq -n 'reduce inputs as $i({};. * $i)' file{1..4}.json
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/137819111
type: Answer
answers question: http://stackoverflow.com/q/78173589

http://stackoverflow.com/a/78177437
has body: You may consider using a temporary file : tempfile=$(mktemp) command | { read -r first_line ; printf "%s\n" "$first_line" > "$tempfile"; cat ; } | process_rest
answers question: http://stackoverflow.com/q/78177405
type: Answer
score: 0

http://stackoverflow.com/comment/137911518
type: Comment
comment on: http://stackoverflow.com/q/78226499
score: 1
type: QuestionComment
has text: C-Z is a SIGSTOP. You're capturing SIGSTOP. Ctrl+C is a SIGINT. You're capturing SIGINT. So the signals don't have normal/default behavior for your program _because you're explicitly overriding them_.

http://stackoverflow.com/q/78284934
has body: I am using mkvdts2ac3.sh script (see https://github.com/JakeWharton/mkvdts2ac3), and I have troubles to use it in a loop. This script is able to extract a dts track from a mkv file, convert it in AC3 and mux it back in the original mkv file. My problem is that I want to do it recursively for all dts tracks in the file. I don't think this is a big issue but I can't find the solution, hope you will understand my problem guys! So I am using a txt file where all the dts tracks ids are stored (ex: 1:fre \n 2:eng). It is working fine when I just let the echo line, it prints all the dts tracks correctly. But when I want to use the script, it stops each time after the first use. Here is the part of the script in question : while IFS=: read -r track_id language; do echo "Extraction de la piste $track_id avec la langue $language" (bash "$mkvdts2ac3_path"/mkvdts2ac3.sh -f -t $track_id -v $merged_file) || continue sleep 5 done < "tracks_info.txt" I have no errors, just the main script is ending without doing the second dts track.
score: 0
tagged with: freebsd
type: Question
tagged with: shell
answer count: 0
tagged with: mkv
tagged with: linux
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/13800225
linked to: http://stackoverflow.com/q/13800225
has comment: http://stackoverflow.com/comment/138014269
has title: Issues while using a loop on a bash script
tagged with: bash
has comment: http://stackoverflow.com/comment/138013992

http://stackoverflow.com/comment/137997791
type: Comment
type: AnswerComment
has text: Please take a look at https://stackoverflow.com/a/37039138/548225 to escape all special characters in the search string
comment on: http://stackoverflow.com/a/78275140
score: 1

rsync
tags question: http://stackoverflow.com/q/78269359
type: Tag
tag name: rsync
tags question: http://stackoverflow.com/q/78398806
tags question: http://stackoverflow.com/q/78808231
tags question: http://stackoverflow.com/q/78816352
tags question: http://stackoverflow.com/q/79073034
tags question: http://stackoverflow.com/q/79076493

http://stackoverflow.com/comment/137865851
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78201122
score: 0
has text: Thank you that worked for search and replace, appreciate the explanation too :)

http://stackoverflow.com/comment/137819180
has text: @LéaGris - That’s why I mentioned “objects” explicitly. Also, the question pretty much implies that each file specifies a JSON object….
score: 1
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78173873

http://stackoverflow.com/comment/138037155
has text: @JohnBollinger I know that I can use python instead and I may create a python version to learn some more python at a later date but I was looking for a quick and dirty solution to the problem (easy access to videos produced by motion). If you know what the answer to the problem is you could add an answer and maybe throw in a example of how this could be done better in python so others wouldn't waste their time doing the same in bash.
type: Comment
comment on: http://stackoverflow.com/q/78292693
type: QuestionComment
score: 0

http://stackoverflow.com/comment/137850783
type: QuestionComment
type: Comment
has text: Yes I made it work by making the generator script also run the playwright command. But I want to separate the scripts so I generate data without starting tests etc. I also tried creating a second script that runs the generator then the npx playwright command. The tests dont have access to the exported variables then either:( ./generate-data.sh \n npx playwright test myTest.spec.ts
comment on: http://stackoverflow.com/q/78166360
score: 0

http://stackoverflow.com/comment/138118569
type: QuestionComment
has text: i appreciate your comments.
comment on: http://stackoverflow.com/q/78286060
type: Comment
score: 0

http://stackoverflow.com/comment/138031663
comment on: http://stackoverflow.com/q/78294975
type: QuestionComment
type: Comment
has text: The awful Bash bugs related to empty arrays with `set -o nounset` (`set -u`) were not fixed until version 4.4 (released in 2016). Prior to that the only safe way to do the array expansion in your `echo` command was `echo ${HELLO_ARRAY[@]+"${HELLO_ARRAY[@]}"}`.
score: 0

http://stackoverflow.com/comment/137888242
has text: no am still having the same problem
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78211761
score: 0

http://stackoverflow.com/comment/137822234
score: 0
has text: Regarding "The 'xargs' is to eliminate the tons of white-space that seemed to surround the result." - then your real input file doesn't look "pretty much" enough like the file you showed us since running the command you provided, minus the pipe to xargs, against the file you provided would not result in tons of white-space being output and so you're unlikely to get the best solution for your real input file. Create and post a [mcve] that demonstrates your actual problem so we can help you with it.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78176143

http://stackoverflow.com/q/78149866
answer count: 2
has body: I have a basic script that I wrote that will ask if you want to create a user and then in a separate section will ask if you want to add that new user to the wheel group. I think this could be simplified in one section but it is beyond my ability to get it right. I've tried different ways but I keep failing. Here is the basic script: echo "^^^ Would you like to setup a new user? yes or no: " read NEWUSERADD if [ "$NEWUSERADD" == "yes" ]; then echo echo -n "Enter a username: " read NAME useradd -m $NAME passwd $NAME else [ "$NEWUSERADD" == "no" ] echo read -p "**** Not creating a user. Hit [Enter] to continue ****" fi # Add new user to wheel group echo "^^^ Add new user to the wheel group? yes or no: " read NEWUSERWHEEL if [ "$NEWUSERWHEEL" == "yes" ]; then echo usermod -aG wheel $NAME else [ "$NEWUSERWHEEL" == "no" ] echo read -p "**** Not adding to wheel group. Hit [Enter} to continue ****" fi I'm trying to get that second section into the first section to ask, if that user is created, if you would like to add them to wheel group and then if yes to then complete the action. Is that possible? If so, what would be the best way to do that? I feel it would be another if/else or elif block but I'm not sure how to do that. Any assistance would be greatly appreciated.
tagged with: bash
has answer: http://stackoverflow.com/a/78150022
has comment: http://stackoverflow.com/comment/137776047
has comment: http://stackoverflow.com/comment/137775890
has comment: http://stackoverflow.com/comment/137775862
has comment: http://stackoverflow.com/comment/137775848
score: 0
has title: Shell script - interactive create user and add to group
type: Question
tagged with: shell
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78149915

http://stackoverflow.com/comment/137855338
comment on: http://stackoverflow.com/a/78195052
has text: Edited my response, and you were right, it becomes the same answer and yours is better due to `NR>=4`. Will upvote yours, then :)
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137872804
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78204849
score: 0
has text: Looks reasonable to me. These seem to be the typical user names found in a Linux system. BTW, you still have not fixed the tags for your question.

http://stackoverflow.com/comment/137908417
type: QuestionComment
comment on: http://stackoverflow.com/q/78224990
type: Comment
score: 0
has text: Huh...afraid I can't help you then I don't have that system to test the usecase either.

http://stackoverflow.com/comment/137872794
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78204849
score: 0
has text: @user1934428: you're right, this are just users. The list relates to the content of /etc/passwd. Thanks a lot!

content-type
tags question: http://stackoverflow.com/q/78228745
type: Tag
tag name: content-type

continuous-integration
tags question: http://stackoverflow.com/q/78178759
tag name: continuous-integration
type: Tag
tags question: http://stackoverflow.com/q/78361550
tags question: http://stackoverflow.com/q/78916872

http://stackoverflow.com/comment/138045890
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78302726
has text: Well, it works here and everywhere else. Perhaps you are doing something different from what you show. For example, your `export` statement is messed up and won't export anything (but that doesn't cause such an error). The error means that the variable is not set.
score: 1

http://stackoverflow.com/a/78183320
has comment: http://stackoverflow.com/comment/137867343
type: Answer
has comment: http://stackoverflow.com/comment/137836613
score: 0
answers question: http://stackoverflow.com/q/78182539
has body: If all your scripts are encoded in UTF-8, and your terminal supports it likewise, and you're running a modern version of Bash (and by "modern", I mainly mean not the version 3.2 that ships in /bin on macOS) ... then Unicode characters should mostly Just Work. Here's a simple demonstration of bash acting Unicode-friendly: $ printf '%X\n' "'" 1F4A4 As you can see, it recognizes the emoji as a single character and displays its code point when requested. But many UNIX tools – like cut – are not so safe for multibyte text. I don't see where in your code you're setting the emoji variable that you use, but if you're doing any kind of parsing to get it the way you're doing for the repo and label, it could be giving you invalid results for that reason. It might help to stick to bash builtins. For example, instead of this: REPO_USER=$(echo "$repo" | cut -f1 -d /) REPO_NAME=$(echo "$repo" | cut -f2 -d /) you could do do this: IFS=/ read REPO_USER REPO_NAME _ <<<"$repo" (Although I don't know why you're naming those vars in all-caps; they don't appear to be being set as environment variables.) If you could supply the whole program (minus auth keys or other sensitive data, of course), it might help.

http://stackoverflow.com/comment/137865395
score: 0
has text: @level42: It makes no sense. `$(...)` is command substitution, it expands to the output of the script.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78196477

hotkeys
tags question: http://stackoverflow.com/q/78226499
tag name: hotkeys
type: Tag

http://stackoverflow.com/comment/138029807
comment on: http://stackoverflow.com/a/78292830
score: 0
has text: If the `curl --unix-socket /var/run/docker.sock` works, and you have the `docker` CLI installed, then yes. You also might consider using a Docker client library in your application code. As always, remember that if you can access the Docker socket at all, you can launch a container that takes over the entire host system, which is another reason to prefer the subprocess approach if that's an option.
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78182867
has comment: http://stackoverflow.com/comment/137833540
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137834121
has answer: http://stackoverflow.com/a/78183161
has comment: http://stackoverflow.com/comment/137833564
tagged with: memory
accepted answer: http://stackoverflow.com/a/78183161
answer count: 1
has body: Consider this situation: $ ps -p $$ -o %mem %MEM 0.0 $ echo $(head -c200M /dev/urandom) &gt; /dev/null # command finishes but memory hasn't been released: $ ps -p $$ -o %mem %MEM 7.4 The moment I exit bash, I can see the memory instantly freed up. Why is this? And, is there a way to free the memory without exiting bash? Not that I really need to do this as I can just fork bash and then end that child, I am mostly curious why this happens.
has title: Why doesn't bash free memory up from unnamed variables once it's done with them?
tagged with: bash
has comment: http://stackoverflow.com/comment/137833593
type: AnsweredQuestion

http://stackoverflow.com/comment/137854780
has text: So why can't arguments passed to source command change the external arguments when the source runs the command in the context of the current shell? @choroba
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78194502

http://stackoverflow.com/comment/137943464
type: Comment
has text: P.S.: strictly speaking you can merge the `-path` and `-name` options into a single `-path` option, but I opted to include both to be a bit more illustrative of what `find` can do.
type: AnswerComment
comment on: http://stackoverflow.com/a/78244642
score: 0

http://stackoverflow.com/q/78267465
type: Question
tagged with: git
type: UnansweredQuestion
score: 1
has answer: http://stackoverflow.com/a/78276584
linked to: http://stackoverflow.com/q/38437891
upvote count: 2
has title: How can I get line numbers that changed and added for a commit
tagged with: bash
answer count: 1
favorite count: 0
downvote count: 1
has body: I want to get the modified line numbers for a file in a single commit by bash script. I searched a lot and got a script like: git diff --unified=0 HEAD origin/develop .gitlab-ci.yml | grep -Po '^\+\+\+ ./\K.*|^@@ -[0-9]+(,[0-9]+)? \+\K[0-9]+(,[0-9]+)?(?= @@)' But this script only displays the modified line number without added lines. Does anyone know how to do that? Example: local .gitlab-ci.yml File: a b c remote develop branch: a k The script should output 2 and 3. Because line 2 was changed and added a new line "c", the line number is 3, so it should output 2 and 3.

http://stackoverflow.com/comment/137895094
comment on: http://stackoverflow.com/q/78216881
has text: As for the bad substitution: `${!BITBUCKET_TAG}` takes the content of the variable `BITBUCKET_TAG` as the name of another variable, and tries to fetch the value of the latter. In your case, the value is `2.2.2`, so you basically ask bash to get the value of a variable with the name _2.2.2_.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137785912
type: Comment
comment on: http://stackoverflow.com/q/78155628
score: 0
type: QuestionComment
has text: I'm looking for a way to do this quickly and repeatedly, to the same file. Preferably by mapping it to a key combo as I mentioned

http://stackoverflow.com/comment/137935746
has text: @konsolebox `redis-cli --latency` don't work same if output is a *`TTY`*, than if *redirected*!
comment on: http://stackoverflow.com/q/78240103
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137861527
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78197884
has text: I find your question pretty unclear: _know where my actual env variable is stored_ : Every environment variable is stored in, well, the _environment_ of a process. Perhaps you want to _know where my actual env variable has been set_? Since you are responsible for setting your variables, you should know this better than me, but: If I would have to research at a foreign accounts, where variables get their values, I would first open a new login shell _with tracing_, i.e. `bash -xl`, and analyze the output . Either I can see immediately from the output, where it happesn, or I can debug from here.
score: 0

http://stackoverflow.com/q/78239630
type: Question
has body: I am running brew list --versions to get this list: user@mac ~ [1]> brew list --versions fish 3.7.0 ncurses 6.4 pcre2 10.43 syncthing 1.27.4 appcleaner 3.6.8 teamviewer 15.51.6 How can I put the output to a json object like this: [ { "name":"fish", "version":"3.7.0" }, { "name":"ncurses", "version":"6.4" } ]
tagged with: homebrew
has title: How to get brew list as JSON output
has answer: http://stackoverflow.com/a/78240810
linked to: http://stackoverflow.com/q/44780761
score: 1
tagged with: bash
upvote count: 1
tagged with: jq
favorite count: 0
accepted answer: http://stackoverflow.com/a/78240810
downvote count: 0
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/137934503
tagged with: http://stackoverflow.com/tag/json

http://stackoverflow.com/comment/137908604
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78225000
has text: while quoting is good advice, that isn't the cause of the error message

http://stackoverflow.com/comment/137923108
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78232840
has text: Concretely, the stderr returned to python says `/bin/bash: testcommand: command not found`.
score: 0

http://stackoverflow.com/comment/137866388
comment on: http://stackoverflow.com/q/78200396
score: 0
type: QuestionComment
has text: @semmelbroesel, `TZ` is just an environment variable. It can be read-only in the sense that you are stuck using a shell that rejects attempts to set it or to pass it to commands, but there is no deeper sense in which an environment variable can be read-only. The `env` command does not use the shell to set environment variables. You might not have access to it, or the version you have might, separately, have its own restrictions, but `env TZ=America/Chicago date` and related commands are at least worth a try.
type: Comment

http://stackoverflow.com/a/78240193
type: Answer
answers question: http://stackoverflow.com/q/78240155
score: 5
upvote count: 5
has body: Since you tagged this sed, I'm assuming a sed-specific answer is acceptable. This doesn't require dynamic pipeline elements at all: You can add more operations to a single sed command by adding to its command line argument list. #!/usr/bin/env bash # ^^^^- NOT /bin/sh; arrays are a non-POSIX feature elements=( A B C D ) # use a proper array, not a string n=1 args=( ) # likewise, using a real array here too for i in "${elements[@]}"; do # iterate over input array args+=( -e "s/$i/$n/g" ) # append to operation array n=$(($n+1)) done sed "${args[@]}" <example.txt # expand command array onto sed command line For an approach that doesn't take advantage of sed behavior and is instead generating a pipeline dynamically (without using eval, which makes it much easier but introduces security problems without used without great care), see the answer to Handling long edit lists in XMLStarlet
downvote count: 0

http://stackoverflow.com/comment/137834117
has text: There aren't any emojis in your posted code. How are you setting, for example, `zzz_unicode`? If your script source is UTF-8, you should just be able to do e.g. `zzz_unicode=''`
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78182539

http://stackoverflow.com/comment/137771689
score: 2
type: Comment
has text: And you're missing a lot of quotes -- https://shellcheck.net/ will catch those faults. And in general, branch directly on return status -- that is, `if is_prime someval; then`, not the more complicated and error-prone `is_prime someval; retval=$?; if [ "$retval" = 1 ]; then`
comment on: http://stackoverflow.com/q/78147701
type: QuestionComment

http://stackoverflow.com/comment/137919631
score: 0
comment on: http://stackoverflow.com/q/78228745
type: QuestionComment
has text: @KamilCuk doesnt work i mean its getting rid of nulls. Check the original post for bytes 9-11 in original file and bytes 9-11 after uudeview. I used manually uudeview -d encoded_file and also by piping cat to uudeview.
type: Comment

http://stackoverflow.com/comment/138013831
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78284887
score: 2
has text: Please show us *usage sample* and expected output!

http://stackoverflow.com/comment/137783973
comment on: http://stackoverflow.com/a/78151323
type: Comment
type: AnswerComment
has text: This sort of information rates as a comment. Glad you solved your problem (I didn't downvote it)
score: 0

http://stackoverflow.com/comment/137855418
type: QuestionComment
type: Comment
has text: If you start the background process using `(command&)` instead of `command&` I think that will prevent this message.
score: 1
comment on: http://stackoverflow.com/q/78194991

apache-kafka
tag name: apache-kafka
type: Tag
tags question: http://stackoverflow.com/q/78202033

http://stackoverflow.com/comment/138025579
score: 0
comment on: http://stackoverflow.com/q/78291764
has text: That quotes suppress tilde expansion? That's right there in black-letter documentation. You already know the rule: your question describes it; I don't know what more there is to say.
type: QuestionComment
type: Comment

canvas
tags question: http://stackoverflow.com/q/78261118
tag name: canvas
type: Tag

http://stackoverflow.com/comment/137922881
type: QuestionComment
type: Comment
has text: @Barmar the glob pattern works as expected when matching filenames. See here https://www.digitalocean.com/community/tools/glob?comments=true&glob=%2A%2Acars-%2B%28%21%28bad-cats%7Cdogs%29%29%2Fsrc%2Fbin%2Fout%2F%2A%2A&matches=false&tests=cars-white-pens%2Fsrc%2Fbin%2Fout%2Ffile.txt&tests=cars-ok-kk%2Fsrc%2Fmain%2Fout%2Fstart.txt&tests=cars-grey-dogs%2Fsrc%2Fbin%2Fout%2Fbottle.txt&tests=cars-bad-cats%2Fsrc%2Fbin%2Fout%2Fcomputer.txt&tests=cars-whales%2Fsrc%2Fbin%2Fmouse.txt&tests=cars-dogs%2Fsrc%2Fbin%2Fout%2Fmouse.txt
comment on: http://stackoverflow.com/q/78232634
score: 0

http://stackoverflow.com/comment/137864537
has text: Thanks for replying. I tried the change and got the same result at the CLI. sed: -e expression #1, char 81: unterminated `s' command.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/78200333
type: AnswerComment

http://stackoverflow.com/comment/137864154
has text: `if [[ \`filename $file\` =~ ^([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2}) ]]` should also work.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78200064
score: 0

http://stackoverflow.com/comment/137783793
type: QuestionComment
type: Comment
has text: A way that _works_ is one thing, a way that's _documented to work_ and guaranteed not to be broken by a bugfix in the future is another. This is a fair question, but you're _really_ better off using `$HOME`.
comment on: http://stackoverflow.com/q/78154583
score: 2

http://stackoverflow.com/a/78194372
type: Answer
has body: I would set environment variable rvm_path directly in function setup_folder by adding after EOF: export rvm_path="$HOME/.rvm"
answers question: http://stackoverflow.com/q/78190505
score: 0

http://stackoverflow.com/comment/137854609
type: QuestionComment
has text: To expand on that, this is what happens when you try to log a secret, but you don't mention anything about secrets. There are also some actions that mask certain strings, but again, that depends on the context.
comment on: http://stackoverflow.com/q/78194442
type: Comment
score: 0

http://stackoverflow.com/comment/137920497
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78231603
has text: The shell expands everything then applies word splitting based on spaces. If there are no spaces in your expanded string, or there are but it's quoted, it doesn't get split.

http://stackoverflow.com/tag/csv
tags question: http://stackoverflow.com/q/78301325
type: Tag
tag name: csv
tags question: http://stackoverflow.com/q/78440219
tags question: http://stackoverflow.com/q/78441743
tags question: http://stackoverflow.com/q/78422072
tags question: http://stackoverflow.com/q/78524211
tags question: http://stackoverflow.com/q/78514302
tags question: http://stackoverflow.com/q/78583045
tags question: http://stackoverflow.com/q/78539085
tags question: http://stackoverflow.com/q/78682104
tags question: http://stackoverflow.com/q/78668918
tags question: http://stackoverflow.com/q/78891591
tags question: http://stackoverflow.com/q/78791284
tags question: http://stackoverflow.com/q/78971884
tags question: http://stackoverflow.com/q/79000846
tags question: http://stackoverflow.com/q/79195993
tags question: http://stackoverflow.com/q/79162791
tags question: http://stackoverflow.com/q/79143036
tags question: http://stackoverflow.com/q/79311905
tags question: http://stackoverflow.com/q/79505924
tags question: http://stackoverflow.com/q/79440348

http://stackoverflow.com/comment/137938902
score: 0
has text: `eix-installed -a | xargs -r sh -c 'for __; do qdepends -QqqC "$__" >/dev/null || echo "$__"; done' --`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78241761

http://stackoverflow.com/comment/137945420
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78245595
has text: Have you considered writing an IPython script (`.ipy` extension) and passing `$i` as an argument from Bash?
score: 0

http://stackoverflow.com/comment/137833019
comment on: http://stackoverflow.com/q/78182539
type: QuestionComment
type: Comment
has text: Forgive me @tripleee. I am no expert in encoding. I've never used emojis before, and don't often do this. Way out of my comfort zone. Files, terminals all UTF-8, which is what github supports. All my code is in my post for the create_labels.sh file. If I should be encoding them somehow differently, please do enlighten me.
score: 0

http://stackoverflow.com/comment/138020335
score: 1
comment on: http://stackoverflow.com/a/78286685
has text: @EdMorton Those corporate downsizing consultants sure paid off. :D I worked for a telco for 10+ years. Same _atmos-fear_.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137821824
score: 0
has text: I put that line in and I'm still getting the whole file, even if the user input is say 250 its still showing the whole file, would there be an alternative way rather than using the $1 and $8 field?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78176347

http://stackoverflow.com/comment/137780988
score: 0
comment on: http://stackoverflow.com/q/78152355
type: QuestionComment
type: Comment
has text: Sorry again, I was too hasty editing and made a typo with the shebang. However, I figured out the issue and will post an answer accordingly.

http://stackoverflow.com/comment/137855818
comment on: http://stackoverflow.com/q/78194973
has text: Okay, the big problem now is that you didn't actually follow the advice to make an array for interfaces. Your `interface=$(...)` is making `interface` one big string, not an array at all. See [BashFAQ #5](https://mywiki.wooledge.org/BashFAQ/005) for an introduction to arrays.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137912264
comment on: http://stackoverflow.com/q/78223744
score: 0
type: QuestionComment
type: Comment
has text: @Lundin Maybe they're implementing the parser in C? Although in that case they should post their current code for it.

http://stackoverflow.com/comment/137780927
comment on: http://stackoverflow.com/q/78152355
score: 1
has text: @A7exSchin shellcheck would definitely have a couple of problems with your code. Even after adding a shebang as you did now (which is still not a valid shebang btw) it'd still complain about the missing quotes around your variable. Posting code that even shellcheck can find problems in makes it harder for us to help you as then we need to walk you through those first. Running shellcheck was just the first suggestion I offered, did you try the other 2 too? What was the result ([edit] your question to show it).
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137784302
type: QuestionComment
has text: @jhnc Sorry for my mistake.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78154583

http://stackoverflow.com/comment/137936614
score: 0
comment on: http://stackoverflow.com/q/78240671
type: QuestionComment
type: Comment
has text: https://mywiki.wooledge.org/BashFAQ/050

http://stackoverflow.com/comment/138031358
type: QuestionComment
type: Comment
has text: Looks like it was fixed in 5.x, I get the same error in 4.2 but not 5.0.
comment on: http://stackoverflow.com/q/78294975
score: 0

http://stackoverflow.com/comment/137939584
has text: oh in addition, for each combination I need to run a command on it and output to file so for example echo DI1.fasta DI1_P1.fastq > DI1_P1.out
type: QuestionComment
comment on: http://stackoverflow.com/q/78241899
type: Comment
score: 0

http://stackoverflow.com/a/78175828
upvote count: 4
score: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/137820711
type: Answer
answers question: http://stackoverflow.com/q/78175779
has body: Is there a way to write a string literal that cannot be read from even once? Yes, bash appends a line break to here-strings but an empty here-document is truly empty. while read foo; do echo ${#foo}; done &lt;&lt;EOF EOF Conversely, what contents does a file need to have, in order to be able to read exactly one empty string from it, and nothing else? A single line break. You can create such a file with this command: echo &gt;file

http://stackoverflow.com/comment/137769397
type: QuestionComment
type: Comment
score: 1
has text: if you really put the `echo` before the `do`, the loop exited immediately. note there are no subshell environments in the code shown
comment on: http://stackoverflow.com/q/78146405

http://stackoverflow.com/a/78252087
accepted answer of: http://stackoverflow.com/q/78252038
type: Answer
answers question: http://stackoverflow.com/q/78252038
score: 2
upvote count: 2
has body: When I run your grep -v ... -v ... token.xml call I get an error: $ grep -v '<?xml version="1.0" encoding="UTF-8"?> ' -v ' ' token.xml grep: : No such file or directory After TOKEN has been populated I recommend you add typeset -p TOKEN (to show the contents of TOKEN); I'm guessing TOKEN does not contain what you think it does. While xml should probably be parsed by a xml-capable tool, if you are 100% sure of the format of the contents in token.xml then the following should extract the token for you: $ sed -En 's|.* (.*) .*|\1|p' token.xml ZsxY7Q9G90jh4FqUiAjxD9XmqLWf0rYg4RUNf6FoVzeTIlPPms0Ov1RERFFRY77o Then update your script with the following TOKEN=$(...) line: $ TOKEN=$(sed -En 's|.* (.*) .*|\1|p' token.xml) $ typeset -p TOKEN declare -- TOKEN="ZsxY7Q9G90jh4FqUiAjxD9XmqLWf0rYg4RUNf6FoVzeTIlPPms0Ov1RERFFRY77o"
downvote count: 0
type: AcceptedAnswer

http://stackoverflow.com/comment/137820358
comment on: http://stackoverflow.com/a/78158163
has text: @user23562505, all did is add a simple `if` check on the file. Updated the answer with references. If you are a novice in shell scripting, [bash cookbook](https://www.google.com/search?q=bash+cookbook&oq=bash+cook&gs_lcrp=EgZjaHJvbWUqCggAEAAY4wIYgAQyCggAEAAY4wIYgAQyBwgBEC4YgAQyBwgCEAAYgAQyBggDEEUYOTIMCAQQABgUGIcCGIAEMgcIBRAAGIAEMgkIBhAAGAoYgAQyCAgHEAAYFhgeMggICBAAGBYYHjIICAkQABgWGB7SAQgyMTkyajBqMagCALACAA&sourceid=chrome&ie=UTF-8#ip=1) is a great book. (Please mark the answer as accepted, if it helped)
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/137854833
type: Comment
type: AnswerComment
score: 0
has text: @Sojab0on ; run-on (or, "oh, one more thing") questions are not appropriate here on S.O. Post a new question with just the relevant code (we don't want/need to see 40 lines of code for a 2 line change.) Also, the section [How to turn a bad script into a good question](https://stackoverflow.com/tags/bash/info) (this advice applies to all languages, not just bash) . Good luck.
comment on: http://stackoverflow.com/a/78192118

http://stackoverflow.com/comment/137869222
score: 0
has text: Thank you so much, I think I will have to try Python based on the link you provided.
comment on: http://stackoverflow.com/a/78201679
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137820452
has text: @manymanyhaha: Try `mkdir -p /tmp/wav/sub; touch /tmp/wav/sub/foundit.wav; ls /tmp/**/*.wav; shopt -s globstar; ls /tmp/**/*.wav`. Will the last command show the wav file?
score: 0
comment on: http://stackoverflow.com/a/78173029
type: Comment
type: AnswerComment

package.json
tags question: http://stackoverflow.com/q/78195387
tag name: package.json
type: Tag

http://stackoverflow.com/comment/137865076
comment on: http://stackoverflow.com/a/78200333
has text: Look for ANSI-C Quoting and Shell Parameter Expansion in the bash manual for detailed information. `$'\n'` expands to a newline character and `${var//pattern/replace}` replaces all occurrences of `pattern` in `var`, so the overall expansion replaces all newlines with escaped newlines to make `sed` happy. This is also another reason that `awk` may be easier to read, you don't have to do any special processing on the variable to make it digestible.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137810258
has text: In [How to Answer](https://stackoverflow.com/help/how-to-answer), note the section _Answer Well-Asked Questions_ and the bullet point regarding questions that "have been asked and answered many times before".
score: 1
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78169487

http://stackoverflow.com/comment/137810264
type: QuestionComment
type: Comment
has text: To extend that: For your script to change the state of the shell that calls it, you need to use `source` to run _your script itself_ just as much as you need to use `source` to run `activate`.
comment on: http://stackoverflow.com/q/78169456
score: 0

aws-cli
tags question: http://stackoverflow.com/q/78240309
tag name: aws-cli
type: Tag
tags question: http://stackoverflow.com/q/78489072
tags question: http://stackoverflow.com/q/78462747
tags question: http://stackoverflow.com/q/78888094
tags question: http://stackoverflow.com/q/79062321
tags question: http://stackoverflow.com/q/79148882
tags question: http://stackoverflow.com/q/79275641

http://stackoverflow.com/comment/137791311
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78158825
has text: since `/tmp/pipe` does not have its sticky bit set, your `chmod` commands will do nothing useful. see my comments on the question
score: 1

http://stackoverflow.com/a/78290606
answers question: http://stackoverflow.com/q/78285559
has body: @mkrieger helped me with his comment: "There is no scripts inside /opt/bitnami/airflow/scripts. PYTHONPATH should contain /opt/bitnami/airflow in order to find scripts"
score: 1
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/78279685
answers question: http://stackoverflow.com/q/78276360
has body: With perl: $ perl -e 'print sort {length($a =~ s/ //gr) &lt;=&gt; length($b =~ s/ //gr)} &lt;&gt;' ip.txt a a b a b c abcde ab cd ef abcdefg With ruby: $ ruby -e 'puts readlines.sort_by {_1.sub(&quot; &quot;, &quot;&quot;).size}' ip.txt a a b a b c abcde ab cd ef abcdefg
type: Answer
score: 0

http://stackoverflow.com/a/78279417
score: 1
answers question: http://stackoverflow.com/q/78278159
downvote count: 0
upvote count: 1
type: Answer
has body: Define myclip function and run bind command : myclip(){ (( READLINE_POINT>0 )) || return 0 local cmd="$READLINE_LINE" READLINE_LINE='' printf "%s\n%s\n" "$cmd" "$($cmd)" | xclip -i -selection clipboard } bind -x '"\e[15~":"myclip"' Now type date followed by F5. The result will be in the clipboard.

http://stackoverflow.com/comment/137810146
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78162277
has text: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

http://stackoverflow.com/comment/137906661
type: QuestionComment
type: Comment
has text: If this isn't for parsing C, then what does C have to do with the question?
comment on: http://stackoverflow.com/q/78223744
score: 4

http://stackoverflow.com/comment/137771660
score: 1
comment on: http://stackoverflow.com/q/78147701
type: QuestionComment
type: Comment
has text: Don't use `$[...]` or `expr`; just use `$((...))` for integer arithmetic.

http://stackoverflow.com/comment/137787942
score: 0
has text: As for the invocation needing to be quoted by the user who's calling the script -- you can't fix that _after the script is started_ because at that point, `*.txt` has already been changed to `a.txt b.txt c.txt`; the fact that that list of words was generated from the original `*.txt` string is something that's never communicated to the child process at all.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78156916

http://stackoverflow.com/comment/137823938
type: Comment
type: AnswerComment
has text: [Shellcheck](https://www.shellcheck.net/) can identify many common problems with shell code (including the use of legacy features such as backticks). The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
comment on: http://stackoverflow.com/a/78177473
score: 0

http://stackoverflow.com/comment/137905191
has text: Thanks, that last hint was actually gold, I didn't think of that. Indeed usually it's only one process in our system that uses these resources so I'll try that.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78220931
type: AnswerComment

http://stackoverflow.com/comment/138000133
has text: For the last part, just use `[^.@]`. That includes everything in `[a-zA-Z0-9_]`, so you don't have to check for that specifically.
type: QuestionComment
comment on: http://stackoverflow.com/q/78276987
type: Comment
score: 1

http://stackoverflow.com/comment/137866028
has text: For what it's worth, your `fold` solution seems to work equally as well, however it seems to stream to the console a fair bit slower, and in sizeable chunks, vs the standard `sed` solution.
comment on: http://stackoverflow.com/a/78196849
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/138005528
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78280175
has text: yes. just the first character of each row.

http://stackoverflow.com/comment/137834247
comment on: http://stackoverflow.com/a/78182177
type: Comment
type: AnswerComment
has text: @DeltaIV oh. That makes sense. Yeah I definitely made an assumption that it was all for one repo rather than a single change for multiple repos. I suppose that clarification could go into the question, since based on the way it's currently written I suspect more people would assume what I did than your actual scenario. That being said, I could have just answered what you asked instead of wrongly assuming this would be even better than what you asked. Hehe.
score: 1

http://stackoverflow.com/comment/137798807
has text: So that only compares the file names to see if it exists or not, not the contents of the file.
type: QuestionComment
comment on: http://stackoverflow.com/q/78163062
type: Comment
score: 0

http://stackoverflow.com/a/78261076
answers question: http://stackoverflow.com/q/78261051
type: Answer
has body: The error is at /home/step/config/defaults.json]];. You have to rewrite it as /home/step/config/defaults.json ]];. You missed the mandatory space before the ]].
score: 0
accepted answer of: http://stackoverflow.com/q/78261051
type: AcceptedAnswer

http://stackoverflow.com/a/78146818
type: Answer
has comment: http://stackoverflow.com/comment/137770095
has body: Assuming the MANIFEST contains glob patterns. Unquoted expansion undergo word splitting and filename expansion. The lazy answer would be just to: shopt -s nullglob echo $(cat MANIFEST) That would result in word splitting. Using bash, we would use compgen -G to expand glob to the list of files. readarray -t patterns &lt;MANIFEST compgen -G &quot;${patterns[@]}&quot;
answers question: http://stackoverflow.com/q/78146721
score: 0
has comment: http://stackoverflow.com/comment/137771462

http://stackoverflow.com/comment/137949310
type: Comment
score: 0
has text: Thank you for the good suggestion! My project has multiple python code, say I make modification to `model.py`, this file will not be cached by using `python_code=$(< main.py)`, will it?
type: AnswerComment
comment on: http://stackoverflow.com/a/78245181

http://stackoverflow.com/comment/137801277
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78155690
has text: Note well that Puppet is not designed to be a script runner, and it is pretty awkward for that role. If that's really what you want, then you could consider looking at its "Bolt" companion system, which might serve you better there. The primary paradigm of Puppet proper is that you define *what* should be included in client machines' configuration, and Puppet works out the how. And enforces it on every run.
score: 0

http://stackoverflow.com/comment/137787540
type: QuestionComment
has text: The fact that it wasn't captured is generally the giveaway :) -- anything that still goes to output was either written to stderr or written direct to the TTY, and the TTY case is rare and generally only done when there's a specific good reason to do so (like making a password prompt difficult to intercept). stderr isn't just for errors -- it's for all "diagnostic content" per POSIX; basically anything/everything that's meant to inform a human operator vs being part of a program's "output" (whatever kind of output that program is written/designed to generate).
type: Comment
comment on: http://stackoverflow.com/q/78156630
score: 2

http://stackoverflow.com/comment/138029337
comment on: http://stackoverflow.com/q/78292693
has text: Why is `$combine` an array?
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137971069
type: QuestionComment
has text: You have two things going on in **parallel**: In the one, task `cat` is started as a child process, and then _cat_ tries to read the file `foo`. In the other task, the file `foo` is replaced by an empty file, and then `grep`is started as a child process. While not impossible, wouldn't it be rather surprising if `cat` finds some file content to display?
type: Comment
comment on: http://stackoverflow.com/q/78245937
score: 0

http://stackoverflow.com/comment/137898148
has text: Do you **really** need two distinct variables here? Otherwise, a `: ${BITBUCKET_TAG:=default}` would do (where _default_ is the value you want to store when _BITBUCKET_TAG_ does not exist or is empty.
comment on: http://stackoverflow.com/q/78216881
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78277290
type: Answer
score: 0
has body: I believe the following code will meet your need. Basically, instead of looping through the ticker's signal channel, use select. See below: package main import ( "fmt" "os" "os/exec" "time" ) type logWriter struct { C chan []byte } func (l logWriter) Write(p []byte) (n int, err error) { l.C <- p return len(p), nil } func newChannelWriter() logWriter { return logWriter{ C: make(chan []byte, 10), } } func main() { // Initialize the ticker to trigger every minute ticker := time.NewTicker(time.Second * 10) defer ticker.Stop() logFolderPath := "./log/" // Initialize the first log file filename := generateFilename() logFile, err := os.OpenFile(logFolderPath+filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { fmt.Println("Error opening log file:", err) return } defer logFile.Close() // Commands to execute sequentially cmd := exec.Command("sh", "-c", "./ledplayer") // Connect command's stdout and stderr to pipes thisLogWriter := newChannelWriter() cmd.Stdout = thisLogWriter cmd.Stderr = thisLogWriter // Start the command if err := cmd.Start(); err != nil { fmt.Println("Error:", err) return } fmt.Println("Command started successfully: ", filename) // Loop to handle ticker events endChan := make(chan interface{}, 1) defer func() { endChan <- true close(endChan) }() go func() { for { select { case <-endChan: return case <-ticker.C: // Close the current log file if err := logFile.Close(); err != nil { fmt.Println("Error closing log file:", err) return } // Generate a new filename for the next minute filename := generateFilename() // Open the new log file logFile, err = os.OpenFile(logFolderPath+filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { fmt.Println("Error opening log file:", err) return } // Print the new log file name fmt.Println("Log file switched to", filename) case content := <-thisLogWriter.C: if _, err := logFile.Write(content); err != nil { fmt.Println("Error writing log:", err) return } } } }() // Wait for the command to finish…
answers question: http://stackoverflow.com/q/78254419

http://stackoverflow.com/comment/137785815
comment on: http://stackoverflow.com/q/78155628
type: QuestionComment
type: Comment
score: 1
has text: Why use `sed` from `vim`? You're in Vim, why not use its power? Open the file in a buffer, go to the 1st line (in case opening a file restores different position), prepend the current line before the 1st, save, delete the buffer.

http://stackoverflow.com/comment/137823732
score: 1
comment on: http://stackoverflow.com/a/78177473
type: Comment
has text: (you might also think about preferring the standardized-since-the-90s `get_data() {` function declaration syntax, vs mixing it with 80s-era ksh `function get_data {` syntax in a way that's incompatible with _both_ the early-90s POSIX sh standard and 80s ksh. Yes, the "Advanced" Bash Scripting guide shows it that way, but continued insistence on showcasing bad-practice examples is much of why everyone else in the bash universe looks down on that so-called "reference").
type: AnswerComment

http://stackoverflow.com/comment/137833579
comment on: http://stackoverflow.com/a/78182177
type: Comment
has text: Thanks for the answer, but I don't get it. I'd like a script which can be called with args `old_mail`, `new_mail`, `author`: if I don't pass one or more args, default values are used. I don't see any args to pass to your invocation. PS yes, Author=Committer always in my use case, so I don't need the added complexity of handling them separately.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137884786
type: Comment
type: AnswerComment
has text: See https://i.sstatic.net/iV8sI.jpg You must have broken something.
comment on: http://stackoverflow.com/a/78211545
score: 0

http://stackoverflow.com/comment/137886087
comment on: http://stackoverflow.com/q/78212116
type: QuestionComment
type: Comment
score: 0
has text: added an entry from courses.jsonl in an edit

http://stackoverflow.com/comment/137886776
comment on: http://stackoverflow.com/q/78212759
score: 1
type: QuestionComment
type: Comment
has text: Something like this: https://gist.github.com/minitech/610850ea303d8835d67df1a0e3377749

http://stackoverflow.com/comment/138137267
has text: My follow-up was answered by this https://stackoverflow.com/a/50350929/11562331, I just need to combine both answers.
score: 0
comment on: http://stackoverflow.com/a/78301430
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78156936
downvote count: 0
upvote count: 1
has body: The shell expands the wildcards even before you scripts starts, so the script doesn't see it as an argument, it sees the names of the files (if there are any). You either have to quote or escape the argument, or make the script accept a list of files instead. For that, use shift to remove the first two parameters from $@, and if it's not empty afterwards, it contains the files.
type: Answer
score: 1
answers question: http://stackoverflow.com/q/78156916

http://stackoverflow.com/comment/137957014
comment on: http://stackoverflow.com/q/78252129
has text: As you have a python script already, why not do everything with python ?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137787929
has text: enclose your variables in double quotes: `find "$directory*...`!
comment on: http://stackoverflow.com/q/78156916
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137826649
type: Comment
score: 0
type: QuestionComment
has text: Do [this answer](https://stackoverflow.com/a/66950971/1765658) your question?
comment on: http://stackoverflow.com/q/78178702

http://stackoverflow.com/comment/137801055
type: Comment
score: 0
type: QuestionComment
has text: @Grobu This is a binary file, but it's hard for me to tell what it is.
comment on: http://stackoverflow.com/q/78151708

http://stackoverflow.com/comment/137791561
comment on: http://stackoverflow.com/q/78158123
has text: The output from the `echo` command you post here, does not fit the error message from the `rm` command. I don't believe that you posted this information correctly. Provide a screenshot of what happens when you run your script.
type: QuestionComment
type: Comment
score: 0

git-bash
tags question: http://stackoverflow.com/q/78244513
type: Tag
tags question: http://stackoverflow.com/q/78152355
tag name: git-bash
tags question: http://stackoverflow.com/q/78441743
tags question: http://stackoverflow.com/q/78337303
tags question: http://stackoverflow.com/q/78378370
tags question: http://stackoverflow.com/q/78440219
tags question: http://stackoverflow.com/q/78469662
tags question: http://stackoverflow.com/q/78520208
tags question: http://stackoverflow.com/q/78535188
tags question: http://stackoverflow.com/q/78647254
tags question: http://stackoverflow.com/q/78648632
tags question: http://stackoverflow.com/q/78650733
tags question: http://stackoverflow.com/q/78880481
tags question: http://stackoverflow.com/q/78983209
tags question: http://stackoverflow.com/q/79234977
tags question: http://stackoverflow.com/q/79201229
tags question: http://stackoverflow.com/q/79292361
tags question: http://stackoverflow.com/q/79412418

github-api
type: Tag
tags question: http://stackoverflow.com/q/78182539
tag name: github-api
tags question: http://stackoverflow.com/q/79433580

http://stackoverflow.com/comment/137971026
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78246449
has text: You have to set PS1 appropriately. Have a look at _man bash_ and search for `PS1`.

numpy
tag name: numpy
tags question: http://stackoverflow.com/q/78180816
type: Tag

http://stackoverflow.com/comment/138012955
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78283701
has text: It's hard to tell how to correlate the question with the code presented. In fact, I suspect that you have framed the question incorrectly. Your two functions, `function1` and `function4`, both emit output that ends with a newline and may contain internal newlines, so what does it even mean to print that on the same line with something else?
score: 0

apache-zookeeper
tag name: apache-zookeeper
type: Tag
tags question: http://stackoverflow.com/q/78202033

http://stackoverflow.com/comment/138052302
has text: `/src` is printed last, but after a `$'\r'`, which returns the cursor to the left and overwrites `Here`.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78306525
type: QuestionComment

http://stackoverflow.com/comment/137778275
type: QuestionComment
comment on: http://stackoverflow.com/q/78146724
has text: @EdMorton The website you sent me only asked me to correct my shebang, so I'm not sure where you got multiple errors from. this is also not a 'real' script whatever you mean by that, but rather a script i wrote while trying to learn shell scripting. i'm sorry i insulted your sensibilities by posting a question on a forum.
type: Comment
score: 0

http://stackoverflow.com/comment/137823722
has text: yes, it does, since `read` isn't performed in a subshell
score: 1
comment on: http://stackoverflow.com/a/78177452
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137800872
comment on: http://stackoverflow.com/a/78160457
score: 0
has text: thanks . i have minor follow up question. so in the script section, is it any linux commands , i can add/run?
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137825267
type: Comment
has text: @masrur It's a pipeline with only one command. See https://www.gnu.org/software/bash/manual/html_node/Pipelines.html and let me know if you need further clarification.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78178190

http://stackoverflow.com/comment/137826057
type: QuestionComment
has text: Do you want the _output_ of `ls` in both the file and STDOUT, or do you want the file to contain, literally, `ls -l /directory/to/check/exists`? If it’s the former then see [this](https://stackoverflow.com/q/22713667/418066), if the latter then [this](https://stackoverflow.com/q/78119052/418066) is a duplicate (but virtually unanswered).
score: 1
type: Comment
comment on: http://stackoverflow.com/q/78178702

http://stackoverflow.com/comment/137855948
type: Comment
has text: See https://gist.github.com/charles-dyfis-net/25cae8331b2b624fd789eb5de60539e3 showing complete scripts for two different approaches I've been suggesting.
score: 0
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment

http://stackoverflow.com/comment/137877843
type: QuestionComment
has text: (also, when adding code, format it as code -- `> ` is for quoting _text_; put three backticks above and below any code segment to ensure your content is syntax-highlighted and otherwise formatted as source code)
comment on: http://stackoverflow.com/q/78207789
score: 1
type: Comment

http://stackoverflow.com/comment/138025263
has text: I do not understand. Instead of logical `&&` between relations, I suggested to use logical `||`. A logical `or` and logical `and` is a logical connective between true or false values. `I have a limitation in this machine that any scheduler` Such requirement is very vague at best. You are in the process of writing a scheduler. You program _is_ a scheduler.|
comment on: http://stackoverflow.com/a/78290897
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/comment/137877810
score: 1
has text: Also on that topic see [BashFAQ #6](https://mywiki.wooledge.org/BashFAQ/006). Mind, in this case you're better off with just an array: `ips=( 1.2.3.4 5.6.7.8 ); for ip in "${ips[@]}"; do echo "Checking $ip" >&2; : "do stuff here"; done` -- you can also refer to individual elements as `"${ip[0]}"` and `"${ip[1]}"`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78207789

http://stackoverflow.com/a/78297142
score: 2
answers question: http://stackoverflow.com/q/78297014
downvote count: 0
type: Answer
has body: Here is a way: paste -d '\0' \ &lt;(sed 's/^\[//; s/].*//' test.log | date -f - '+%F %T') \ &lt;(sed 's/[^]]*]//' test.log)
upvote count: 2

http://stackoverflow.com/comment/137955463
has text: Speaking to the first one: Changed the first `eval` to an `echo` running the code inside an online sandbox. Read the output of that echo, which was reversing content then base64 decoding it then evaling the result, and just took out the eval and let the output of the reverse and base64 decode operations go to stdout.
type: QuestionComment
comment on: http://stackoverflow.com/q/78239018
type: Comment
score: 0

http://stackoverflow.com/q/78156679
answer count: 2
has title: Bash: loop through lists (array of arrays) and access sublist value
tagged with: bash
has comment: http://stackoverflow.com/comment/137787550
has answer: http://stackoverflow.com/a/78156830
has body: In BASH, consider a (pseudo)structured list of arrays like so: ## all my arrays definitions: myArray1=("userList1" "emailList1" "valueList1") myArray2=("userList2" "emailList2" "valueList2") ... myArrayN=("userListN" "emailListN" "valueListN") ## a list of the arrays I need to loop through: active_lists=("myArray1" "myArray2" [... "myArrayN"]) I want to loop through each of the arrays I've configured in my active_lists collection. This is often mentioned in tutorials and one would assume the following would do the trick: for indexd in "${active_lists[@]}"; do username=${!indexd}[0] email=${!indexd}[1] echo "Email: ${email}, username: ${username}" done Putting all this in a Bash script (with strict mode enabled) should be most straightforward: #!/bin/bash set -euo pipefail declare -a myArray1=("userList1" "emailList1" "valueList1") declare -a myArray2=("userList2" "emailList2" "valueList2") declare -a active_lists=("myArray1" "myArray2") for indexd in "${active_lists[@]}"; do username=${!indexd}[2] email=${!indexd}[1] echo "Email: ${email}, username: ${username}" sublist=(${!indexd}) echo "List Value: ${sublist[1]}" done However running the above script results in literal printing of the elements names, or unbound variable warning when attempting to access an index in the sublist: Email: userList1[1], username: userList1[2] Email: userList2[1], username: userList2[2] or line 16: sublist[1]: unbound variable This should be simple AF and I am obviously missing something fundamental but I cannot figure out what that is, and I'm going mad! Please help.
favorite count: 0
downvote count: 1
tagged with: sh
has answer: http://stackoverflow.com/a/78156732
type: Question
upvote count: 4
tagged with: shell
type: UnansweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/137787751

http://stackoverflow.com/comment/137793031
comment on: http://stackoverflow.com/a/78156004
has text: @romainl Done, tnx!
score: 2
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137787751
type: QuestionComment
comment on: http://stackoverflow.com/q/78156679
type: Comment
score: 0
has text: This is all but an academic exercise, purely for my understanding. I wanted to loop through these arrays and assign various indices to local variable for readability (i.e. `for indexd in "${active_lists[@]}"; do` ... `username=${indexd[0]}`).

http://stackoverflow.com/comment/137864728
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78196477
has text: Hey, thanks for clarifying this for me. This seems to work for my example of `sudo apt upgrade` however my real world example is actually running a python script. `$($VENV_DIR/bin/python3 install.py) 2>&1 >&1 | sed -e 's/^\(.\{0,60\}\).*/'"$esc"'[35m║ \1/'`. When I try to prefix the information with your fix, the bash script seems to just freeze (while I presume the python file is running in the background). After which, the bash shell simply outputs a py error (separate issue), but nothing is prefixed at all. Will append further details to my original post.

http://stackoverflow.com/comment/137802276
type: QuestionComment
score: 2
type: Comment
has text: The single quotes prevent substitution. Try `echo '$PATH'` and compare that to `echo "$PATH"`.
comment on: http://stackoverflow.com/q/78165163

http://stackoverflow.com/comment/138004756
type: QuestionComment
has text: I want the $ to be prepended.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78278159

http://stackoverflow.com/comment/137816338
comment on: http://stackoverflow.com/a/78173029
type: Comment
type: AnswerComment
has text: Thank you but it's only going to the first level for me. Found this: https://stackoverflow.com/questions/28176590/what-does-the-double-asterisk-wildcard-mean. Says it won't work in Bash until globstar is enabled via "shopt -s globstar", which I tried, but still only going one level.
score: 0

http://stackoverflow.com/a/78242737
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/78240103
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78240103
has body: When you try to capture Redis Latency output to a variable or file, by default Redis samples the latency for 1 second. To customize the duration of the latency test, you can specify the interval between samples using the -i option like this Latency=$(/usr/local/bin/redis-cli --latency -h 127.0.0.1 -p 6379 -i 20) You can get also get this information using the help command for redis latency. Image from Redis help redis-cli --latency --help
downvote count: 0

http://stackoverflow.com/comment/138170967
has text: @kievon what do the contents of your node_modules directory look like? do you see dotenvx in there?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78277187
score: 0

http://stackoverflow.com/comment/137982425
has text: @user1934428 You are right - I did not expect it to run under Cygwin right away. Below I posted the answer how one could get it to work or what the author could easily add to their code and wiki to support it. desaster, IT, banks and global agendas is ok and far from unexpected :) someday soon all the banks may be gone and we can celebrate ;) centralized, controlled, digital currencies.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78249607
type: Comment

http://stackoverflow.com/comment/137840351
has text: Is the question "what is `$@`", or "why did Bash never introduce a named version of `$@`"?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78186259
type: Comment

http://stackoverflow.com/a/78298442
answers question: http://stackoverflow.com/q/78297014
score: 3
upvote count: 3
downvote count: 0
type: Answer
has body: Using any awk: $ awk '{ split($0,d) sub(/[^]]+]./,"") mth = (index("JanFebMarAprMayJunJulAugSepOctNovDec",d[2]) + 2) / 3 printf "%04d-%02d-%02d %s %s\n", d[5], mth, d[3], d[4], $0 }' test.log 2024-04-09 03:32:21 {cmd1} 2024-04-09 03:33:42 {cmd2} 2024-04-09 03:35:51 {cmd3}

http://stackoverflow.com/comment/138050754
type: QuestionComment
has text: Using `text=True` gets rid of some of the pesky decoding etc. You can add `encoding='utf-8'` if Python's default encoding is something else than what your shell is configured for; but on modern platforms you would generally expect UTF-8 everywhere (except in some holdouts like Java and the Windows ghetto).
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78305587

http://stackoverflow.com/comment/137972055
comment on: http://stackoverflow.com/a/78261291
type: Comment
type: AnswerComment
has text: I edit it with your request...
score: 0

http://stackoverflow.com/comment/137798912
has text: Does this answer your question? [Given two directory trees, how can I find out which files differ by content?](https://stackoverflow.com/questions/4997693/given-two-directory-trees-how-can-i-find-out-which-files-differ-by-content)
type: Comment
comment on: http://stackoverflow.com/q/78163062
type: QuestionComment
score: 2

http://stackoverflow.com/a/78246478
has body: You are probably using an sh terminal. The sh shell typically presents a minimalist prompt, containing only the $ symbol, while bash often displays additional information such as the current username and working directory in its default prompt, making it appear more complex. To get it to not show the line "dayne@DESKTOP-323EO95 MINGW64 ~", you could change the default terminal in VS Code.
downvote count: 1
type: Answer
upvote count: 0
score: -1
answers question: http://stackoverflow.com/q/78246449

http://stackoverflow.com/comment/138000243
type: QuestionComment
type: Comment
score: 0
has text: @GordonDavisson Update: `raw_value="- & -" && value="$(echo "$raw_value" | sed -e 's/&/\\\\&/g')"` also makes awk substitution work. Nice!
comment on: http://stackoverflow.com/q/78274893

http://stackoverflow.com/a/78253546
score: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138371160
has body: Apologies for the confusion earlier. I've found a solution. In the .env.development file, instead of defining API_KEY, it should be defined as REACT_APP_API_KEY: .env.development: REACT_APP_API_KEY="my_api_key"
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78252063
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78252063

http://stackoverflow.com/q/78199142
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/137862914
linked to: http://stackoverflow.com/q/28725333
has body: I have some paired files (R1 and R2 in names show they are paired) as follows: sample1_R1.fastq sample1_R2.fastq sample2_R1.fastq sample2_R2.fastq sample3_R1.fastq sample3_R2.fastq I am trying to loop over the files and run the following command: motus profile -f sample1_R1.fastq -r sample1_R2.fastq -t 4 &gt; taxon1.txt the expected output would be one txt file per sample. to do so I made the following short bash script but it does not return the expected output. where is the problem in the below script? location = PWD for file in location: do fastq1=$location/${file}_R1.fastq fastq2=$location/${file}_R2.fastq motus profile -f fastq1 -r fastq2 -t 4 &gt; &quot;${file}&quot;.txt
has answer: http://stackoverflow.com/a/78199319
tagged with: for-loop
tagged with: bash
has answer: http://stackoverflow.com/a/78199624
type: Question
duplicate of: http://stackoverflow.com/q/28725333
has title: loop over paired files in a bash script and create one txt file per sample
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137864349

http://stackoverflow.com/a/78164681
type: Answer
has body: You can simply do this by adding a bash script, and calling it in your package.json. Step 1: create a bash script generate-controller-model-route.sh in the route folder #!/bin/bash file_name=$1 if -z $file_name ; then echo "Error: file name not received." exit 1 fi controller_folder='./src/controllers' model_folder='./src/models' route_folder='./src/routes' touch "$controller_folder/$file_name.controller.js" touch "$model_folder/$file_name.model.js" touch "$route_folder/$file_name.route.js" Step 2: add the bash script to the package.json (scripts property). "scripts": { "generate": "bash ./api/generate-controller-model-route.sh $1" } Step 3: call it with yarn/npm yarn generate client
score: 0
answers question: http://stackoverflow.com/q/78164579
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78164579
has comment: http://stackoverflow.com/comment/137801796

http://stackoverflow.com/comment/137855180
has text: I cannot use that. We don't have it installed by default and getting it on our boxes would be ... painful. same for pidwait
type: QuestionComment
comment on: http://stackoverflow.com/q/78194991
score: 0
type: Comment

http://stackoverflow.com/comment/137855603
comment on: http://stackoverflow.com/q/78195172
has text: @JohnBollinger it's just my OCD. I expect things to work `exactly` and `specifically`, which is why I raised the question in the first place. I understand it's "more work than it's worth", but otherwise, to me, it just seems sloppy, and unfinished.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78166564
type: Answer
score: 2
upvote count: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78166538
has body: ls lists the file names and you then filter those with grep and try to gunzip the matching filenames as string input. Changing | gunzip to | xargs gunzip would correctly operate on the files and not on the filenames (unless you have spaces in the filenames). But I would not pipe the output of ls to anything, it's not meant to be parsed: http://mywiki.wooledge.org/ParsingLs
answers question: http://stackoverflow.com/q/78166538
type: AcceptedAnswer

http://stackoverflow.com/comment/137873017
comment on: http://stackoverflow.com/q/78203871
score: 0
type: QuestionComment
type: Comment
has text: What happens if you run it in your script as `( ./example )` or as `(sh -c ./example & wait)`?

http://stackoverflow.com/comment/137855730
comment on: http://stackoverflow.com/q/78195172
type: QuestionComment
has text: What do you mean *changing* `[yY]* )` into `[yY] )`? The latter is what was in the question from the beginning. **Of course** the patterns for the responses you want to accept as valid should match only the patterns you want to accept as valid. And note well that these are shell patterns (globs), not regular expressions.
type: Comment
score: 0

http://stackoverflow.com/comment/137858845
comment on: http://stackoverflow.com/q/78183354
has text: @Nic3500 I checked out.txt It's empty and err.txt has this error message crontab: tmp/tmp.94636: Operation not permitted I checked in google and what it supposed to be solution is to give Full Disk Access to Terminal. Now I don't got nothing in err.txt and same in out who supposed to shows logs from my webScraping.py .. Do you know what's the issue in this case ?
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/137817370
score: 0
comment on: http://stackoverflow.com/a/78171801
has text: One last thing, is there a conversion that fmt handles ms rather sec, i have some cases where the times will look like 1708746085000 rather than sec 1708746085. Thanks again really appreciate it.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137871809
type: QuestionComment
score: 0
type: Comment
has text: Please paste your script at [shellcheck.net](http://www.shellcheck.net/) and try to implement the recommendations made there.
comment on: http://stackoverflow.com/q/78203880

http://stackoverflow.com/comment/140050064
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78166553
score: 1
has text: The `docker build` command line is an anti-pattern. Things that are to be properties of the constructed image should be specified in the Dockerfile language, not via ad-hoc command line arguments. It's like the Perl disease. Oh, you want that kind of implicit loop in the program? Then use `perl -zdoer9fvg <yourprogram>`. The command line becomes part of the coding language.

http://stackoverflow.com/comment/137857501
type: Comment
type: AnswerComment
has text: i did not give 40 lines of code that was someone who gave a answer. please just help or just not bother to answer
comment on: http://stackoverflow.com/a/78192118
score: 0

http://stackoverflow.com/comment/137874368
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78203898
score: 0
has text: `-i` means something different in posix - https://pubs.opengroup.org/onlinepubs/9699919799/utilities/file.html

http://stackoverflow.com/a/78211596
has comment: http://stackoverflow.com/comment/137886346
downvote count: 0
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/137886410
has comment: http://stackoverflow.com/comment/137886398
has comment: http://stackoverflow.com/comment/137886440
answers question: http://stackoverflow.com/q/78211473
has body: Try this, untested: #!/usr/bin/env bash InternalIP="" lip() { ip addr show; } lip6() { ip -6 addr show scope global; } IPv6="" PIPv6="" InternalIP=$(lip | awk -F':' '/inet/ && !/127\.0\.0\.1/ && split($2,a," ")>1{print a[2]}') IPv6=$(lip | awk '/inet6/ && !/128/{print $2}') PIPv6=$(lip6 | awk '/inet6/ && !/128/{print $2}') if -z $PIPv6 ; then PIPv6='Unknown' fi echo "$InternalIP" | awk '{print substr($0, 1, length($0)-3)}' echo "$IPv6" | awk '{print substr($0, 1, length($0)-3)}' echo "Public IPv6: $PIPv6" I don't understand some of your code and you didn't provide the output of your 2 ip commands so I don't know why you're using the commands you are on it so the above is just a translation of your code into what I think you wanted it to do. The most significant change is probably that I think you wanted to set PIPv6 to Unknown when it's empty, not just print a blank line.
has comment: http://stackoverflow.com/comment/137886334
accepted answer of: http://stackoverflow.com/q/78211473
has comment: http://stackoverflow.com/comment/137886361
type: AcceptedAnswer
upvote count: 1
has comment: http://stackoverflow.com/comment/137886350

http://stackoverflow.com/comment/137776047
type: Comment
has text: @t3kg33k: yes, you are free ^^
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78149866

http://stackoverflow.com/comment/137886513
score: 0
type: Comment
has text: tbh, simply because i am learning bash, and because i know more bash. could probably do the whole thing in python but wanted to do it in bash
type: AnswerComment
comment on: http://stackoverflow.com/a/78212459

http://stackoverflow.com/comment/137906491
type: QuestionComment
has text: @trincot Usually, in shells `&&`and `||` have the same precedence
score: 0
comment on: http://stackoverflow.com/q/78223744
type: Comment

http://stackoverflow.com/comment/137917090
type: QuestionComment
score: 2
type: Comment
has text: Learn to check you code first by copy/paste into https://shellcheck.net and fixing any flagged items. If you still have a problem, post the corrected code with a note "shellcheck verified". Good luck.
comment on: http://stackoverflow.com/q/78229406

http://stackoverflow.com/a/78247592
type: Answer
has body: I made a slight modification to the script to let the game get the same process ID as the script but the real problem was that the game and executable were nested in a subfolder. So the export LD_LIBRARY_PATH=&quot;.&quot; the path was wrong. I removed the unnecessary folder and lifted everything up one step and now it works :) Modified script: #!/bin/sh export LD_LIBRARY_PATH=&quot;.&quot; exec ./glow &quot;$@&quot;
score: 0
answers question: http://stackoverflow.com/q/78233393

http://stackoverflow.com/comment/137854392
comment on: http://stackoverflow.com/a/78194502
type: Comment
score: 0
type: AnswerComment
has text: If they can change (or edit a copy of) the script, it's possible

http://stackoverflow.com/comment/137790462
comment on: http://stackoverflow.com/a/78157136
score: 0
type: Comment
has text: See https://ideone.com/nPd5S0
type: AnswerComment

http://stackoverflow.com/q/78295010
has comment: http://stackoverflow.com/comment/138031430
tagged with: bash
has comment: http://stackoverflow.com/comment/138031935
linked to: http://stackoverflow.com/q/44192376
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138031388
answer count: 0
type: UnansweredQuestion
has title: How would you add a new line after redirecting a command's output using >> in Bash?
duplicate of: http://stackoverflow.com/q/44192376
has body: read -r -p "Enter process name: " childpid apid=$(pgrep "$childpid") ps -p "$apid" # process-specific information read -r -p "Log process info [yes/no] " log if $log == "yes" then ps -p "$apid" >> pslog.txt # logging process-specific information fi Basically, when I rerun the script the information just stacks in a way that looks ugly. I want to add a new line each time the script is run before any information is logged. I tried to echo before and after ps -p "$apid" >> pslog.txt but it didn't work. I'm using Cygwin if that matters.

http://stackoverflow.com/comment/138040477
type: QuestionComment
type: Comment
has text: You haven't clearly defined the parameters of the question, but isn't it enough to add something like `CONFIG_TYPE = dev` followed by `include config_$(CONFIG_TYPE).env`, then if you want to run the test version you invoke `make CONFIG_TYPE=test` ?
comment on: http://stackoverflow.com/q/78298728
score: 0

syntax
tags question: http://stackoverflow.com/q/78234242
type: Tag
tag name: syntax
tags question: http://stackoverflow.com/q/78186259
tags question: http://stackoverflow.com/q/78419580
tags question: http://stackoverflow.com/q/78319248
tags question: http://stackoverflow.com/q/78634545
tags question: http://stackoverflow.com/q/78880481

http://stackoverflow.com/comment/138054281
comment on: http://stackoverflow.com/q/78307692
type: QuestionComment
has text: What about putting the `find` command into a file `scripts/copy-html.sh`, and then in your `scripts` section just reference `./scripts/copy-html.sh`? That removes the escaping problem *and* means you get proper linting/formatting/etc when editing your shell script.
score: 0
type: Comment

http://stackoverflow.com/comment/137875167
has text: Also see [BashFAQ/004 (How can I check whether a directory is empty or not? How do I check for any *.mpg files, or count how many there are?)](https://mywiki.wooledge.org/BashFAQ/004).
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78203984

http://stackoverflow.com/comment/137889856
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78212724
has text: you've provided a sample set of 8 lines from `colorvalues.csv`; please update the question to show the expected output for those same 8 lines
score: 0

http://stackoverflow.com/comment/137855431
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment
type: Comment
has text: @CharlesDuffy Hard to say, this question is wide! Maybe a dup of [How do I set a variable to the output of a command in Bash?](https://stackoverflow.com/q/4651437/1765658)
score: 0

http://stackoverflow.com/comment/137972667
comment on: http://stackoverflow.com/q/78261314
score: 0
has text: (also, note that using backticks for command substitution is outdated _even for `sh`_ -- the newer `$( )` syntax nests better, generally behaves more intuitively, and has been standardized since the early 90s).
type: QuestionComment
type: Comment

trailing-newline
type: Tag
tag name: trailing-newline
tags question: http://stackoverflow.com/q/78196374

http://stackoverflow.com/a/78274313
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78274285
has body: Assumptions: all fields are wrapped in double quotes double quotes do not show up as actual data there is no white space between the double quotes and comma (delimiter) NOTE: if these assumptions are incorrect then OP will need to update the question with a more realistic set of sample data A simple sed idea: $ sed 's/","/";"/g' test.csv "001";"User,Super";"04/04/2024"
type: Answer
score: 2

http://stackoverflow.com/comment/137830554
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78180816
score: 0
has text: @chepner Yup, actually on updating it. Thank you!

http://stackoverflow.com/comment/137852096
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78192118
has text: i tested it the menu works one change i like to add is a progress bar instead found this conv=notrunc,noerror) 2>&1 \ | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0 but that will not work i assume
score: 0

m4
tags question: http://stackoverflow.com/q/78276793
type: Tag
tag name: m4

http://stackoverflow.com/comment/137770156
has text: As the [tag:bash] tag you used instructs - "For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting them here.". Your script contains multiple errors that shellcheck could tell you about and, given the shebang you're using, I highly doubt if what you've shown us is a real script you're running. Post a real [mcve] after it's shellchecvk-clean if you'd like help.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78146724
type: Comment

http://stackoverflow.com/comment/137865740
type: QuestionComment
type: Comment
has text: @user1934428 The latter is what is happening. When I write the stdout to a new file, the file is identical to the original file. I can see no substitutions were made for the 2 lines I altered for testing
comment on: http://stackoverflow.com/q/78196837
score: 0

http://stackoverflow.com/comment/138014767
score: 0
comment on: http://stackoverflow.com/q/78285382
type: QuestionComment
has text: (correspondingly, the `_sh` extension and `.sh` in the filename are both arguably deliberate misdirections attempting to lead the reader away from accurate understanding).
type: Comment

http://stackoverflow.com/comment/137813127
type: QuestionComment
score: 0
has text: @DavidMaze, if that's the case, it looks like I will always have to call this command at each step separately if `ARG` doesn't support substitutions.
comment on: http://stackoverflow.com/q/78166553
type: Comment

http://stackoverflow.com/comment/138014269
has text: Indeed it was the problem, thank you Philippe ! I just modified the invocation of mkvdts2ac3.sh to explicitly redirect standard input from /dev/null to prevent it from consuming input meant for the loop and it works. I can continue now thanks again!
comment on: http://stackoverflow.com/q/78284934
type: Comment
score: 3
type: QuestionComment

http://stackoverflow.com/q/78235520
accepted answer: http://stackoverflow.com/a/78235578
downvote count: 0
has answer: http://stackoverflow.com/a/78236202
tagged with: bash
has body: I have two color characters: a="\033[38;5;154ma" b="\033[38;5;199mb" I can print them to the terminal, like: printf "$a$b\n" Likewise, I print them verbatim with echo: echo $a echo $b But how do I do both at the same time. For example, I would like to do: printf "$a$(echo $b)\n" But this doesn't just execute "echo", it also executes the output of "echo" and thus colors the letter b instead of printing verbatim. I want to print a string where $a has been colored and $b is verbatim and not colored, something like a\033[38;5;199mb.
favorite count: 0
possible better answer: http://stackoverflow.com/a/78236202
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78235578
score: 3
has comment: http://stackoverflow.com/comment/137931117
answer count: 2
has comment: http://stackoverflow.com/comment/137927576
type: Question
has comment: http://stackoverflow.com/comment/137927560
has title: printing color character in bash and the verbatim of another color character
upvote count: 3

http://stackoverflow.com/comment/138025766
type: QuestionComment
comment on: http://stackoverflow.com/q/78291764
type: Comment
score: 0
has text: "If a word begins with an unquoted tilde character" - in both cases this is true but the result is different. I do not see where my question is answered in the given above "duplicate" question.

http://stackoverflow.com/comment/137825307
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78178190
has text: Thank you very much for your assistance. It was an enlightenment

http://stackoverflow.com/comment/138027585
has text: I encourage you to not `echo` a huge, multiline string. It's a lot clearer to `cat` a heredoc, instead.
score: 0
comment on: http://stackoverflow.com/q/78292693
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78209490
downvote count: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78209376
upvote count: 6
has body: The immediate improvement to this is to replace -exec ... {} \; with -exec ... {} + (as @pjh suggested in a comment, though it is not necessary to split it into two find commands). This makes find run the chmod commands on batches of files (a lot like how xargs does it) rather than one at a time. Creating processes (e.g. the chmod subprocesses) is computationally expensive, and doing that fewer times will almost certainly improve performance by a lot. But if I understand the situation and goal properly, you can make it much simpler (and probably even faster) by using the chmod command's built-in capability to decide when to add execute permission: chmod -R u=rwX,go=rX . The capital-X symbolic mode basically means "execute permission if it makes sense" (i.e. if the item is a directory and/or already has at least one execute permission bit set). This is not exactly the same as your find command in a couple of ways: it'll set the perms on files with starting perms other than those in the lists of -perm flags, and will set perms to 755 for directories even if they didn't originally have execute perms set. Also, it may behave differently with symbolic links (I'm not clear on the goal of the -L flag in the original command -- are there symlinks to files outside the directory it's operating on?).
answers question: http://stackoverflow.com/q/78209376
score: 6
type: Answer

http://stackoverflow.com/comment/137936304
comment on: http://stackoverflow.com/q/78240309
score: 0
type: QuestionComment
type: Comment
has text: AWS_PROFILE holds just the name of the profile that you want to use (local to your machine). This is the same as a name that you use in aws configure (sso in this example). The profile is something that should be set once, not every time (if your assuming a role, aws cli can help with that as well)

http://stackoverflow.com/comment/137844861
type: Comment
has text: TIL about `SECONDS`, thanks!
type: AnswerComment
comment on: http://stackoverflow.com/a/78187835
score: 0

http://stackoverflow.com/comment/137853145
comment on: http://stackoverflow.com/q/78178090
type: QuestionComment
type: Comment
has text: Your shebang is or is not resepcted, depending on how you execute the script. To give a precise description of you situation, not only post your script, but exaplain **how** you invoke it, and from what kind of interactive shell you invoke it.
score: 0

http://stackoverflow.com/comment/138001586
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78277043
score: 1
has text: Of course you can. What's preventing you from trying, or looking at the documentation?

http://stackoverflow.com/comment/137858139
comment on: http://stackoverflow.com/q/78196593
has text: Do you mean on the same line as read? No specific reason, i also tried one without echo but it didn't work either.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137812365
comment on: http://stackoverflow.com/a/78167873
has text: @EdMorton: Ah yes you are right, there are only 2 fields per records. (Edited)
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/a/78224927
type: Answer
answers question: http://stackoverflow.com/q/78224799
has body: @oguzismail has the correct answer in their comment (you need to pass arguments to a function if you intend to use position variables like $1, etc), but I wanted to suggest some things you could do to debug this sort of thing in the future. If you run your script with tracing enabled (-x), you will see: $ bash -x thescript.sh hostnames.txt + initialInput=hostnames.txt + fileChk=.txt + names.txt == *.txt* + Domain_Lookup_Func + filename= lookup.sh: line 3: : No such file or directory That shows clearly that $1 inside the function is evaluating to the empty string. In fact, the error message was already providing that clue; if you attempt to redirect input form a nonexistent file, bash includes the filename in the error: $ cat &lt; filethatdoesnotexist.txt -bash: filethatdoesnotexist.txt: No such file or directory In the error message you see, the spot normally occupied by the filename is blank, which is why you see line 3: : ....
score: 0

http://stackoverflow.com/comment/137914699
score: 0
comment on: http://stackoverflow.com/q/78228111
type: QuestionComment
has text: ...to be more clear about what I was saying about nohup -- it's basically equivalent to adding `</dev/null >nohup.out 2>&1 & disown -h` to the end of a command; hardcoding the filename `nohup.out` is generally more a bug than a feature (you should use a unique name, typically one with a timestamp!) and the `disown` part is only needed at all in interactive shells, as noninteractive ones don't pay attention to HUP in the first place.
type: Comment

http://stackoverflow.com/comment/138052394
has text: Make sure your script is saved as a POSIX text file, not a DOS text file.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78306525

http://stackoverflow.com/comment/137888107
score: 1
type: QuestionComment
type: Comment
has text: this question should probably be tagged [regex](https://stackoverflow.com/questions/tagged/regex). Note that according to that description, questions asking "what does this regex do?" are off-topic for SO
comment on: http://stackoverflow.com/q/78213645

http://stackoverflow.com/comment/137858420
score: 1
has text: Please correct any issues flagged when you paste your code into https://shellcheck.net . Be sure to start with the appropriate "she-bang" line, usually `#!/bin/bash`. Good luck.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78195964

http://stackoverflow.com/comment/138118564
comment on: http://stackoverflow.com/a/78286286
type: Comment
type: AnswerComment
score: 0
has text: I appreciate your response.

http://stackoverflow.com/comment/137872849
type: QuestionComment
type: Comment
has text: I would do a series of tests (for instance -d, -f and at last -e) and abort once I got a hit, but this is a matter of taste. BTW, what output do you expect if the entry is a symlink to a directory, respectively a symlink to a plain file?
comment on: http://stackoverflow.com/q/78203880
score: 0

http://stackoverflow.com/comment/137861567
type: QuestionComment
type: Comment
has text: What exactly do you mean by _does not seem to make any substitutions_? The command, as it is written, is not supposed to modify any file, but to write to stdout a copy of `filename`, with the substitutions applied. If you mean that what is written to stdout is identical to what is in `filename`, please say so explicitly.
comment on: http://stackoverflow.com/q/78196837
score: 0

http://stackoverflow.com/comment/137891624
has text: See the updated question ... I haven't yet seen the reversed order of stdout and stderr outputs ... not aware also this can be in the wrong order. My issue is that I would like to see the outcome between the separator lines, not after ...
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78215669
type: Comment

http://stackoverflow.com/comment/137834474
type: Comment
score: 1
has text: Yes, but the suggestions correct your faulty code. Without the quotation marks, several consecutive spaces are reduced to one.
comment on: http://stackoverflow.com/q/78183354
type: QuestionComment

http://stackoverflow.com/comment/138039085
comment on: http://stackoverflow.com/q/78299332
has text: You're right! The provided answer in the other script also works for my example
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138193501
type: QuestionComment
comment on: http://stackoverflow.com/q/78253800
has text: (As a completely separate matter, _don't do this at all_: you can make a one-shot systemd service that's started in response to `dumpingserver` exiting to decide how to handle that exit, or configure systemd's built-in restart behavior to taste; moreover, if that server is something you wrote yourself, update the code to make the TLS handshake failure immediately fatal and systemd will immediately be in a position to restart after it triggers)
type: Comment
score: 0

autoreconf
tags question: http://stackoverflow.com/q/78274675
tag name: autoreconf
type: Tag

http://stackoverflow.com/comment/137789198
has text: The code in the question is correct to use lower-case variable names -- all-caps names are used for variables that reflect or modify shell behavior by POSIX convention. Unfortunately, comment formatting munges code enough that I can't really follow the above beyond that aside to speak more directly to the question at hand.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78156916

http://stackoverflow.com/a/78273234
score: 0
answers question: http://stackoverflow.com/q/78272291
has body: Using any awk: $ awk 'BEGIN{FS=OFS="\t"} NR>1{for (i=4; i<=NF; ++i) $i=sprintf("%.3f", $i)} 1' TestAllScore.tsv chr start end EE85756 EE85757 EE85770 EE85775 chr1 9900 10000 0.371 0.506 0.250 0.663 chr1 10000 10100 214.787 313.545 250.865 335.980 chr1 10100 10200 511.215 684.635 540.710 713.896 chr1 10200 10300 516.526 630.297 465.875 545.823 chr1 10300 10400 297.539 396.572 346.689 339.295 chr1 10400 10500 142.162 272.538 238.372 255.093 chr1 10500 10600 191.072 295.151 246.118 277.635 chr1 10600 10700 237.142 345.102 308.460 306.311 chr1 10700 10800 239.860 270.513 294.342 272.497
type: Answer

http://stackoverflow.com/comment/137856160
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78194973
has text: this is the debug https://pastecode.io/s/mq3yfcqv

php
tag name: php
type: Tag
tags question: http://stackoverflow.com/q/78202378
tags question: http://stackoverflow.com/q/78346345
tags question: http://stackoverflow.com/q/78444401
tags question: http://stackoverflow.com/q/78484913
tags question: http://stackoverflow.com/q/78594448
tags question: http://stackoverflow.com/q/78874089
tags question: http://stackoverflow.com/q/78954119
tags question: http://stackoverflow.com/q/78983275
tags question: http://stackoverflow.com/q/79022674
tags question: http://stackoverflow.com/q/79078733
tags question: http://stackoverflow.com/q/79530394
tags question: http://stackoverflow.com/q/79460476
tags question: http://stackoverflow.com/q/79535541
tags question: http://stackoverflow.com/q/79498895

http://stackoverflow.com/a/78289713
type: Answer
has body: Here's a better way to draw the box: $ cat ./messagetBox #!/usr/bin/env bash # `printf` will expand `\n` to newline and `\t` to tab # `pr` will convert any tabs to the appropriate number # of blanks to match the alignment seen in the input. printf '%b\n' "$*" | pr -e -t | awk ' { width = length($0) maxWidth = ( width > maxWidth ? width : maxWidth ) lines[NR] = $0 } END { lineBeg = "| " lineEnd = " |" dashes = sprintf("%*s", maxWidth + length(lineBeg) + length(lineEnd), "") gsub(/ /,"-",dashes) print dashes for ( lineNr=1; lineNr<=NR; lineNr++ ) { line = sprintf("%-*s", maxWidth, lines[lineNr]) print lineBeg line lineEnd } print dashes } ' $ ./messagetBox "Hello\nMy name is Lorenzo, I was born in Italy." -------------------------------------------- | Hello | | My name is Lorenzo, I was born in Italy. | -------------------------------------------- It isn't clear from your question what you're using all those escape sequences for but just add them to that output as you like if you need them. In particular I kept the populating of line separate from printing so you could add escape sequences around that to change color or whatever inside the box if that's what you're trying to do.
answers question: http://stackoverflow.com/q/78284887
accepted answer of: http://stackoverflow.com/q/78284887
type: AcceptedAnswer
score: 0

http://stackoverflow.com/comment/138026029
comment on: http://stackoverflow.com/q/78291764
has text: ...I can edit the duplicate question's answer to cover that explicitly, if it'll help. (That question was built with the intent of being a canonical dupe target, so this kind of edit is very much in-keeping with same).
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137975739
type: Comment
comment on: http://stackoverflow.com/q/78263189
has text: You improved it. Since you seem open to it, I improved it a bit more.
type: QuestionComment
score: 0

http://stackoverflow.com/comment/137857693
score: 0
has text: @JohnBollinger well dam look at that ... asked a class room question at the end.. I'll update my post
type: Comment
comment on: http://stackoverflow.com/a/78196086
type: AnswerComment

http://stackoverflow.com/comment/137821763
has text: By using awk $1 and $8 I thought it would pull out the 1st and 8th field in the file, but I just get the whole file as output
comment on: http://stackoverflow.com/q/78176347
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137857321
comment on: http://stackoverflow.com/a/78196086
score: 1
type: Comment
has text: "*I think you are just trying to call a script with command line options*" -- possibly, but that's not at all what the question as posed actually asks.
type: AnswerComment

http://stackoverflow.com/comment/137792183
comment on: http://stackoverflow.com/a/78158825
has text: https://serverfault.com/questions/10353/what-is-the-sticky-bit-in-unix-file-systems-when-is-it-used
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/78240810
answers question: http://stackoverflow.com/q/78239630
has comment: http://stackoverflow.com/comment/139747565
has body: You can get directly json format with brew info: brew info --json --installed | jq 'map({name, version:.installed[0].version})'
type: Answer
accepted answer of: http://stackoverflow.com/q/78239630
score: 8
upvote count: 8
downvote count: 0
has comment: http://stackoverflow.com/comment/137959067
type: AcceptedAnswer

gitlab-ci
tags question: http://stackoverflow.com/q/78146721
tag name: gitlab-ci
tags question: http://stackoverflow.com/q/78200394
type: Tag
tags question: http://stackoverflow.com/q/78421398
tags question: http://stackoverflow.com/q/78496979
tags question: http://stackoverflow.com/q/78669861
tags question: http://stackoverflow.com/q/78785884
tags question: http://stackoverflow.com/q/78808824
tags question: http://stackoverflow.com/q/79022536
tags question: http://stackoverflow.com/q/79017951
tags question: http://stackoverflow.com/q/79118101

http://stackoverflow.com/comment/138034687
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78290118
has text: Yes. Service exists and enabled+started. Then, that script executes remotely doing these steps via ssh -i "/myssh.key" myuser@host "<command>": 1) sudo systemclt stop myService.service >>>>> Succesfully executed and service stopped 2) Modify some values in /etc/systemdsystem/myService.service file >>>> The resulting file is valid 3) sudo systemctl daemon-reload >>>>>>> Executed correctly, showing no errors 4) sudo systemctl start myService.service >>>>>> myServices is started successfully and stays running again BUT running service didn't notice of changes to myService.service file
score: 0

http://stackoverflow.com/comment/137941158
type: QuestionComment
type: Comment
has text: I am running this on a server which uses bash shell, when I run there I can create an array correctly
comment on: http://stackoverflow.com/q/78241899
score: 0

http://stackoverflow.com/comment/137935307
has text: I use free Fastpanel, cPanel was an example , what I'm trying to buy is shared imunify360 license and I'm little sceptic about what that bash script will actually do..I don't to get in more troubles when I actually need to protect my server.
type: QuestionComment
comment on: http://stackoverflow.com/q/78239018
score: 0
type: Comment

http://stackoverflow.com/comment/137858545
score: 1
type: Comment
has text: How do you know if a timestamp is daylight savings or not? Please provide complete input examples and expected output.
comment on: http://stackoverflow.com/q/78196837
type: QuestionComment

http://stackoverflow.com/comment/137916019
score: 0
type: QuestionComment
has text: When you say "encounters", do you mean that `$1` contains spaces already? If so, then obviously you need to put that in quotes.
type: Comment
comment on: http://stackoverflow.com/q/78228875

http://stackoverflow.com/comment/137790564
score: 1
has text: @oguzismail okay, `printf '%s' ~/` :-P (the outer `echo` is from the question so I'm not too bothered by that)
type: Comment
comment on: http://stackoverflow.com/a/78157136
type: AnswerComment

http://stackoverflow.com/comment/137816062
comment on: http://stackoverflow.com/a/78173029
type: Comment
type: AnswerComment
has text: That only runs the first level of subdirectories. How do I get it to run further down? E.g. not just y/level1 but also y/level1/level2 and y/level1/level2/level3 etc.
score: 0

http://stackoverflow.com/comment/137818670
comment on: http://stackoverflow.com/a/78174152
score: 1
type: Comment
type: AnswerComment
has text: Simply `$subdir ` also checks whether `$subdir` is non-empty. The braces add no value there.

http://stackoverflow.com/comment/138118556
type: Comment
score: 0
comment on: http://stackoverflow.com/a/78286685
type: AnswerComment
has text: my thought has been updated and now i am seeking other way than hex code based approach. Should I delete this post?

http://stackoverflow.com/comment/138018224
score: 3
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78287441
has text: To actually list directories directly with `ls`, try `ls -d */`; but for programmatic use, generally [don't use `ls` in scripts.](http://mywiki.wooledge.org/ParsingLs)

http://stackoverflow.com/comment/137809942
score: 2
type: QuestionComment
has text: It doesn't stay activated for the same reason you have to source `activate` instead of executing it as a script.
type: Comment
comment on: http://stackoverflow.com/q/78169456

http://stackoverflow.com/comment/137856886
has text: (the bug in https://pastecode.io/s/nkdib49c is that you used `readarray`, but then you used `for x in $interfaces` and not `for x in "${interfaces[@]}"`; those two changes need to be both made together; when you do one and not the other they don't work)
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
type: Comment

http://stackoverflow.com/comment/137871580
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78204135
has text: assumes caller has necessary `rx` permissions on the directory

http://stackoverflow.com/comment/137875405
score: 1
has text: These functions leave `nullglob` and `dotglob` set after they return. That may cause problems elsewhere in a program. Also, none of the variables are localized, so assigning to them may clobber the values of variables used elsewhere in the program (possibly leading to lots of debugging fun). Finally, the `echo` commands may produce incorrect output if `IFS` has an unusual value.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78204135

http://stackoverflow.com/comment/137868686
type: QuestionComment
has text: My previous research about read-only values related to `/etc/localtime` and `/etc/timezone` being write-protected. But maybe these are not related to `TZ`...
type: Comment
comment on: http://stackoverflow.com/q/78200396
score: 0

http://stackoverflow.com/comment/137773151
comment on: http://stackoverflow.com/q/78148102
score: 1
has text: Perhaps define a function that takes `stage` as an argument?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137798780
has text: `$i` contains the directory part, so `PROD/Today/$i` will contain the directory twice. Use `diff "$i" "PROD/Yesterday/$(basename "$i")"`
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78163062
type: QuestionComment

global-variables
tag name: global-variables
type: Tag
tags question: http://stackoverflow.com/q/78146405
tags question: http://stackoverflow.com/q/78576698
tags question: http://stackoverflow.com/q/79270352

http://stackoverflow.com/comment/137856460
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78194973
has text: fixed it - https://pastecode.io/s/mq3yfcqv Thank you so much for your help. still a bit messy but much better than it was
score: 0

mkv
tags question: http://stackoverflow.com/q/78284934
tag name: mkv
type: Tag

http://stackoverflow.com/comment/137826172
type: Comment
comment on: http://stackoverflow.com/q/78178702
type: QuestionComment
score: 0
has text: I tried with tee , and with >>, nothing i do works, each time i get an output file that only has the output result and not showing the command itself. unless i'm doing echo which i'm trying to avoid ..

visual-studio-code
type: Tag
tag name: visual-studio-code
tags question: http://stackoverflow.com/q/78246449
tags question: http://stackoverflow.com/q/78175570
tags question: http://stackoverflow.com/q/78387338
tags question: http://stackoverflow.com/q/78474553
tags question: http://stackoverflow.com/q/78575374
tags question: http://stackoverflow.com/q/78636388
tags question: http://stackoverflow.com/q/78692243
tags question: http://stackoverflow.com/q/78889201
tags question: http://stackoverflow.com/q/78806346
tags question: http://stackoverflow.com/q/78776633
tags question: http://stackoverflow.com/q/78811660
tags question: http://stackoverflow.com/q/79105138
tags question: http://stackoverflow.com/q/79412418
tags question: http://stackoverflow.com/q/79471800
tags question: http://stackoverflow.com/q/79547451

http://stackoverflow.com/comment/137870259
has text: Thanks, that's what I thought, but I was hoping there's a shortcut
comment on: http://stackoverflow.com/a/78202297
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137893210
has text: `exec "$(pwd)/$@" ` does the trick ... preserving the current working directory
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78216128
score: 0

http://stackoverflow.com/comment/137773350
score: 2
type: Comment
type: AnswerComment
has text: OP can use a subshell if needed: `( x=foobar; echo ... )`
comment on: http://stackoverflow.com/a/78148123

http://stackoverflow.com/comment/138035823
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78297369
has text: These are all common FAQs; probably search before asking. I have added a couple of other duplicates to cover all bases, and updated the answer to show how to mix different quotes.
score: 0

http://stackoverflow.com/a/78147865
score: 2
answers question: http://stackoverflow.com/q/78147838
downvote count: 0
type: Answer
upvote count: 2
has body: Try with: if gunzip --test "${file}" 2>/dev/null 1>/dev/null; then echo "This is a gzipped file!" else echo "This is NOT a gzipped file." fi

http://stackoverflow.com/comment/137988150
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78269359
score: 0
has text: (obviously this is different for _remote_ paths, where the local shell sees the strings as not matching any path it knows about and passes them through unmodified; but in the examples given here it's only local paths subject to globbing)

prefix
tags question: http://stackoverflow.com/q/78175689
tag name: prefix
type: Tag

http://stackoverflow.com/comment/137887468
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78212724
has text: Your link to onlinegdb results in "Not Found".
score: 0

scripting
tag name: scripting
tags question: http://stackoverflow.com/q/78207789
tags question: http://stackoverflow.com/q/78175689
type: Tag
tags question: http://stackoverflow.com/q/78224942
tags question: http://stackoverflow.com/q/78428595
tags question: http://stackoverflow.com/q/78419884
tags question: http://stackoverflow.com/q/78339485
tags question: http://stackoverflow.com/q/78434093
tags question: http://stackoverflow.com/q/78392466
tags question: http://stackoverflow.com/q/78389511
tags question: http://stackoverflow.com/q/78440831
tags question: http://stackoverflow.com/q/78428782
tags question: http://stackoverflow.com/q/78393091
tags question: http://stackoverflow.com/q/78388939
tags question: http://stackoverflow.com/q/78340874
tags question: http://stackoverflow.com/q/78353316
tags question: http://stackoverflow.com/q/78444070
tags question: http://stackoverflow.com/q/78363374
tags question: http://stackoverflow.com/q/78572680
tags question: http://stackoverflow.com/q/78668918
tags question: http://stackoverflow.com/q/78628280
tags question: http://stackoverflow.com/q/78676272
tags question: http://stackoverflow.com/q/78596837
tags question: http://stackoverflow.com/q/78803876
tags question: http://stackoverflow.com/q/78849261
tags question: http://stackoverflow.com/q/78876319
tags question: http://stackoverflow.com/q/79030244
tags question: http://stackoverflow.com/q/78927409
tags question: http://stackoverflow.com/q/79055342
tags question: http://stackoverflow.com/q/79041382
tags question: http://stackoverflow.com/q/79234977
tags question: http://stackoverflow.com/q/79155042
tags question: http://stackoverflow.com/q/79125465
tags question: http://stackoverflow.com/q/79153351
tags question: http://stackoverflow.com/q/79103952

http://stackoverflow.com/comment/137943223
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78244513
type: Comment
has text: The command line arguments to `git add` will be expanded by Bash, so its patterns should work for you.

http://stackoverflow.com/comment/137770182
comment on: http://stackoverflow.com/q/78146721
score: 1
has text: Never just use the word "pattern" when talking about pattern matching - say literal string, regexp, or globbing pattern, whichever type of "pattern matching" it is you're trying to do, for your own clarity and ours. Does your manifest file contain literal strings, regexps, or globbing patterns? Is that the type of matching you want to do against your file names (you seem to be trying to convert them to regexps but if they're globbing patterns why not do a glob match)? Do you want to do full or partial matching (does `the` match `then`)?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137921473
comment on: http://stackoverflow.com/q/78232246
score: 0
type: QuestionComment
type: Comment
has text: sample chapters.txt file `id=1 start_time=0.000000 end_time=15.000000 TAG:title=Introduction id=2 start_time=15.000000 end_time=272.000000 TAG:title=Course Overview` sample temp.txt `id=1 start=1 end=15.000000 title=Introduction ------ id=2 start=2 end=272.000000 title=Course Overview ------ id=3 start=3 end=690.000000 title=Development Tools ------ id=690.000000 start=690.000000 end=C compiler support title=5 ------ id=857.000000 start=857.000000 end=Installing the compilers title=6`

http://stackoverflow.com/comment/138005519
comment on: http://stackoverflow.com/q/78280175
type: Comment
score: 0
has text: I have edited the question here. Sorry for the confusion. The spacing got mixed up.
type: QuestionComment

http://stackoverflow.com/comment/138040785
score: 0
comment on: http://stackoverflow.com/q/78298728
has text: I intend to run `make dev_setup` and `make test_setup` commands to run python script with different configurations on different environments
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137775625
comment on: http://stackoverflow.com/a/78147860
score: 1
type: Comment
type: AnswerComment
has text: I would not overwrite `type` builtin

http://stackoverflow.com/comment/137866712
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78201574
has text: _If you personally own and control_ the NSS/LDAP configuration, you could decide to map the relevant AD/LDAP groups into UNIX groups and use traditional tools like `getent`; _or_ you could decide to use `ldapsearch` and similar to directly query the directory service; but you, as someone familiar with how your directory infrastructure is set up, need to make that decision; we can't make it for you. (Often, your sysadmin team or AD administrator will be the people you want to reach out to for help here).

ping
type: Tag
tags question: http://stackoverflow.com/q/78207789
tag name: ping
tags question: http://stackoverflow.com/q/79276938
tags question: http://stackoverflow.com/q/79269544
tags question: http://stackoverflow.com/q/79528273

http://stackoverflow.com/comment/137879423
type: QuestionComment
comment on: http://stackoverflow.com/q/78184175
type: Comment
has text: Running `bash` creates a *new* interactive shell (which implicitly sources `.bashrc`).
score: 0

http://stackoverflow.com/comment/137935205
has text: Also, keep your own variables out of all-caps namespace, which are used for variables with meaning to the shell itself or OS-provided tools. Using lowercase names for your own variables prevents you from changing special names unintentionally.
score: 0
comment on: http://stackoverflow.com/q/78239545
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78157779
has comment: http://stackoverflow.com/comment/137789759
has answer: http://stackoverflow.com/a/78157986
score: 0
type: Question
has comment: http://stackoverflow.com/comment/137791596
type: UnansweredQuestion
answer count: 1
has comment: http://stackoverflow.com/comment/137789747
has comment: http://stackoverflow.com/comment/137790435
has body: In my bash script, I'd like to replace the part of the filename with the path of the current location of where I am running the script in. #!/bin/bash $MY_SPECIAL_FILE=&quot;$(pwd)/hello.txt Currently, when I echo $MY_SPECIAL_FILE, it always prints out the initial pwd I was in, regardless of where I echo this from. I want this to print out banana/hello.txt if I am in the banana directory, and apple/hello.txt if I am in the apple directory. How do I achieve this?
has title: Replace variable with the path of the current location of where I am running
tagged with: bash

http://stackoverflow.com/comment/137884876
has text: If I understand what you want correctly, you want the `PIPv6` variable to have the value `Unknown` if you don't find an IPv6 address. The code doesn't work because it makes no attempt to change the value of the variable if it finds its value to be empty. A simple fix for the problem is to replace `echo "Unknown"` with `PIPv6=Unknown`. Another option is to use one of the techniques described in answers to the duplicate question that I've suggested. One way to do it is to replace the `if [ -z $PIPv6 ] ... fi` with `: "${PIPv6:=Unknown}"`.
comment on: http://stackoverflow.com/q/78211473
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138013342
type: QuestionComment
has text: Something like: `read -pNumber:\ number;p1=$(star=;for ((i=number;i--;));do star+='*';printf '%*s\n' $number "$star";done );paste -d '' <(echo "$p1") <(rev <<< "$p1") | tee >(sleep .1;tac);sleep .2`
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78283701

http://stackoverflow.com/comment/138025122
type: Comment
has text: Yes this works: gnome-terminal --title "A TITLE" --tab --profile Red-White -- bash --rcfile setENVS.sh
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78260557

game-development
tag name: game-development
type: Tag
tags question: http://stackoverflow.com/q/78233393

http://stackoverflow.com/comment/137884537
type: Comment
type: AnswerComment
has text: This still terminates `gnome-calculator`, unfortunately.
comment on: http://stackoverflow.com/a/78211545
score: 0

grep
tag name: grep
tags question: http://stackoverflow.com/q/78241761
tags question: http://stackoverflow.com/q/78261247
tags question: http://stackoverflow.com/q/78216460
type: Tag
tags question: http://stackoverflow.com/q/78278018
tags question: http://stackoverflow.com/q/78147838
tags question: http://stackoverflow.com/q/78444623
tags question: http://stackoverflow.com/q/78319238
tags question: http://stackoverflow.com/q/78341621
tags question: http://stackoverflow.com/q/78423821
tags question: http://stackoverflow.com/q/78411166
tags question: http://stackoverflow.com/q/78330348
tags question: http://stackoverflow.com/q/78513720
tags question: http://stackoverflow.com/q/78451797
tags question: http://stackoverflow.com/q/78504692
tags question: http://stackoverflow.com/q/78582237
tags question: http://stackoverflow.com/q/78720313
tags question: http://stackoverflow.com/q/78712681
tags question: http://stackoverflow.com/q/78741961
tags question: http://stackoverflow.com/q/78603249
tags question: http://stackoverflow.com/q/78736701
tags question: http://stackoverflow.com/q/78654909
tags question: http://stackoverflow.com/q/78827742
tags question: http://stackoverflow.com/q/78815815
tags question: http://stackoverflow.com/q/78788854
tags question: http://stackoverflow.com/q/78838067
tags question: http://stackoverflow.com/q/78758811
tags question: http://stackoverflow.com/q/78887315
tags question: http://stackoverflow.com/q/78843200
tags question: http://stackoverflow.com/q/78962905
tags question: http://stackoverflow.com/q/79040002
tags question: http://stackoverflow.com/q/79055914
tags question: http://stackoverflow.com/q/78945398
tags question: http://stackoverflow.com/q/78971432
tags question: http://stackoverflow.com/q/79051305
tags question: http://stackoverflow.com/q/78994565
tags question: http://stackoverflow.com/q/79123895
tags question: http://stackoverflow.com/q/79186645
tags question: http://stackoverflow.com/q/79201229
tags question: http://stackoverflow.com/q/79123943
tags question: http://stackoverflow.com/q/79102410
tags question: http://stackoverflow.com/q/79171297
tags question: http://stackoverflow.com/q/79153212
tags question: http://stackoverflow.com/q/79103952
tags question: http://stackoverflow.com/q/79224372
tags question: http://stackoverflow.com/q/79358209
tags question: http://stackoverflow.com/q/79376403
tags question: http://stackoverflow.com/q/79252378
tags question: http://stackoverflow.com/q/79504080
tags question: http://stackoverflow.com/q/79522023
tags question: http://stackoverflow.com/q/79472702
tags question: http://stackoverflow.com/q/79447335

snakemake
tags question: http://stackoverflow.com/q/78231607
tag name: snakemake
type: Tag
tags question: http://stackoverflow.com/q/79429771

pam
tag name: pam
type: Tag
tags question: http://stackoverflow.com/q/78192206

http://stackoverflow.com/comment/137800553
has text: The usual way for a command to pass data out is for it to print the data to stdout, and for the calling script to capture it with something like `DELIVER_USER=$(fastlane beta)`. Note that this captures *everything* the command sends to stdout, so anything you don't want captured (e.g. status or error messages) should be sent to stderr instead (that's what it's for). If it needs to send more than one value, it needs to print the values in some form that the script can parse to separate out the values.
comment on: http://stackoverflow.com/q/78163771
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/137830024
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78180816
type: Comment
has text: Voting to close as unreproducible, since the problem was with an undisclosed failure to properly create the virtual environment in the first place.

until-loop
tags question: http://stackoverflow.com/q/78146405
type: Tag
tag name: until-loop

http://stackoverflow.com/comment/137828604
has text: `grep -Po '^\s*appid="\K[^"]+'` ?
score: 0
comment on: http://stackoverflow.com/q/78176143
type: QuestionComment
type: Comment

continuous-deployment
tag name: continuous-deployment
type: Tag
tags question: http://stackoverflow.com/q/78261175

text
tag name: text
type: Tag
tags question: http://stackoverflow.com/q/78284887
tags question: http://stackoverflow.com/q/78528580
tags question: http://stackoverflow.com/q/78511517
tags question: http://stackoverflow.com/q/78637408
tags question: http://stackoverflow.com/q/79341086

http://stackoverflow.com/comment/137875130
score: 1
comment on: http://stackoverflow.com/q/78203984
type: QuestionComment
type: Comment
has text: See [How can I get a count of files in a directory using the command line?](https://unix.stackexchange.com/q/1125/264812).

http://stackoverflow.com/comment/138006261
type: Comment
type: AnswerComment
has text: @IchigoKurosaki replace it with `{1,10}` to limit to 10.
score: 0
comment on: http://stackoverflow.com/a/78277043

http://stackoverflow.com/comment/138006168
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78280230
score: 0
has text: Another approach, using `paste` instead of `join`: `paste <(sed -f <(sed -n '$! { N;/^\([^_]*\)_.*\n\1/{ h;s|^\([^_]*\)_.*|/^\1/p|p;;g;};D }' file-b.txt) file-a.txt) file-b.txt`

http://stackoverflow.com/comment/137924193
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78233340
score: 0
has text: Then use `jq` to extract the value, then transform it. You can probably do the transformation in `jq` too. Had the json data been properly encoded no transformation had been needed and you could just use `jq` to extract it.

http://stackoverflow.com/a/78147680
score: -1
upvote count: 0
has body: Here is the solution I have found so far using virtual environments: installed pip via sudo apt install python-pip then python2 -m pip install virtualenv create a virtual environment with Python 2 isolated from system's default Python ~/.local/bin/virtualenv --python=/usr/bin/python2 jmodelica_env then activate the virtual environment to use the isolated Python installation within it source jmodelica_env/bin/activate
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78146600

http://stackoverflow.com/comment/138006245
score: 1
has text: Since this is a legacy codebase, I presume that configuration and building worked at some time, in some environment. Obviously, you should be looking at what has changed since then. Is it only the build environment, or have their been changes to the autotooling, too? Instead of trying to troubleshoot the current state *de novo*, it would probably be easier to examine the changes to determine which one(s) caused the failures to start manifesting.
type: QuestionComment
comment on: http://stackoverflow.com/q/78274675
type: Comment

http://stackoverflow.com/comment/137798769
score: 0
has text: You can just do `diff PROD/Today PROD/Yesterday` and it will compare each file.
comment on: http://stackoverflow.com/q/78163062
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137927044
score: 1
type: QuestionComment
type: Comment
has text: yes, I'd actually forgotten about `-g`. if you're nested a few levels deep and something higher declared a local, `-g` undoes the shadowing: `v=10; f(){ local v=1; g; }; g(){ v=2; }; f; declare -p v` vs same with `declare -g` in g
comment on: http://stackoverflow.com/q/78235101

http://stackoverflow.com/a/78150022
has body: This worked: #!/bin/bash echo "^^^ Would you like to setup a new user? yes or no: " read -r NEWUSERADD if [ "$NEWUSERADD" == "yes" ]; then echo echo -n "Enter a username: " read -r NAME useradd -m "$NAME" passwd "$NAME" # Add new user to wheel group echo "^^^ Add new user to the wheel group? yes or no: " read -r NEWUSERWHEEL if [ "$NEWUSERWHEEL" == "yes" ]; then echo usermod -aG wheel "$NAME" else [ "$NEWUSERWHEEL" == "no" ] echo echo "**** Not adding to wheel group. Hit [Enter} to continue ****" fi else [ "$NEWUSERADD" == "no" ] echo echo "**** Not creating a user. Hit [Enter] to continue ****" fi
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78149866

http://stackoverflow.com/comment/137844646
has text: I can't get the comment to format. I'll edit the question.
comment on: http://stackoverflow.com/a/78188933
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137780968
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78150761
type: Comment
has text: Shouldn't it be `more() { cat }`? Otherwise `more` would not only not ask for confirmation, but also don't print the text.

http://stackoverflow.com/comment/137784119
comment on: http://stackoverflow.com/q/78154583
has text: `tmpVar=${unsetVar:-~}; echo "$tmpVar"` ?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137922775
score: 0
comment on: http://stackoverflow.com/q/78232634
type: QuestionComment
has text: Does the glob pattern work as expected when matching filenames in a directory?
type: Comment

ruby-on-rails
type: Tag
tag name: ruby-on-rails
tags question: http://stackoverflow.com/q/78208548
tags question: http://stackoverflow.com/q/79083586

http://stackoverflow.com/comment/137833911
has text: BTW, expr isn't good form in modern code -- it's an artifact of back when shells didn't support built-in math. `echo $(( 1 + 1 ))` has been standardized since the early 1990s; there's almost never a good reason to use expr these days.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78183119

file
tag name: file
type: Tag
tags question: http://stackoverflow.com/q/78254419
tags question: http://stackoverflow.com/q/78176347
tags question: http://stackoverflow.com/q/78358550
tags question: http://stackoverflow.com/q/78315911
tags question: http://stackoverflow.com/q/78528580
tags question: http://stackoverflow.com/q/78721219
tags question: http://stackoverflow.com/q/78592814
tags question: http://stackoverflow.com/q/78754984
tags question: http://stackoverflow.com/q/78823644
tags question: http://stackoverflow.com/q/78953203
tags question: http://stackoverflow.com/q/79002678
tags question: http://stackoverflow.com/q/79000846
tags question: http://stackoverflow.com/q/79320316
tags question: http://stackoverflow.com/q/79547103

timer
tag name: timer
tags question: http://stackoverflow.com/q/78182030
type: Tag
tags question: http://stackoverflow.com/q/78724459

http://stackoverflow.com/comment/137923151
type: Comment
type: AnswerComment
score: 0
has text: I read that aliases are not available on the same line that they are defined in. Is there a way to get around this (given that I cannot use two subprocess calls)?
comment on: http://stackoverflow.com/a/78232840

http://stackoverflow.com/comment/137867407
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78199112
has text: Setting `HOME` to `/dev/null` will *absolutely* cause an error when `git` tries to access `/dev/null/.gitconfig`,
score: 0

http://stackoverflow.com/comment/137897260
comment on: http://stackoverflow.com/a/78214419
has text: Note also that no part of my answer parses JSON with awk or bash nor do I suggest that anyone do so.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138002531
has text: It would be great if the command output would be copied to the clipboard as well as being displayed on the terminal.
type: Comment
comment on: http://stackoverflow.com/q/78278159
score: 0
type: QuestionComment

http://stackoverflow.com/comment/137827449
comment on: http://stackoverflow.com/q/78177875
type: Comment
score: 0
type: QuestionComment
has text: Assuming that `aws s3 ls` has the same behavior as regular `ls` then see https://mywiki.wooledge.org/ParsingLs.

http://stackoverflow.com/comment/137822260
score: 1
type: QuestionComment
has text: You're getting answers that will fail when your string values contain `=` and `"` (e.g. try them with input like `appid="foo=bar"` or `appid="foo""quoted""bar"` or `appid="foo\"quoted\"bar"`) so make sure to include those and any other rainy-day cases in your example when you post it.
comment on: http://stackoverflow.com/q/78176143
type: Comment

http://stackoverflow.com/comment/137826001
comment on: http://stackoverflow.com/q/78177847
score: 0
type: QuestionComment
type: Comment
has text: Check different solutions here: https://stackoverflow.com/questions/4903570/how-does-one-start-a-node-js-server-as-a-daemon-process

http://stackoverflow.com/comment/137830043
comment on: http://stackoverflow.com/q/78180816
has text: @chepner Answered my own question due to the issue being in package version discrepancies
score: 0
type: QuestionComment
type: Comment

singularity-container
tags question: http://stackoverflow.com/q/78147406
tag name: singularity-container
tags question: http://stackoverflow.com/q/78167188
type: Tag
tags question: http://stackoverflow.com/q/79347783
tags question: http://stackoverflow.com/q/79374693

http://stackoverflow.com/comment/137812302
has text: A *pure bash solution* would probably use `printf "%s,%s,%s,%s,%(%c)T\n" "$n" "$t" "$f" "$c" "$t"`.
comment on: http://stackoverflow.com/a/78170836
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/78214277
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/78212724
has body: You're close. Maybe something like: #!/bin/bash #set -x make_swatches() { counter=1 swatches='' input_file=$1 limit=$2 template=".swatch div:nth-child(%d){ background: %s; }" while read swatch; do swatches+="$(printf "$template\n" "$counter" "$swatch")"$'\n' ((counter++)) "$counter" -gt "$limit" && break done < "$input_file" echo "$swatches" } make_swatches colorvalues.csv 8
upvote count: 1

datatable
type: Tag
tag name: datatable
tags question: http://stackoverflow.com/q/78286060

http://stackoverflow.com/comment/137936779
has text: Piecemeal, but there's a mix in terms of which reputation services are publicly available and which are subscription services. https://talosintelligence.com/reputation_center/ is one option (disclosure: I used to work in a different security arm of the same parent company -- they're owned by Cisco) -- paste the URL in there and see what they think.
type: QuestionComment
comment on: http://stackoverflow.com/q/78239018
type: Comment
score: 0

http://stackoverflow.com/a/78248684
score: 0
type: Answer
has body: You can run bash --restricted which after processing any startup file (where you can disable builtins) these restrictions are applied (among others): Adding or deleting builtin commands with the -f and -d options to the enable builtin. Using the enable builtin command to enable disabled shell builtins. see the full list at https://www.gnu.org/software/bash/manual/html_node/The-Restricted-Shell.html
answers question: http://stackoverflow.com/q/78248223

http://stackoverflow.com/comment/138013126
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78283701
type: QuestionComment
has text: For me, the question is not clear. As others have said, you can do a certain amount of string manipulation in the shell, and construct character sequences "piecewise" that way. It is also possible to _output_ multiple shell variables at the same time - `echo $part1 $part2`. It is also possible to _consume_ two (or more) _input_ lines from a shell pipe and print them on a single output line - `echo ... | paste - -` (`paste` command).

http://stackoverflow.com/comment/137805966
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78166553
has text: This is similar to [Dockerfile - Defining an ENV variable with a dynamic value](https://stackoverflow.com/questions/34859987/dockerfile-defining-an-env-variable-with-a-dynamic-value). The same rules apply to `ARG` and `ENV`: Docker does no substitutions here other than simple variable substitution, and it in particular does not run subcommands here.

http://stackoverflow.com/comment/137855169
has text: BTW, all-caps names are used for variables that have internal meaning to the shell itself or OS-defined tools. Use lowercase names for your own variables to avoid unintentional conflicts.
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78194973

http://stackoverflow.com/comment/137862436
type: Comment
type: AnswerComment
score: 3
comment on: http://stackoverflow.com/a/78199112
has text: One potential reason could be that OP explicitly specified that they didn't want to change `HOME`.

http://stackoverflow.com/comment/137892953
type: QuestionComment
type: Comment
score: 0
has text: (on the other hand, if _everything_ you write is intended for human consumption, and none of it is meant to go to disk or be piped to another program, just write everything to stderr and the problem is moot; similarly, if everything you write is output proper -- in the sense of being the content your program exists to create, as opposed to logs/status/diagnostics/prompts/etc -- just write all that content to stdout, and again problem solved).
comment on: http://stackoverflow.com/q/78215669

http://stackoverflow.com/a/78172085
score: 1
has body: Here is a Ruby to do that: #!/bin/bash arr=(test,meta my,amazon test,amazon this,meta test,google my,google hello,microsoft) ruby -F, -lane 'BEGIN{ grps=Hash.new{|h,k| h[k]=[]} } grps[$F[0]] << $F[1] END{ grps.each{|k,v| puts "#{v.length} #{k}: #{v.join(", ")}"} } ' <(printf '%s\n' "${arr[@]}") Or a two pass awk: awk -F, 'FNR==NR{cnt[$1]++; line[$1]=$1 in line ? line[$1] ", " $2 : $2; next} !($1 in p){printf "%s %s: %s\n", cnt[$1],$1,line[$1]; p[$1]} ' <(printf '%s\n' "${arr[@]}") <(printf '%s\n' "${arr[@]}") Either prints 3 test: meta, amazon, google 2 my: amazon, google 1 this: meta 1 hello: microsoft
answers question: http://stackoverflow.com/q/78167734
downvote count: 0
upvote count: 1
type: Answer

xclip
tags question: http://stackoverflow.com/q/78278159
type: Tag
tag name: xclip
tags question: http://stackoverflow.com/q/79014791

fastlane
tag name: fastlane
type: Tag
tags question: http://stackoverflow.com/q/78163771
tags question: http://stackoverflow.com/q/79514971

http://stackoverflow.com/comment/137911847
comment on: http://stackoverflow.com/q/78226499
has text: my bad, I clearly should have read the rules _before_ writing the question
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/137854442
has text: Right, but it has its own arguments, and `set --` generally writes to the current stack frame's arguments; if you run it inside a function, you change only that function's arguments, not the arguments of the larger script or the context that _invoked_ that function.
type: Comment
comment on: http://stackoverflow.com/a/78194502
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137854422
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78194502
type: Comment
has text: @CharlesDuffy: Yes, I ran it in a fresh terminal.

colors
tags question: http://stackoverflow.com/q/78216460
tag name: colors
type: Tag
tags question: http://stackoverflow.com/q/78372273
tags question: http://stackoverflow.com/q/79143919

http://stackoverflow.com/a/78225807
has body: In fork_process_redi you are setting the output file descriptor but not the input, like you are doing in fork_process_pipe. The last command in pipeline with redirection will be reading from STDIN until EoF readed instead from the pipe of the last command. "cat file" will not read from stdin and it runs ok. Not related, but the free sentences after execve will never be executed. The memory is freed when the forked process exits so it's not an issue.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137934953
answers question: http://stackoverflow.com/q/78218663
score: 0
accepted answer of: http://stackoverflow.com/q/78218663
type: Answer
has comment: http://stackoverflow.com/comment/137914849

http://stackoverflow.com/comment/137851090
comment on: http://stackoverflow.com/q/78192206
score: 0
type: QuestionComment
has text: So you are implementing php pam_auth https://stackoverflow.com/questions/3765304/how-would-i-use-php-to-authenticate-with-linux-users-and-passwords ? So, maybe again, any reason not to use `sudo -S`?
type: Comment

command-line-interface
tags question: http://stackoverflow.com/q/78252063
tags question: http://stackoverflow.com/q/78299332
type: Tag
tag name: command-line-interface
tags question: http://stackoverflow.com/q/78503442
tags question: http://stackoverflow.com/q/78572680
tags question: http://stackoverflow.com/q/78447803
tags question: http://stackoverflow.com/q/78553947
tags question: http://stackoverflow.com/q/78518299
tags question: http://stackoverflow.com/q/78653717
tags question: http://stackoverflow.com/q/78650733
tags question: http://stackoverflow.com/q/78776633
tags question: http://stackoverflow.com/q/79043844
tags question: http://stackoverflow.com/q/78943372
tags question: http://stackoverflow.com/q/79034879
tags question: http://stackoverflow.com/q/79143919
tags question: http://stackoverflow.com/q/79125293

http://stackoverflow.com/comment/137876740
score: 0
comment on: http://stackoverflow.com/a/78203971
has text: `[conditional]` is the same as `test [conditional]`. I prefer using that over the `file` command because I think it's more readable. But as Giles pointed out, using `file` allows for the switch statement, which is easier to scale to other file types.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137893904
comment on: http://stackoverflow.com/q/78216881
score: 0
type: QuestionComment
type: Comment
has text: Why `BITBUxCKET_TAG` instead of `BITBUCKET_TAG` ??

http://stackoverflow.com/comment/137981930
score: 0
has text: What speaks agains executing a `clear` after the docker command, or maybe a `sleep 3; clear`, so that bystanders can for 3 seconds stare with admiration to the output diasppears?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78261786

http://stackoverflow.com/comment/137863604
has text: @dawg fair enough, I added a couple of any-awk-only solutions for anyone who doesn't have [that version of] `column`.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78193436
score: 1

http://stackoverflow.com/comment/137855575
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78195172
has text: You seem to be making unnecessary trouble for yourself. Suppose you provide no `-n` option at all. What harm results?
type: Comment

http://stackoverflow.com/comment/137791181
score: 3
has text: see: https://unix.stackexchange.com/questions/503111/group-permissions-for-root-not-working-in-tmp
comment on: http://stackoverflow.com/q/78158725
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137938863
comment on: http://stackoverflow.com/q/78241899
score: 0
type: QuestionComment
type: Comment
has text: I added it, it is unix

http://stackoverflow.com/comment/137960567
comment on: http://stackoverflow.com/q/78253195
type: QuestionComment
type: Comment
has text: Thank you for that. I knew it was something simple. However, now I try to convert to bash array (the desired output). I only get the first value of the array.
score: 0

http://stackoverflow.com/comment/137854159
score: 1
type: QuestionComment
has text: What do you mean by "why"? You can't do it because it doesn't do that.
type: Comment
comment on: http://stackoverflow.com/q/78194467

http://stackoverflow.com/a/78147072
answers question: http://stackoverflow.com/q/78146721
score: 0
has body: I have some questions but this MAY be what you want: $ cat tst.sh #!/usr/bin/env bash shopt -s nullglob readarray -t glob_pats < manifest_globs.txt for filename; do for glob_pat in "${glob_pats[@]}"; do if $filename == $glob_pat ; then echo "$filename matched $glob_pat" fi done done $ ./tst.sh A_cycles.pdf A_filter_passed_vs_occupied.pdf A_grouped_cycle.csv A_grouped_lane.csv A_grouped_lane_cycle.csv A_metadata.csv A_percent_q30.pdf A_raw.csv seqrun_A.json A_grouped_cycle.csv matched *_grouped_cycle.csv A_grouped_lane.csv matched *_grouped_lane.csv A_grouped_lane_cycle.csv matched *_grouped_lane_cycle.csv A_metadata.csv matched *_metadata.csv A_raw.csv matched *_raw.csv seqrun_A.json matched seqrun_*.json
type: Answer

http://stackoverflow.com/a/78301560
score: 1
type: Answer
upvote count: 2
downvote count: 1
accepted answer of: http://stackoverflow.com/q/78298036
type: AcceptedAnswer
has body: If it weren't the program's fault, the PR you wrote wouldn't work; the fact that that PR addresses the problem is in and of itself proof that the environment variable is being passed to the program but the program is ignoring it (as if the variable weren't passed, 'PGPASSWORD' in os.environ would be false). Further means you can prove this to your own satisfaction: Given the PID of a running program, you can read a NUL-delimited stream of the environment variables defined for that program from /proc/PID/environ. Use tr '\0' '\n' to change the NUL delimiters to newlines for easier human readability, or to make sure every variable is readably printed: #!/usr/bin/env bash (( $# )) || { echo "Usage: $0 pid [pid2] ..." >&2; exit 1; } for pid in "$@"; do while IFS= read -r -d '' entry; do var=${entry%%=*} value=${entry#*=} printf '%s=%q\n' "$var" "$value" done <"/proc/$pid/environ" done ...can be passed a PID (or list of them), and will dump environment variables' values in printable form even if they contain newlines or other nonprinting characters. In the shell, declare -p varname will emit declare -- varname=... if a string-type variable is not exported (arrays will have declare -a, integers declare -i, namevars declare -n, etc); or declare -x varname=... if it is (or write an error if the variable is not set at all).
answers question: http://stackoverflow.com/q/78298036

http://stackoverflow.com/q/78305587
has comment: http://stackoverflow.com/comment/138050738
has comment: http://stackoverflow.com/comment/138056310
has comment: http://stackoverflow.com/comment/138050692
tagged with: bash
type: Question
answer count: 0
tagged with: subprocess
has body: I was wondering if there is some way to execute a bash func call from python. I've tried to run something like this import subprocess print(subprocess.run("_get_app_creation_timestamp", shell=True, capture_output=True).stdout.decode("utf-8").strip()) Shell function definition could be something like this BASH_FUNC__get_app_creation_timestamp%%=() { _get_app | jq '.metadata.creationTimestamp' | sed -e 's/^"//' -e 's/"$//' But I just get an empty string. From a shell script code, call would be something so easy like TIME="$(_get_app_creation_timestamp)" My main goal is porting shell script into python but it's not being so easy as I thought :)
has comment: http://stackoverflow.com/comment/138055981
type: UnansweredQuestion
has title: Getting bash function result from python
has comment: http://stackoverflow.com/comment/138050927
tagged with: python
has comment: http://stackoverflow.com/comment/138050754
has comment: http://stackoverflow.com/comment/138058629
has comment: http://stackoverflow.com/comment/138052263
score: 0

http://stackoverflow.com/a/78228855
answers question: http://stackoverflow.com/q/78228798
score: 3
type: AcceptedAnswer
upvote count: 3
accepted answer of: http://stackoverflow.com/q/78228798
has body: You're looking for something like this: find . -type f -name 'brain.mgz' -exec sh -c ' for src; do dst=${src%/*/*} dst=$dst/${dst##*/}_${src##*/} echo cp "$src" "$dst" done' sh {} + Drop echo if the output looks good.
downvote count: 0
type: Answer

http://stackoverflow.com/comment/138027091
comment on: http://stackoverflow.com/q/78290808
score: 1
type: QuestionComment
type: Comment
has text: think about what that conditional is testing for .... how can `$currentTime` be *both* greater than '230000' and less than '010000'?

http://stackoverflow.com/comment/137842506
type: Comment
type: AnswerComment
score: 0
has text: I have a follow up question. I like the second construct the best, but I can't figure out how to get the PID or return code of producer. I'd like to ensure that the process completed successfully down the line, but can't seem to figure out how. I added `"$?"` and `"$!"` to try to get the return code or pid in both the command block `{ ... }` and after the construct, but they always appear unset / not having the value I would expect.
comment on: http://stackoverflow.com/a/78177452

http://stackoverflow.com/comment/137817550
score: 0
has text: @bobmonty, the `%(fmt)T` conversions only handle an integer number of seconds. They can't handle milliseconds or fractional seconds. You could use Bash arithmetic to convert milliseconds to seconds (e.g. `"$((utime_ms/1000))"`).
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78171801

http://stackoverflow.com/a/78179609
has body: Based on oguz's answer i came up with the following script: if [ $? -eq 139 ]; then # Get the core dump location core_dump_location=$(cat /proc/sys/kernel/core_pattern) echo "Core dumps are stored in: $core_dump_location" # If it did, find the most recently created coredump and copy it to the current directory latest_coredump=$(ls -t ${core_dump_location}* | head -n 1) cp "$latest_coredump" . # Open the coredump with gdb and print the backtrace gdb -ex "bt" -batch ./test "$latest_coredump" fi
answers question: http://stackoverflow.com/q/78178759
downvote count: 0
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/comment/137880750
score: 3
has text: One thing to try is to replace `\;` with `+`. That will cause `chmod` to be run on many files at once, rather than one at a time. I think you will have to run two `find` commands (one to run `chmod 755` and another to run `chmod 644`) to make that work though. I have not tested this.
type: QuestionComment
comment on: http://stackoverflow.com/q/78209376
type: Comment

http://stackoverflow.com/comment/137869933
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78200064
has text: I have to test it properly, and I'll confirm you, but it looks like with the conditional Oguz Ismail said, it's working. This one: `[[ ${file##*/} =~ ^([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2}) ]]` Thank you very much to all of you!!
score: 0

http://stackoverflow.com/comment/137796448
type: QuestionComment
has text: You are correct, that was the issue. Not the most intuitive response. Reply an answer and I'll mark you correct.
type: Comment
comment on: http://stackoverflow.com/q/78161552
score: 0

http://stackoverflow.com/comment/138024402
has text: I did not understand how Or can be used? I have a limitation in this machine that any scheduler cannot be used in it. Can you elaborate on the OR part and how to run it like run when time is between 11 to 1 do this and other time do nothing and then the if part should again start after 5 mins.
comment on: http://stackoverflow.com/a/78290897
type: Comment
score: 0
type: AnswerComment

environment-variables
tags question: http://stackoverflow.com/q/78298036
tags question: http://stackoverflow.com/q/78298728
tags question: http://stackoverflow.com/q/78252063
tag name: environment-variables
tags question: http://stackoverflow.com/q/78197884
tags question: http://stackoverflow.com/q/78272610
type: Tag
tags question: http://stackoverflow.com/q/78146600
tags question: http://stackoverflow.com/q/78445411
tags question: http://stackoverflow.com/q/78366773
tags question: http://stackoverflow.com/q/78587160
tags question: http://stackoverflow.com/q/78723492
tags question: http://stackoverflow.com/q/78660562
tags question: http://stackoverflow.com/q/78620437
tags question: http://stackoverflow.com/q/78699233
tags question: http://stackoverflow.com/q/78697242
tags question: http://stackoverflow.com/q/78808594
tags question: http://stackoverflow.com/q/78810525
tags question: http://stackoverflow.com/q/79050654
tags question: http://stackoverflow.com/q/78978949
tags question: http://stackoverflow.com/q/79188455
tags question: http://stackoverflow.com/q/79224813
tags question: http://stackoverflow.com/q/79249391
tags question: http://stackoverflow.com/q/79530284
tags question: http://stackoverflow.com/q/79536203

http://stackoverflow.com/comment/137840296
comment on: http://stackoverflow.com/a/78182177
has text: No problem! I will edit the question accordingly.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137865967
has text: A lot of the steps proposed are unnecessary. You don't generally _need_ to create files before you can write to them -- when you open for write with `>` or `>>`, that uses the `O_CREAT` flag by default, causing the file to be created if it doesn't already exist; no `touch` or anything else needed.
score: 0
comment on: http://stackoverflow.com/q/78200978
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138038385
comment on: http://stackoverflow.com/q/78298936
has text: Does this answer your question? [Interrupt sleep in bash with a signal trap](https://stackoverflow.com/questions/27694818/interrupt-sleep-in-bash-with-a-signal-trap)
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137935432
type: QuestionComment
comment on: http://stackoverflow.com/q/78239018
type: Comment
score: 0
has text: See https://ideone.com/nkAdAz -- mind, it looks like ideone redacts links to be only available to the person who first created a code segment, so you might need to fork and rerun it.

gnu
type: Tag
tags question: http://stackoverflow.com/q/78301325
tag name: gnu
tags question: http://stackoverflow.com/q/78502959
tags question: http://stackoverflow.com/q/78596837
tags question: http://stackoverflow.com/q/78680643
tags question: http://stackoverflow.com/q/78827252
tags question: http://stackoverflow.com/q/79000268
tags question: http://stackoverflow.com/q/78943372
tags question: http://stackoverflow.com/q/79074586
tags question: http://stackoverflow.com/q/79329866

http://stackoverflow.com/comment/137855150
score: 1
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment
type: Comment
has text: it looks like you could reduce duplication and also eliminate harcoding the number of interfaces by strategic use of arrays and loops.

http://stackoverflow.com/comment/137973087
score: 0
comment on: http://stackoverflow.com/q/78261786
type: QuestionComment
has text: Why can't you just redirect the std out and error to a file and delete that file once you are done with the process. your-process > proc.out 2>&1
type: Comment

http://stackoverflow.com/comment/137865572
comment on: http://stackoverflow.com/q/78200396
score: 0
has text: I updated that part mentioning that in that line, I am using the colloquial version of CST.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137821770
type: Comment
comment on: http://stackoverflow.com/q/78176347
type: QuestionComment
score: 0
has text: You need to prevent bash interpolation. Use single quotes: `awk '$1 >= 200 && $8 <= 400 {print}' numbers.txt`. For the file you've shown `$8 <= 400` will be true on _all_ lines though

http://stackoverflow.com/a/78201957
answers question: http://stackoverflow.com/q/78182539
has body: Github requires that you use their naming convention when submitting a request. Here is an example of my lables I wanted to implement: labels=( "Bug :bug::FF0000" # "Feature :sparkles::00FF00" # ✨ "Documentation :books::0000FF" # ) And then just ensuring you are extracting label components properly when making your request. label_name=$(echo "$label" | cut -d ":" -f 1) label_emoji=$(echo "$label" | grep -oP ':[^:]+:') label_color=$(echo "$label" | grep -oP '::\K.*$') Here is an overview: for label in "${labels[@]}"; do # Extract label components label_name=$(echo "$label" | cut -d ":" -f 1) label_emoji=$(echo "$label" | grep -oP ':[^:]+:') label_color=$(echo "$label" | grep -oP '::\K.*$') # Construct the label text with emoji shortcode label_text="\"name\":\"$label_name $label_emoji\"" label_color="\"color\":\"$label_color\"" # Print label text and color echo "{ $label_text, $label_color }" # Ensure proper color format (remove leading '#') label_color=$(echo "$label_color" | sed 's/^#//') # Prepare data for the POST request data="{ $label_text, $label_color }" # Ensure proper color format # Send POST request to create label response=$(curl -s -w "%{http_code}" -u "$token:x-oauth-basic" --request POST --data "$data" "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels") response_code=$(echo "$response" | tail -n1) response_body=$(echo "$response" | sed '$d') if $response_code -eq 201 ; then echo "Label '$label_name $label_emoji' created successfully in repository '$REPO_USER/$REPO_NAME'" else echo "Failed to create label '$label_name $label_emoji' in repository '$REPO_USER/$REPO_NAME'. Response: $response_body" fi done ```
score: 1
type: AcceptedAnswer
upvote count: 1
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/78182539

http://stackoverflow.com/comment/137853132
comment on: http://stackoverflow.com/a/78187835
has text: I wish :-). Today I Leaned.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138004070
comment on: http://stackoverflow.com/q/78278159
has text: No. I want this to be usable the way I described.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137802510
has text: You might find [this post](https://stackoverflow.com/questions/52621444/delete-line-that-matches-pattern-and-all-subsequent-lines-until-second-pattern) useful.
comment on: http://stackoverflow.com/q/78165163
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78157986
answers question: http://stackoverflow.com/q/78157779
score: 1
upvote count: 1
has body: Currently, when I echo $MY_SPECIAL_FILE, it always prints out the initial pwd I was in, regardless of where I echo this from. Well, yes. In the shell, the value you assign to a variable is expanded at the time of the assignment. When you later expand the variable, you get whatever value was set. If you want something different, you want the value to change then you must perform a new assignment. Moreover, parameter expansion is not recursive, so even if you arranged your quoting so that $(pwd) was not expanded at the time you assigned your value to MY_SPECIAL_FILE, it also would not be expanded when you expanded the variable. You would get the literal string "$(pwd)". Possibly you are looking for a shell function, instead: my_special_file() { echo "$(pwd)/hello.txt" } You would then execute that as a command: $ my_special_file /home/me/hello.txt $ cd subdir $ my_special_file /home/me/subdir/hello.txt And you can, of course, capture the output of that command so as to use it similarly to a variable: $ cat "$(my_special_file)" Hello, World from /home/me/subdir !
type: Answer
downvote count: 0

http://stackoverflow.com/comment/138012420
comment on: http://stackoverflow.com/q/78283701
score: 0
has text: What you're doing in your question is manipulating text. Shells aren't intended for manipulating text, they're intended for manipulating (creating/destroying) files and processes and sequencing calls to other tools. The mandatory POSIX (available on all Unix boxes) tool for manipulating text is awk so if you really wanted to write a concise, portable, efficient bash script to manipulate text then the bash part would just be to call awk and then awk would do the rest. So, do you want help to do THAT or is this just an exercise for you in learning bash constructs?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138018661
type: QuestionComment
comment on: http://stackoverflow.com/q/78286124
type: Comment
score: 0
has text: *replaced these four-flag attribute to hex numbered* did you documented that properly, so future user will know if he should use little endian or [middle endian](https://www.catb.org/jargon/html/M/middle-endian.html) or big endian?

http://stackoverflow.com/comment/137909886
type: Comment
has text: Note that if you've got Bash 5.0 or later you can use the [BASH_ARGV0](https://www.gnu.org/software/bash/manual/bash.html#index-BASH_005fARGV0) special variable to change `$0`/`argv[0]` from inside a Bash program.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78225038

http://stackoverflow.com/a/78214419
has comment: http://stackoverflow.com/comment/137897211
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78212759
type: Answer
has comment: http://stackoverflow.com/comment/137897260
has comment: http://stackoverflow.com/comment/137893885
has body: Let's take the JSON and Python out of this as your question is about bash arrays and so those are just muddying things as you wouldn't have bash arrays involved in processing JSON with python. So your current script basically looks like: $ cat tst.sh #!/usr/bin/env bash ids=$(printf '%s\n' 123 97 512) cns=$(printf '%s\n' "This Is First" "Second Here" "And Third") crs=$(printf '%s\n' "Joe Shmo" "Sue Me" "Perry The Platypus") for id in $ids; do ida+=($id) done for i in "${!ida[@]}"; do printf 'i: <%s>\n' "$i" printf 'ID: <%s>\n' "${ida[i]}" printf 'Course Name: <%s>\n' "${cns[i]}" printf 'Creator Name: <%s>\n' "${crs[i]}" printf "\n" done and when executed it'll output: $ ./tst.sh i: <0> ID: <123> Course Name: <This Is First Second Here And Third> Creator Name: <Joe Shmo Sue Me Perry The Platypus> i: <1> ID: <97> Course Name: <> Creator Name: <> i: <2> ID: <512> Course Name: <> Creator Name: <> when what you want output is: i: <0> ID: <123> Course Name: <This Is First> Creator Name: <Joe Shmo> i: <1> ID: <97> Course Name: <Second Here> Creator Name: <Sue Me> i: <2> ID: <512> Course Name: <And Third> Creator Name: <Perry The Platypus> That's because you're trying to access the contents of cns and crs by indexing them with the index from ida[], e.g. "${cns[i]}", but neither cns nor crs are arrays, they're strings, and so cns[0] is interpreted as just cns and so prints the whole cns string while cns[any other index] prints null. If you want them to be arrays then you could do: $ cat tst.sh #!/usr/bin/env bash readarray -t ids < <(printf '%s\n' 123 97 512) readarray -t cns < <(printf '%s\n' "This Is First" "Second Here" "And Third") readarray -t crs < <(printf '%s\n' "Joe Shmo" "Sue Me" "Perry The Platypus") for i in "${!ids[@]}"; do printf 'i: <%s>\n' "$i" printf 'ID: <%s>\n' "${ids[i]}" printf 'Course Name: <%s>\n' "${cns[i]}" printf 'Creator Name: <%s>\n' "${crs[i]}" printf "\n" done $ ./tst.sh i: <0> ID: <123> Course Name: <This Is First> Creator Name: <Joe Shmo> i: <…

http://stackoverflow.com/comment/137806601
score: 0
type: QuestionComment
type: Comment
has text: Does this answer your question? [How can I pipe to the next command with new environment variables?](https://stackoverflow.com/questions/18684685/how-can-i-pipe-to-the-next-command-with-new-environment-variables)
comment on: http://stackoverflow.com/q/78166360

http://stackoverflow.com/comment/137886595
comment on: http://stackoverflow.com/q/78212759
score: 1
has text: `grep | awk | awk`, really ? oO Use `jq` instead.
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78245595
tagged with: bash
has title: Bash Scripting an Iterated Sequence of IPython Commands
has comment: http://stackoverflow.com/comment/137945420
has body: I am planning to run a series of commands in IPython, and I plan to do this in multiple iterations. Is there a way for me to streamline the process by making a shell script that: Will activate the conda environment Will activate IPython and execute a series of commands Will exit IPython, move some files, etc. Will return to Step 2 with a parameter in the commands changing in each iteration Thank you! I tried the following: #!/usr/bin/bash source activate env name for i in {0..1000} do ipython import &lt;package&gt; commands commands commands(arg, i) commands exit() done
duplicate of: http://stackoverflow.com/q/37586811
linked to: http://stackoverflow.com/q/37586811
score: 0
type: Question
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/137945387
has comment: http://stackoverflow.com/comment/137945263

http://stackoverflow.com/comment/137909113
type: Comment
has text: Drop single quotes. Double quotes already handle spaces.
type: QuestionComment
comment on: http://stackoverflow.com/q/78224990
score: 2

http://stackoverflow.com/comment/137787551
has text: @Friedrich I run `vim` in `rxvt` terminals, never use tabs, never use windows, seldom use splits. I usually open 1 or max 2 files and switch between them using `CTRL-^`. For me `vim` is a programmable text editor, not an IDE; I start `vim`, edit a file, save and exit. Instead of mandate `:update` I use `:set hidden`. :-)
score: 1
type: Comment
comment on: http://stackoverflow.com/a/78156004
type: AnswerComment

http://stackoverflow.com/comment/137954578
has text: Maybe just `if $p == *bytes\ from* ; then`
score: 1
comment on: http://stackoverflow.com/q/78251094
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137777373
has text: Yes, tested, works
comment on: http://stackoverflow.com/a/78150663
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137865135
score: 0
comment on: http://stackoverflow.com/a/78200333
type: Comment
has text: `sed` will still break if, for example, you have a filesystem with `|` in the name. You can address that in a similar way by escaping any instance of `|` in the variable, but the more edge cases you have to account for with escaping the harder it will be to read your code.
type: AnswerComment

http://stackoverflow.com/comment/137996593
score: 1
comment on: http://stackoverflow.com/q/78274893
type: QuestionComment
type: Comment
has text: In the replacement, the symbol `&` represents the text that `sub` matched. It needs to be escaped. eg: `value='- \\& -'`

http://stackoverflow.com/comment/137799315
score: 0
comment on: http://stackoverflow.com/q/78163062
type: QuestionComment
type: Comment
has text: @tink That asks how to get just the filenames, not the differences in contents.

http://stackoverflow.com/comment/137857724
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78196374
score: 1
has text: The `\n` is what moves the remaining string to the next line, so I feel like it's a catch-22 here.

http://stackoverflow.com/comment/137913398
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591
score: 2
type: Comment
has text: @CrayonViolent OP is using `jq`, which is a json util that does exactly what you suggest (and more! you should check it out if you're not familiar with it).

http://stackoverflow.com/comment/137868430
score: 0
type: QuestionComment
has text: What do you mean. I have a shebang in the beginning for zsh specifically. I `chmod +x` the file and execute it afterwards. It has to do something with `read` and how the `&` being interacting
type: Comment
comment on: http://stackoverflow.com/q/78178090

http://stackoverflow.com/a/78203676
has body: Two issues were identified: As OneCricketeer mentioned above I am overriding the container command. It looks as though Kafka is set to auto create, so there is no need for a bash script which waiting on a failed service caused by 1.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78202033

http://stackoverflow.com/comment/137887426
has text: @stackbiz Why'd you remove the quotes? BAD!
type: Comment
comment on: http://stackoverflow.com/a/78195996
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137858537
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78196837
has text: The `~` are not required, unless you really have those characters in your data file? Cannot help much without a [mcve].
type: Comment

http://stackoverflow.com/comment/137886557
comment on: http://stackoverflow.com/a/78212459
has text: You should copy/paste that into http://shellcheck.net and fix the issues it'll tell you about.
score: 2
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78201679
score: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/137913383
has body: It is possible that the server owners made changes to their time zone settings, but that does not explain why the debug output returns UTC. More likely, the change to DST in your area is what produced the breakage. I just ran some test code: now1=$(date '+%s' -d "now CST") now2=$(date '+%s' -d "now CDT") echo "Human readable times:" echo "Now CST: $(date -d @$now1)" echo "Now CDT: $(date -d @$now2)" It is currently 8:11am CST [edit: CST in colloquial terms, not in computer terms]. This should be 1:11pm UTC according to Google. The output when I convert the timestamp back into human readable: Now CST: Thu Mar 21 19:11:44 UTC 2024 Now CDT: Thu Mar 21 18:11:44 UTC 2024 So that is 7pm and 6pm instead of the expected 1pm. The command ... date '+%s' -d "now CDT" ... says "take the current local time, reinterpret it as being expressed in CDT, and print the corresponding timestamp." If that makes you scratch your head, then it may make more sense if you think about what you would expect when an explicit time is specified instead of now; for example, 13:01:00 EDT. Such timestamps are defined relative to UTC, however, regardless of the local time zone, so the command ... date -d @$now2 ... says "expand variable now2, interpret the result as a timestamp (relative to UTC, regardless of local time zone), and print the resulting date and time in the default format." The default format uses the local time zone, which in your case happens to be UTC. Chaining those together produces what the time is / was / will be in the local time zone when the CDT time is what the local time is now. That's a bit of a mouthful, so here's a breakdown: you ran the first date command at 13:11:44 according to the server's local time a timestamp corresponding to 13:11:44 CDT today was stored you read back that timestamp with the second date command, and asked for it to be formatted in the default format the default format uses the local time zone, which happens to be UTC in your case. The UTC time corr…
has comment: http://stackoverflow.com/comment/137868794
downvote count: 0
has comment: http://stackoverflow.com/comment/137869222
upvote count: 1
has comment: http://stackoverflow.com/comment/137869173
answers question: http://stackoverflow.com/q/78200396
type: Answer
accepted answer of: http://stackoverflow.com/q/78200396

http://stackoverflow.com/a/78252525
type: Answer
has body: OP Here. Both of the following commands are working for me: curl -Lfs "https://motivatedsisters.com/2019/07/08/arabic-review-sr-rahat-basit/" | rg -o ' .*?href="(.*?)".*? (.*?)<\/li>' -r 'echo $1 $(unescape_html "$2")' | bash | rg -o '(https?://\S+)\s(.*)' -r 'echo $1 $(unescape_html "$2")' -r '{"url": "$1", "title": "$2"}' | jq -s '.' and curl -Lfs "https://motivatedsisters.com/2019/07/08/arabic-review-sr-rahat-basit/" | rg ' .*?href="(.*?)".*? (.*?)<\/li>' -or '$1 $2' | while read -r link title; do echo "$link" "$(unescape_html "$title")"; done | rg -o '(https?://\S+)\s(.*)' -r '{"url": "$1", "title": "$2"}' | jq -s '.'
answers question: http://stackoverflow.com/q/78252129
score: 0

makefile
type: Tag
tags question: http://stackoverflow.com/q/78298728
tag name: makefile
tags question: http://stackoverflow.com/q/78390223
tags question: http://stackoverflow.com/q/78422837
tags question: http://stackoverflow.com/q/78457962
tags question: http://stackoverflow.com/q/78608225
tags question: http://stackoverflow.com/q/78862151
tags question: http://stackoverflow.com/q/78757815
tags question: http://stackoverflow.com/q/78826936
tags question: http://stackoverflow.com/q/78931386
tags question: http://stackoverflow.com/q/79028575
tags question: http://stackoverflow.com/q/78950801
tags question: http://stackoverflow.com/q/79077163
tags question: http://stackoverflow.com/q/79352421
tags question: http://stackoverflow.com/q/79361411

http://stackoverflow.com/comment/137770817
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78146724
has text: You did not show how you run the script, but unless you source it, the last `cd` won't have any effect. From a bash viewpoint, I don't see an error with the loop, and I would run it with `set -x` for getting debug output.
type: Comment

http://stackoverflow.com/comment/137855149
has text: Arrays are your friend.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
type: Comment

http://stackoverflow.com/comment/137855163
score: 2
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78194991
has text: Soo like `pkill`? just `pkill -f procname1 ; pidwait -f procname1`? `Any suggestions ?` Research bash job control https://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html . The message comes from bash.

http://stackoverflow.com/comment/137934953
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78225807
has text: I do not know too much about stack overflow protocol but I think that if you edit your question and add the new code, it will be clearer and more usable for future readers with similar problems.
score: 0

http://stackoverflow.com/comment/138035720
has text: I have added the update method for testing your solution with `$var1`, please check. How to make `$var1` working with this method (`without END block`)?
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78297369

module
tags question: http://stackoverflow.com/q/78180816
tag name: module
type: Tag

http://stackoverflow.com/comment/137804714
has text: Thanks @ruohola. I know it's not meant to be grepped. The question came up in a discussion.
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78166538
type: Comment

http://stackoverflow.com/comment/137920165
type: Comment
score: 0
has text: I used chat gpt for this one, as I have no idea what I am doing here, thats why I am here as well :)
type: QuestionComment
comment on: http://stackoverflow.com/q/78226551

http://stackoverflow.com/comment/137945263
has text: Why do they have to be run from an ipython interperter and not as a script?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78245595

http://stackoverflow.com/comment/137887258
has text: i am learning bash as part of the offensive side of cybersecurity, not the defensive side. stuff like automating searching databases and such.
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78212759

http://stackoverflow.com/comment/137937989
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78241462
has text: Variable assignments don't have spaces around `=`.
type: Comment

http://stackoverflow.com/comment/138002349
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78278018
has text: Neither `\S` nor `+` are valid in _basic regular expressions_. Have a look [here](https://www.regular-expressions.info/posix.html). For your case, the first chapter _POSIX Basic Regular Expressions_ applies.

http://stackoverflow.com/a/78208742
score: 1
answers question: http://stackoverflow.com/q/78208234
downvote count: 0
has body: You must use if: ${{ env.READY == 'true' }} and if: ${{ env.READY != 'true' }} as mentioned by @GuiFalourd. I want also give my opinion, storing environment variables at complex github workflow is not easy to manage, If I had a error, must edit again the workflow file, test the workflow again. Usually I'm wrap it to bash script to run a complex job. As example name: Test on: workflow_dispatch jobs: testing: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Validating Task run: | # Run some validation task, then store at $GITHUB_ENV echo "READY=true" >> $GITHUB_ENV - name: Execute task if ready if: ${{ env.READY == 'true' }} run: | echo "Executing task !" bash ./tools.sh update id - name: Execute task if not ready if: ${{ env.READY != 'true' }} run: | echo "Not ready!" bash ./tools.sh notify id Also I'm test the workflows file with https://github.com/nektos/act in github codespace. Just install and run with act -W test.yaml Output : @anasfanani ➜ /workspaces/act (master) $ act -W test.yaml INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' [Greeting on variable day/testing] Start image=catthehacker/ubuntu:act-latest INFO[0000] Parallel tasks (0) below minimum, setting to 1 [Greeting on variable day/testing] docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true [Greeting on variable day/testing] using DockerAuthConfig authentication for docker pull INFO[0002] Parallel tasks (0) below minimum, setting to 1 [Greeting on variable day/testing] docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [Greeting on variable day/testing] docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [Greeting on variable day/testing] ⭐ Run Main actions/checkout@v4 [Greeting on variable day/testing] docker cp src=/workspaces/act/. dst=/workspaces/act [Greeting …
upvote count: 1
type: Answer

http://stackoverflow.com/comment/137773325
score: 0
comment on: http://stackoverflow.com/a/78148123
has text: It should be noted that these alternatives are semantically different from the OP's in that they will leave the `env` variable set in the host shell. The original command does not set any variables in the host shell.
type: Comment
type: AnswerComment

css
type: Tag
tag name: css
tags question: http://stackoverflow.com/q/78212724

optimization
tag name: optimization
tags question: http://stackoverflow.com/q/78209376
type: Tag
tags question: http://stackoverflow.com/q/78260874

http://stackoverflow.com/comment/137856105
comment on: http://stackoverflow.com/q/78195387
has text: Only step 3 has code because I think the `jq '. += dependencies` should add the "`dependencies`" to the "`{}`". So I just split the description into Step 2 and Step 3. The two steps are using the same code under step 3.
type: Comment
score: 0
type: QuestionComment

caching
tag name: caching
tags question: http://stackoverflow.com/q/78244372
type: Tag

http://stackoverflow.com/comment/137999422
comment on: http://stackoverflow.com/q/78276574
score: 0
has text: For more general solutions, see https://stackoverflow.com/questions/16571739/parsing-variables-from-config-file-in-bash
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137936562
type: QuestionComment
score: 2
type: Comment
has text: Just to emphasize the problem for future users: the length of the commandOutput value is 6 characters -- it contains literal quote characters. The right-hand side of the equality comparison is only 4 characters. Thus they are unequal
comment on: http://stackoverflow.com/q/78240671

http://stackoverflow.com/comment/137865899
has text: choroba corrected me in a comment below his answer, and pointed out that everything I wrote in my edit, was for not. I'm ashamed and embarrassed that it came to this. I'm just a fool and going cross eyed from looking at this script for the last 2 weeks. Thanks again for your assistance Ed Morton. I will cleanup my original question shortly.
comment on: http://stackoverflow.com/a/78196849
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137972372
score: 0
comment on: http://stackoverflow.com/a/78261291
type: Comment
type: AnswerComment
has text: Regarding "and without awk" - avoiding awk when you need to manipulate text from a shell is like avoiding the washing machine when it's laundry day. In addition to being more code than an awk script, this will run orders of magnitude slower than an awk script and is less portable than an awk script with no benefits over using an awk script. Please read [why-is-using-a-shell-loop-to-process-text-considered-bad-practice](https://unix.stackexchange.com/questions/169716/why-is-using-a-shell-loop-to-process-text-considered-bad-practice).

http://stackoverflow.com/comment/138012201
has text: As far I can see, your question does not mention that the output should be shown in the terminal as well. Perhaps you can clarify this. However, a more tricky problem is that you said that you also want to have the command itself in the clipboard. Do you mean here "the command before expansion", or "after expansion"? Perhaps you could edit your question by adding the example: `ls -A ~`. What exactly would you like to see in the clipboard afterwards?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78278159

http://stackoverflow.com/comment/137864344
has text: @Spencer copy/paste that into http://shellcheck.net and it'll tell you about a couple of problems with it plus it's using an external non-standard tool unnecessarily. Do it as shown in the answer instead for robustness, portability and efficiency.
comment on: http://stackoverflow.com/a/78200064
type: Comment
type: AnswerComment
score: 1

flutter
type: Tag
tags question: http://stackoverflow.com/q/78207181
tag name: flutter
tags question: http://stackoverflow.com/q/78211761
tags question: http://stackoverflow.com/q/78388693
tags question: http://stackoverflow.com/q/79264431

http://stackoverflow.com/comment/137858225
comment on: http://stackoverflow.com/q/78196593
type: QuestionComment
score: 1
has text: (see https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo for an extensive writeup if you're curious about my statements about `echo`'s lack of reliability; or, for something shorter but less exhaustive, see the APPLICATION USAGE and RATIONALE sections of the POSIX standard for `echo` itself, at https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html)
type: Comment

raspberry-pi4
tag name: raspberry-pi4
tags question: http://stackoverflow.com/q/78273096
type: Tag
tags question: http://stackoverflow.com/q/78782089

http://stackoverflow.com/comment/137822194
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78176143
type: QuestionComment
has text: please update the question to show the expected results for variables `appid`, `another` and `option`

http://stackoverflow.com/comment/137893086
has text: https://codepen.io/ricoThaka/pen/yLrXYry it really works out `cnt=0 ` #humor
comment on: http://stackoverflow.com/a/78214785
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137960777
comment on: http://stackoverflow.com/a/78254659
type: Comment
type: AnswerComment
has text: It is creating new file per second or maybe per iteration. also doesn't write log into file. I also tried to modify to create per minute, also doesn't work.
score: 0

http://stackoverflow.com/comment/137938772
comment on: http://stackoverflow.com/q/78241761
has text: Just use `qdepends -Q`.
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/137908964
score: 0
has text: @oguzismail where is this said? and check my update
comment on: http://stackoverflow.com/a/78225303
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137908493
comment on: http://stackoverflow.com/q/78224799
score: 0
has text: (BTW, in general, nslookup is somewhat antiquated; a more modern equivalent would be `dig +short`)
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78242394
downvote count: 0
has body: read by default trims leading and trailing whitespace and consumes backslashes. You can disable those by setting IFS to empty string and specifying the -r flag, respectively. See: $ echo ' \&quot; ' | while read i; do echo ${#i}; done 1 $ echo ' \&quot; ' | while IFS= read i; do echo ${#i}; done 3 $ echo ' \&quot; ' | while read -r i; do echo ${#i}; done 2 $ echo ' \&quot; ' | while IFS= read -r i; do echo ${#i}; done 4 Note that wc -c would print 5 but that's not an error. wc counts the terminating newline too while read always trims it.
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78242340

http://stackoverflow.com/comment/137869380
comment on: http://stackoverflow.com/a/78196739
has text: Based on all comments provided i attempted several options, but this one is the only one that completely solves my problem. It's worth to highlight that the use of -d option on read is the one that preserves the newlines on sThirdFieldTwoLines, but the use of an extra delimiter character (i.e. '%') solves an additional issue where a newline is appended by read at the end of sFourthField.
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137926809
has text: elements / entire arrays are created as required but it makes a difference if you try something like `myvar+=(["RANDOM"]=3)`; bash assumes indexed unless `declare -A myvar` was done beforehand
type: QuestionComment
comment on: http://stackoverflow.com/q/78235101
type: Comment
score: 0

http://stackoverflow.com/comment/137834447
has text: Please paste your script at [shellcheck.net](http://www.shellcheck.net/) and try to implement the recommendations made there.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78183354
type: Comment

http://stackoverflow.com/comment/137865585
type: QuestionComment
comment on: http://stackoverflow.com/q/78200978
type: Comment
has text: Why do you need an array? You should be able to do this using `sed`.
score: 0

http://stackoverflow.com/a/78232653
has body: The default rule is not affected by the include command (see here). So from snakemakes perspective there is nothing you request to be created thus, everything is already done. So the rule all should be part of the snakefile and not your download.smk. As far as i understand it smk-files should really only include the rules (In your case, the way you structured your rule, I think it must also include the config definition). If i move rule-all the dag is formed as expected.
answers question: http://stackoverflow.com/q/78231607
type: Answer
score: 0

http://stackoverflow.com/comment/137845063
type: Comment
type: QuestionComment
has text: The backtick is not special for regexp but it is special for shells. You don't have to escape it in the regexp but you have to escape it if the regexp is a string enclosed in [double quotes](https://www.gnu.org/software/bash/manual/bash.html#Double-Quotes) (`"`) in a shell script. If it is not escaped, the shell thinks that it starts a [command substitution](https://www.gnu.org/software/bash/manual/bash.html#Command-Substitution) and complains that it cannot find where the substitution ends. Or, worse, if there is another unescaped backtick, it tries to run the text between them as a command.
comment on: http://stackoverflow.com/q/78188914
score: 2

http://stackoverflow.com/comment/137804222
type: QuestionComment
comment on: http://stackoverflow.com/q/78166124
score: 4
has text: Tangentially, `test` is `[`, not `[[`.
type: Comment

qsub
tag name: qsub
type: Tag
tags question: http://stackoverflow.com/q/78260874
tags question: http://stackoverflow.com/q/79071046

http://stackoverflow.com/comment/137824354
comment on: http://stackoverflow.com/a/78170533
has text: Tried this for loop but not getting expected output for by in "${bytes[@]}" ; do echo "$by"| numfmt --to=iec done
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137777346
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78150663
has text: Does this actually work? `more` is getting the content to display from stdin connected to a temporary file created from the heredoc, so I'd think it would need to be reading user input direct from the TTY, not on stdin.
score: 0

http://stackoverflow.com/comment/137894047
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78216881
score: 0
has text: The last two attempts utilize `varr=${!BITBUCKET_TAG}`. Seems like there may be a stray `!` in the variable name.

http://stackoverflow.com/comment/137821873
comment on: http://stackoverflow.com/q/78176347
has text: As I said, `$8 <= 400` is true in all the lines you've shown. If there are only 7 columns, then `$8` will be zero, which is less than or equal to 400. `(200)` and `(300)` are not numbers so when doing a numerical comparison, they will be treated as zero. Again making the condition true.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138052328
score: 0
type: QuestionComment
type: Comment
has text: Ah yes I had suspicions of a carriage return. (this on git bash on windows, so there might be some oddities). Is there a way to clean it up? Maybe a flag in `read`?
comment on: http://stackoverflow.com/q/78306525

http://stackoverflow.com/comment/137775862
score: 0
comment on: http://stackoverflow.com/q/78149866
type: QuestionComment
type: Comment
has text: This is what you expect? http://pastie.org/p/5zfzD3LBvaYzS5XbqRTSMJ

http://stackoverflow.com/a/78183878
has body: Doesn't really combine files like .[0] * .[1] but will merge an any number of files into a single object jq -n 'reduce inputs as $s (.; .[input_filename] += $s)' *.json Example output: combine cars.json, cities.json, contacts.json, and countries.json { "cars.json": [ { "name": "AMC Ambassador Brougham", "brand": "AMC", "economy_mpg_": 13, "cylinders": 8, "displacement_cc_": 360, "power_hp_": 175, "weight_lb_": 3821, "0_60_mph_s_": 11, "year": 1973 } ], "cities.json": [ { "Continent": "Asia", "Country": "China", "City": "Shanghai", "Population": 24256800 } ], "contacts.json": [ { "person": { "personid": 123456, "name": "Person 1", "addresses": { "address": [ { "addressid": "2", "street": "Street 2", "postcode": "1234 AB", "city": "City 1" }, { "addressid": "2", "street": "Street 2", "postcode": "5678 CD", "city": "City 2" } ] } } } ], "countries.json": [ { "country": "Afghanistan", "Region": "ASIA (EX. NEAR EAST)", "Population": 31056997, "Area_square_miles": 647500, "GDP_per_capita": 700 } ] }
score: 0
answers question: http://stackoverflow.com/q/78173589
type: Answer

http://stackoverflow.com/comment/137963746
has text: oh right! im going to read about printf in bash for learn arguments. And is it possible to do the print inside the if ? so i dont need the function, like if {printf %f "$2" > /dev/null;} 2>/dev/null; then...
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78255939

http://stackoverflow.com/comment/137872537
score: 0
has text: I would expect in zsh to see a list of usernames after the tab (and perhaps the same in bash). If you want to cd into the home directory of user _foo_, you could select by completion a `cd ~foo` from this list. If you don't see such a list, it would make sense to upload a screenshot which shows the effect. Also, it does not make sense to use the tags _bash_ **and** _zsh_ here. You can't use two shells at the same time, and we have no idea which of these shells you are using.
type: QuestionComment
comment on: http://stackoverflow.com/q/78204849
type: Comment

http://stackoverflow.com/comment/137945387
has text: Why not just use IPython instead of Bash? It can run shell commands with the `!` prefix.
comment on: http://stackoverflow.com/q/78245595
type: QuestionComment
score: 0
type: Comment

containers
tags question: http://stackoverflow.com/q/78292636
type: Tag
tag name: containers
tags question: http://stackoverflow.com/q/79014732

http://stackoverflow.com/comment/138018170
score: 0
has text: @user15181 ***" Is this OK?"*** If it worked for you than it is. If it did not, then it is not. But neither the csv you are using, nor how you are getting the table headers (eg project name) are defined in your question, making it difficult to provide you a solution, unless someone guesses your actual situation.
comment on: http://stackoverflow.com/q/78286124
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137947725
comment on: http://stackoverflow.com/a/78243565
has text: Thank you, this is working very well, amazing, yeah it is a nested loop followed by an if statement to check if the file has same prefix, got it. I am not sure why this question had been closed but it is different from what they said it is a duplicate because this is not about subsequent pairs of files, it is one file in the first array paired with not one file in second array but one group of files, if you can vote to reopen appreciated
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137803698
has text: You never need sed when you're using awk, you shouldn't use a shell loop for this (https://unix.stackexchange.com/q/169716/133219), if you did use a shell loop that's not how you'd write it (https://mywiki.wooledge.org/BashFAQ/001), and do as the [tag:bash] tag you used instructs and "For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting them here.".
comment on: http://stackoverflow.com/q/78165163
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137881965
has text: For the sake of documentation, with focus on the initial issue: "If I concatenate "IP" with $i, I end up with the name of my variable: IP1, IP2, ... but how can I refer to the value of this variable?" This technique is called "indirect" and is documented in https://stackoverflow.com/tags/bash/info My solution was simply to do this: ``` for i in $(seq 1 2) do target="IP"$i echo "${!target}" #I can then do smth like ping -c1 -W10 ${!target} done ```
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78207789
type: Comment

sqlite
tags question: http://stackoverflow.com/q/78181239
tag name: sqlite
type: Tag
tags question: http://stackoverflow.com/q/78881011
tags question: http://stackoverflow.com/q/79074334

azure-keyvault
tag name: azure-keyvault
type: Tag
tags question: http://stackoverflow.com/q/78261175

http://stackoverflow.com/comment/138000123
type: Comment
has text: You shouldn't have a space before `[.@]`
type: QuestionComment
comment on: http://stackoverflow.com/q/78276987
score: 0

http://stackoverflow.com/comment/138050927
score: 3
type: QuestionComment
type: Comment
has text: Are you sure that `subprocess.run` is actually using `bash`? Try `run('_get_app_creation_timestamp', shell=True, executable='/bin/bash')`.
comment on: http://stackoverflow.com/q/78305587

http://stackoverflow.com/comment/137837740
type: QuestionComment
type: Comment
has text: Try `sed -i "/^[^#]/ s|\(\^PASS *= *\)[^ ]*|\1${conf//[&$'\n'|\\]/\\&}|g" file.ini`
score: 0
comment on: http://stackoverflow.com/q/78185284

http://stackoverflow.com/comment/137834121
has text: (in general, on modern operating systems that use paging, the OS will figure out on its own that a given piece of memory isn't being accessed frequently and swap it out, if there's memory pressure enough that not everything can afford to stick around in physical memory at once).
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78182867

http://stackoverflow.com/comment/137818161
score: 0
type: QuestionComment
type: Comment
has text: You aren't quoting inside `[[ -d ${target} ]]`, which is potentially a problem. You may also need to use GNU ls instead of the BSD version with `gls -Qd` if you want to ensure the output of each ls entry is quoted. And why not just `-n "$2" ` instead of reinventhing it with `isnull`?
comment on: http://stackoverflow.com/q/78166124

http://stackoverflow.com/comment/137908491
comment on: http://stackoverflow.com/q/78224799
type: QuestionComment
type: Comment
score: 0
has text: xargs reads content from stdin and moves it to command line arguments. _By default_ it performs roughly shell-like parsing of input (trying to honor quotes/backslashes/etc), but when either `-0` is used to split on NULs or `-d` is used to specify a different delimiter, it skips that parsing and _only_ splits on the desired character. `-n 1` tells it to only put one hostname on each nslookup command's arguments -- that might be unnecessary, but since I didn't check the nslookup manual it seemed prudent.

http://stackoverflow.com/comment/137873110
type: Comment
type: AnswerComment
has text: I know that colon shouldn't be used that way ^^. Edit is already on the way, but shellcheck still didn't found it. So as I trusted shellcheck, I didn't notice it. Thank you by the way
score: 1
comment on: http://stackoverflow.com/a/78199319

http://stackoverflow.com/comment/137996395
comment on: http://stackoverflow.com/a/78274517
score: 1
has text: Thank you Ed, for your answer and especially for the explanation of why $PATH needs to be added to the end.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137787830
comment on: http://stackoverflow.com/a/78156830
score: 1
has text: technically you're not declaring a *local copy* of each array but rather dynamically (re)declaring (on each pass through the loop) a type of symlink from `sublist` to the desired array; if you make a change to `sublist` you'll find the change is actually made to the underlying/referenced array (ie, that wouldn't happen with a *copy* of the array)
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137814819
score: 0
comment on: http://stackoverflow.com/a/78171801
type: Comment
type: AnswerComment
has text: Awesome everybody, thanks

puppet
type: Tag
tag name: puppet
tags question: http://stackoverflow.com/q/78155690
tags question: http://stackoverflow.com/q/78953169

http://stackoverflow.com/comment/137788159
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78156916
type: Comment
has text: Thanks for the reply, but even in a little more complex script like this `#!/bin/bash DAYS=$1 DIR=$2 PAT=${3:-'*'} DEL=${4:-''} CONF=${5:-''} FILES=() while IFS= read -r -d $'\0'; do FILES+=("$REPLY") done < <(find "$DIR" -type f -mtime +"$DAYS" -name "$PAT" -print0) for FILE in "${FILES[@]}"; do echo "$FILE" if [ "$DEL" = "--delete" ]; then if [ "$CONF" = "--confirm" ]; then read -p "Sei sicuro" -n 1 -r echo if [[ $REPLY =~ ^[Ss]$ ]]; then rm "$FILE" fi else rm "$FILE" fi fi done`

http://stackoverflow.com/a/78149915
answers question: http://stackoverflow.com/q/78149866
has body: Use a nested if block to call useradd with the -g wheel option. Also, remember to quote all your variables. read -p "^^^ Would you like to setup a new user? yes or no: " NEWUSERADD if [ "$NEWUSERADD" = "yes" ]; then echo read -p "Enter a username: " NAME read -p "^^^ Add new user to the wheel group? yes or no: " NEWUSERWHEEL if [ "$NEWUSERWHEEL" = "yes" ]; then useradd -m -g wheel "$NAME" else useradd -m "$NAME" fi passwd "$NAME" else echo read -p "**** Not creating a user. Hit [Enter] to continue ****" fi
type: Answer
score: 0

tee
tag name: tee
tags question: http://stackoverflow.com/q/78240309
type: Tag
tags question: http://stackoverflow.com/q/78331935
tags question: http://stackoverflow.com/q/78539667
tags question: http://stackoverflow.com/q/78573688
tags question: http://stackoverflow.com/q/78661614
tags question: http://stackoverflow.com/q/79039745
tags question: http://stackoverflow.com/q/79171297
tags question: http://stackoverflow.com/q/79499872

excel
tags question: http://stackoverflow.com/q/78286124
tag name: excel
type: Tag

http://stackoverflow.com/comment/137963719
type: QuestionComment
has text: `!=` is not a regex in bash - it's a negative glob match. Similar, but not the same.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78254632

ubuntu
type: Tag
tags question: http://stackoverflow.com/q/78290118
tags question: http://stackoverflow.com/q/78218123
tags question: http://stackoverflow.com/q/78195387
tags question: http://stackoverflow.com/q/78146724
tags question: http://stackoverflow.com/q/78152355
tags question: http://stackoverflow.com/q/78228745
tag name: ubuntu
tags question: http://stackoverflow.com/q/78155690
tags question: http://stackoverflow.com/q/78297320
tags question: http://stackoverflow.com/q/78146600
tags question: http://stackoverflow.com/q/78366286
tags question: http://stackoverflow.com/q/78419450
tags question: http://stackoverflow.com/q/78419884
tags question: http://stackoverflow.com/q/78385195
tags question: http://stackoverflow.com/q/78570634
tags question: http://stackoverflow.com/q/78502959
tags question: http://stackoverflow.com/q/78518786
tags question: http://stackoverflow.com/q/78484913
tags question: http://stackoverflow.com/q/78716440
tags question: http://stackoverflow.com/q/78729706
tags question: http://stackoverflow.com/q/78806346
tags question: http://stackoverflow.com/q/78755032
tags question: http://stackoverflow.com/q/78802409
tags question: http://stackoverflow.com/q/78812372
tags question: http://stackoverflow.com/q/78792841
tags question: http://stackoverflow.com/q/78834215
tags question: http://stackoverflow.com/q/78849261
tags question: http://stackoverflow.com/q/78811660
tags question: http://stackoverflow.com/q/78994422
tags question: http://stackoverflow.com/q/78987993
tags question: http://stackoverflow.com/q/79073086
tags question: http://stackoverflow.com/q/79088795
tags question: http://stackoverflow.com/q/79336136
tags question: http://stackoverflow.com/q/79321546
tags question: http://stackoverflow.com/q/79302612
tags question: http://stackoverflow.com/q/79541083
tags question: http://stackoverflow.com/q/79535156
tags question: http://stackoverflow.com/q/79528513
tags question: http://stackoverflow.com/q/79544368

http://stackoverflow.com/comment/138042025
has text: My suggestion in my last comment doesn't require extra typing in the terminal.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78298728

http://stackoverflow.com/a/78312608
answers question: http://stackoverflow.com/q/78297014
score: 0
has body: Using jq: $ jq -sRc 'split("\n")[]|strptime("[%a %b %e %T %Y]")' test.log [2024,3,9,3,32,21,2,99," {cmd1}"] [2024,3,9,3,33,42,2,99," {cmd2}"] [2024,3,9,3,35,51,2,99," {cmd3}"] $ jq -sRr 'split("\n")[]|strptime("[%a %b %e %T %Y]")|strftime("%F %X") + values[-1]' test.log 2024-04-09 03:32:21 {cmd1} 2024-04-09 03:33:42 {cmd2} 2024-04-09 03:35:51 {cmd3} taking it further... here's an example using ps that looks similar to your test.log $ ps -eo pid,lstart,command PID STARTED COMMAND 1 Tue Mar 26 00:19:40 2024 /usr/lib/systemd/systemd --switched-root --system --deserialize 30 2 Tue Mar 26 00:19:40 2024 [kthreadd] 3 Tue Mar 26 00:19:40 2024 [rcu_gp] ps -eo pid,lstart,command | jq -sRr 'split("\n")[1:-1] | map([split("[\\s]+";"x")[]|select(length>0)] | { pid: .[0], time: .[4], cmd: .[6], args: .[7:] })' Output [ { "pid": "1", "time": "00:19:40", "cmd": "/usr/lib/systemd/systemd", "args": [ "--switched-root", "--system", "--deserialize", "30" ] }, { "pid": "2", "time": "00:19:40", "cmd": "[kthreadd]", "args": [] }, { "pid": "3", "time": "00:19:40", "cmd": "[rcu_gp]", "args": [] } ]
type: Answer

http://stackoverflow.com/comment/137855633
score: 0
has text: I kind of got it going - but its not running each as a variable its adding all the lines in at once.
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78233340
type: Answer
has comment: http://stackoverflow.com/comment/137923626
answers question: http://stackoverflow.com/q/78233301
has comment: http://stackoverflow.com/comment/137924150
has body: The following command did the translation for me sed 's/\\n/\n/g ; s/\\t/\t/g' - Just have to note that you need to mark the end of your file (i.e. put Ctrld enter )
score: 0
has comment: http://stackoverflow.com/comment/137924193

http://stackoverflow.com/comment/137789705
has text: @Jinux you'd have to trace the flow of execution in each implementation to be sure what is happening. I can't immediately find the relevant part of the [source](https://github.com/gitGNU/gnu_bash)
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78155222

http://stackoverflow.com/comment/137856169
has text: code so far https://pastecode.io/s/nkdib49c
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
type: Comment

http://stackoverflow.com/comment/137963650
has text: It tries to print format as float %f/ printf will fail if argument is not number
comment on: http://stackoverflow.com/a/78255939
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137988439
score: 0
has text: BTW, note that all variables in shell are global _unless you explicitly declare otherwise_. If you want the various `path` variables you define in your functions to be local to those functions, you'll want the line `local path` to be present within that function.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78270350

http://stackoverflow.com/comment/137935047
score: 0
type: QuestionComment
type: Comment
has text: Use a variable to hold the value of the `cell` flag, and give it a default value. Then use `getopts` to process the command-line arguments, and update the variable when processing `--cell`.
comment on: http://stackoverflow.com/q/78239545

http://stackoverflow.com/comment/137785927
comment on: http://stackoverflow.com/q/78155628
score: 1
type: QuestionComment
has text: I don't see how calling `sed` from Vim would be quicker then using the very Vim. Precise timings should be benchmarked, of course. Write a function, call it from any mapping a hundred of times.
type: Comment

http://stackoverflow.com/comment/137922446
type: Comment
has text: BTW, all the `awk` runs are needless. `id=${chapter_id##*=}` is **far** faster.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78232246

http://stackoverflow.com/comment/137864644
has text: Fair, newlines do break as well. I will address. But really the `awk` solution is probably the best in my opinion.
score: 0
comment on: http://stackoverflow.com/a/78200333
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137939492
has text: @konsolebox net-firewall/iptables-1.8.10 depends on app-eselect/eselect-iptables-20220320 (equery doesn't list; qdepends does); dev-lib/gmp-6.3.0-r1 (output from eix-installed) shows nothing for me for qdepends but does if I leave out the version
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78241761

http://stackoverflow.com/comment/137771740
score: 3
has text: If you don't insist on `sed` or `awk`, a simple shell loop would suffice; `while IFS= read -r line; ./prepend_largest_prime.sh "$line"; done < input_file.txt`.
comment on: http://stackoverflow.com/q/78147701
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137866790
score: 1
type: QuestionComment
type: Comment
has text: You might also want to do a similar inspection of the `getent group` output. If you ran, say, `group_members=$(getent group pan-sgg-dalas)` and then added `declare -p computer_name group_members >&2` to your script, that would make the script's output have enough details that someone else who isn't you could run `printf '%s\n' "$group_members" | grep -q "$computer_name"` and get the same results you have here.
comment on: http://stackoverflow.com/q/78201574

http://stackoverflow.com/comment/137831034
score: 0
comment on: http://stackoverflow.com/q/78166124
type: QuestionComment
has text: @ToddA.Jacobs I believe you are thinking of single brackets. Quoting is not needed in double brackets. See section 3.6 here: https://www.baeldung.com/linux/bash-single-vs-double-brackets. And the reason for having a function just do one simple thing is just so I could remember it back in the day and now it's all over my code, I don't even notice it. Easy to remember "isnull" but hard to remember -z $var or whatever. Cheers.
type: Comment

http://stackoverflow.com/comment/137807129
comment on: http://stackoverflow.com/a/78167823
type: Comment
score: 0
type: AnswerComment
has text: Piped out the awk ` | sort -rn -k1`

bitbucket-pipelines
type: Tag
tag name: bitbucket-pipelines
tags question: http://stackoverflow.com/q/78238193
tags question: http://stackoverflow.com/q/78454099
tags question: http://stackoverflow.com/q/78585407

http://stackoverflow.com/comment/137769527
type: QuestionComment
score: 2
type: Comment
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code (e.g. mistaken use of `set`). The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
comment on: http://stackoverflow.com/q/78146405

http://stackoverflow.com/comment/137807124
comment on: http://stackoverflow.com/a/78167873
score: 1
type: Comment
has text: please try again, it should work now
type: AnswerComment

http://stackoverflow.com/comment/137923469
type: Comment
score: 1
has text: Does this answer your question? [JQ how to print newline and not newline character from json value](https://stackoverflow.com/questions/32715008/jq-how-to-print-newline-and-not-newline-character-from-json-value). The answers there explain how to do this both with `jq` and with `sed`
type: QuestionComment
comment on: http://stackoverflow.com/q/78233301

http://stackoverflow.com/comment/137988203
comment on: http://stackoverflow.com/q/78270350
type: Comment
has text: (As a completely unrelated matter that has nothing to do with your problem -- `function funcname() {` merges the 1980s ksh syntax `function funcname {` and the modern (1990s) POSIX sh syntax `funcname() {` into an amalgam that's needlessly incompatible with _both_ legacy ksh and POSIX sh; bash only supports `function` for ksh backwards compatibility, and even then it's not quite compatible with the original ksh behavior where its use changed behavior of `typeset`; there's no reason to use it in modern code).
type: QuestionComment
score: 0

http://stackoverflow.com/comment/137840893
has text: Very super special indeed. +1
type: AnswerComment
comment on: http://stackoverflow.com/a/78186982
score: 0
type: Comment

http://stackoverflow.com/comment/137850096
type: Comment
type: AnswerComment
has text: Thanks for this. The 'mapfile' suggestion works, but the output format means extra tweaks will be needed to reformat. The majority of the users simply won't entertain this :(. Unfortunately when I run the script with the 'declare -p' entries I get the same block for each variable :( The blocks of 4 are correct but each of the variables are output as: declare -- var_1="2345" declare -- var_2="2345" declare -- var_3="2345" declare -- var_4="2345"
comment on: http://stackoverflow.com/a/78188212
score: 0

completion
tag name: completion
tags question: http://stackoverflow.com/q/78204849
type: Tag
tags question: http://stackoverflow.com/q/78983217
tags question: http://stackoverflow.com/q/79369897

http://stackoverflow.com/comment/137832166
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78182030
score: 0
has text: When you say you want to time aliases, do you mean you want to time *alias expansion* by the shell, or do you mean you want to time the execution of the aliased command? Alias expansion should always be pretty fast because, as you note, aliases' values are expanded at the time you define the alias. When an alias is expanded, the shell just has to swap the alias's already-fully-expanded value in place of its name.

http://stackoverflow.com/comment/137773351
has text: This does leave variable `env` set in the host environment after the `mvn` command terminates, which the original does not.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78148131
score: 0

http://stackoverflow.com/comment/137886334
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78211596
has text: I have tried what you wrote. awk for InternalIP will not work when I try it in the terminal (lLinux), it comes out empty.
score: 0

http://stackoverflow.com/comment/137855158
score: 3
has text: `interfaces=( /sys/class/net/* ); interfaces=( "${interfaces[@]##*/}" )` for example will give you an array called `interfaces` with values `"${interfaces[0]}"` through `"${interfaces[5]}"` (assuming that's the number of items you actually have).
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137858169
score: 2
type: Comment
has text: You can just write `IFS="$sMABz_IFS"`. The double quotes prevent processing the `|` inside the value of `sMABz_IFS`, and the single quotes are being added literally.
comment on: http://stackoverflow.com/q/78196593
type: QuestionComment

http://stackoverflow.com/comment/137888261
type: Comment
score: 0
has text: Thank you for helping me everyone! I can understand this regular expression now. I really appreciate your help.
type: QuestionComment
comment on: http://stackoverflow.com/q/78213645

http://stackoverflow.com/comment/137913404
type: QuestionComment
type: Comment
has text: @yshavit ah I see. o/` the more you know o/`
score: 1
comment on: http://stackoverflow.com/q/78227591

eof
tag name: eof
tags question: http://stackoverflow.com/q/78263189
type: Tag

http://stackoverflow.com/a/78263365
has body: You cannot embed shell code directly into a heredoc. How is the shell supposed to recognize that it's meant as code, not data? The whole idea has bad code smell, but if for some reason you think that's your best alternative (as opposed, say, to piping the appropriate data into the command's standard input) then you can take advantage of the fact that command substitution is performed inside heredocs, provided that the delimiter word is presented unquoted. Additionally, you seem to want to pull out not just "uboot" but also "extra" as special cases. You can do that within your for loop by simply testing for those keys and producing no output for them, leaving them to be handled separately. However, I would consider instead just omitting them from the NameUrl array, or else creating a separate array that omits them. For example: $ sudo sfdisk "/dev/$DEV" --wipe always <<EOF label: gpt first-lba: 64 table-length: 10 attrs="RequiredPartition, type=D7B1F817-AA75-2F4F-830D-84818A145370, start=64", size=32704 name="${BASE}-uboot" $( for name in "${!NameUrl[@]}"; do case ${name} in uboot|extra) continue ;; esac printf '%s\n' "attrs=\"$ATTR\", size=$SIZE, name=\"$BASE-${name}\"" done | sort ) attrs="$ATTR", size=+, name="extra" EOF Note that I took the liberty of adding double quotes around the attributes for the uboot line, for consistency with the other lines.
answers question: http://stackoverflow.com/q/78263189
score: 3
type: AcceptedAnswer
upvote count: 3
accepted answer of: http://stackoverflow.com/q/78263189
downvote count: 0
type: Answer

http://stackoverflow.com/comment/137935462
type: Comment
has text: Which is all to say -- when I identified myself as a grumpy graybeard I meant it :) -- the kind of stack I trust to automate administration of my servers is tooling where every part of the stack is OSS and there's a very solid audit log of how every component was built / from which inputs and those builds are fully reproducible.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78239018

http://stackoverflow.com/comment/137945887
type: QuestionComment
type: Comment
has text: In `cat foo | tee foo`, `tee` _may_ open the file with the `O_TRUNC` and thus empty its contents before `cat` finishes reading from it -- it's a race condition. There's no guarantee that it will or won't, so any code that assumes either way is inherently buggy. If you're reliably getting results that mean that `cat` wins the race, then you're obviously testing with (relatively) small files, and on systems with predictable timing characteristics. :)
comment on: http://stackoverflow.com/q/78245937
score: 3

http://stackoverflow.com/comment/137829802
has text: Your output doesn't include *anything* from the `if` statement that either creates or reactivates your virtual environment, so it's not clear if `pip install` ever executed.
comment on: http://stackoverflow.com/q/78180816
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137938365
type: Comment
score: 0
has text: I'm a greybeard who started using UNIX around 1984. Back then when you often connected to a computer over a single serial connection being able to background processes was important. I haven't backgrounded a job in the past 20 years. There are much better alternatives today. Such as using `tmux` or your terminal's ability to have multiple tabs/windows. As Duffy pointed out your script is explicitly placing jobs into the background without waiting for them to finish (done using the `wait` builtin). But if you want them to run sequentially why background them at all?
type: QuestionComment
comment on: http://stackoverflow.com/q/78228111

calculator
tag name: calculator
type: Tag
tags question: http://stackoverflow.com/q/78158852

telegraf
tags question: http://stackoverflow.com/q/78222483
tag name: telegraf
type: Tag

msys2
type: Tag
tags question: http://stackoverflow.com/q/78152355
tag name: msys2
tags question: http://stackoverflow.com/q/78778821
tags question: http://stackoverflow.com/q/79120307

http://stackoverflow.com/comment/137917156
type: QuestionComment
has text: Totally agree with the 2 comments above. echo "$HELLOPRINT" will not interpret \n by default, if you want to echo interpreting the escape sequences (each hello on new line) you can use ```echo -e "$HELLOPRINT"```
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78229406

http://stackoverflow.com/comment/137876672
type: QuestionComment
has text: None of them offers a solution to my problem. I know how to run my server continuously. The challenge is to restart the app (running "npm run server") after the EC2 restarts.
comment on: http://stackoverflow.com/q/78177847
type: Comment
score: 0

http://stackoverflow.com/a/78255128
type: Answer
has body: You dont need to put square brackets around grep command as it already returns "0" or "1" which is what exactly if needs. here for example: $ grep -q PASS /tmp/file $ echo $? 0 $ grep -q FOO /tmp/file $ echo $? 1 So your code could be: $ if grep -q PASS /tmp/file && grep -q "All tests fine" /tmp/file2 ; then echo "PASS"; fi PASS $ cat /tmp/file PASS $ cat /tmp/file2 All tests fine let me know if this is not what you are looking for.
answers question: http://stackoverflow.com/q/78255091
accepted answer of: http://stackoverflow.com/q/78255091
type: AcceptedAnswer
score: 0

http://stackoverflow.com/comment/138038401
has text: The answer is probably to replace `sleep 1` with `sleep 1 & wait`. Since `sleep` ignores SIGINT, your script may choose not to handle the signal when it sees that `sleep` exited normally.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78298936
type: Comment

http://stackoverflow.com/comment/138009717
score: 0
comment on: http://stackoverflow.com/q/78278018
type: QuestionComment
type: Comment
has text: You have to check the man page on your mac to see what your grep supports. Open a terminal and type `man grep` (or `man 1 grep` to be specific). It will list the options. You can also just type `grep --help`.

http://stackoverflow.com/a/78183686
score: 2
answers question: http://stackoverflow.com/q/78183685
upvote count: 2
has body: I was able to come with a solution that works in bash and dash but not in fish: rz &lt;&gt;/dev/ttyUSB0 &gt;&amp;0 &lt;&gt; opens file in read-write mode. It is used as stdin. &gt;&amp;0 redirects stdout to the file descriptor used by stdin.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/137835414
has comment: http://stackoverflow.com/comment/137835682

http://stackoverflow.com/comment/137882194
has text: Have a look at [this post on ServerFault](https://serverfault.com/a/592941/142978) and/or [this duplicate](https://stackoverflow.com/q/3830823/1765658)
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78210154
type: Comment

http://stackoverflow.com/comment/137820473
type: Comment
comment on: http://stackoverflow.com/q/78175689
score: 0
has text: Enclose both commands in parenthesis or braces : `{ sudo apt update && sudo apt -y upgrade ;} > >(sed "s/^/[prefix1]/") 2> >(sed "s/^/[prefix2]/" >&2)`
type: QuestionComment

http://stackoverflow.com/comment/137840993
comment on: http://stackoverflow.com/a/78176886
has text: I really appreciate your help in this, that link is very useful too thank you!
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/comment/137814146
type: Comment
has text: I don't get your point @nbk. There's no connection between the source of the command's input and what the command does. You can provide commands to `mysql` from one file, which tell mysql to write a different file. See example for proof of concept.
comment on: http://stackoverflow.com/a/78171975
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137993441
has text: Not fully understand what you trying to do but there is an option to create readonly vars: `declare -r SOME_VAR=1` Now if you try to write to this var or source it, it won't change.
type: Comment
comment on: http://stackoverflow.com/q/78272610
type: QuestionComment
score: 0

http://stackoverflow.com/comment/137992732
comment on: http://stackoverflow.com/q/78272610
score: 0
type: QuestionComment
has text: Doesn't work if `SOME_VAR` as unset.
type: Comment

http://stackoverflow.com/comment/138007431
comment on: http://stackoverflow.com/a/78281278
type: Comment
has text: I think the point is that they don't control how `bash_var` is created, they want to make it correct when passing it to `awk`.
type: AnswerComment
score: 1

http://stackoverflow.com/comment/137810286
has text: @CharlesDuffy, even following the pointers in the section, I tried `ve() { source $1/bin/activate; ve}` as indicated in the answer but no, it doesn't activate the environment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/78169487
type: AnswerComment

http://stackoverflow.com/comment/137973374
score: 0
comment on: http://stackoverflow.com/q/78261247
type: QuestionComment
type: Comment
has text: consider manually stepping through your script for each line of input; what happens when `count == 1`? `count == 0` never occurs

http://stackoverflow.com/comment/137789555
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78157136
type: AnswerComment
has text: This gives another insight. Thank you.

http://stackoverflow.com/comment/137824659
has text: Why not use `wc -l`, that's what it's for?
score: 1
comment on: http://stackoverflow.com/q/78177875
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137935079
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78239545
has text: tip: either use `bash launch_training.sh` or don't use bash-isms in your script
type: QuestionComment

http://stackoverflow.com/comment/137856064
score: 0
has text: Thank you - doesnt seem to be running "ip route add "$broadcast" dev "$interface" table vrack" even after its been flushed - works when i manually add the command
comment on: http://stackoverflow.com/q/78194973
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137840578
type: QuestionComment
has text: `why this aspect was not cleaned up` I do not understand. What is there to clean up? Is something dirty in `"$@"`?
comment on: http://stackoverflow.com/q/78186259
score: 2
type: Comment

http://stackoverflow.com/comment/137923046
has text: The `testcommand` is recognized by `command -v`, but after sourcing the bashrc, I can nevertheless not run that alias command (simply by entering `testcommand`), even with the `shopt -s` flag. The `subprocess` call would be like `subprocess.Popen(/bin/bash -c source /home/wssadmin/.bashrc; shopt -s expand_aliases; testcommand, ...)`. Is there another flag that needs to be set?
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78232840

http://stackoverflow.com/comment/137769325
score: 0
type: QuestionComment
has text: Use `local loopSwitch` at begin of your function
type: Comment
comment on: http://stackoverflow.com/q/78146405

http://stackoverflow.com/comment/137850808
has text: Something missing in `sudo`? What do you mean by "use" PAM in a script? What do you want to "use" and how exactly?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78192206
type: Comment

http://stackoverflow.com/comment/138037847
score: 0
has text: the question has been tagged with `bash` but the script has a shebang of `#!/bin/sh`; while `/bin/sh` may actually refer to `/bin/bash` in *your* environment this is not guaranteed to be the case in other environments (eg, in my Ubuntu environment `/bin/sh` is actually `/bin/dash`); if your intent is to run your script under `bash` then consider updating the script with an explicit reference to `bash` in the shebang (ie, `#!/bin/bash` or `#!/bin/env bash`)
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78292693

http://stackoverflow.com/comment/137872495
has text: In this case, it would have made more sense to post a simple `echo ...... | sed .....`, which demonstrates the problem. No need to mention your file, and we would then have a testcaes which can be reproduced by everyone.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78196837
type: Comment

http://stackoverflow.com/comment/137921763
has text: thx, the solution you provided worked! I accepted it and upvoted as well :)
type: Comment
comment on: http://stackoverflow.com/a/78230530
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137871678
score: 0
comment on: http://stackoverflow.com/q/78203871
type: QuestionComment
type: Comment
has text: I'm not too hung up on the rest of the script running inside the newly created shell, I just want the rest of the script to run at all. Ctrl+D also works in my testing, but unfortunately I cannot rely on user interaction for my purposes.

http://stackoverflow.com/comment/137791957
has text: https://www.gnu.org/s/bash/manual/ might be a better link, it has HTML sections you can link to.
score: 1
comment on: http://stackoverflow.com/a/78158865
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137856092
type: QuestionComment
comment on: http://stackoverflow.com/q/78194973
type: Comment
score: 0
has text: its still trying to add both "ip route add default dev eth0 eth1 table vrack"

http://stackoverflow.com/comment/137945947
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78245937
has text: BTW, general note, prefer `<foo` to `cat foo |`. It doesn't make a huge difference for `grep`, but a lot of standard UNIX tools can optimize their performance when given a seekable file descriptor -- `sort` can have different threads sort different subsets of the file in parallel and merge the results; `tail` and `tac` can jump direct to the end without reading intervening content (and `tac` can move the file pointer backwards towards the front of the file as it goes); `wc -c` can just use `seek()` and `tell()` (or a `stat`-family syscall) to check the file's size in constant time; etc.

http://stackoverflow.com/comment/137993389
type: Comment
comment on: http://stackoverflow.com/a/78272868
score: 0
has text: If you don't want to spend another variable, you can also print the value to a file and restore it from there.
type: AnswerComment

http://stackoverflow.com/comment/137905139
type: Comment
type: AnswerComment
score: 0
has text: I use "$LINE" in a more or less report with further system information. I will do this in a crontab job to get the history of the memory usage for the current day. Unfortunately, I don't know any other way to find the memory consumption of the last 24 hours. Thanks for the help, the tip with the system resources and use only awk command makes totally sense.
comment on: http://stackoverflow.com/a/78220527

http://stackoverflow.com/comment/137771378
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78146724
has text: what's the output when you run `run test_01.py` manually from the command prompt? what's the output when you run `run test_02.py` manually from the command prompt?
type: Comment

http://stackoverflow.com/a/78283992
answers question: http://stackoverflow.com/q/78280175
has body: I wouldn't normally answer a question that doesn't contain any attempt by the OP to solve the problem themselves, but since this one has multiple answers already ... using any awk: $ awk -F'[_\t]' -v OFS='\t' 'NR==FNR{a[$1]=$0; next} {print a[$1], $0}' file1 file2 a 1 2 3 a_rna_1 r r x a 1 2 3 a_rna_2 q q d a 1 2 3 a_rna_3 c c c b 6 7 8 b_rna_1 e e e c 9 0 9 c_rna_1 a a g
score: 0
type: Answer

http://stackoverflow.com/comment/137877802
comment on: http://stackoverflow.com/q/78207789
type: Comment
has text: Each Stack Overflow question should be about _one_ underlying technical question. For example, the `IP$i` part is answered by our existing Q&A about "dynamic" or "indirect" variables in bash
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137864550
has text: It wasn't 8:11am CST when you posted this, it was 8:11am CDT.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78200396
score: 0

http://stackoverflow.com/comment/137823679
has text: This would set `$first_line` outside the while loop?
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78177452

http://stackoverflow.com/comment/138038665
type: QuestionComment
comment on: http://stackoverflow.com/q/78298936
score: 0
has text: trap SIGUSR1 and send SIGUSR1
type: Comment

command
tags question: http://stackoverflow.com/q/78164579
tag name: command
type: Tag
tags question: http://stackoverflow.com/q/78393091
tags question: http://stackoverflow.com/q/78444070
tags question: http://stackoverflow.com/q/78362703
tags question: http://stackoverflow.com/q/78561876
tags question: http://stackoverflow.com/q/78538377
tags question: http://stackoverflow.com/q/78682104
tags question: http://stackoverflow.com/q/78808231
tags question: http://stackoverflow.com/q/78811543
tags question: http://stackoverflow.com/q/78899277
tags question: http://stackoverflow.com/q/79159487

docker-compose
tags question: http://stackoverflow.com/q/78292636
type: Tag
tags question: http://stackoverflow.com/q/78202033
tag name: docker-compose
tags question: http://stackoverflow.com/q/78374366
tags question: http://stackoverflow.com/q/78332428
tags question: http://stackoverflow.com/q/78479103
tags question: http://stackoverflow.com/q/78588025
tags question: http://stackoverflow.com/q/78500956
tags question: http://stackoverflow.com/q/78663492
tags question: http://stackoverflow.com/q/78987363
tags question: http://stackoverflow.com/q/78961912
tags question: http://stackoverflow.com/q/79100587
tags question: http://stackoverflow.com/q/79109633
tags question: http://stackoverflow.com/q/79091421
tags question: http://stackoverflow.com/q/79301901
tags question: http://stackoverflow.com/q/79443511
tags question: http://stackoverflow.com/q/79528513

http://stackoverflow.com/comment/137999405
has text: fwiw, `x=123; x=hello.world echo $x` will print `123` since the `$x` is expanded before the `x=hello.world` is executed; and if `x` is undefined then `x=hello.world echo $x` will print a blank line
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78276574
score: 0

http://stackoverflow.com/comment/138056310
score: 0
type: QuestionComment
has text: @JohnBollinger you are absolutely right. But this was to be an easy change to add functionality and doing that could mean me refactoring thousands of lines of code. I will create a Jira task for that. But I need a fast approach for the moment.
type: Comment
comment on: http://stackoverflow.com/q/78305587

http://stackoverflow.com/comment/137908800
type: QuestionComment
comment on: http://stackoverflow.com/q/78225038
type: Comment
score: 1
has text: If it's so important you can re-implement what execve does with scripts and change arg. 0 before actually calling execve. The manpage for execve is pretty detailed

netpbm
tags question: http://stackoverflow.com/q/78261118
type: Tag
tag name: netpbm

function
tags question: http://stackoverflow.com/q/78241462
tags question: http://stackoverflow.com/q/78203984
tag name: function
type: Tag
tags question: http://stackoverflow.com/q/78211473
tags question: http://stackoverflow.com/q/78284887
tags question: http://stackoverflow.com/q/78390602
tags question: http://stackoverflow.com/q/78480370
tags question: http://stackoverflow.com/q/78538302
tags question: http://stackoverflow.com/q/78855437
tags question: http://stackoverflow.com/q/79009885
tags question: http://stackoverflow.com/q/79151673
tags question: http://stackoverflow.com/q/79434419

http://stackoverflow.com/comment/137867634
score: 0
has text: `New` != `NEW`.
type: QuestionComment
comment on: http://stackoverflow.com/q/78200217
type: Comment

http://stackoverflow.com/comment/137908835
comment on: http://stackoverflow.com/a/78225303
type: Comment
has text: It's execve that overwrites argv[0], the manual even warns about it: *Note that there is no way to get the argv[0] that was passed to the execve() call.*
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137802480
type: QuestionComment
comment on: http://stackoverflow.com/q/78165163
type: Comment
score: 1
has text: Note that `awk '/^EEEEEEEEE$/,/^$/ {next} 1' file` would do the same as your complete script, without `sed`, and would also be much safer: no risk to delete partly matching lines, no need to consider lines with regex operators in them... If one of the lines to delete is `.*`, your script will delete all lines. If you have GNU `awk` use `awk -i inplace '/^EEEEEEEEE$/,/^$/ {next} 1' file` for in-place modification.

go
tags question: http://stackoverflow.com/q/78254419
type: Tag
tag name: go
tags question: http://stackoverflow.com/q/78373696
tags question: http://stackoverflow.com/q/78570634
tags question: http://stackoverflow.com/q/78975927
tags question: http://stackoverflow.com/q/79327606
tags question: http://stackoverflow.com/q/79397922
tags question: http://stackoverflow.com/q/79266920

cat
type: Tag
tag name: cat
tags question: http://stackoverflow.com/q/78297320
tags question: http://stackoverflow.com/q/78533115
tags question: http://stackoverflow.com/q/78827774
tags question: http://stackoverflow.com/q/78933042
tags question: http://stackoverflow.com/q/79102410

logging
tags question: http://stackoverflow.com/q/78254419
type: Tag
tag name: logging
tags question: http://stackoverflow.com/q/78445450
tags question: http://stackoverflow.com/q/78607470
tags question: http://stackoverflow.com/q/78810394
tags question: http://stackoverflow.com/q/78989602
tags question: http://stackoverflow.com/q/79070045

http://stackoverflow.com/comment/137849565
type: Comment
comment on: http://stackoverflow.com/q/78187590
type: QuestionComment
score: 0
has text: Thanks all for your comments. For a bit more clarity, the string will always contain hex values with no whitespace and will always have a length of multiples of four. Once the string is split into blocks and the variables created these will then be used further to convert the hex to decimal..

http://stackoverflow.com/comment/137996295
comment on: http://stackoverflow.com/q/78274675
score: 5
has text: Placing `set -x` before any suspect code (and `set +x` afterward to turn it off) can at least give you some insight into how bash is parsing the code which may explain what went wrong. Otherwise the best debugging technique is probably going to be starting with a smaller code sample and trying to work up to a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) - code with `eval` is notoriously hard to even _read_ let alone debug, and the code here is layering multiple invocations of `eval` which compounds that problem.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137942958
type: Comment
comment on: http://stackoverflow.com/q/78244372
has text: Why does running `main.py` modify `main.py`? Is it a self-mutating virus? I'd try to not modify my code like that. But if you must, just copy the script before running, e.g., add a `cp main.py main-$SIZE.py` and then run that instead of plain `main.py`.
type: QuestionComment
score: 0

artifactory
tag name: artifactory
tags question: http://stackoverflow.com/q/78226551
type: Tag

python-3.x
tags question: http://stackoverflow.com/q/78156372
tags question: http://stackoverflow.com/q/78202789
tag name: python-3.x
type: Tag
tags question: http://stackoverflow.com/q/78475004
tags question: http://stackoverflow.com/q/79042155
tags question: http://stackoverflow.com/q/79182504
tags question: http://stackoverflow.com/q/79192699
tags question: http://stackoverflow.com/q/79537639

http://stackoverflow.com/comment/137913409
type: Comment
score: 0
has text: @yshavit added an edit with the bash script i'm using
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591

http://stackoverflow.com/comment/137863035
type: Comment
comment on: http://stackoverflow.com/a/78199112
score: 1
has text: OP wanted to avoid changing it permanently, yes, but isn't this a "just for this command" modification?
type: AnswerComment

http://stackoverflow.com/comment/137953894
has text: thanx very much, but why the output of the echo $f is just one line? shouldn't be 2 lines?
score: 0
comment on: http://stackoverflow.com/a/78250534
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137827383
comment on: http://stackoverflow.com/q/78177875
has text: If the last line doesn't end in `\n` than it's not a valid text file per POSIX and then you can't rely on sed or any other text processing tool handling it as you want either. Why don't your files end with `\n` and can you fix whatever is creating them?
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/137883678
has text: The answer by choroba explains how to fix this. Aside from this, you could also consider writing your shell scripts in zsh instead of bash, where you wouldn't face this problem.
comment on: http://stackoverflow.com/q/78210405
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137792138
comment on: http://stackoverflow.com/a/78158825
type: Comment
score: 0
has text: note the comment on the answer at your link which tells you that removing the sticky bit on /tmp is not a good solution (especially on a multiuser system where it creates a security hole) - just create a subdirectory
type: AnswerComment

sum
tags question: http://stackoverflow.com/q/78176347
tag name: sum
type: Tag

http://stackoverflow.com/comment/137814729
type: Comment
type: AnswerComment
has text: Wow! Really good explanations and I learned lots of new things. I should have added in my question that none of these solutions work (at least out of the box) because I am not really using a static filename (but I left that out so as not to confuse the issue). So instead of 'Test1618' it is really '$FILENAME' which is constructed from a fixed string and today's date. Which means both your solutions break, I think? I can probably figure out a way to write the .sql on the fly and then read it in, but I wonder if there is a cleaner solution...
comment on: http://stackoverflow.com/a/78171975
score: 0

http://stackoverflow.com/comment/137854288
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193
type: Comment
has text: You also forgot the parens around `++TICKCOUNT`. When you write `foo ++bar`, it's syntactically the same as writing `foo ++ bar` or `foo++ bar` so if you want to ensure that awk treats the `++` as a pre-increment of `bar`, i.e. `foo (++bar)`, then that's what you need to write. Awk will TRY to figure out what you meant by the types of `foo` and `bar` but just write what you mean for robustness and clarity.

homebrew
tags question: http://stackoverflow.com/q/78239630
type: Tag
tag name: homebrew
tags question: http://stackoverflow.com/q/78636137
tags question: http://stackoverflow.com/q/78975735
tags question: http://stackoverflow.com/q/79528846

http://stackoverflow.com/comment/137858160
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78196593
type: Comment
has text: What he's referring to are the escaped single quotes in ```IFS=\'...```

http://stackoverflow.com/comment/137769509
comment on: http://stackoverflow.com/q/78146405
score: 0
type: QuestionComment
type: Comment
has text: This doesn't seem to work either. Do you mean to set local just after Guessing_Game() or within the until loop? I am trying to echo my variable also, and it keeps printing a blank line

http://stackoverflow.com/a/78270165
has body: Use a loop so you can process each subdirectory separately. for dir in targetvolume/targetdir/*/myfolder do base=$(basename "$(dirname "$dir")") rsync -ahv "$dir/" "./outputdir/$base/myfolder/" done
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78269359

http://stackoverflow.com/comment/137991946
has text: aliases, non-exported functions, and non-exported variables are absolutely the private business of a given shell, therefore they are not passed on during an `exec`.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78260557
type: QuestionComment

http://stackoverflow.com/comment/137957173
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78252458
has text: Yes, or `cd /etc || { es=$?; echo "cd /etc failed with exit status $es" >&2; exit "$es"; }` or similar. Replace `cd /etc` with whatever command you like.
type: Comment

http://stackoverflow.com/comment/137812324
type: Comment
type: AnswerComment
has text: Good observation. I must be falling behind in my old age `:)`. Thank you.
score: 1
comment on: http://stackoverflow.com/a/78170836

http://stackoverflow.com/comment/137884892
comment on: http://stackoverflow.com/q/78211473
score: 0
type: QuestionComment
type: Comment
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.

http://stackoverflow.com/comment/138012186
comment on: http://stackoverflow.com/q/78283701
type: QuestionComment
type: Comment
has text: using output is very inefficient because spawns subshells, it would be better to use `printf -v varname ...` and working with variables
score: 1

vim
tags question: http://stackoverflow.com/q/78155628
type: Tag
tag name: vim
tags question: http://stackoverflow.com/q/78846569
tags question: http://stackoverflow.com/q/79099799

http://stackoverflow.com/comment/137914493
comment on: http://stackoverflow.com/q/78228111
type: Comment
has text: (...as a completely different matter -- don't use nohup; it's 100% pointless, and does not a single thing that bash can't do itself).
score: 1
type: QuestionComment

http://stackoverflow.com/comment/137893376
type: Comment
has text: @Claudio, `$(pwd)` is generally an antipattern -- it's _much_ slower to execute than just evaluating `$PWD`, and the results differ only in deeply unusual corner cases. More immediately relevant, _either_ `"$(pwd)/$@"` or `"$PWD/$@"` will introduce bugs when `$0` was already an absolute path.
comment on: http://stackoverflow.com/a/78216128
type: AnswerComment
score: 0

http://stackoverflow.com/comment/137939462
comment on: http://stackoverflow.com/q/78241761
type: QuestionComment
has text: @jhnc I have `app-eselect/eselect-iptables-20220320` installed. `equery d app-eselect/eselect-iptables`, `equery d app-eselect/eselect-iptables-20220320`, and `equery d app-eselect/eselect-iptables-20220320::gentoo` for me shows no output after `* These packages depend on app-eselect/eselect-iptables[-20220320]:` besides the irrelevant error message I mentioned earlier in your answer. `qdepends -Q` always shows `qdepends: no matches found for your query`. Commands against `dev-libs/gmp` OTOH show output.
type: Comment
score: 0

gdb
tag name: gdb
tags question: http://stackoverflow.com/q/78178759
type: Tag
tags question: http://stackoverflow.com/q/78901615

http://stackoverflow.com/comment/137955499
type: QuestionComment
score: 4
type: Comment
has text: `%t` is expanded by `magick` later - it's not a variable in your shell. You ask bash to literally take first 8 chars of string `%t`. which is `%t`, and then feed it to the command.
comment on: http://stackoverflow.com/q/78251624

http://stackoverflow.com/comment/138005978
has text: You should check `configure`'s log file, too. That would be `config.log` in the build directory. Also, the first `configure` excerpt you presented is incomplete: a heredoc starts on the third line, and is not yet complete at the end of the excerpt. It looks like you put the `set -x` *inside* the heredoc, which feeds the generated `config.status` script. What's more, I don't see anything in it that connects to the error messages, so I'm inclined to doubt that it's even the right code in the first place.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78274675
type: Comment

redis-cli
type: Tag
tag name: redis-cli
tags question: http://stackoverflow.com/q/78240103

http://stackoverflow.com/comment/137891197
type: QuestionComment
type: Comment
has text: Aside: `declare -p assscheme` is a much more reliable/unambiguous way to display the contents of an associative array.
score: 1
comment on: http://stackoverflow.com/q/78214961

http://stackoverflow.com/comment/137963618
type: Comment
has text: Hi, thank you for your answer. I dont understant the functions isNumber(), how it check if argument is a number? Best regards.
comment on: http://stackoverflow.com/a/78255939
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138055358
has text: Tested. The adding of 10s delay between the calls resolved the problem: `ssh -i "/myssh.key" myuser@host "sudo bash 'echo -e \"ExecStart=/mydir/run-service.sh\" >> /etc/systemd/system/myService.service'"` `sleep 10s` `ssh -i "/myssh.key" myuser@host "sudo systemctl daemon-reload" `
comment on: http://stackoverflow.com/q/78290118
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78215529
upvote count: 1
type: Answer
has body: One idea using the bash/select command to prompt the user to select items from a dynmically built menu: $ cat scheme.1.bash #!/usr/bin/bash unset schemes scheme color declare -A schemes while IFS='=' read -r key value # split input on '='; 'key' == text on left of '='; 'value' == text on right of '=' do schemes[${key}]="${value}" done < schemes select scheme in "${!schemes[@]}" 'Quit' # build menu from array indices + literal 'Quit'; user is then prompted to select from the menu do if [[ -z "${scheme}" ]] # if no selection then ... then echo "invalid scheme; select again ..." # print message and let 'select' prompt for a new input elif [[ "${scheme}" = 'Quit' ]] # if user wants to exit the menu then ... then echo "exiting ..." unset scheme # unset our variable and ... break # break out of the 'select' else select color in ${schemes[${scheme}]} 'Quit' # build a new menu based on the colors of the chosen scheme + 'Quit'; prompt user to select from menu do if [[ -z "${color}" ]] # if no selection then ... then echo "invalid color; select again ..." # print message and let 'select' prompt for a new input elif [[ "${color}" = 'Quit' ]] # if user wants to exit the menu then ... then echo "exiting ..." unset color # unset our variable break 2 # break out of both 'select' loops else break 2 fi done fi done # display results typeset -p scheme color # display contents of variables NOTES: if user chose Quit at any time then one or both of the variables (scheme, color) will be empty in place of the typeset -p scheme color OP can add code to validate both variables are set before proceeding with further processing Taking for a test drive: $ ./scheme.1.bash 1) sch-002 2) sch-001 3) Quit #? 4 invalid scheme; select again ... #? 1 1) green 2) yellow 3) black 4) Quit #? 7 invalid color; select again ... #? 2 declare -- scheme="sch-002" declare -- color="yellow" $ ./scheme.1.bash 1) sch-002 2) sch-001 3) Quit #? 2 1) red 2) blue 3) white 4) Quit #? 4 exiting ... declare -- scheme="sc…
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78214961

http://stackoverflow.com/tag/html
tag name: html
tags question: http://stackoverflow.com/q/78292693
type: Tag
tags question: http://stackoverflow.com/q/78212724
tags question: http://stackoverflow.com/q/78671189
tags question: http://stackoverflow.com/q/79397883

compositing
tags question: http://stackoverflow.com/q/78261118
tag name: compositing
type: Tag

http://stackoverflow.com/comment/138008139
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78281234
type: QuestionComment
has text: Dragons be there. Use the environment like in oguz ismail's answer. With `-v`, you're not only worrying about shell escaping, but the fact that Awk interprets the argument as Awk string literal syntax: so for instance the two-character sequence `\n` becomes a newline character.

http://stackoverflow.com/comment/137922806
type: QuestionComment
comment on: http://stackoverflow.com/q/78232634
type: Comment
score: 1
has text: Something odd happens with the `+(!(x|y))` pattern but you might be able to make that work as you want to by using `@` instead of `+`. Furthermore you can simplify it to just `!(x|y)`.

http://stackoverflow.com/comment/138016782
type: QuestionComment
has text: @mkrieger1 Thank you very much. I am so stupid... =( I spent about 10 hours trying to find a problem. Pls make the answer from your comment i will mark it as answer.
comment on: http://stackoverflow.com/q/78285559
type: Comment
score: 0

imagemagick
tags question: http://stackoverflow.com/q/78251624
type: Tag
tag name: imagemagick
tags question: http://stackoverflow.com/q/78385603
tags question: http://stackoverflow.com/q/78437863
tags question: http://stackoverflow.com/q/79287921

prompt
tags question: http://stackoverflow.com/q/78195172
type: Tag
tag name: prompt
tags question: http://stackoverflow.com/q/78422398

http://stackoverflow.com/comment/137858133
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78196593
type: Comment
has text: Also, you almost certainly don't want to be adding literal single quotes to IFS. They absolutely do not do what you intend: IFS is a collection of literal characters, so `IFS=\'abc\'` is exactly 100% identical to `IFS=cba\'`. One quote character would make sense if you wanted that character to be part of the set; two just implies a misunderstanding of how IFS works.

http://stackoverflow.com/a/78290714
answers question: http://stackoverflow.com/q/78274299
type: Answer
has body: The directories listed in PATH are checked from left to right, and the first match wins. Therefore, putting the bash directory at the end of your PATH does not help much. However, if you have a script which requires a particular bash version, I would not rely on the PATH variable at all. Either I would use a #! line for the script pointing to the desired bash version, make the script executable and then run it just with SCRIPTNAME. Or alternatively, don't care about the #! and execute the script with /opt/homebrew/Cellar/bash/5.2.26/bin/bash SCRIPTNAME Since this is awkward to type, you could consider using symbolic links: ln -s /opt/homebrew/Cellar/bash/5.2.26/bin/bash /usr/local/bin/bash5 and then (on the reasonable assumption that you have /usr/local/bin in your PATH) run it with bash5 SCRIPTNAME
score: 0

http://stackoverflow.com/comment/138016112
has text: please update the question with your awk and/or bash coding attempts
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78286124

http://stackoverflow.com/comment/137926914
has text: `unset v; v+=(1); v+=(2); unset v[0]` I would have stupidly thought 2 would get the index 0 after the second unset… Thx again! ^^ Well, think I have to keep in mind "first element" isn’t forcibly the 0 index element.
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78235101

http://stackoverflow.com/comment/137939370
score: 0
has text: @konsolebox app-eselect/eselect-iptables-20220320 is one example (but the equery output looks wrong); dev-libs/gmp-6.3.0-r1 is another (but qdepends looks wrong). I don't know much about gentoo; maybe down to the version number being included?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78241761

http://stackoverflow.com/comment/137936491
score: 3
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78240671
has text: As a slight aside, what's the reason for storing a command to `eval`, instead of using something like `myJson=$(echo ...)` assuming `echo` as the placeholder for something more complex, or even directly `myJson='{"data": ... }'`?

http://stackoverflow.com/a/78280733
upvote count: 3
has body: I've learned that autoconf and autom4te have a --trace option that could potentially be used to figure out which part of the configure.ac file leads to this generated script section. However, I'm unsure how to effectively use this --trace option for this purpose. Ignore autom4te. It is a support tool used by the front-end Autotools, not really intended for you to use directly. You would leverage it by running autoconf with its --trace option. But I don't see any way that that would serve your purpose. The --trace option provides information about invocations of specific macros that you designate, telling you where those macros are used. That might be of interest if you already knew which macros were involved in generating the text you're looking at, but that's what you're trying to find out. A better initial approach to that problem could be an m4 version of print-statement debugging. Bear in mind that configure is generated from configure.ac by expanding macros appearing in the latter. Anything in configure.ac that is not a macro or an m4 directive is carried through to configure as literal text. Thus, you can put characteristic literal commands in configure.ac that you will recognize in the generated configure. You could consider echo or printf commands with characteristic arguments, such that you could get information from them not only by examining the configure script, but also by running it. For example: AC_INIT([jmodelica.org], [0.0.0]) echo Foad1 AM_INIT_AUTOMAKE() echo Foad2 ... You may be able to do similar by tracking details already present in configure.ac to configure, but that probably will not give you the granularity you want. You do need to be aware that autoconf makes use of m4 facilities that allow it to perform a certain amount of reordering, but I don't think that will interfere too much.
has comment: http://stackoverflow.com/comment/138026410
answers question: http://stackoverflow.com/q/78276793
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78276793
type: Answer
score: 3
type: AcceptedAnswer

http://stackoverflow.com/comment/137832218
comment on: http://stackoverflow.com/q/78182030
score: 3
type: QuestionComment
has text: In any case, if you find yourself using aliases heavily, then you're probably using them *wrongly*. Prefer shell functions or full-blown scripts for most purposes.
type: Comment

stderr
tag name: stderr
tags question: http://stackoverflow.com/q/78175689
type: Tag
tags question: http://stackoverflow.com/q/78885332
tags question: http://stackoverflow.com/q/78824592
tags question: http://stackoverflow.com/q/79039745
tags question: http://stackoverflow.com/q/79055675
tags question: http://stackoverflow.com/q/79449855

http://stackoverflow.com/comment/137858207
score: 1
type: QuestionComment
type: Comment
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
comment on: http://stackoverflow.com/q/78196593

segmentation-fault
type: Tag
tags question: http://stackoverflow.com/q/78178759
tag name: segmentation-fault

http://stackoverflow.com/a/78156830
score: 3
has body: MarkP-Fuso, thank you very much for your reply! It is indeed the nameref that I couldn't get my head around (it's still a bit fuzzy tbh). This is all but an academic exercise, really. To reiterate, all my initial script was missing was: declare -n sublist="${indexd}" Effectively I needed to declare a local copy of each of my arrays when looping through the array placeholder (i.e. active_lists). By doing declare -n sublist="${indexd}" I can read any indices in the array and assign them to local variables. This is my working script: #!/bin/bash set -euo pipefail declare -a myArray1=("userList1" "emailList1" "valueList1") declare -a myArray2=("userList2" "emailList2" "valueList2") declare -a active_lists=("myArray1" "myArray2") for indexd in "${active_lists[@]}"; do declare -n sublist="${indexd}" username=${sublist[0]} email=${sublist[1]} echo "List ${indexd}: Email: ${email}, username: ${username} (${sublist[2]})" done
has comment: http://stackoverflow.com/comment/137787841
upvote count: 3
answers question: http://stackoverflow.com/q/78156679
has comment: http://stackoverflow.com/comment/137787830
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/137787958

http://stackoverflow.com/comment/137927680
has text: It's important to note that this redeclaring behavior is completely different when `declare` is used inside a function since the values are reset there.
comment on: http://stackoverflow.com/a/78235206
score: 2
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137822063
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78176347
has text: Well, you would need to extract the numeric part from `$8` since `$8 != 0` will be false in all your rows. Perhaps `awk '-F[ ()]+' '$1 >= 200 && $8 > 0 && $8 <= 400 {print}' numbers.txt` would be more successful. Here I made `(` and `)` into field separators too.

http://stackoverflow.com/comment/137886264
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78212459
score: 2
has text: Just one question. Why involve Bash, and awk two times rather than read the json lines file within the python script itself using the dedicated jsonline library here? https://jsonlines.org/examples/

airflow-2.x
tag name: airflow-2.x
tags question: http://stackoverflow.com/q/78285559
type: Tag

http://stackoverflow.com/comment/137785004
score: 0
type: Comment
has text: "skip the more command" in OP
type: AnswerComment
comment on: http://stackoverflow.com/a/78150761

http://stackoverflow.com/comment/137858199
has text: `read -r -d ''` _doesn't_ remove newlines. Doesn't happen. Full-stop. Anything that appears to lead you to think it does is based on an incorrect interpretation of the data at hand.
comment on: http://stackoverflow.com/q/78196593
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138024313
type: QuestionComment
type: Comment
has text: @oguzismail we do not have and cant have any scheduler running at that machine.
comment on: http://stackoverflow.com/q/78290808
score: 1

http://stackoverflow.com/a/78308378
upvote count: 1
answers question: http://stackoverflow.com/q/78290118
downvote count: 0
score: 1
has body: SOLVED As suggested by Nick ODell, adding a sleep 10s between commands solved the problem: ssh -i "/myssh.key" myuser@host "sudo bash 'echo -e \"ExecStart=/mydir/run-service.sh\" >> /etc/systemd/system/myService.service'" sleep 10s ssh -i "/myssh.key" myuser@host "sudo systemctl daemon-reload"
type: Answer

cron
tags question: http://stackoverflow.com/q/78183354
tag name: cron
type: Tag
tags question: http://stackoverflow.com/q/78388939
tags question: http://stackoverflow.com/q/78320604
tags question: http://stackoverflow.com/q/78431133
tags question: http://stackoverflow.com/q/78497806
tags question: http://stackoverflow.com/q/78470611
tags question: http://stackoverflow.com/q/78551987
tags question: http://stackoverflow.com/q/78570866
tags question: http://stackoverflow.com/q/78722918
tags question: http://stackoverflow.com/q/78653040
tags question: http://stackoverflow.com/q/78832187
tags question: http://stackoverflow.com/q/78824967
tags question: http://stackoverflow.com/q/78997848
tags question: http://stackoverflow.com/q/78952087
tags question: http://stackoverflow.com/q/79034810
tags question: http://stackoverflow.com/q/79088795
tags question: http://stackoverflow.com/q/79097497
tags question: http://stackoverflow.com/q/79207537
tags question: http://stackoverflow.com/q/79319046
tags question: http://stackoverflow.com/q/79375762
tags question: http://stackoverflow.com/q/79276938

http://stackoverflow.com/comment/137920189
score: 0
comment on: http://stackoverflow.com/a/78230530
has text: Thank you very much, I will try to implement your solution, and come back with the results!
type: Comment
type: AnswerComment

kubernetes
tags question: http://stackoverflow.com/q/78202789
type: Tag
tag name: kubernetes
tags question: http://stackoverflow.com/q/78365034
tags question: http://stackoverflow.com/q/78758715
tags question: http://stackoverflow.com/q/78781574
tags question: http://stackoverflow.com/q/79409439
tags question: http://stackoverflow.com/q/79251059
tags question: http://stackoverflow.com/q/79323386
tags question: http://stackoverflow.com/q/79537887

http://stackoverflow.com/comment/137855617
comment on: http://stackoverflow.com/q/78195172
has text: You may try to re-invent wheel by re-construct string and play with `read -rsn 1 oneKey` and a big loop containing all `case` ... This could become a very big job!
type: QuestionComment
type: Comment
score: 0

range
type: Tag
tag name: range
tags question: http://stackoverflow.com/q/78176347
tags question: http://stackoverflow.com/q/78626809

http://stackoverflow.com/a/78277043
has comment: http://stackoverflow.com/comment/138001586
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78276987
type: Answer
has comment: http://stackoverflow.com/comment/138006261
has body: You're close. You shouldn't have a space between (aa|bb|cc) and [.@]. For the third part, use [^.@]+$` to match at least one character not in this charset continuing to the end. ^(aa|bb|cc)[.@][^.@]+$ DEMO In the demo I added \n to the last part so it doesn't match newlines. That shouldn't matter for your use if $string is just one line.
has comment: http://stackoverflow.com/comment/138000826

http://stackoverflow.com/comment/137785042
type: Comment
score: 4
type: AnswerComment
comment on: http://stackoverflow.com/a/78155222
has text: @Jinux It was revealed to me in a dream.

http://stackoverflow.com/comment/137856814
has text: Or `jq '...' package.json | sponge package.json`
type: Comment
comment on: http://stackoverflow.com/a/78195834
type: AnswerComment
score: 1

http://stackoverflow.com/comment/137807322
score: 0
has text: The file itself already exists, it's shown in the echo display and log, the issue is that additional symbols are added once that file and path are fed to rm. But thank you,
comment on: http://stackoverflow.com/a/78158163
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137810650
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78169456
score: 0
has text: Thanks @CharlesDuffy, great catch!, and finally I solved it running with: `. ./myenv.sh`

http://stackoverflow.com/comment/138141857
has text: I found `git diff` command with regular expression solved my question. Thank you anyway! The command is `git diff --unified=0 --word-diff=porcelain origin/develop HEAD fileName | grep -E '^([+-]{3}|\@\@)' | grep -oP '^\+\+\+ \./\K.*|^\@\@ -[0-9]+(,[0-9]+)? \+[0-9]+(,[0-9]+)?(?= \@\@)'`
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78276584

http://stackoverflow.com/comment/137789939
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78157309
has text: Thanks for the git alias reminder. I will probably make an alias out @jthill's approach.
score: 1

http://stackoverflow.com/comment/138038446
type: Comment
has text: tjm3772 Trieed, that didn't help
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78298936

http://stackoverflow.com/comment/137886604
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78212759
type: Comment
has text: yea imma be real, im barely learning bash as part of a cybersecurity class, so i dont know a lot of the optimal stuff

http://stackoverflow.com/comment/137871770
score: 0
has text: Unless this is an exercise consider using the `file` utility: `file your-file` does exactly what you want and even more. See `man file` for the version you have or [the POSIX specification](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/file.html) if you care about portability.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78203880

http://stackoverflow.com/comment/138004000
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78278695
has text: you are correct: in order for my solution also to work from terminal to Text Editor or other X11 apps I needed to specify the xclip flags as in your original script i.e.: `m() { ( echo "$( history 1 | head -n 1 | cut -c 26- | cut -d\| -f 1 )" ; cat ) | xclip -selection clipboard ; }`
type: AnswerComment

http://stackoverflow.com/comment/137813478
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78170533
has text: Perhaps use ` awk -F, -v OFS=, '$2~/^[0-9]{10}$/ { system...` for an injection check.
score: 2

http://stackoverflow.com/comment/137908632
score: 0
type: QuestionComment
has text: The answer is here https://unix.stackexchange.com/a/717673/8215
comment on: http://stackoverflow.com/q/78225038
type: Comment

pipestatus
tags question: http://stackoverflow.com/q/78178153
tag name: pipestatus
type: Tag

http://stackoverflow.com/comment/137814253
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78171975
has text: now it is clearer what you mean

kill
tag name: kill
tags question: http://stackoverflow.com/q/78194991
type: Tag
tags question: http://stackoverflow.com/q/78317514
tags question: http://stackoverflow.com/q/79244510

http://stackoverflow.com/a/78276869
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78274285
score: 0
answers question: http://stackoverflow.com/q/78274285
has comment: http://stackoverflow.com/comment/138006456
type: Answer
has body: This might work for you (GNU sed): sed -E ':a;s/^((&quot;[^,&quot;]*&quot;,)*&quot;[^,&quot;]*),/\1\n/;ta;y/\n,/,;/' file Iterate along the line replacing any commas within double quotes by newlines. When there are no more substitutions, translate newlines to commas and commas to semicolons.

systemctl
tags question: http://stackoverflow.com/q/78290118
tag name: systemctl
type: Tag
tags question: http://stackoverflow.com/q/78690427

http://stackoverflow.com/comment/137815775
score: 1
comment on: http://stackoverflow.com/a/78171975
has text: Perhaps see also https://stackoverflow.com/a/54434993/874188
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137834482
score: 0
has text: @Cyrus Nothing wrong except adding quotes : /usr/bin/python3 "$SCRIPT_DIR"/webScraping.py >> "$PWD"/$LOG_FILE 2>&1
comment on: http://stackoverflow.com/q/78183354
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137820484
comment on: http://stackoverflow.com/q/78175689
score: 0
type: QuestionComment
has text: Have a look [here](https://stackoverflow.com/a/66950971/1765658)
type: Comment

http://stackoverflow.com/comment/138039534
score: 2
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78299434
has text: Check your scripts with shellcheck. It's `"$@"` not `$@`, otherwise there will be problems .

http://stackoverflow.com/comment/137806073
comment on: http://stackoverflow.com/q/78166124
has text: What is `isnull`?
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137876825
has text: @pjh ah, got it. thanks, hadn't thought of that issue with echo
comment on: http://stackoverflow.com/a/78204135
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/137908357
has text: yeah I tried running the command by its self and it works
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78224990
type: Comment

http://stackoverflow.com/comment/138018386
comment on: http://stackoverflow.com/a/78281278
has text: @Fravadona Which version of awk do you use ? I don't get that error with awk/Ubuntu.
type: Comment
score: 0
type: AnswerComment

subdirectory
tags question: http://stackoverflow.com/q/78173011
tags question: http://stackoverflow.com/q/78203984
type: Tag
tag name: subdirectory
tags question: http://stackoverflow.com/q/78520070

http://stackoverflow.com/comment/137772871
has text: @GillesQuénot there is no point
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78148131

http://stackoverflow.com/comment/137858202
type: QuestionComment
type: Comment
has text: Mind, _one_ thing that might lead you to have that impression is that your second `read` doesn't have `-d ''` on it, so it's using the default `-d $'\n'` and only reading up to the first newline.
comment on: http://stackoverflow.com/q/78196593
score: 3

http://stackoverflow.com/comment/138016277
score: 0
has text: In Excel you can use `HEX2DEC` and `BITAND`. You just need to translate that your comparators for `{1,2,3,4}` would be `{8,4,2,1}`
type: QuestionComment
comment on: http://stackoverflow.com/q/78286124
type: Comment

http://stackoverflow.com/comment/137943353
score: 0
type: QuestionComment
has text: @Robert It's not changing itself, he's continuing to do development of it while running the script.
type: Comment
comment on: http://stackoverflow.com/q/78244372

http://stackoverflow.com/comment/137811895
type: QuestionComment
has text: `echo "$time" | gawk '$2{print $0,strftime("%a %b %-d %Y %l:%M:%S %p",$2)}' FS=, OFS=,` ?
type: Comment
comment on: http://stackoverflow.com/q/78170444
score: 0

http://stackoverflow.com/comment/137924160
type: QuestionComment
comment on: http://stackoverflow.com/q/78233301
has text: I'm not using JQ because I am just grabbing part of a JSON output. Hence why I asked for Bash.
type: Comment
score: 0

messagebox
tag name: messagebox
tags question: http://stackoverflow.com/q/78284887
type: Tag

http://stackoverflow.com/comment/137850963
score: 0
has text: You could save a cycle if you don't call `sprintf()`, just concatenate the strings `commandSQL = "sqlite3 -noheader " db " \""; ... system(command_query_SQL (++TICKCOUNT) "\";")` but I highly doubt you'll ever get the performance you need out of using awk + subshells like this. We know you have python so if you can't use `Go` as @CharlesDuffy suggested then do this timing process in `python`. It's not obvious why you don't have the main `python` process just do this part for itself too (though "the muxed signal is available via a manufacturer provided awk script" may be a clue!).
type: QuestionComment
comment on: http://stackoverflow.com/q/78190193
type: Comment

postgresql
tags question: http://stackoverflow.com/q/78298036
tag name: postgresql
type: Tag
tags question: http://stackoverflow.com/q/78302587
tags question: http://stackoverflow.com/q/78390602
tags question: http://stackoverflow.com/q/78371491
tags question: http://stackoverflow.com/q/78338056
tags question: http://stackoverflow.com/q/78580571
tags question: http://stackoverflow.com/q/78824967
tags question: http://stackoverflow.com/q/78956029
tags question: http://stackoverflow.com/q/79275950
tags question: http://stackoverflow.com/q/79399187

http://stackoverflow.com/comment/137813119
type: QuestionComment
type: Comment
score: 0
has text: @Philippe I do not have control over `docker build` as it is managed via organization wide remote GitHub Action script. So, I need to handle this inside the Dockerfile itself.
comment on: http://stackoverflow.com/q/78166553

http://stackoverflow.com/comment/137906469
comment on: http://stackoverflow.com/q/78218663
score: 0
has text: actually my output from my command does not work but I cannot find the solution
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137785735
has text: What you've shown here is code to implement _a copy of_ `more`, not to control a copy of `more` provided by the local OS vendor. We don't allow LLM-generated answers in no small part because they're often this kind of plausibly-stated irrelevancy.
score: 2
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78150771

http://stackoverflow.com/a/78170706
score: 2
upvote count: 2
has body: If you can afford writing $time to a file, there is a much simpler way: awk -F, '{print &quot;@&quot;$2}' file | date -f - | paste -d, file -
downvote count: 0
answers question: http://stackoverflow.com/q/78170444
type: Answer

http://stackoverflow.com/comment/137960478
score: 0
has text: I can't kill that process. It has to run a long time. Also every 10 seonds is just for development purpose, It can be one log file per day.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78254419

http://stackoverflow.com/comment/137920361
score: 1
type: QuestionComment
type: Comment
has text: `How does the shell know how to pair up the single quotes?` Like literally _pairs_ them? `'/home/'` that's one pair, `'/'` that's another pair.
comment on: http://stackoverflow.com/q/78231603

tilde
tags question: http://stackoverflow.com/q/78204849
type: Tag
tag name: tilde

http://stackoverflow.com/comment/137854446
has text: Oh, I see now. `set -- "$@"` seems like a no-op....
comment on: http://stackoverflow.com/a/78194502
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/137900448
type: Comment
type: AnswerComment
has text: I edited this several times, but it still seems...unnecessarily pompous and snarky to me. Apologies, it isn't intended. Hope it helps.
score: 1
comment on: http://stackoverflow.com/a/78220527

http://stackoverflow.com/comment/138007624
has text: See [How do I use shell variables in an awk script?](https://stackoverflow.com/q/19075671/4154375).
comment on: http://stackoverflow.com/q/78281234
score: 3
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137857196
has text: @chenzhang From documentation : `If any arguments are supplied, they become the positional parameters when filename is executed.` Notice `when filename is executed`
comment on: http://stackoverflow.com/a/78194502
type: Comment
score: 0
type: AnswerComment

stream
type: Tag
tag name: stream
tags question: http://stackoverflow.com/q/78181450
tags question: http://stackoverflow.com/q/78746139
tags question: http://stackoverflow.com/q/79536213

http://stackoverflow.com/comment/137999325
score: 0
has text: @tjm3772 Could you be kind enough to check the **P.S.** I just added?
type: QuestionComment
comment on: http://stackoverflow.com/q/78274675
type: Comment

http://stackoverflow.com/comment/137900950
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78219094
has text: [Shellcheck](https://www.shellcheck.net/) identifies the problem with the code (missing quotes). The report that it produces includes links to more information about the problem and how to fix it. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.

http://stackoverflow.com/a/78151323
has body: I fixed the shebang line, removed the final cd command, and then restarted the wsl instance. The bash script now works as i expected it to. I don't know what fixed it, but I suspect that, in my ignorance, I was doing something stupid in the background that caused this error. Thank you to all who answered.
answers question: http://stackoverflow.com/q/78146724
has comment: http://stackoverflow.com/comment/137783973
score: -2
type: Answer
downvote count: 2
upvote count: 0

http://stackoverflow.com/comment/138018052
score: 1
has text: "the logic behind the solution is logic" - reminds me of when I worked at a large firm that had just gone through layoffs and at a company meeting someone asked the CEO if there were plans for more layoffs and she replied "we have no plans beyond our current plans" which I thought was a brilliant answer compared to "yes" (we then went through 10+ more years of monthly layoffs).
type: Comment
comment on: http://stackoverflow.com/a/78286685
type: AnswerComment

azure-pipelines
type: Tag
tag name: azure-pipelines
tags question: http://stackoverflow.com/q/78261175
tags question: http://stackoverflow.com/q/78338056
tags question: http://stackoverflow.com/q/78449032
tags question: http://stackoverflow.com/q/78477819
tags question: http://stackoverflow.com/q/78683001
tags question: http://stackoverflow.com/q/78765811
tags question: http://stackoverflow.com/q/79054869
tags question: http://stackoverflow.com/q/78998116
tags question: http://stackoverflow.com/q/78973167
tags question: http://stackoverflow.com/q/79040226
tags question: http://stackoverflow.com/q/79235368
tags question: http://stackoverflow.com/q/79100748
tags question: http://stackoverflow.com/q/79095253
tags question: http://stackoverflow.com/q/79265910
tags question: http://stackoverflow.com/q/79472516
tags question: http://stackoverflow.com/q/79431393

http://stackoverflow.com/comment/138029133
has text: What OS _is_ this? systemd-timer is built into systemd, so _you already have it_ on basically all modern Linux systems that aren't dedicated-purpose embedded systems (which are also unlikely to have bash and may require implementing POSIX-compliant shell scripts).
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78290808

initialization
tag name: initialization
type: Tag
tags question: http://stackoverflow.com/q/78235101
tags question: http://stackoverflow.com/q/79291946

ls
tags question: http://stackoverflow.com/q/78287441
tag name: ls
type: Tag
tags question: http://stackoverflow.com/q/79241790

http://stackoverflow.com/comment/137842542
score: 0
has text: @tripleee, ...well, I'd want to invert that from a pipeline to a process substitution to avoid [BashFAQ #24](https://mywiki.wooledge.org/BashFAQ/024) issues, but yes.
comment on: http://stackoverflow.com/q/78187590
type: QuestionComment
type: Comment

environment
tag name: environment
tags question: http://stackoverflow.com/q/78298728
type: Tag
tags question: http://stackoverflow.com/q/78927392

http://stackoverflow.com/comment/137787958
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78156830
score: 0
has text: But if I did something like `sublist="${indexd}"` instead of `declare -n sublist="${indexd}"` that would obviously wouldn't work. However, coming from other languages, I should be able to access the the arrays defined outside of the `for loop`, as you'd expect it to be in the same context. Bash is strange....

http://stackoverflow.com/comment/137813771
comment on: http://stackoverflow.com/q/78170444
type: Comment
score: 0
has text: Or, from *variable `$time`*: `sed <<<"$time" 's/^[0-9]*,\([0-9]\+\),.*/@\1/'|LANG=C date -f -| paste -d, <(echo "$time") -`
type: QuestionComment

http://stackoverflow.com/comment/137832816
comment on: http://stackoverflow.com/q/78182539
type: QuestionComment
type: Comment
score: 0
has text: @MarkReed Thanks for feedback. I don't use stack too often. I updated my post with more clarification.

http://stackoverflow.com/a/78266239
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78240671
has body: $commandOutput == "true" compares the value of $commandOutput to the string true. The string against which the value is compared does not contain quotes, the quotes are part of the shell's syntax. The following is equivalent to the test: $commandOutput == true . You can easily verify this claim yourself: noquotes=true noquotes2='true' noquotes3="true" withquotes='"true"' withquotes2="'true'" $noquotes == true && echo 'no quotes!' $noquotes2 == true && echo 'no quotes!' $noquotes3 == true && echo 'no quotes!' $noquotes == "true" && echo 'no quotes!' $noquotes2 == "true" && echo 'no quotes!' $noquotes3 == "true" && echo 'no quotes!' $noquotes == 'true' && echo 'no quotes!' $noquotes2 == 'true' && echo 'no quotes!' $noquotes3 == 'true' && echo 'no quotes!' $withquotes == '"true"' && echo 'double quotes!' $withquotes2 == "'true'" && echo 'single quotes!' echo '{"data":"true"}' | jq '.data' outputs "true" (with quotes; you get valid JSON strings as output), if you want to get the raw strings (no longer valid JSON), you can pass the -r/--raw-output flag to jq: echo '{"data":"true"}' | jq -r '.data' This will only output the string content; true (without quotes) in your case. But you don't need to compare the string in your shell at all, you can do the comparison directly in jq and leverage the -e/--exit-status flag to set the exit code from jq: if echo '{"data":"true"}' | jq -re '.data=="true"' >/dev/null; then echo 'data was "true"' fi

batch-file
tag name: batch-file
type: Tag
tags question: http://stackoverflow.com/q/78181239
tags question: http://stackoverflow.com/q/78343975
tags question: http://stackoverflow.com/q/78778821
tags question: http://stackoverflow.com/q/79301328

http://stackoverflow.com/comment/137949850
score: 1
comment on: http://stackoverflow.com/q/78248223
type: QuestionComment
type: Comment
has text: Well, then building a custom bash (or finding a shell without a `kill` builtin) may be your best choice.

http://stackoverflow.com/comment/137771678
has text: Aside: Backticks for command substitution have been outdated since the early 90s standardized `$()`. Better to use `max=$(echo "sqrt($1)" | bc)`. Similarly, `$[ ]` is a legacy ksh syntax that has _never_ been standardized; the standard math syntax is `counter=$(( counter - 1 ))`, or the modern bashism is `(( counter-- ))`
comment on: http://stackoverflow.com/q/78147701
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/a/78227319
has body: ~/.config/hypr/Wallpapers/'Chill Study.jpg' from your comment is not the same thing as: &quot;~/.config/hypr/Wallpapers/'Chill Study.jpg'&quot; from your code (expanded from Wallpaper_Dir=&quot;~/.config/hypr/Wallpapers/&quot; ... &quot;$Wallpaper_Dir'$chosen'&quot; and assuming $chosen has the value Chill Study.jpg) In the first case, .../'Chill Study.jpg', the 's are quotes read by the shell so that the spaces are treated as literal characters in your file name, but in the second case, &quot;.../'Chill Study.jpg'&quot;, the ' themselves are inside a double quoted string and so the 's as well as the spaces are treated as literal characters in your file name. Please read https://mywiki.wooledge.org/Quotes to learn about quotes and there are other issues with your script too, some of which http://shellcheck.net could help you with.
answers question: http://stackoverflow.com/q/78224990
type: Answer
score: 0

http://stackoverflow.com/comment/137789759
score: 1
has text: provide code we can run to demonstrate the problem - [minimum reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)
type: QuestionComment
comment on: http://stackoverflow.com/q/78157779
type: Comment

http://stackoverflow.com/comment/137865370
comment on: http://stackoverflow.com/q/78200396
type: QuestionComment
has text: I never suggested it did, just mentioning a mistake I noticed in your question,
type: Comment
score: 0

dongle
type: Tag
tag name: dongle
tags question: http://stackoverflow.com/q/78252038

github-actions
tags question: http://stackoverflow.com/q/78194442
type: Tag
tags question: http://stackoverflow.com/q/78208234
tag name: github-actions
tags question: http://stackoverflow.com/q/78412927
tags question: http://stackoverflow.com/q/78453492
tags question: http://stackoverflow.com/q/78510327
tags question: http://stackoverflow.com/q/78604424
tags question: http://stackoverflow.com/q/78802409
tags question: http://stackoverflow.com/q/78854738
tags question: http://stackoverflow.com/q/79210669
tags question: http://stackoverflow.com/q/79117431
tags question: http://stackoverflow.com/q/79263236
tags question: http://stackoverflow.com/q/79302612
tags question: http://stackoverflow.com/q/79297764
tags question: http://stackoverflow.com/q/79292361

real-number
tag name: real-number
tags question: http://stackoverflow.com/q/78213645
type: Tag

http://stackoverflow.com/a/78283486
downvote count: 0
has body: apparently the ENVIRON approach even allows even shell arrays to be passed in full (but awk sees it as a single string not an array) I tested the zsh shell-generated array called signals : signals=( EXIT HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2 ZERR DEBUG ) __=$signals [m/g/n]awk 'BEGIN { print ENVIRON[&quot;__&quot;] }' EXIT HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2 ZERR DEBUG
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/78281234

http://stackoverflow.com/comment/137927591
comment on: http://stackoverflow.com/a/78235578
has text: @Bobby %b interprets escape sequences, %s doesn't. It's all written in the manual
score: 1
type: Comment
type: AnswerComment

wait
tags question: http://stackoverflow.com/q/78218663
tag name: wait
type: Tag
tags question: http://stackoverflow.com/q/79125465
tags question: http://stackoverflow.com/q/79419573
tags question: http://stackoverflow.com/q/79475480

http://stackoverflow.com/comment/137878102
comment on: http://stackoverflow.com/q/78207789
type: QuestionComment
type: Comment
score: 0
has text: Shell programming hasn't advanced in the last 20 years (or even 30 years for that matter). Re-learning it is almost certainly a waste of time. If you want to learn something useful, modern, and powerful, learn Python. If you must learn shell then learn how to use [Shellcheck](https://www.shellcheck.net/). It can identify many common problems with shell code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.

http://stackoverflow.com/a/78254812
has body: Let's assume that a "valid" real literal is one of: an integer (42) a dot followed by an integer (.42) an integer followed by a dot, followed by an integer (42.42) optionally preceded by a + or - sign. Then, if you are allowed to use extended glob: shopt -s extglob if (( $# == 3 )) && [[ "$3" != ?([-+])?([0-9]).+([0-9]) ]] && [[ "$3" != ?([-+])+([0-9]) ]]; then echo "Error: optional third argument is not a valid frequency" exit 1 fi
answers question: http://stackoverflow.com/q/78254632
has comment: http://stackoverflow.com/comment/137963225
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/137963661
type: Answer

http://stackoverflow.com/comment/137963260
has text: Other than using `[[` instead of `[`, this is asked and answered in [Checking the success of a command in a bash `if [ .. ]` statement](https://stackoverflow.com/q/36371221/3266847)
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78255091

bitbucket
tags question: http://stackoverflow.com/q/78238193
tag name: bitbucket
type: Tag

http://stackoverflow.com/comment/137815444
score: 1
type: Comment
comment on: http://stackoverflow.com/a/78170533
type: AnswerComment
has text: To give credit where it is due, the first suggestion to use the `%(fmt)T` specifier with `printf` was in a [comment by oguz ismail](https://stackoverflow.com/questions/78170444/convert-unix-time-human-readable-loop#comment137812302_78170836).

http://stackoverflow.com/comment/137773177
score: 0
comment on: http://stackoverflow.com/q/78147701
type: QuestionComment
has text: Regarding awk I suggest taking look at [redirection to command](https://www.gnu.org/software/gawk/manual/html_node/Redirection.html)
type: Comment

http://stackoverflow.com/comment/137884688
score: 1
comment on: http://stackoverflow.com/q/78211473
has text: your test seems (a) backwards: `if [ -z $PIPv6 ]; then echo $PIPv6` seems to want to print the value when it is empty instead of when it is not empty, and (b) buggy - when `$PIPv6` **is** empty, because you didn't quote the variable, the test becomes `if [ -z ]; then echo $PIPv6` which still succeeds (because the string "-z" is not empty)
type: QuestionComment
type: Comment

curl
tags question: http://stackoverflow.com/q/78161552
tag name: curl
type: Tag
tags question: http://stackoverflow.com/q/78226551
tags question: http://stackoverflow.com/q/78252038
tags question: http://stackoverflow.com/q/78428595
tags question: http://stackoverflow.com/q/78383368
tags question: http://stackoverflow.com/q/78581308
tags question: http://stackoverflow.com/q/78483806
tags question: http://stackoverflow.com/q/78557465
tags question: http://stackoverflow.com/q/78515364
tags question: http://stackoverflow.com/q/78530810
tags question: http://stackoverflow.com/q/78627719
tags question: http://stackoverflow.com/q/78736348
tags question: http://stackoverflow.com/q/78742408
tags question: http://stackoverflow.com/q/78739785
tags question: http://stackoverflow.com/q/78737512
tags question: http://stackoverflow.com/q/78873635
tags question: http://stackoverflow.com/q/78808824
tags question: http://stackoverflow.com/q/79025069
tags question: http://stackoverflow.com/q/79068201
tags question: http://stackoverflow.com/q/78962905
tags question: http://stackoverflow.com/q/78953114
tags question: http://stackoverflow.com/q/79186999
tags question: http://stackoverflow.com/q/79123895
tags question: http://stackoverflow.com/q/79193786
tags question: http://stackoverflow.com/q/79084052
tags question: http://stackoverflow.com/q/79160533
tags question: http://stackoverflow.com/q/79105586
tags question: http://stackoverflow.com/q/79103952
tags question: http://stackoverflow.com/q/79213205
tags question: http://stackoverflow.com/q/79086707
tags question: http://stackoverflow.com/q/79440815

http://stackoverflow.com/comment/138021751
score: 0
comment on: http://stackoverflow.com/q/78287441
type: QuestionComment
type: Comment
has text: See at Unix & Linux: [is piped ls the same as ls -1?](https://unix.stackexchange.com/q/410550/74329)

http://stackoverflow.com/comment/137853767
type: QuestionComment
has text: disregard. i forgot to remove a set of quotes. \*facepalm\*
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78190193

ripgrep
tags question: http://stackoverflow.com/q/78252129
type: Tag
tag name: ripgrep
tags question: http://stackoverflow.com/q/79086563

http://stackoverflow.com/comment/138017090
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78286060
has text: CSV is not a well specified format. Please edit your question and add the missing information: do you have quoted fields with commas in them, can you have newlines inside quoted fields, etc. And also explain what you want if a person is listed several times in `1.csv` with different scores (or state that this cannot happen).

http://stackoverflow.com/comment/137933437
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78229406
has text: In order to keep the newlines, the argument of both `echo` commands must be quoted, i. e. `eval echo \""${line}"\"` and `echo "${emailbody}"`.
type: QuestionComment

fold
tags question: http://stackoverflow.com/q/78187590
tag name: fold
type: Tag

jenkins
tags question: http://stackoverflow.com/q/78226551
type: Tag
tag name: jenkins
tags question: http://stackoverflow.com/q/78429844
tags question: http://stackoverflow.com/q/78376379
tags question: http://stackoverflow.com/q/78654286
tags question: http://stackoverflow.com/q/78861447
tags question: http://stackoverflow.com/q/78797390
tags question: http://stackoverflow.com/q/79147830
tags question: http://stackoverflow.com/q/79312384
tags question: http://stackoverflow.com/q/79483250
tags question: http://stackoverflow.com/q/79440815

http://stackoverflow.com/comment/137975719
score: 0
comment on: http://stackoverflow.com/q/78263189
type: QuestionComment
has text: I edited the EOF term, is it still misleading?
type: Comment

http://stackoverflow.com/comment/138026058
type: QuestionComment
comment on: http://stackoverflow.com/q/78291764
has text: As for the _rationale_ for this being the actual behavior -- things in quotes are data (subject to explicit, clear exceptions only available for double quotes), whereas things outside quotes can be syntax. When someone writes `~user/`, the fact that they wanted tilde expansion is authorial intent -- it's syntax; you don't want a variable with content that's expected to start with a `/` but instead contains `othername/` to change from the current user's home directory to someone else's, for example.
type: Comment
score: 0

tcsh
type: Tag
tag name: tcsh
tags question: http://stackoverflow.com/q/78298936
tags question: http://stackoverflow.com/q/78154096

http://stackoverflow.com/a/78184536
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78184175
has body: source ~/.bashrc means applies changes in .bashrc into current session. bash executes commands from stdin or stdout or a file.

http://stackoverflow.com/comment/137973006
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78261786
has text: See https://unix.stackexchange.com/questions/243237/how-to-save-restore-terminal-output on [unix.se]
score: 1

algorithm
type: Tag
tags question: http://stackoverflow.com/q/78223744
tag name: algorithm
tags question: http://stackoverflow.com/q/78368689

http://stackoverflow.com/comment/137823729
comment on: http://stackoverflow.com/a/78177473
type: Comment
type: AnswerComment
has text: As an aside -- avoid the backtick-based command substitution syntax. `$( )` has been standardized since the early 90s, nests better, and avoids having confusing side effects on the parsing process (backticks change how backslashes behave within them; nesting them gets very, _very_ messy)
score: 1

http://stackoverflow.com/comment/137893442
type: Comment
score: 0
comment on: http://stackoverflow.com/a/78216128
type: AnswerComment
has text: @Claudio, accordingly, I've changed the examples to use `./yourscript` everywhere they previously said `yourscript`.

http://stackoverflow.com/comment/137938711
score: 1
type: Comment
type: AnswerComment
has text: Similar answer: https://stackoverflow.com/a/18125979/445221
comment on: http://stackoverflow.com/a/78241429

http://stackoverflow.com/comment/137818635
type: Comment
has text: Have a look at this answer: [Read a file by bytes in BASH](https://stackoverflow.com/a/13890319/1765658)
score: 0
comment on: http://stackoverflow.com/q/78173269
type: QuestionComment

http://stackoverflow.com/comment/137876192
score: 0
has text: Generally, learn to debug your code by using `set -x` (`set +x` to turn off). You will see each line as it is executed preceded with a `+ ` (or the value `$PS4`) after all substitutions for env vars is complete. You will see that `$this_dir` has different values in both cases. It is your responsibility to see the starting environment (`$PWD`) are the same. ... Specifically, you could also use `echo "value for this_dir now = $this_dir"`. Good lu k.
comment on: http://stackoverflow.com/q/78204675
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137853490
type: Comment
score: 0
has text: the `typeset -p` (`typeset -p` and `declare -p` are interchangeable) is just my way of showing the contents of the array; I could've instead used a `for` loop with the index ranging from `0` to `${#arr[@]}-1` (the `#` gives the count of elements in the array); as for the individual variables (the output from the chatGPT code) ... how were you going to know that list to start with?
type: AnswerComment
comment on: http://stackoverflow.com/a/78188212

http://stackoverflow.com/comment/137851159
type: Comment
score: 0
has text: @KamilCuk I am using php to pass the variables, but I didn't know about this package! It looks perfect too! i'll get on it and let you know how it goes!!
type: QuestionComment
comment on: http://stackoverflow.com/q/78192206

http://stackoverflow.com/comment/137856244
has text: Thankyou for your help! I'll also look more into ldap to see how it functions with pam!
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78193474
score: 0

http://stackoverflow.com/comment/137827767
has text: Looks fine to me. Good day
score: 0
comment on: http://stackoverflow.com/q/78178759
type: QuestionComment
type: Comment

pipe
tag name: pipe
tags question: http://stackoverflow.com/q/78216460
type: Tag
tags question: http://stackoverflow.com/q/78445450
tags question: http://stackoverflow.com/q/78369669
tags question: http://stackoverflow.com/q/78331935
tags question: http://stackoverflow.com/q/78451035
tags question: http://stackoverflow.com/q/78458050
tags question: http://stackoverflow.com/q/78553947
tags question: http://stackoverflow.com/q/78662076
tags question: http://stackoverflow.com/q/78663739
tags question: http://stackoverflow.com/q/78720313
tags question: http://stackoverflow.com/q/78772491
tags question: http://stackoverflow.com/q/78797976
tags question: http://stackoverflow.com/q/78824592
tags question: http://stackoverflow.com/q/79013018
tags question: http://stackoverflow.com/q/79146653
tags question: http://stackoverflow.com/q/79144100
tags question: http://stackoverflow.com/q/79252378
tags question: http://stackoverflow.com/q/79377055
tags question: http://stackoverflow.com/q/79277670
tags question: http://stackoverflow.com/q/79547302
tags question: http://stackoverflow.com/q/79536213
tags question: http://stackoverflow.com/q/79441402

http://stackoverflow.com/comment/137787156
has text: You can make this working, but it is not the puppet way. With puppet, all installation actions should be inside puppet, not in a smart `install.sh`. When you do want to use your install.sh, perhaps place your tar bare on a shared location or a website and copy/download it in your install.sh.
score: 0
comment on: http://stackoverflow.com/q/78155690
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/137927576
has text: No I want the string "a\033[38;5;199mb" to print. Here the "a" got colored, but the "b" includes verbatim the color. Run printf "$a$b\n" and echo $a$b.
comment on: http://stackoverflow.com/q/78235520
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/137865717
score: 0
type: QuestionComment
has text: @Ishan Thank you for the tips. I will give that a shot. I don't need to make the change in place, but good to know
comment on: http://stackoverflow.com/q/78196837
type: Comment

http://stackoverflow.com/comment/137944752
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78212459
has text: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

output
type: Tag
tags question: http://stackoverflow.com/q/78156630
tag name: output
tags question: http://stackoverflow.com/q/79499872

http://stackoverflow.com/comment/138014689
has text: There's a pretty good explanation of it here: [How does the #! shebang work?](https://stackoverflow.com/questions/3009192/how-does-the-shebang-work). The [second answer](https://stackoverflow.com/a/40938907/530160) is the one that I think is most helpful to your question.
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78285382

http://stackoverflow.com/comment/137891576
score: 0
has text: Run the code with and without sleep ... with sleep you will see the lines `stdout \n stderr` between 1 and 2, and without sleep after `--1--` and `--2--`. The code is sufficient to reproduce the issue,
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78215669

http://stackoverflow.com/comment/137963225
comment on: http://stackoverflow.com/a/78254812
type: Comment
type: AnswerComment
score: 0
has text: Hi, Thank you for your answer. Could you tell me how it construct? [[ "$3" != ?([-+])?([0-9]).+([0-9]) ]] && [[ "$3" != ?([-+])+([0-9]) ]];

stdout
type: Tag
tag name: stdout
tags question: http://stackoverflow.com/q/78175689
tags question: http://stackoverflow.com/q/78445450
tags question: http://stackoverflow.com/q/78363374
tags question: http://stackoverflow.com/q/78661614
tags question: http://stackoverflow.com/q/78876319
tags question: http://stackoverflow.com/q/78797976
tags question: http://stackoverflow.com/q/79055675
tags question: http://stackoverflow.com/q/79039745
tags question: http://stackoverflow.com/q/79449855

http://stackoverflow.com/comment/137814015
score: 1
comment on: http://stackoverflow.com/a/78171801
type: Comment
has text: Variant, using *`extglob`*: `time+=$'\n';mapfile -t times <<<"${time//,*([!,]),*([!,])$'\n'/$'\n'}";printf -v fmt '%%s,%(%c)T\n' ${times[@]#*,};(IFS=$'\n'; printf "$fmt" $time)`
type: AnswerComment

http://stackoverflow.com/comment/137810737
has text: (mind, if you're defining the function as a one-liner like that, you need a `;` before the `}`)
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78169487

http://stackoverflow.com/comment/138006055
has text: `set -x (+x)` is always good. You can also use `export PS4='$LINENO >'` to get the line Num prepended. This may be better information than the current line numbers, but given the complex nature of this build, it may only confuse things further. OR the build system may be controlling `PS4` already. You may also want to `export sav_PS4="$PS4"` before you start. Good luck!
type: QuestionComment
comment on: http://stackoverflow.com/q/78274675
type: Comment
score: 0

http://stackoverflow.com/tag/txt
tag name: txt
tags question: http://stackoverflow.com/q/78155628
type: Tag
tags question: http://stackoverflow.com/q/78995324

http://stackoverflow.com/comment/137819115
has text: @TasosPapastylianou portability is one of the most basic desirable attributes of all software (along with robustness, conciseness, and efficiency). Adding `function` reduces portability so don't use it.
comment on: http://stackoverflow.com/a/78160193
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/a/78293719
type: Answer
has body: Use crontab to define when your script should run The time and date fields are: field allowed values ----- -------------- minute 0-59 hour 0-23 day of month 1-31 month 1-12 (or names, see below) day of week 0-7 (0 or 7 is Sunday, or use names) * 23,0,1 * * * /path/to/your/script this would run every minute, so if you want to run every 30 secs you may need to invoke your command twice cmd() { ps aux | sort -nrk 3,3 | head -n 5 &gt; /tmp/processrunning.txt } cmd sleep 30 cmd
answers question: http://stackoverflow.com/q/78290808
score: 0

http://stackoverflow.com/comment/137988177
score: 3
comment on: http://stackoverflow.com/q/78270350
type: QuestionComment
has text: See [BashFAQ #50](https://mywiki.wooledge.org/BashFAQ/050): *I'm trying to put a command in a variable, but the complex cases always fail!* -- the very short form is that you can't use literal quotes (quotes in your data) as if they were quotes in your syntax, and when you need to build a command dynamically, you should do that using shell _arrays_, not strings.
type: Comment

if-statement
tags question: http://stackoverflow.com/q/78213645
type: Tag
tag name: if-statement
tags question: http://stackoverflow.com/q/78393978
tags question: http://stackoverflow.com/q/78405034
tags question: http://stackoverflow.com/q/78538302
tags question: http://stackoverflow.com/q/78579093
tags question: http://stackoverflow.com/q/78673688
tags question: http://stackoverflow.com/q/78790696
tags question: http://stackoverflow.com/q/78880481
tags question: http://stackoverflow.com/q/78765041
tags question: http://stackoverflow.com/q/78932608
tags question: http://stackoverflow.com/q/79123895
tags question: http://stackoverflow.com/q/79105586
tags question: http://stackoverflow.com/q/79376403
tags question: http://stackoverflow.com/q/79440348

fork
tags question: http://stackoverflow.com/q/78218663
tag name: fork
type: Tag
tags question: http://stackoverflow.com/q/79534222

http://stackoverflow.com/comment/137877409
type: Comment
type: AnswerComment
score: 0
has text: I missed the subshell. Duh. Sorry. The question is a duplicate, but almost all of the answers to duplicates on Stack Overflow contain code that doesn't work in general. This answer is a rare exception.
comment on: http://stackoverflow.com/a/78204135

http://stackoverflow.com/comment/137913440
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78227591
has text: @yshavit one sec, sorry, i'm trying to create an example without using work code
type: Comment

yaml
tag name: yaml
type: Tag
tags question: http://stackoverflow.com/q/78200394
tags question: http://stackoverflow.com/q/78758715
tags question: http://stackoverflow.com/q/78826936
tags question: http://stackoverflow.com/q/79016925
tags question: http://stackoverflow.com/q/79144794
tags question: http://stackoverflow.com/q/79251059
tags question: http://stackoverflow.com/q/79303341

automator
type: Tag
tags question: http://stackoverflow.com/q/78199979
tag name: automator

rtsp
tag name: rtsp
type: Tag
tags question: http://stackoverflow.com/q/78181450

http://stackoverflow.com/comment/137863320
score: 1
comment on: http://stackoverflow.com/a/78193436
has text: @EdMorton: It is primarily a note to future MacOS or BSD visitors in the future...
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/137886629
type: QuestionComment
has text: https://stedolan.github.io/jq/
comment on: http://stackoverflow.com/q/78212759
type: Comment
score: 1

http://stackoverflow.com/comment/137813941
score: 1
comment on: http://stackoverflow.com/a/78171801
type: Comment
has text: Pure [tag:bash] too, could be quicker as doesn't use any loop: `mapfile -t lines <<<"$time";times=(${lines[@]#*,});printf -v fmt '%%s,%(%c)T\n' ${times[@]%%,*};printf "$fmt" "${lines[@]}"`
type: AnswerComment

http://stackoverflow.com/comment/138004827
score: 1
type: QuestionComment
has text: Fixing the line breaks may be as simple as quoting "$output". eg `echo "$output"` in the copyclip function. If HISTTIMEFORMAT is set (and, HISTTIMEFORMAT should always be set, because a history file without timestamps is useless!) you will need to tweak the `sed` when filtering the output of `history`.
type: Comment
comment on: http://stackoverflow.com/q/78278159

http://stackoverflow.com/comment/137780727
has text: If you continue giving snotty responses to helpful suggestions then YMMV being able to get help on this forum or anywhere else. I see in [your profile](https://stackoverflow.com/users/23290753/girish-manjunath) you describe yourself as "Always looking for; and rarely providing; help" - try helping some people and you may get a better understanding and appreciation for the people trying to help you.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78146724
type: Comment

hex
tags question: http://stackoverflow.com/q/78151708
type: Tag
tag name: hex
tags question: http://stackoverflow.com/q/78645192
tags question: http://stackoverflow.com/q/78642423
tags question: http://stackoverflow.com/q/78808564

http://stackoverflow.com/comment/137938831
type: Comment
has text: `equery` produces very strange output that somehow mixes up line ordering when fed into a pipe. it's why @oguz-ismail's answer didn't work
type: AnswerComment
comment on: http://stackoverflow.com/a/78241862
score: 1

java
tags question: http://stackoverflow.com/q/78210154
type: Tag
tag name: java
tags question: http://stackoverflow.com/q/78335326
tags question: http://stackoverflow.com/q/78398495
tags question: http://stackoverflow.com/q/78346697
tags question: http://stackoverflow.com/q/78519993
tags question: http://stackoverflow.com/q/78506003
tags question: http://stackoverflow.com/q/78567995
tags question: http://stackoverflow.com/q/78695386
tags question: http://stackoverflow.com/q/79050490
tags question: http://stackoverflow.com/q/79344993
tags question: http://stackoverflow.com/q/79250646
tags question: http://stackoverflow.com/q/79263236
tags question: http://stackoverflow.com/q/79525280

ffmpeg
type: Tag
tags question: http://stackoverflow.com/q/78181450
tag name: ffmpeg
tags question: http://stackoverflow.com/q/78409475
tags question: http://stackoverflow.com/q/78324080
tags question: http://stackoverflow.com/q/78465874
tags question: http://stackoverflow.com/q/79096190
tags question: http://stackoverflow.com/q/79347194
tags question: http://stackoverflow.com/q/79476632

http://stackoverflow.com/comment/137935648
type: QuestionComment
comment on: http://stackoverflow.com/q/78240103
type: Comment
has text: Timeout works with a simple `echo` command. It's gotta be a redis issue or how you execute the script.
score: 0

http://stackoverflow.com/comment/137834358
comment on: http://stackoverflow.com/q/78183354
type: QuestionComment
type: Comment
score: 0
has text: you should try pointing explicitly to python3. ex: `/usr/local/bin/python3`

http://stackoverflow.com/comment/137961171
score: 1
comment on: http://stackoverflow.com/q/78255091
type: QuestionComment
type: Comment
has text: drop parenthesis! `grep -q "Build of target from_sms.compfiles.xf : PASS" failed.log && grep -q "All tests fine" test.log && echo "PASS"` could be enough

http://stackoverflow.com/comment/139747565
score: 0
comment on: http://stackoverflow.com/a/78240810
type: Comment
type: AnswerComment
has text: @beli3ver `brew info --cask --installed --json=v2 | jq '.casks'`

http://stackoverflow.com/comment/138511257
has text: `arr=($(echo $drp | jq -r '.[]'))` has multiple problems and is fundamentally not the way to populate a shell array with the output of a command, ask a new question about that if you'd like help with it.
type: QuestionComment
comment on: http://stackoverflow.com/q/78253195
type: Comment
score: 0

memory
tags question: http://stackoverflow.com/q/78182867
tag name: memory
type: Tag

cicd
type: Tag
tags question: http://stackoverflow.com/q/78157839
tag name: cicd
tags question: http://stackoverflow.com/q/79095253
tags question: http://stackoverflow.com/q/79100748
tags question: http://stackoverflow.com/q/79440815

http://stackoverflow.com/a/78286286
type: Answer
has body: From you 1.csv you can get attendance for 3rd day with awk -F, 'NR&gt;1 {c+=$4} END {print c}' 1.csv
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78286124
has comment: http://stackoverflow.com/comment/138118564

http://stackoverflow.com/comment/138007552
type: Comment
has text: It seems like the way to go, +1
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78281380

http://stackoverflow.com/comment/137938849
type: Comment
comment on: http://stackoverflow.com/a/78241862
score: 0
type: AnswerComment
has text: Oooh. It shouldn't as `awk` just reads lines, but I'm concerned about the non ASCII characters involved. That's interesting. How is a pipe different from `stdin` from that standpoint? We are just tying `stdout` from the prior process to `stdin` of the current which should be have the same as a heredoc. Do you have an example I could try?

redis
type: Tag
tags question: http://stackoverflow.com/q/78240103
tag name: redis

http://stackoverflow.com/comment/137864854
score: 1
type: QuestionComment
has text: If CST and CDT currently are 1h apart, how does this account for a 5 hour difference in my results?
type: Comment
comment on: http://stackoverflow.com/q/78200396

http://stackoverflow.com/a/78215263
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78211761
has body: it ended up being an ownership and permission thing I managed to fix it by going to the directory of flutter and did change the permission by running the command chown [USER]:root [FLUTTER DIRECTORY PATH] and then everything just worked

http://stackoverflow.com/comment/138049487
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78302726
type: AnswerComment
has text: @PaulHodges Double quotes would be fine. The error message indicates that the `psql` variable is not set.

configure
tags question: http://stackoverflow.com/q/78274675
type: Tag
tag name: configure
tags question: http://stackoverflow.com/q/78276793

init.d
tag name: init.d
type: Tag
tags question: http://stackoverflow.com/q/78273096

http://stackoverflow.com/comment/137860940
type: QuestionComment
has text: May I recommend to rephrase and remove the assumption that the content you see in PATH variable is coming from a (single) file from which it is reloaded? Maybe something like "Where is the content of PATH environment variable come from?" I do not know the answer, but I suspect that it will be a) not reading from one file b) not contradict the explanations in the duplicate c) be more useful for you. You might end up with answers listing diverse init and setup scripts/executables which concatenate values into the variable. My guess is "lots", but you might get the most common ones.
comment on: http://stackoverflow.com/q/78197884
type: Comment
score: 0

airflow
tag name: airflow
type: Tag
tags question: http://stackoverflow.com/q/78285559
tags question: http://stackoverflow.com/q/78479103
tags question: http://stackoverflow.com/q/78816795
tags question: http://stackoverflow.com/q/78840846
tags question: http://stackoverflow.com/q/79401075
tags question: http://stackoverflow.com/q/79545368

dataset
tag name: dataset
type: Tag
tags question: http://stackoverflow.com/q/78212116

http://stackoverflow.com/q/78388939
has answer: http://stackoverflow.com/a/78541981
favorite count: 0
answer count: 3
has title: Bash script (cron job?) to process files uploaded to a directory?
has comment: http://stackoverflow.com/comment/138197261
score: 2
upvote count: 2
downvote count: 0
tagged with: bash
accepted answer: http://stackoverflow.com/a/78390423
type: AnsweredQuestion
tagged with: scripting
has answer: http://stackoverflow.com/a/78390423
has comment: http://stackoverflow.com/comment/138197276
possible better answer: http://stackoverflow.com/a/78541981
has comment: http://stackoverflow.com/comment/138197243
has answer: http://stackoverflow.com/a/78389053
type: Question
has body: Let's say I have a tool called jpeg2txt. I need to write a bash script that: Constantly checks if there are any new files (JPEGs) in source directory Launches jpeg2txt on them, and writes the results to target directory Deletes source JPEGs afterwards Now, I'm a developer, but my knowledge of bash scripting is rather limited. Could you point me to where should I start? I imagine the script would probably need to be scheduled as a cron job, launched every minute...? But two problems I can see: let's say step 2. (JPEG processing) could take very long - e.g. 15 minutes. Will cron continue spawning new script instances every minute, which would end up in ~15 parallel jobs running on the same set of files? Perhaps instead of using cron, it would be better to have a script running in a loop (in the background, like a daemon), sleeping for 1 minute if there's nothing to process? let's say files are uploaded to the source directory via (S)FTP. What if one file is only 50% uploaded and we start its processing? In other words, how to make sure step 2.) is only launched on complete uploads, not partial ones? Can we somehow skip processing open files? Thanks!
tagged with: shell
has comment: http://stackoverflow.com/comment/138197234
tagged with: cron

http://stackoverflow.com/q/78445450
has comment: http://stackoverflow.com/comment/138298058
linked to: http://stackoverflow.com/q/8304259
has title: Bash - Log timestamp of the moment data was received on stdin, coming from a pipe
has comment: http://stackoverflow.com/comment/138301488
score: 0
type: Question
tagged with: stdout
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138297741
answer count: 1
has answer: http://stackoverflow.com/a/78684526
tagged with: logging
has body: I have an application that outputs to stdout from time to time - random intervals, random durations of outputting before going silent again. Its output (binary data) is captured into a file. I want to be able to log a timestamp of the moment when the output started, but only if the application kept outputting for at least 3 seconds, and also log the time when the output has stopped if no output was received for at least 5 seconds after the stop (if it is received, consider it part of the previous period). Start: (date +'%d.%m - %H:%M:%S') End: (date +'%d.%m - %H:%M:%S') The output must be transparently redirected to the file after that. Something like tee, but with timestamp logger, say: app | monitor &gt; out monitor could output either to a log file or stderr, doesn't matter. Is there a way to do this with common tools available on the shell? I could write a Python script, but i don't wanna overcomplicate the task for no reason.
tagged with: stdin
tagged with: pipe
tagged with: bash

http://stackoverflow.com/comment/138212201
comment on: http://stackoverflow.com/q/78396373
score: 0
type: QuestionComment
has text: What exactly version of awk you are using?
type: Comment

http://stackoverflow.com/comment/138187570
type: Comment
comment on: http://stackoverflow.com/q/78383503
score: 0
has text: Are multiple inputs being processed simultaneously? What does this code have to do with "increasing performance" specifically? Is this a general question about how to process tasks in parallel?
type: QuestionComment

http://stackoverflow.com/q/78433528
tagged with: sh
linked to: http://stackoverflow.com/q/6697753
has comment: http://stackoverflow.com/comment/138276265
tagged with: bash
has body: I have following script to change the firewall rules of one of my cloud servers. The variables API_TOKEN and FIREWALL_ID are converted, but PUBLIC_IP doesn't get converted - it stays PUBLIC_IP, not 1.1.1.1 for example. PUBLIC_IP=$(dig +short txt ch whoami.cloudflare @1.0.0.1) API_TOKEN="XXX" FIREWALL_ID="YYY" curl \ -X POST \ -H "Authorization: Bearer $API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"rules":[{"direction":"in","port":"80","protocol":"tcp","source_ips":[$PUBLIC_IP/32]},{"direction":"in","port":"443","protocol":"tcp","source_ips":["$PUBLIC_IP/32"]},{"direction":"in","port":"22","protocol":"tcp","source_ips":["$PUBLIC_IP/32"]},{"direction":"in","protocol":"icmp","source_ips":["$PUBLIC_IP/32"]}]}' \ "https://api.hetzner.cloud/v1/firewalls/$FIREWALL_ID/actions/set_rules" Any clue? Thanks Chris
tagged with: bin
duplicate of: http://stackoverflow.com/q/6697753
has comment: http://stackoverflow.com/comment/138276249
has comment: http://stackoverflow.com/comment/138278116
duplicate of: http://stackoverflow.com/q/13799789
score: 0
type: Question
linked to: http://stackoverflow.com/q/13799789
answer count: 0
tagged with: shell
type: UnansweredQuestion
has title: bash api script doesn't recognize variables

http://stackoverflow.com/a/78363871
has comment: http://stackoverflow.com/comment/138158245
type: Answer
has body: You need to enclose in double-quotes to prevent word splitting. ls &quot;`1`&quot; But you could also disable word splitting by providing an empty set of characters on which to split. IFS= ls `1` Demo: $ alias show_args='perl -le'\''print for 0+@ARGV, @ARGV'\'' --' $ unset IFS # Default, which is splitting on spaces, tabs and line feeds. $ show_args `echo 'foo bar'` 2 foo bar $ show_args &quot;`echo 'foo bar'`&quot; 1 foo bar $ IFS= $ show_args `echo 'foo bar'` 1 foo bar
score: 1
has comment: http://stackoverflow.com/comment/138162872
upvote count: 1
has comment: http://stackoverflow.com/comment/138156181
downvote count: 0
answers question: http://stackoverflow.com/q/78363374

http://stackoverflow.com/q/78380184
has body: I recently stumbled upon something that doesn't seem to make sense: echo "Hit ENTER to continue or CTRL+D to abort." read -s -t 3 || { case $? in 0) echo "should not occur"; ;; 1) echo "CTRL+D"; ;; *) echo "Timeout"; ;; esac } works as expected (both CTRL+D/EOF and timeout are caught), but echo "Hit ENTER to continue or CTRL+D to abort." if ! read -s -t 3; then case $? in 0) echo "should not occur"; ;; 1) echo "CTRL+D"; ;; *) echo "Timeout"; ;; esac fi does NOT work as expected ($? is always 0). Why (and how) is $? reset before if's body is being executed? Interestingly enough, the inverted construct: echo "Hit ENTER to continue or CTRL+D to abort." if read -s -t 3; then : else case $? in 0) echo "should not occur"; ;; 1) echo "CTRL+D"; ;; *) echo "Timeout"; ;; esac fi does work as expected. That indicates that ! might be responsible, but I couldn't find any documentation to back that up. Bash version: 5.1.16
type: Question
has title: Why is exit code reset after negated if expression
has comment: http://stackoverflow.com/comment/138181950
has answer: http://stackoverflow.com/a/78380299
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138181949
accepted answer: http://stackoverflow.com/a/78380299
has comment: http://stackoverflow.com/comment/138182336
downvote count: 0
score: 1
tagged with: bash

http://stackoverflow.com/q/78334722
has comment: http://stackoverflow.com/comment/138102112
has comment: http://stackoverflow.com/comment/138102202
has title: Reading and Writing more than 4096 bytes to and from STDIN
has comment: http://stackoverflow.com/comment/138102072
answer count: 1
has comment: http://stackoverflow.com/comment/138102451
has comment: http://stackoverflow.com/comment/138103047
has comment: http://stackoverflow.com/comment/138102706
has comment: http://stackoverflow.com/comment/138102092
tagged with: stdin
upvote count: 6
has comment: http://stackoverflow.com/comment/138102587
has comment: http://stackoverflow.com/comment/138102318
has body: I'm trying to implement a here document like the one used in bash (in C), but I noticed that I can't give it a line that's longer than 4096 bytes, I looked it up and It was because of the max size of the Kernel I/O queues so my process never receives the full input that I type in the shell. Meanwhile the bash's heredoc can handle that. is there a way to get around this using C. with any word that exceeds 4096 characters only the 4096 characters gets printed or the input gets corrupted #include &lt;unistd.h&gt; int main() { ssize_t r_bytes; char buf[42]; while (r_bytes = read(0, buf, 42)) { write(1, buf, r_bytes); } return (0); } 1-Compile and execute this code. 2-Give it this input: &lt;start&gt;herrslcrwhjsyxlnuvxoofkmnnqnqplyyomfekjdvifzmzqsjjffjlqgvxrmhplzfaywnsptodrwygvhtplduhivfefqefkwcrficiatatbvlpzikietxdfekfnqvgazseylfagktlaseeedbbeajmnvshwkzvlfyhdoswwzzdesnaphprclhihfdckjcpepytllszcucuyvgqlfreyknejkjbthgociqxzellhzgdqkpnglnaocygxqifkjikcrepkcosxclwqlhhgzndoqroocniwrjaoumuvlvtvdrsyaupmkldzhvurnzgwhpvsyzrqzxgtlythlqflciocyepzbxyepegfxifkuopqrivsnhzqhmjmbrdkoxwrgpmdntoqlksjxwrfdadkjzjvyknulhlhmseykfpqnpvfpfbxncefcbfzdfndkwskdusuhylklqcxnmbibgmerllmzgmorqpqawbiexnbgkuaxbiucrkfsxndhdifgrfiuyanximidvvfaqnurmsnvfnwahuvpyjjvpukbrkemqotmvnvqcwivueqisxqvrfunmaaeuguqpullxgyuypepxgkrmgpfxlihmazubjmnlifqoyfidhpvvpyraddjlxoalrhsrpviqkhmcszkluelumfpukwynrmlhdvnwhhukorlpqzouzakphkgorumfqabjxrtghrvynqazsoahewbhpujofcokzeapdlpkgzrrdnmmwintaoowbzctqnxatvfecwnirxaacqmsrbecdgikauqosygzyxkyfikryohidyslrizbwnnhbiwnqbbgqylhvkmtnazfdzvweucoqdovuzfuqlywxdfkmzgsssnprekjfnutlmhbdvtcngeitphqywvtmppptaxyielehppdxjgzuvwybjealhkjjlgibgjcysgvmgfvgqpnpmadtjlngmsxgvolvdlzkfyfqoujjiegunytjkxornyruaxgpqqjhqyfwymvyglnccfbdslqdbrqpmwtonklsajnuaemvkqwjuscectjwbvohfvuecltlkhszplqxipaymbtxjztjofubjblqrrantnfcsoirrvkwnvmwnwqpdsysqsokmwylnvvryhnaatnlbmvtfhbquzmnrukbvqbvwjdqrdgthrqpnjebcokbroruogaswulugwxkrrmbrkskqhlgbufanzafdsbgcqcjxntmczmzrsjqjfcpmetvjirmcpmfmobfslagzlvoppuachoyxbrgqejrdbykeczesigww…
accepted answer: http://stackoverflow.com/a/78334773
tagged with: http://stackoverflow.com/tag/c
has comment: http://stackoverflow.com/comment/138102329
tagged with: bash
has comment: http://stackoverflow.com/comment/138102348
has comment: http://stackoverflow.com/comment/138102221
has comment: http://stackoverflow.com/comment/138102301
has comment: http://stackoverflow.com/comment/138103068
has comment: http://stackoverflow.com/comment/138102280
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138102818
has comment: http://stackoverflow.com/comment/138102460
score: 3
has comment: http://stackoverflow.com/comment/138102270
downvote count: 3
has comment: http://stackoverflow.com/comment/138102619
has answer: http://stackoverflow.com/a/78334773
type: Question
tagged with: shell
tagged with: linux

http://stackoverflow.com/q/78319248
has body: Consider the following bash script: #!/bin/bash # List of required commands required_commands=('git', 'curl', 'sdfsdf', 'jq') # this will correctly exit if the 'git' command is missing cc1='git' command -v '$cc1' >/dev/null 2>&1 || { echo "Missing '$cc1' cannot run."; exit 1; } # this function, when called below will have an error exit code for each missing_commands=() check_command() { command -v "$1" >/dev/null 2>&1 || missing_commands+=("$1") } # check each required command for cmd in "${required_commands[@]}"; do check_command "$cmd" done # Check if any commands are missing if [ ${#missing_commands[@]} -eq 0 ]; then echo "All required commands are available. Starting the script..." # Your script continues here else echo "The following commands are required but not installed:" for missing_cmd in "${missing_commands[@]}"; do echo " - $missing_cmd" done exit 1 fi # continue if all commands are available echo "All required commands are available. Starting." Unfortunately, when called inside the check_command() function, the exit code for command -v "$1" >/dev/null 2>&1 is always non-zero?? This seems unusual, and I can't understand what the difference seems to be. The target OS here is MacOS Sonoma 14.2.1 (23C71), running in ZSH in a plain terminal.
tagged with: shell
downvote count: 1
has comment: http://stackoverflow.com/comment/138075141
type: Question
tagged with: arrays
tagged with: syntax
tagged with: macos
type: UnansweredQuestion
score: 1
tagged with: bash
answer count: 1
has answer: http://stackoverflow.com/a/78319265
favorite count: 0
has comment: http://stackoverflow.com/comment/138075122
has comment: http://stackoverflow.com/comment/138075113
upvote count: 2
has title: Why does `command -v` exit code behave differently inside vs outside a bash function?

http://stackoverflow.com/q/78358550
tagged with: linux
tagged with: bash
duplicate of: http://stackoverflow.com/q/20796200
tagged with: file
has comment: http://stackoverflow.com/comment/138144237
score: 0
tagged with: arrays
type: Question
has body: I'm working on a project to manage my FLAC music files, and organize them into directories by the artist name. I am using metaflac to obtain the files' meta and getting the artist value, and then I want to create (if not exist) a directory using the artist name value and move the file into that directory. I want to load the filenames of a specified directory (arg) into an array, and iterate that array to get the file's metaflac information. My script is almost working, but the filenames values are showing with newlines in the filenames. One other thing, this will be happening on a mounted USB drive ie; media/scott/usbstick. This is my current script which is running on my ~/Music/ directory, however I don't think it matters where I run it. echo "You entered: '${*-}'" ( if [ ! -d "$1" ] then echo "Arg "$1" is NOT a directory!" exit fi flacfiles=`ls -l "$1"*.flac` for filename in $flacfiles do echo "$filename"; # pull the artist=name string from flac # s=`metaflac --show-tag=ARTIST "$file"` # get the artist on the right of the = sign # artist=$(echo "$s" | cut -d'=' -f2) # echo " Creating folder $artist and moving $file into it" # create dir of the artist, if not already exists # mkdir -p "$artist" # move the file into the artist directory # mv "$file" "$artist" done } And my output looks like this scott@minty-fresh:~/Music$ ./process.sh Oplayers/ You entered: 'Oplayers/' Oplayers/Dance (If Ya Wanta).flac Oplayers/Everybody Loves The Sunshine.flac Oplayers/Fight Me, Chase Me.flac The desired output for each $filename is a single line. metaflac is complaining it cannot find the file, probably because of the newlines in the $filename.
type: UnansweredQuestion
tagged with: flac
linked to: http://stackoverflow.com/q/20796200
has title: bash script directory of flac files to array produces strange results
answer count: 0

http://stackoverflow.com/q/78381387
tagged with: key
accepted answer: http://stackoverflow.com/a/78382071
has comment: http://stackoverflow.com/comment/138183883
downvote count: 0
has comment: http://stackoverflow.com/comment/138183985
score: 1
upvote count: 1
favorite count: 0
tagged with: jq
has answer: http://stackoverflow.com/a/78382071
has comment: http://stackoverflow.com/comment/138183989
tagged with: insert
has comment: http://stackoverflow.com/comment/138184009
tagged with: bash
type: Question
type: AnsweredQuestion
answer count: 1
has title: pass arguments to jq when inserting key not interpolated
has body: When I run jq --arg md "blablabla" '. +={'content': "$md"}' blog.json in blog.json { "foo": "bar" } I get { "foo": "bar", "content": "$md" } The desired output would be: { "foo": "bar", "content": "blablabla" }

http://stackoverflow.com/comment/138090182
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78325122
score: 0
has text: Sorry for the silly mistake. The value wasn't declared. Thanks for your great explanation.

http://stackoverflow.com/comment/138136403
type: QuestionComment
type: Comment
has text: A quotes file with `%` as a delimiter? Bet you can use `fortune` with it.
comment on: http://stackoverflow.com/q/78354041
score: 2

http://stackoverflow.com/comment/138269932
type: Comment
has text: @sven you can't, because it wasn't an answer; it was a comment. I have now written a full answer.
score: 0
comment on: http://stackoverflow.com/q/78428595
type: QuestionComment

http://stackoverflow.com/comment/138203559
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78392419
has text: Indirect expansion is only good for internal use. If you're taking a variable name from the user it's on you to validate it.
type: QuestionComment

http://stackoverflow.com/q/78353017
type: Question
has title: Strange behavior of bash (overflow of argument passed to an executable)
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138138821
has answer: http://stackoverflow.com/a/78353326
tagged with: terminal
has comment: http://stackoverflow.com/comment/138134885
answer count: 2
tagged with: linux
tagged with: bash
has body: I am doing a script in bash that aims to run some test for one of my project, and I faced a strange behavior. In my code, I have a function test_it that takes $info: an info to output, $type: a type of test, $files: a list of file name, $options: args passed at each iteration to "./prog", $optdesc: a string describing the options, and $precond: an array of string describing a precondition for each file in $files. #!/bin/sh test_it() { info=$1 type=$2 files=$3 options=$4 optdesc=$5 precond=$6 for idx in ${!files[@]} do filename="log/$type/$filed-$optdesc.log" if ! -f $filename ; then touch $filename fi if [[ "${options[@]}" = "" ]] then ./prog $file -precondition "${precond[idx]}" > $filename else ./prog $file "${options[@]}" -precondition "${precond[idx]}" > $filename fi done } I ran it first with this setting ## termination (CFG) with default setting: ## -domain boxes ## -joinbwd 2 type="termination" info="info1" files=("tests/termination/boolean.c" "tests/termination/cacm2009a.c" "tests/termination/cav2006.c" "tests/termination/example1.c" "tests/termination/example2a.c" "tests/termination/tacas2013a.c" ) precond=("${files[@]/*/"true"}") options=("-ctl-cfg" "AF{exit: true}") optdesc="termCFG" test_it "$info" $type $files $options $optdesc $precond Here everything went well. Then I ran the second test suit. ## conditional termination type="termination" info="info2" files=( "tests/termination/example7.c" "tests/termination/sas2014a.c" "tests/termination/sas2014c.c" "tests/termination/tap2008a.c" "tests/termination/tap2008b.c" "tests/termination/tap2008c.c" "tests/termination/tap2008d.c" "tests/termination/tap2008e.c" "tests/termination/widening3.c") precond=( "x > 6" "r <= 0" "x < 0" "x < 25 || x > 30" "x <= 30 && x >= 0 || x > 35 || x < -5" "x < 30" "x <= 0" "x <= 11" "x <= 0") options=() optdesc="condtermAST" test_it "$info" $type $files $options $optdesc "$precond" Here I have a problem, in the function test_it, if I print the value of each variable I obtain…
has comment: http://stackoverflow.com/comment/138134255
tagged with: unix
has comment: http://stackoverflow.com/comment/138134876
tagged with: sh
has answer: http://stackoverflow.com/a/78354347
score: 0

http://stackoverflow.com/comment/138148497
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78360964
has text: `x=44; printf '%*s' $x | tr ' ' -`?

http://stackoverflow.com/comment/138223916
score: 0
comment on: http://stackoverflow.com/a/78401596
type: Comment
type: AnswerComment
has text: Again, a very detailed and educational response. I think that item 1. Using declare simply is a very direct solution that is most easily implemented, and directly considers variable dec_array lengths. This was important. Thx!

http://stackoverflow.com/comment/138199358
has text: I figured out to fix ${x[3]} to get my desired result but it was a garbage way since it wouldn't work with engineID's of differing length.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78367681
score: 0

http://stackoverflow.com/q/78419985
type: Question
tagged with: icalendar
has body: I have this bash script that fetches calendar event data from a specified ICS (iCalendar) URL and displays events for the current date. The start and end of the events is displayed in the ics format. I have not idea how I can convert the ics format to the YYYY:MM:DD:HH:mm format. Here is my script: # Define the ICS URL of your calendar ics_url="your_url" # Get today's date in YYYYMMDD format today=$(date +%Y%m%d) # Use curl to fetch the ICS data and process it curl -s "$ics_url" | awk -v date="$today" ' BEGIN { inEvent = 0; matched = 0; eventBuffer = ""; } /BEGIN:VEVENT/ { inEvent = 1; matched = 0; eventBuffer = ""; # Reset event buffer at the beginning of a new event } /END:VEVENT/ { if (matched) { print eventBuffer; # Print the event buffer if matched print ""; # Print an empty line after each event } inEvent = 0; } /^DTSTART:/ { if (index($0, date) > 0) { matched = 1; } # Replace "DTSTART" with "start" sub(/^DTSTART:/, "start:", $0); eventBuffer = eventBuffer "\n" $0; } /^DTEND:/ { # Replace "DTEND" with "end" sub(/^DTEND:/, "end:", $0); eventBuffer = eventBuffer "\n" $0; } /^SUMMARY|DESCRIPTION/ { eventBuffer = eventBuffer "\n" $0; } ' Example output: start:20240502T080000Z end:20240502T090000Z SUMMARY:Event Desired output: start:2024:05:02:08:00:00 end:2024:05:02:09:00:00 SUMMARY:Event or start:08:00 end:09:00 SUMMARY:Event I found a solution. Thanks for all the answers. They helped a lot. ics_url="your_url" # Get today's date in YYYYMMDD format today=$(date +%Y%m%d) # Use curl to fetch the ICS data and process it curl -s "$ics_url" | awk -v date="$today" ' BEGIN { inEvent = 0; matched = 0; } /BEGIN:VEVENT/ { inEvent = 1; matched = 0; # Reset the matched flag at the beginning of a new event start = ""; # Reset variables at the start of a new event end = ""; summary = ""; } /END:VEVENT/ { if (matched) { # Extract hour and minute from start and end variables start1 = substr(start, 10, 2); start2 = substr(start, 12, 2); end1 = substr(end, 10, 2); end2 = substr(end…
has title: Converting ICS Date to YYYY:MM:DD:HH:mm
has comment: http://stackoverflow.com/comment/138260632
has comment: http://stackoverflow.com/comment/138254462
tagged with: awk
has answer: http://stackoverflow.com/a/78422089
has comment: http://stackoverflow.com/comment/138253201
score: 0
has comment: http://stackoverflow.com/comment/138253167
has answer: http://stackoverflow.com/a/78420842
has answer: http://stackoverflow.com/a/78420654
accepted answer: http://stackoverflow.com/a/78420842
has comment: http://stackoverflow.com/comment/138254672
favorite count: 0
tagged with: formatting
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78421638
has comment: http://stackoverflow.com/comment/138252763
possible better answer: http://stackoverflow.com/a/78421638
has answer: http://stackoverflow.com/a/78425130
upvote count: 2
downvote count: 2
tagged with: bash
answer count: 5

http://stackoverflow.com/a/78430002
answers question: http://stackoverflow.com/q/78412927
score: 0
type: Answer
has body: The digitalocean API doesn't handle CAA records as a single record_data string, but has specific fields for tags and flags (only the authority goes to the data field). This basically solved my issue.

http://stackoverflow.com/a/78421667
upvote count: 1
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78374366
type: Answer
has body: docker-compose.yml: version is obsolete&quot; As Docker has made this version line obsolete, remove this line from the docker-compose.yml file which is most probably causing this problem.

http://stackoverflow.com/a/78402923
upvote count: 2
has comment: http://stackoverflow.com/comment/138222181
answers question: http://stackoverflow.com/q/78402822
type: Answer
score: 2
has body: The up-arrow can be preceded by a count to indicate how many commands back you want to go. How you do that depends on whether you use emacs or vi bindings, but I'll assume you are using the default emacs bindings. To go back 7 commands, press Escape, then 7, then ⇧. If you wanted to go back 10 or more times, press Escape before each digit in the count. (For example, to go back 13 commands, press Escape 1 Escape 3 ⇧.)
downvote count: 0
has comment: http://stackoverflow.com/comment/138222067
has comment: http://stackoverflow.com/comment/138222114
has comment: http://stackoverflow.com/comment/138222122

http://stackoverflow.com/q/78351657
has answer: http://stackoverflow.com/a/78351708
answer count: 1
upvote count: 3
accepted answer: http://stackoverflow.com/a/78351708
tagged with: bash
tagged with: exit-code
favorite count: 0
has body: GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu) Consider this simple while loop: while false; do true; done; echo &quot;${PIPESTATUS[0]}&quot; It prints 1 instead of 0. This is unexpected to me and I can't find any documentation about this. The same loop, when checked for actual exit code: while false; do true; done; echo $? prints 0, as expected. I also noticed that if a break is used in the body: while true; do true; break; done; echo &quot;${PIPESTATUS[0]}&quot; then both the PIPESTATUS as well as the exit code are both 0, as expected. Setting pipefail option does not seem to change this behaviour. My guess: I guess the loop condition is technically the last statement to be executed, and hence its exit code is returned in PIPESTATUS. This explains why break did not return 1 while false loop condition does. However, this leads to more questions: Why the disparity between PIPESTATUS and actual exit code? Won't all while loops end with PIPESTATUS 1, since every loop has to stop due loop condition being false? (Except the loops that end due to a break) Does this mean it is a reliable way to tell whether the loop exited to loop condition becoming false or because of a break? Thanks in advance for your help.
type: AnsweredQuestion
has title: Why does a Bash while loop result in PIPESTATUS "1" instead of "0"?
score: 3
has comment: http://stackoverflow.com/comment/138131909
type: Question
downvote count: 0

http://stackoverflow.com/comment/138258430
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78420632
has text: Thank you, I will try this and let you know the result.
score: 0

http://stackoverflow.com/comment/138252768
type: QuestionComment
has text: @Barmar Good point with the disk being too full. I suppose ANY echo command with a redirect could fail. If I suppose I should check if that particular partition is close to being full at the beginning. That said, a redirect could be a to a network-mapped drive that occasionally fails, so it's not like I can handle every possible error condition.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78420131

http://stackoverflow.com/q/78350497
score: 0
has comment: http://stackoverflow.com/comment/138137524
has comment: http://stackoverflow.com/comment/138137136
tagged with: bash
has comment: http://stackoverflow.com/comment/138130314
linked to: http://stackoverflow.com/q/78342895
has comment: http://stackoverflow.com/comment/138129958
accepted answer: http://stackoverflow.com/a/78350523
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138137551
has comment: http://stackoverflow.com/comment/138129949
has comment: http://stackoverflow.com/comment/138129894
has answer: http://stackoverflow.com/a/78350523
has comment: http://stackoverflow.com/comment/138137499
type: Question
tagged with: shell
has body: I'm able to zip a file, upload it, and expand it into a directory on a server like so: tar -pzcf - example.txt | ssh user@198.123.45.678 'cd /some-path/ && tar -zxf -' Is it possible to do the same thing with heredoc? Something like the following (which doesn't work): tar -pzcf - example.txt | ssh user@198.123.45.678 /bin/bash <<EOF cd /some-path/ tar -zxf - EOF Justification: I have a bunch of local scripts I'm running over SSH on two servers that treat quotes differently, and heredoc fixes that issue. However, several of the scripts pipe files though pipe viewer to the server so I can monitor progress, and I've not been able to find a way to pipe the contents of a local file into pv and then into a heredoc expression so that I can manipulate that file on the server (like I can without heredoc). EDIT It also needs to support expansion so I can read values from a config file, which is why the above justification/link mentions quotes being an issue: root_path=`jq -r '.config.path.remote' config.json` tar -pzcf - example.txt | ssh user@198.123.45.678 "cd '$root_path' && tar -zxf -" and (again, not working, but the expansion works): root_path=`jq -r '.config.path.remote' config.json` tar -pzcf - example.txt | ssh user@198.123.45.678 /bin/bash <<EOF cd "$root_path" tar -zxf - EOF
answer count: 1
has comment: http://stackoverflow.com/comment/138137388
has title: Is it possible to pipe a file into heredoc in bash?
has comment: http://stackoverflow.com/comment/138137299
has comment: http://stackoverflow.com/comment/138137384
has comment: http://stackoverflow.com/comment/138129919

http://stackoverflow.com/a/78438409
score: 4
has body: To simulate OP's grep -v output: $ cat grep.out 0: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7714 1 000000009796c30c 100 0 0 10 0 1: 845DA8C0:1F91 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 66072 1 0000000080e84053 100 0 0 10 0 2: 0100007F:86FD 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 476 1 000000005f80511b 100 0 0 10 0 3: 00000000:1F90 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 29391 1 0000000098b1d0d1 100 0 0 10 0 4: 00000000:1F92 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 66342 1 0000000004ea4afe 100 0 0 10 0 5: 9F01A8C0:0016 0101A8C0:E488 01 00000000:00000000 02:000AD0D3 00000000 0 0 68121 2 000000008fdfa15d 20 4 16 10 -1 0: 00000000000000000000000000000000:0016 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7716 1 0000000037928e79 100 0 0 10 0 One awk approach: cat grep.out | awk -v iplist='845DA8C0,00000000' ' # set awk variable "iplist" to set of ip addresses delimited by comma BEGIN { split(iplist,a,",") # split iplist into array a[] for (i in a) ips[a[i]] # convert a[1]=845DA8C0 to ips[845DA8C0] } { split($2,a,":") # split 2nd field on ":" if (a[1] in ips) # if 1st tuple is an index in ips[] array then ... ports[a[2] $4] # save 2nd tuple and 4th field as index in array ports[]; this will eliminate duplicates } END { for (port in ports) # loop through indices of port[] array and ... print port # print the port info to stdout } ' | sort # output order from this awk script is not guaranteed so let "sort" provide the desired order This generates: 00160A 1F910A 1F900A 1F920A As has been pointed out in comments, once you bring awk into the mix you can usually eliminate the need for grep, cut and using sort (to filter out duplicates). Modifying the awk script to directly process the /proc/net files: awk -v iplist='845DA8C0,00000000' ' BEGIN { split(iplist,a,",") for (i in a) ips[a[i]] } /local_address/ { next } # skip processin…
has comment: http://stackoverflow.com/comment/138285080
has comment: http://stackoverflow.com/comment/138285657
type: AcceptedAnswer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/78438262
type: Answer
answers question: http://stackoverflow.com/q/78438262
has comment: http://stackoverflow.com/comment/138285628
downvote count: 0

http://stackoverflow.com/q/78398495
has comment: http://stackoverflow.com/comment/138222480
has comment: http://stackoverflow.com/comment/138214496
type: Question
has comment: http://stackoverflow.com/comment/138214466
type: UnansweredQuestion
has body: I am trying to install java 11 on oracle linux 9. using the below script for instalation. #! /bin/bash java_version=11.0.22.7.1 # Linux os_arch=$(uname -s); os_arch_lower=$(echo "$os_arch" | tr '[:upper:]' '[:lower:]'); echo "$os_arch_lower" # architecture x86 os_arch=$(uname -i | cut -d'_' -f1 | tr '[:upper:]' '[:lower:]'); echo "$os_arch" # Create the destination directory if it does not exist mkdir -p /usr/java/ # Install Amazon correto jdk 11 curl -LO https://corretto.aws/downloads/resources/${java_version}/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz \ && mv "amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz" "/usr/java/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz" \ && cd /usr/java \ && tar zxvf "amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz" \ && JAVA_HOME=/usr/java/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch} \ && export JAVA_HOME=/usr/java/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch} \ && export PATH=$JAVA_HOME/bin:$PATH \ && echo $PATH \ && java --version even though after untarring the files to /usr/java/ i am getting error while running java command which means some issue with java installation. bash.sh: line 23: /usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java: No such file or directory please help me. what am i missing? https://github.com/devwithkrishna/create-jenkins-docker-image/blob/main/download_install_amazon_correto.sh i have tried to fix issue myself and with available solutions from google. but none of them worked. even though it says it didnt find java file on error: /usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java: No such file or directory The file is present. [root@83f38c9b634e /]$ ls -la /usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java -rwxr-xr-x 1 root root 7436 Jan 10 19:48 /usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java
duplicate of: http://stackoverflow.com/q/56754859
tagged with: java-11
has comment: http://stackoverflow.com/comment/138222881
answer count: 0
has title: java 11 installation issue on oracle linux docker container
tagged with: bash
has comment: http://stackoverflow.com/comment/138214447
tagged with: java
has comment: http://stackoverflow.com/comment/138214450
has comment: http://stackoverflow.com/comment/138214477
linked to: http://stackoverflow.com/q/56754859
score: 0

http://stackoverflow.com/comment/138094901
comment on: http://stackoverflow.com/q/78330326
type: QuestionComment
has text: You could use [this](https://unix.stackexchange.com/questions/21363/execute-bash-scripts-on-entering-a-directory) to execute a script when you enter each directory, and it could load that directory's completions.
type: Comment
score: 0

http://stackoverflow.com/comment/138237897
type: AnswerComment
comment on: http://stackoverflow.com/a/78411741
score: 0
has text: it works great and concise script. Since my actual case is to process several files in folder and subfolders, how to add the path of the current file processed? it should be outside the `jq` command? My final goal if to get a "tree" like view of the json files based on the files location and `Paths` showed in each file.
type: Comment

http://stackoverflow.com/comment/138132009
has text: What does it do instead of executing the step? Print anything in logs? Fails the pipeline? Just silently skips?
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524

http://stackoverflow.com/q/78317514
has comment: http://stackoverflow.com/comment/138072469
has comment: http://stackoverflow.com/comment/138072389
has comment: http://stackoverflow.com/comment/138072498
has comment: http://stackoverflow.com/comment/138072486
has title: Why does my Bash script give an error at the end of ps command when I terminate background a process?
tagged with: bash
has comment: http://stackoverflow.com/comment/138072078
has comment: http://stackoverflow.com/comment/138072417
has comment: http://stackoverflow.com/comment/138072518
answer count: 1
has answer: http://stackoverflow.com/a/78320219
has comment: http://stackoverflow.com/comment/138072445
has comment: http://stackoverflow.com/comment/138072059
has comment: http://stackoverflow.com/comment/138072481
tagged with: kill
has comment: http://stackoverflow.com/comment/138073349
linked to: http://stackoverflow.com/q/690266
score: 0
has body: So for my class I am tasked to write a script, everything works fine until after the ps command finishes output it also adds an error message (script.sh: line 42: PID Terminated sleep 900 &) after what seems to be successfully output for the ps command on line 42. script.sh: #!/bin/bash # Clears screen and displays current running processes clear ps # Pauses for 10 seconds sleep 10 # Displays Parent Process ID using $BASHPID env var (expands to subshells) # $BASHPID requires Bash 4 or later echo echo -e "Parent Process ID:\t$BASHPID" echo # Creates background process: Pause for 900 seconds sleep 900 & # Displays background jobs jobs -l # Pauses for 10 seconds sleep 10 # Uses jobs -l, grep (in case other jobs are running), and cut to find PID of background job and saves it as a variable bgjob=$(jobs -l | grep "sleep 900" | cut -d" " -f2) # Terminates the background job created kill -SIGTERM $bgjob # Displays current processes so you can verify background job sucsessfully terminated echo ps echo # Pauses for 10 seconds sleep 10 exit 0 I was expecting it to have a clean output like output from the ps command and maybe some sort of output for the kill command or at least the error to be on that line
type: Question
has comment: http://stackoverflow.com/comment/138072457
tagged with: background-process
has comment: http://stackoverflow.com/comment/138072089
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138072427
has comment: http://stackoverflow.com/comment/138072461
has comment: http://stackoverflow.com/comment/138073341
has comment: http://stackoverflow.com/comment/138072074

http://stackoverflow.com/a/78421638
has body: Assumptions: DTSTART / DTEND could occur anywhere including outside of a BEGIN:VEVENT / END:EVENT but ... we're only interested in the DTSTART / DTEND entries that occur within a BEGIN:VEVENT / END:VEVENT pair within a BEGIN:VEVENT / END:VEVENT pair the 4x desired data points may be in any order or even missing (if this is not true then the proposed solution may be a bit overkill but it should still generate the desired results) OP hasn't provided the actual output from the curl call so I'm going to copy/modify azbarcea's data set: $ cat curl.out BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Example Corp.//iCal4j 1.0//EN CALSCALE:GREGORIAN BEGIN:VEVENT DTSTAMP:20240502T120000Z DTSTART:20240502T090000Z DTEND:20240505T100000Z SUMMARY:Team Meeting DESCRIPTION:Weekly team meeting to discuss progress and upcoming tasks. LOCATION:Conference Room UID:1234567890 SEQUENCE:0 END:VEVENT # scramble order of entries; remove SUMMARY BEGIN:VEVENT DESCRIPTION:Present our latest project updates to the client. DTSTART:20240510T140000Z DTEND:20240510T160000Z DTSTAMP:20240502T120000Z LOCATION:Client's Office UID:0987654321 SEQUENCE:0 END:VEVENT END:VCALENDAR One awk idea: cat curl.out | awk -v date="${today}" ' function parse_dt(dt) { # reformat the ICS datetime string if (dt ~ /[0-9]{8}T[0-9]{6}Z/) return substr(dt,1,4) ":" \ substr(dt,5,2) ":" \ substr(dt,7,2) ":" \ substr(dt,10,2) ":" \ substr(dt,12,2) ":" \ substr(dt,14,2) } function print_event() { if (event[1] != "") { # if we have a match (ie, DSTART == date) then print array print event[1] # event[1] == DTSTART for (i=2;i<=4;i++) # event[2] == DTEND if (event[i] != "") # event[3] == SUMMARY print event[i] # event[4] == DESCRIPTION } delete event # clear/reset array } BEGIN { FS =":" map["SUMMARY"] = 3 map["DESCRIPTION"] = 4 } $2=="VEVENT" { if ($1 == "BEGIN") # we are only interested in DSTART/DTEND pairs within a BEGIN:VEVENT/END:VEVENT pair inEvent = 1 else if ($1 == "END" ) { print_event() inEvent = 0 } next } inEvent { if ($1 == "D…
downvote count: 0
answers question: http://stackoverflow.com/q/78419985
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/a/78439618
has body: Using any awk: $ awk '{print (NR==1 || /^#/ ? "" : "E_") $0}' file EMP_ID,EMP_NAME,JOINING_DATE,SALARY E_1,T Natarajan,22-APR-2024,6000000 E_2,Velmurugan,22-JUL-2024,2000000 E_3,Rowin,21-OCT-2024,5000000 #END_OF_FILE
answers question: http://stackoverflow.com/q/78423090
upvote count: 1
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/comment/138079619
has text: Also, while this isn't strictly your problem, `echo -e "$foo\n$bar"` has unintended consequences. `printf '%s\n' "$foo" "$bar"` is safer -- it doesn't treat the contents of your variables as format strings themselves, and it's compatible with shells and shell configurations that don't honor the `-e` argument to `echo` as anything other than a string to print on output (which is what a strict reading of POSIX requires, so even in bash that behavior can be disabled).
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78321765

http://stackoverflow.com/q/78356050
upvote count: 2
has comment: http://stackoverflow.com/comment/138142803
has comment: http://stackoverflow.com/comment/138139943
tagged with: bash
has answer: http://stackoverflow.com/a/78356251
has comment: http://stackoverflow.com/comment/138139967
has answer: http://stackoverflow.com/a/78427475
favorite count: 0
has comment: http://stackoverflow.com/comment/138139957
tagged with: regex
type: Question
has answer: http://stackoverflow.com/a/78357565
type: UnansweredQuestion
score: 1
has comment: http://stackoverflow.com/comment/138139961
has comment: http://stackoverflow.com/comment/138140310
has body: I'm testing regular expressions in .sed script to replace a number &lt; 100. I have to change numbers lower than 100 only in the fifth field of the CSV. The CSV is separated by commas. Example CSV: datetime,car,brand,model,km,new 10/10/1949 20:30,yes,ford,f150,20,yes 10/10/1949 20:30,no,yamaha,r7,1560,yes 10/10/1949 20:30,yes,renault,twingo,37,yes 10/10/1949 20:30,no,honda,cbr600rr,2000,no and i have this script: # Replace s/\([^,]*,[^,]*,[^,]*,[^,]*,\)\(0\|[1-9][0-9]\{0,1\}\)\([^,]*\)/\1none\3/ answer in terminal must be: datetime,car,brand,model,km,new 10/10/1949 20:30,yes,ford,f150,none,yes 10/10/1949 20:30,no,yamaha,r7,1560,yes 10/10/1949 20:30,yes,renault,twingo,none,yes 10/10/1949 20:30,no,honda,cbr600rr,2000,no I run the script with sed -f script.sed ./sample.csv and the answer is datetime,car,brand,model,km,new 10/10/1949 20:30,yes,ford,f150,none,yes 10/10/1949 20:30,no,yamaha,r7,none60,yes 10/10/1949 20:30,yes,renault,twingo,none,yes 10/10/1949 20:30,no,honda,cbr600rr,none00,no it replace always the first to numbers, not only the fields that have number to 0-99. EDIT: I cant use awk for that. Could you help me? Thank you very much. Best regards.
answer count: 3
has comment: http://stackoverflow.com/comment/138265640
has comment: http://stackoverflow.com/comment/138139987
has comment: http://stackoverflow.com/comment/138139941
downvote count: 1
tagged with: sed
has title: Regex that replace number lower than 100 by a string in sed script
has comment: http://stackoverflow.com/comment/138140349
has comment: http://stackoverflow.com/comment/138139949

http://stackoverflow.com/q/78419674
tagged with: shell
has title: What's the difference if subshell vs compound statements in if statement?
favorite count: 0
score: 2
upvote count: 2
answer count: 2
has body: In bash script, I need to run a command, which is a &amp;&amp; compound, I wonder what's the difference between put it in a subshell, and just run it in if condition? if ! ( cmd_A &amp;&amp; cmd_B ); then doSth fi vs. if ! cmd_A &amp;&amp; cmd_B; then doSth fi
possible better answer: http://stackoverflow.com/a/78419717
downvote count: 0
tagged with: bash
accepted answer: http://stackoverflow.com/a/78419699
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78419717
has answer: http://stackoverflow.com/a/78419699
type: Question

http://stackoverflow.com/comment/138102112
type: Comment
comment on: http://stackoverflow.com/q/78334722
score: 3
type: QuestionComment
has text: When using `read` you most probably want to check that you read `> 0` characters. Note that it may return `-1` in which case you will try to `write` `size_t(-1)` bytes which is _a lot_ and will access your `buf` out of bounds.

http://stackoverflow.com/q/78354041
tagged with: linux
has comment: http://stackoverflow.com/comment/138136076
has answer: http://stackoverflow.com/a/78543432
upvote count: 1
has title: Output random chunk of file divided by an arbitrary character in Bash Script
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138136403
has body: I have a text file of quotes. I want to output one quote every time I open bash through WSL. I know I need to put my commands in .bashrc, my issue is knowing which command to use. I found one called shuf that sounds like it'd work well, but my quotes contain newlines and I haven't found an option that allows me to divide the quote file by an arbitrary character. Essentially, I need to convert this Python code into Bash Script import random with open("csciquotes.txt", 'r') as f: result = random.choice(f.read().split("%")) print(result) The issue is finding how to mimic .split("%"). I've read several questions and haven't found anything, as well as some guides.
tagged with: bash
has answer: http://stackoverflow.com/a/78354378
type: Question
has answer: http://stackoverflow.com/a/78355289
has answer: http://stackoverflow.com/a/78354221
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138136417
score: 0
has comment: http://stackoverflow.com/comment/138149248
answer count: 4

http://stackoverflow.com/comment/138137153
type: AnswerComment
comment on: http://stackoverflow.com/a/78350523
score: 0
has text: There are many uses of sudo and ssh where it can be extremely difficult to get all the quoting and escaping right (the worst may be the combination `ssh hostname sudo ...`). I've probably posted an answer at [unix.se] where a here-doc was the solution. I usually recommend that they copy a script to the remote, then execute the script using ssh, rather than try to combine everything. Unfortunately, they usually say this isn't possible.
type: Comment

http://stackoverflow.com/q/78438262
has answer: http://stackoverflow.com/a/78438419
tagged with: parsing
tagged with: bash
possible better answer: http://stackoverflow.com/a/78438419
type: Question
has body: I want to create a oneliner using awk with some logic. this is the command and the output to work with: grep -v "local_address" --no-filename "/proc/net/tcp" "/proc/net/tcp6" 0: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7714 1 000000009796c30c 100 0 0 10 0 1: 845DA8C0:1F91 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 66072 1 0000000080e84053 100 0 0 10 0 2: 0100007F:86FD 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 476 1 000000005f80511b 100 0 0 10 0 3: 00000000:1F90 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 29391 1 0000000098b1d0d1 100 0 0 10 0 4: 00000000:1F92 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 66342 1 0000000004ea4afe 100 0 0 10 0 5: 9F01A8C0:0016 0101A8C0:E488 01 00000000:00000000 02:000AD0D3 00000000 0 0 68121 2 000000008fdfa15d 20 4 16 10 -1 0: 00000000000000000000000000000000:0016 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7716 1 0000000037928e79 100 0 0 10 0 I'm creating a function to detect possible port conflicts and I already have functions for ip and port conversions from hex to dec and viceversa. In this case for example, IP 192.168.93.132 is 845DA8C0. So if I ask for possible port conflicts on this interface, the querie should return all the ports pertaining to this ip (845DA8C0) and all pertaining to 00000000 which is on decimal 0.0.0.0 and are also affecting and conflicting. So in this case the correct answer should be 0016, 1F91, 1F90 and 1F92 (not relevant but in dec are ports 22, 8081, 8080 and 8082). And I also want the $4 column which contains the 0A or whatever value because it is used to determine if the port is used. So the expected and desired output should be: 00160A 1F910A 1F900A 1F920A My current oneliner approach is adding to the array all the ports, no matter what interface are they on: declare -a busy_ports=($(grep -v "local_address" --no-filename "/proc/net/tcp" "/proc/net/tcp6" | awk '{prin…
accepted answer: http://stackoverflow.com/a/78438409
has comment: http://stackoverflow.com/comment/138284770
tagged with: text-parsing
upvote count: 1
has comment: http://stackoverflow.com/comment/138284788
has comment: http://stackoverflow.com/comment/138284755
answer count: 2
has answer: http://stackoverflow.com/a/78438409
has comment: http://stackoverflow.com/comment/138285610
has title: Bash + awk advanced parsing
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/138284825
has comment: http://stackoverflow.com/comment/138284821
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138284762
has comment: http://stackoverflow.com/comment/138285503
tagged with: awk
has comment: http://stackoverflow.com/comment/138284799

http://stackoverflow.com/comment/138080049
comment on: http://stackoverflow.com/q/78322081
has text: [shellcheck](https://www.shellcheck.net) says "Expected comparison operator (don't wrap commands in []/[[]])." because you should not put `[ .. ]` around commands you want to run (`/usr/bin/[` is a command in itself, not shell syntax)
type: QuestionComment
type: Comment
score: 4

http://stackoverflow.com/a/78327018
downvote count: 0
score: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78326995
has body: FILE EXISTS: LoD2_326625712.jsonl LoD2_326625712.jsonl Before the first LoD2_326625712.jsonl, there are two space. echo "FILE EXISTS: $file_exists $base.jsonl" Before $file_exists, there is only one space. So I think there is one extra space before $file_exists
answers question: http://stackoverflow.com/q/78326995
type: Answer
upvote count: 2

jenkins-groovy
tags question: http://stackoverflow.com/q/78376379
tags question: http://stackoverflow.com/q/78348524
type: Tag
tag name: jenkins-groovy
tags question: http://stackoverflow.com/q/78956880
tags question: http://stackoverflow.com/q/79312384
tags question: http://stackoverflow.com/q/79483250

http://stackoverflow.com/comment/138102282
comment on: http://stackoverflow.com/a/78334773
score: 0
has text: Thanks for the answer! but unfortunatly I can only use these c functions: open, close, read, write, malloc, free, perror, strerror, access, dup, dup2, execve, exit, fork, pipe, unlink, wait, waitpid any ideas if it's still fixable in my case
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78331935
tagged with: pipe
linked to: http://stackoverflow.com/q/6871859
tagged with: bash
tagged with: tee
answer count: 1
has comment: http://stackoverflow.com/comment/138109606
tagged with: sed
linked to: http://stackoverflow.com/q/68465355
linked to: http://stackoverflow.com/q/1221833
score: 0
type: Question
tagged with: shell
duplicate of: http://stackoverflow.com/q/68465355
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/1221833
has body: I'm using turbo feature called turbo prune which creates folder out with partial copy of my monorepo, but unfortunately that means that when running in GitHub Actions commands like turbo run lint will print out paths that have out in them (thus breaking regular github error reporting), so I instead of having this command: turbo run lint I tried to replace it with: turbo run lint | sed 's/\/out//g' Which outputs correct paths, but my lint check always passes because even though turbo exited with exit code 1, but sed exited with 0.
has answer: http://stackoverflow.com/a/78331936
has title: Bash pipe swallows exit code when pipe like sed or tee

http://stackoverflow.com/comment/138070973
score: 0
has text: I've seen that discussion before but honestly don't think it's a similar issue or I'm not understanding the text correctly. There is no equivalent program to MMM in my project
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78316783

http://stackoverflow.com/q/78428782
has comment: http://stackoverflow.com/comment/138268302
duplicate of: http://stackoverflow.com/q/39527571
tagged with: bash
type: UnansweredQuestion
tagged with: scripting
has title: Can't echo same variable twice on one line
duplicate of: http://stackoverflow.com/q/45772525
score: 0
type: Question
answer count: 0
tagged with: shell
linked to: http://stackoverflow.com/q/39527571
has body: PORT=$(cat /root/EnvironmentConfigurations/mbc_back/.env | grep '^PORT=' | cut -d '=' -f 2) echo $PORT:$PORT OUTPUT IS-> ":6590" SHOULD BE-> "6590:6590" I have tried to display 6590:6590 but i only got :6590 for some reason first one becomes empty also tried getting another variable from that file still the same result.
tagged with: sh

http://stackoverflow.com/q/78437288
has comment: http://stackoverflow.com/comment/138284026
tagged with: bash
has comment: http://stackoverflow.com/comment/138282936
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78437427
linked to: http://stackoverflow.com/q/4651437
has body: I got 2 bash scripts: sc1.sh #!/bin/bash function func_name() { var123="abcd123" return $var123 } func_name script2.sh #!/bin/bash var= <-here I want to have value abcd123 How to do it? I know there is a error in sc1.sh because return requires numeric only. I want that sc1.sh return/export etc. value like "abd3831d" and in sc2.sh use this value and passes to another variable e.g.: var=(value of var123 form sc1.sh)
has comment: http://stackoverflow.com/comment/138284019
has title: How to call bash script or function to return nonnumerical value in another bash script
type: Question
has comment: http://stackoverflow.com/comment/138282908
answer count: 1
has comment: http://stackoverflow.com/comment/138283064
linked to: http://stackoverflow.com/q/3236871
score: 0

http://stackoverflow.com/comment/138122513
score: 2
comment on: http://stackoverflow.com/q/78346345
has text: What is an _if-**loop**_?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/138106061
comment on: http://stackoverflow.com/a/78336467
has text: Your edit does not seem to work because the `-l` "Make bash act as if it had been invoked as a login shell" which among other things sets the cwd to the default home. This is in fact the root of the problem. The solution it seems is to drop the `-l` argument.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/138200003
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78389737
score: 0
has text: Thank you. That looks exactly like what I need. However, I can't seem to get it to work. There's something about the syntax. I used `set -x` to track what is going on. Where the line `source <(grep = <path_to_file>)` is, the log shows `+ source /dev/fd/63` . I tried various combinations of whitespace and parantheses (I am still a bit confused about some details of the syntax) but no joy.

http://stackoverflow.com/comment/138203987
comment on: http://stackoverflow.com/q/78392466
type: QuestionComment
type: Comment
has text: Once you've got the issues described in the linked duplicate worked out, if you're still having problems, consider using `set -x;` at the front of your remote command to get more logging so you can narrow down a specific problem and ask a question that's narrowly focused on that problem.
score: 0

http://stackoverflow.com/comment/138255034
type: AnswerComment
comment on: http://stackoverflow.com/a/78421472
has text: "Snippets" are only for code that can be run inside a web browser. Use the `{}` button, not the snippet button, for everything that isn't HTML/JS/CSS.
score: 0
type: Comment

http://stackoverflow.com/comment/138207592
comment on: http://stackoverflow.com/q/78341621
score: 0
type: QuestionComment
has text: In your last approach, you are doing the `ls` locally (because of the backticks), before the ssh is executed. You have to escape the backticks, so that they are "seen" by the remote shell.
type: Comment

http://stackoverflow.com/comment/138278444
score: 1
type: QuestionComment
has text: You can use `for count in 0 1 2` or `for count in {0..2}`
type: Comment
comment on: http://stackoverflow.com/q/78434093

http://stackoverflow.com/comment/138222077
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78402103
has text: What's with all the `var=$(echo blah)`? And especially, what's with capturing the standard output (only) of the `mysql` command, only to output it? And what makes you think that `echo "$output"` would produce any output to its standard error that would be of any interest?

http://stackoverflow.com/a/78425130
type: Answer
score: 0
has body: I also added an option to convert the UTC +0 time to a different time zone ( in my case +2 UTC). timeshift="2" start1 = substr(start, 10, 2); start2 = substr(start, 12, 2); start1= start1+timeshift; end1 = substr(end, 10, 2); end2 = substr(end, 12, 2); end1= end1+timeshift;
answers question: http://stackoverflow.com/q/78419985

http://stackoverflow.com/q/78403621
answer count: 1
tagged with: linux
tagged with: bash
has answer: http://stackoverflow.com/a/78403776
has title: Avoid 100% cpu when I read a FIFO file
has comment: http://stackoverflow.com/comment/138223408
has body: I need to read FIFO file, because it's arriving snmp traps in a FIFO file that I need to read and process them sequentially. So I've created a while (true) loop to begin to read lines of FIFO file and process the output. Problem is machine increase cpu up 100% with the use of the script. I don't know if I insert a sleep 3s in script. Will read all lines of fifo file? Or could be that it doesn't read all lines? I need to decrease cpu performnace of script My code is like these: while true do if read linea; then initialice PintaInfo "$linea" ...... Fifo file is feeding with snmp traps Thanks and sorry for my English!
has comment: http://stackoverflow.com/comment/138228526
tagged with: performance
score: 0
has comment: http://stackoverflow.com/comment/138228150
type: Question
tagged with: fifo
type: UnansweredQuestion

http://stackoverflow.com/comment/138251248
score: 1
comment on: http://stackoverflow.com/q/78419450
type: QuestionComment
has text: Probably something to do with `*` being expended by your shell. Try `calculator 1 2 '*'`. Also, checkout `elif` ;)
type: Comment

http://stackoverflow.com/a/78386431
accepted answer of: http://stackoverflow.com/q/78386230
downvote count: 0
type: AcceptedAnswer
score: 2
upvote count: 2
has body: Assumptions: must process files based on names in the L00? files must process files in the same order in which they are listed in the L00? files we do not know beforehand the names of the files in the L00? files One idea using a pair of for/while loops: rm -rf All_file*.file for ((i=1;i<=4;i++)) do while read -r fname do pfx="${fname%_*}" cat "${fname}" >> "All_${pfx}.file" done < L00${i} done If we know for a fact that all of the 1st line filenames are to be cat'd together, then all of the 2nd line filesnames, etc ... Use the paste command to match associated files, eg: $ paste L001 L002 L003 L004 | head -3 file1_L001 file1_L002 file1_L003 file1_L004 file2_L001 file2_L002 file2_L003 file2_L004 file3_L001 file3_L002 file3_L003 file3_L004 We could then feed this into a single while loop, eg: while read -r flist do read -r f1 _ <<< "${flist}" # f1 == first file name pfx="${f1%_*}" # strip off the '_L00?' suffix cat "${flist}" > "All_${pfx}.file" done < <(paste L001 L002 L003 L004) This 2nd approach is going to be more efficient if simply because we go from 192 (4x48) cat / >> operations down to 48 cat / > operations.
type: Answer
answers question: http://stackoverflow.com/q/78386230

http://stackoverflow.com/a/78422867
has comment: http://stackoverflow.com/comment/138257440
answers question: http://stackoverflow.com/q/78422837
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/138257503
has comment: http://stackoverflow.com/comment/138269072
has comment: http://stackoverflow.com/comment/138257473
has body: By default make runs a Makefile with /bin/sh, which explains your error. With GNU make you can change that shell by defining the SHELL variable at the start of the Makefile: SHELL = /usr/local/bin/bash
downvote count: 0
has comment: http://stackoverflow.com/comment/138278755
upvote count: 1

http://stackoverflow.com/comment/138159151
has text: it would be the latest modified file in the directory. . And the filename cannot contain newline characters.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78341621
type: QuestionComment

http://stackoverflow.com/comment/138270280
has text: Your variable URL contains the newline. How do you set it?
type: Comment
comment on: http://stackoverflow.com/q/78429844
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138244735
comment on: http://stackoverflow.com/q/78415633
type: QuestionComment
has text: Sorry, I misunderstood when you said "and the script exits with that".
type: Comment
score: 0

http://stackoverflow.com/a/78368119
has body: You start the threads at different times, so wait a while before you start the next thread. As a simple demonstration: #include <stdio.h> #include <pthread.h> #include <unistd.h> void *thread_function(void *arg) { int thread_num = *((int *)arg); printf("Dit is thread %d\n", thread_num); sleep(300); printf("Einde thread %d\n", thread_num); pthread_exit(NULL); } int main() { pthread_t threads[3]; int thread_args[3]; for (int i = 0; i < 3; i++) { thread_args[i] = i; pthread_create(&threads[i], NULL, thread_function, &thread_args[i]); sleep(60); } for (int i = 0; i < 3; i++) { pthread_join(threads[i], NULL); } return 0; }
answers question: http://stackoverflow.com/q/78362703
type: Answer
score: 0

readline
tag name: readline
type: Tag
tags question: http://stackoverflow.com/q/78344372
tags question: http://stackoverflow.com/q/78875305
tags question: http://stackoverflow.com/q/79397922

http://stackoverflow.com/q/78320604
has title: crontab won't open chromium at boot
has comment: http://stackoverflow.com/comment/138077833
has comment: http://stackoverflow.com/comment/138206767
has comment: http://stackoverflow.com/comment/138078950
score: 0
tagged with: raspberry-pi
tagged with: bash
answer count: 1
tagged with: boot
type: AnsweredQuestion
tagged with: cron
has comment: http://stackoverflow.com/comment/138207933
has comment: http://stackoverflow.com/comment/138078136
has answer: http://stackoverflow.com/a/78399045
type: Question
accepted answer: http://stackoverflow.com/a/78399045
has comment: http://stackoverflow.com/comment/138206932
has body: I set crontab to execute a bash script at boot @reboot bash /home/user/linuxconfig/startup.sh During every boot I see the bash is executed because it creates dummy files. #!/usr/bin/bash touch /home/user/linuxconfig/test.txt chromium-browser https://open.spotify.com/ touch /home/user/linuxconfig/test2.txt The files are created but chromium won't open. When I execute the script after boot on a terminal, it opens chromium. What am I doing wrong ? Edit: I tried to open directly chromium from crontab so I don't have to deal with the bash part: @reboot /usr/bin/chromium-browser --no-sandbox &gt;&gt; /home/user/linuxconfig/log/startupCrontab.log 2&gt;&amp;1 also the log gave me : [856:856:0427/103429.042950:ERROR:ozone_platform_x11.cc(243)] Missing X server or $DISPLAY [856:856:0427/103429.043040:ERROR:env.cc(257)] The platform failed to initialize. Exiting. so I tried to set the DISPLAY: @reboot export DISPLAY=:0 @reboot /usr/bin/chromium-browser --no-sandbox &gt;&gt; /home/user/linuxconfig/log/startupCrontab.log 2&gt;&amp;1 But the result is the same, the log still says that the $DISPLAY or X server is missing. I'm starting to wonder if it is even possible to start a graphical application during the crontab call. Since the DISPLAY is missing during this step, but when I start chromium after boot it's working fine and $DISPLAY is set to :0 automatically

http://stackoverflow.com/q/78325081
has comment: http://stackoverflow.com/comment/138088426
has answer: http://stackoverflow.com/a/78325122
has comment: http://stackoverflow.com/comment/138089889
type: Question
has body: I'm learning about bash and zsh. One command I came across was exec. I know that it will replace the current process with the supplied command. By what I have read over the internet, the local variables will not be inherited in the replaced process of exec. I tested it and failed. I am using zsh 5.9 on MacOS 14. Here is what I wrote, &gt; a=2 &gt; exec echo $a 2 process exited... I thought it might be due to parameter expansion and I tried the following &gt; a=2 &gt; exec echo '$a' $a process exited... Since it printed $a, I'm guessing that parameter expansion didn't happen. Otherwise, the single quotes would have been removed and $a would have been treated as an expansion instead of a string. To further verify if the variable was inherited or not, I used the declare command. The output is as follows &gt; aa=2 &gt; exec declare -p | grep aa typeset aa=2 Even this shows the local variable. Since exec doesn't inherit the local variables, why is it happening? I don't think it is only related to zsh.
downvote count: 0
score: 1
tagged with: bash
answer count: 1
has comment: http://stackoverflow.com/comment/138087531
upvote count: 1
favorite count: 0
tagged with: exec
tagged with: zsh
has comment: http://stackoverflow.com/comment/138088493
has comment: http://stackoverflow.com/comment/138088361
has comment: http://stackoverflow.com/comment/138088852
has comment: http://stackoverflow.com/comment/138089060
accepted answer: http://stackoverflow.com/a/78325122
type: AnsweredQuestion
has title: `exec` is accessing local variables

http://stackoverflow.com/q/78335326
has comment: http://stackoverflow.com/comment/138103565
tagged with: java
has comment: http://stackoverflow.com/comment/138103123
has comment: http://stackoverflow.com/comment/138104571
has comment: http://stackoverflow.com/comment/138103212
tagged with: netbeans
has comment: http://stackoverflow.com/comment/138104318
has comment: http://stackoverflow.com/comment/138104315
downvote count: 2
has comment: http://stackoverflow.com/comment/138109789
has title: Is there an alternative way to run succesfully a .java program without commenting the package name line?
has comment: http://stackoverflow.com/comment/138104543
has answer: http://stackoverflow.com/a/78335433
type: Question
type: UnansweredQuestion
answer count: 1
tagged with: fedora
favorite count: 0
score: -2
has comment: http://stackoverflow.com/comment/138104707
has body: I created a simple java program on netbeans and it working just fine when I execute it within the Netbeans IDE. However, this is the issue I'm dealing with: I'm getting this error when running the program after compiling with "javac" using the command line, specifically bash on fedora: java EjerciciosClase Error: Could not find or load main class EjerciciosClase Caused by: java.lang.NoClassDefFoundError: com/estudio/ejerciciosclase/EjerciciosClase (wrong name: EjerciciosClase) I was able to solve it by commenting the package name line: package com.estudio.ejerciciosclase; I have removed the line from package and it seems to be working. /* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package com.estudio.ejerciciosclase; import java.util.Scanner; // import the scanner class /** * * @author jfac * */ public class sumScanner { public static void main(String[] args) { int numA, numB, theSum; System.out.println("Program that reads y sums two numbers"); Scanner newObj = new Scanner(System.in); System.out.println("Enter the first number: "); numA = newObj.nextInt(); //String numAString = Integer.toString(numA); System.out.println("Enter the second number: "); numB = newObj.nextInt(); //String numBString = Integer.toString(numB); theSum = numA + numB; // String theSumString = Integer.toString(theSum); System.out.println("The sum of " + numA + " + " + numB + " is equal to " + theSum); } } is there any alternative way to run this program without removing the package name line? I'd like to run programs both on netbeans IDE and BASH terminal without modifying the code.
has comment: http://stackoverflow.com/comment/138109899
upvote count: 0
has comment: http://stackoverflow.com/comment/138107683
tagged with: linux
tagged with: bash

http://stackoverflow.com/q/78361550
has body: I just want to create not a simple condition to start the versioning script Condition: execute_versioning_script: stage: execute_versioning_script before_script: - project_url=$(echo $CI_PROJECT_URL | sed 's/https:\/\///') - git remote set-url origin https://oauth2:$VERSIONING_TOKEN@$project_url script: - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash - python .secure_files/main.py rules: - if: "$CI_COMMIT_TAG != null" when: never - if: "$CI_COMMIT_BRANCH == 'main'" - if: "$CI_COMMIT_BRANCH == 'dev'" - if: "$CI_COMMIT_BRANCH == 'hot-fix'" - if: "$CI_COMMIT_BRANCH =~ /^feature\/[A-Z]{3,8}-[0-9]{1,4}-fix$/" But every time I got a GitLab error about incorrect yaml file. In the end I want to start runner only on main, dev, hot-fix and feature/--fix branches when last commit does not have tag
type: Question
has title: Condition in GitLab CI Runner
has answer: http://stackoverflow.com/a/78364311
score: 0
tagged with: gitlab
tagged with: bash
tagged with: git
type: UnansweredQuestion
tagged with: continuous-integration
answer count: 1

http://stackoverflow.com/comment/138219652
type: Comment
has text: The low-contrast screen shots are more annoying than informative. Please [don't post images of code, error messages, or other textual data.](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors)
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78401442

http://stackoverflow.com/q/78406644
has comment: http://stackoverflow.com/comment/138241082
downvote count: 0
has comment: http://stackoverflow.com/comment/138229340
tagged with: bash
type: Question
has body: I was working with BASH and used output redirection to save a directory path to a file. When I try to re-use the input stored in the file using input redirection it doesn't work. I wrote 2 functions, one which redirects the output and the other which redirects input to the cd command. #!/bin/bash savepath () { pwd &gt; /home/user/Documents/save_path.txt } gotopath () { cd &lt; /home/user/Documents/save_path.txt } Save the shell script and made it executable. I then used source to enable myself to call my functions inside the shell. After running the first savepath() and changing to any random directory, running the second function should send me back to the directory I ran savepath() from. It isn't doing that, instead it sends me to my home directory.
tagged with: output-redirect
has comment: http://stackoverflow.com/comment/138239894
linked to: http://stackoverflow.com/q/53571637
has comment: http://stackoverflow.com/comment/138241061
has title: Use output redirection to change directory
has comment: http://stackoverflow.com/comment/138229294
has comment: http://stackoverflow.com/comment/138229187
has comment: http://stackoverflow.com/comment/138228977
has comment: http://stackoverflow.com/comment/138230367
has comment: http://stackoverflow.com/comment/138233392
score: 1
has comment: http://stackoverflow.com/comment/138247900
has answer: http://stackoverflow.com/a/78431101
answer count: 1
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138230488
has comment: http://stackoverflow.com/comment/138228966
accepted answer: http://stackoverflow.com/a/78431101

http://stackoverflow.com/comment/138253857
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78420308
score: 0
has text: @Barmar, I'm trying to output a file that can be used with `INFILE` (which interprets `\N` as `NULL`). `--table` still outputs `NULL` which needs to be converted to `\N`

http://stackoverflow.com/q/78340874
type: Question
upvote count: 0
tagged with: shell
has body: Why does the below script fail if i add "=" in the first and second character class of the regular expression. #! /bin/bash read -p "Enter an email address: " email if [[ $email =~ ^[a-zA-Z0-9._%=-+]+@[a-zA-Z0-9.=-+]+\.[a-zA-Z]{2,}$ ]] then echo "Valid mail id " else echo "invalid mail id" fi It works fine when i remove "=", does it hold any special meaning.
type: UnansweredQuestion
has title: Shell script error while using "=" in regular expression
tagged with: scripting
answer count: 2
score: -1
tagged with: linux
tagged with: bash
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138112757
has answer: http://stackoverflow.com/a/78340953
has answer: http://stackoverflow.com/a/78341268

http://stackoverflow.com/comment/138079677
comment on: http://stackoverflow.com/q/78321765
has text: Thanks! I used a 1password to manage the password and it only knows it in the non-root setting. Not sure whether I am meant to use it as root. I got something working in the answer, but I am not sure why? I suspect it's the boundary between root and non-root but I am not sure why it happens and why my weird command works.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138062031
has text: Thank you. but here's another question: I used C# code to generate this string command like this: string command = $"export MY_HOME={directory}; echo $MY_HOME", so is there a way that I can replace the double quote by single quote?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78311972
score: 0

http://stackoverflow.com/q/78344853
tagged with: vmware
answer count: 1
has comment: http://stackoverflow.com/comment/138174064
has answer: http://stackoverflow.com/a/78610457
has comment: http://stackoverflow.com/comment/138134402
has title: vCenter 7 script to edit/delete VM
has comment: http://stackoverflow.com/comment/138121682
score: 0
type: Question
tagged with: shell
has body: I have a cloning task set on vCenter 7.x, it runs every day. it clones "machine A" with name "machine B" My problem is that on the next day, it wont clone as there is already a "Machine B" in the environment. To my understanding I can access vCenter VM via SSH, and set up a script to perform the following actions. Detect names for all VMs If "Machine B" detected in Name create dictionary of "Machine B" and created "date" Rename "Machine B"s as "Machine B_(date)" if "Machine B" is older than 3 days, "read from name" compare with current time then erase VM otherwise keep it I would like to know if/how this script can be created? I imagine I need to run the script once and keep it running, problem is that I do not know the scripting language, from my research, vCenter runs in PHOTON OS https://vmware.github.io/photon/assets/files/html/3.0/, a subdivision of Linux, but the commands I can find do not cover what I need. greatly appreciate your input. or if vCenter is not the best, then an alternative, or if script is not the best then an alternative on the UI.
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138130415
has comment: http://stackoverflow.com/comment/138134390
has comment: http://stackoverflow.com/comment/138174084
tagged with: vcenter
tagged with: vsphere
tagged with: bash

http://stackoverflow.com/comment/138073643
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78313378
has text: Wherever `jupyter nbconvert` is running, it isn't accessing your installed packages. (My second sentence is hopefully getting at sorting that out.) I see mention of `repo_venv` in the script's source line and in the kernel name; however, either that is the wrong environment or it isn't working as you expect. You should be able to run those steps that you presently have in the first two command lines of `.sh` file on the command line and try troubleshooting them by running `which python` and `python -c "import example"` and/or `python -c "import pandas".
type: Comment

http://stackoverflow.com/a/78381324
type: Answer
answers question: http://stackoverflow.com/q/78371491
has body: Doing sudo -u postgres echo ~ doesn't give your postgres's home directory, because the ~ character is evaluated before the shell calls 'sudo', and of course it gets evaluated to the calling user's home directory, root's in this case. To get what you want try echo ~postgres instead.
score: 0

http://stackoverflow.com/q/78410973
has comment: http://stackoverflow.com/comment/138236475
duplicate of: http://stackoverflow.com/q/13182070
upvote count: 1
has body: Context: I have a script which makes multiple calls to bc to set some values, ie: many foo="$(echo '1/3' | /usr/bin/bc -q)" What I want to achieve: do not call bc every times, but keep one bc instance and re-use it multiple times. I guess coproc may be what I need, but as I’m curious and want to understand how Bash works, I try to do it using named pipes. This is my code so far, not the code of the script on which I intend to do this, but a code sample I wrote to try to help me understand what’s going on. It’s probably full of UUO* and questionable parts, but you’ll tell me then: #!/bin/env -S -i bash --norc set -euo pipefail IFS=$'\t\n' init_bc() { -p /tmp/bci || mkfifo /tmp/bci -p /tmp/bco || mkfifo /tmp/bco tail -n1 -f >&/tmp/bci & cat /tmp/bco & /usr/bin/bc -q /tmp/bci >&/tmp/bco & echo "scale=50" >/tmp/bci wait & } do_bc() { echo "${1}" >/tmp/bci >&1 } do_exit() { rm -vf /tmp/{bci,bco} >&2 pkill -e -P $$ } trap do_exit TERM EXIT INT init_bc echo Sleeping… >&2 foo="$(do_bc "${1}")" echo "FOO: ${foo}" sleep 5 echo "Awake!" >&2 wait & echo "End of script. We wait for all sub-shells." >&2 wait Running it (waiting a few seconds and then hitting Ctrl+C) this is what I get: $ ./piped_bc '1/7' Sleeping… FOO: .14285714285714285714285714285714285714285714285714 Awake! End of script. We wait for all sub-shells. ^Cremoved '/tmp/bci' removed '/tmp/bco' killed (pid 5585) killed (pid 5586) killed (pid 5587) As you can see, the $foo variable doesn’t get valued, and this is what I do not understand. The bc result seems to be “going” to the standard output, because if I run the script adding 1>/dev/null the result isn’t displayed, but I don’t understand why $foo is not valued then, and it upsets me (more than I’d like to admit). Last thing which may be of interest for my question: If I do this in the terminal: foo=$(/usr/bin/bc -q <(echo 'scale=7;1/7') &) The variable $foo gets the result of 1/7 as expected: $ echo $foo .1428571 Why is it not in my script? Any help w…
linked to: http://stackoverflow.com/q/13182070
tagged with: named-pipes
duplicate of: http://stackoverflow.com/q/10990949
duplicate of: http://stackoverflow.com/q/35274597
tagged with: shell
answer count: 0
tagged with: linux
has comment: http://stackoverflow.com/comment/138236616
has title: Bash − Using one bc instance in a named pipe
tagged with: bash
type: UnansweredQuestion
score: 1
favorite count: 0
tagged with: bc
has comment: http://stackoverflow.com/comment/138236749
linked to: http://stackoverflow.com/q/28693737
type: Question
has comment: http://stackoverflow.com/comment/138238419
has comment: http://stackoverflow.com/comment/138236553
downvote count: 0

http://stackoverflow.com/q/78339485
tagged with: scripting
tagged with: awk
has answer: http://stackoverflow.com/a/78340540
has comment: http://stackoverflow.com/comment/138111010
score: 0
possible better answer: http://stackoverflow.com/a/78340243
type: Question
answer count: 4
tagged with: shell
linked to: http://stackoverflow.com/q/11710552
has answer: http://stackoverflow.com/a/78343860
has comment: http://stackoverflow.com/comment/138111779
has comment: http://stackoverflow.com/comment/138111775
has body: We are using a script that takes in some data and converts it to a csv file, the script we are using is below: !/bin/bash read -p "Enter /DIR/PATH/FILENAME where you wish to copy the data: " FILENAME cat test.txt | awk ' BEGIN { OFS = "," numTags = split("insert_job job_type box_name command machine owner date_conditions condition run_calendar exclude_calendar days_of_week run_window start_times start_mins resources profile term_run_time watch_file watch_interval",tags) for ( tagNr=1; tagNr<=numTags; tagNr++ ) { tag = tags[tagNr] printf "\"%s\"%s", tag, (tagNr<numTags ? OFS : ORS) } } !NF || /^\/\*/ { next } { gsub(/^[[:space:]]+|[[:space:]]+$/,"") } match($0,/[[:space:]]job_type:/) { if ( jobNr++ ) { prt() delete tag2val } # save "insert_job" value tag = substr($1,1,length($1)-1) val = substr($0,length($1)+1,RSTART-(length($1)+2)) gsub(/^[[:space:]]+|[[:space:]]+$/,"",val) tag2val[tag] = val # update $0 to start with "job_type" to look like all other input $0 = substr($0,RSTART+1) } { tag = val = $0 sub(/:.*/,"",tag) sub(/[^:]+:[[:space:]]*/,"",val) tag2val[tag] = val } END { prt() } function prt( tagNr,tag,val) { for ( tagNr=1; tagNr<=numTags; tagNr++ ) { tag = tags[tagNr] val = tag2val[tag] printf "\"%s\"%s", val, (tagNr<numTags ? OFS : ORS) } } ' > $FILENAME.csv And below is the test data: $ cat test.txt /* ----------------- Test_A ----------------- */ insert_job: Test_A job_type: CMD command: sleep 3000 machine: machine1 owner: user1 permission: date_conditions: 1 days_of_week: mo,tu,we,th,fr start_times: “06:00,08:00,10:00,12:00,14:00,16:00” term_run_time: 1 alarm_if_fail: 1 alarm_if_terminated: 1 /* ----------------- Test_B ----------------- */ insert_job: Test_B job_type: CMD command: echo machine: machine2 owner: user2 permission: date_conditions: 0 description: "Test" std_out_file: "/tmp/$AUTO_JOB_NAME.$AUTORUN.out" std_err_file: "/tmp/$AUTO_JOB_NAME.$AUTORUN.err" max_run_alarm: 1 alarm_if_fail: 0 alarm_if_terminated: 0 send_notification: 1 /* ------------…
linked to: http://stackoverflow.com/q/45420535
has answer: http://stackoverflow.com/a/78340243
has title: Text file to csv script
has answer: http://stackoverflow.com/a/78340597
tagged with: linux
tagged with: bash
accepted answer: http://stackoverflow.com/a/78340540
type: AnsweredQuestion

http://stackoverflow.com/comment/138201729
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78390223
type: QuestionComment
has text: `xargs -I{} bash -c '...{}...'` is a route to serious security bugs; don't *ever* substitute data into code directly like that. Instead, pass `find`'s results into bash _as arguments_ and write your bash code to iterate over its argument list; `xargs bash -c 'for arg; do ..."$arg"...; done' _` (no `-I` needed on the xargs) doesn't have the same risks.

http://stackoverflow.com/a/78320219
has body: It is not an error message from your script. The message comes from the fact that you killed a background job. You'll get the message when the next prompt comes. As an example, try: $ sleep 50 &amp; $ kill $! ; sleep 5 [1]+ Terminated sleep 50 $ sleep 50 &amp; $ kill $! $ #give an enter [1]+ Terminated sleep 50
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78317514

http://stackoverflow.com/comment/138129933
score: 0
type: Comment
type: AnswerComment
has text: I'm not sure the former would work as currently written: you're starting up bash with stdin connected to a temporary file with the heredoc contents. How is `tar` going to get a file handle on the original stdin? If you saved a copy of the original fd, _that_ should work, but IIRC the OP had a prior question implying that their default remote shell was something unusual and surprising on a subset of the systems they needed to be able to run code on.
comment on: http://stackoverflow.com/a/78350523

http://stackoverflow.com/a/78462615
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/138327827
has body: History search is controlled by the shell, and has nothing to do with the terminal emulator or the OS, beyond what’s installed by default. If you like what your Windows system is doing, check the shell there (echo $0), its version, and history-related settings in the config files, and use the same setup on your Mac. You don’t actually say what shell you’re using, but zsh can be configured to do pretty much anything.
answers question: http://stackoverflow.com/q/78402822

http://stackoverflow.com/q/78427118
has comment: http://stackoverflow.com/comment/138270080
has comment: http://stackoverflow.com/comment/138265150
answer count: 1
has comment: http://stackoverflow.com/comment/138265093
has title: bash: conditional statement causes "unexpected end of file" on macOS
has answer: http://stackoverflow.com/a/78438016
score: 0
tagged with: macos
has comment: http://stackoverflow.com/comment/138268467
tagged with: syntax-error
accepted answer: http://stackoverflow.com/a/78438016
has comment: http://stackoverflow.com/comment/138269659
has comment: http://stackoverflow.com/comment/138265148
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138270287
has comment: http://stackoverflow.com/comment/138265743
has body: When I source the following simple script in a bash shell on macOS (Sonoma 14.4.1), I get "syntax error: unexpected end of file". #!/bin/bash echo "Hello" echo "$SHELL" echo "$BASH_VERSION" /bin/bash --version if -n "foobar" ; then echo "Ok" fi echo "Bye" If I knock out the if-statement (lines 7-9), it behaves as expected. On Linux (CentOS 7), it (with the if-statement) produces the expected output with "Ok". I'm using Unix line endings (LF). macOS result: $ source bash-if-trouble.sh Hello /bin/bash 3.2.57(1)-release GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23) Copyright (C) 2007 Free Software Foundation, Inc. -bash: bash-if-trouble.sh: line 12: syntax error: unexpected end of file source ./bash-if-trouble.sh produces a similar result. CentOS7 result, which is also expected on macOS (modulo the version details, of course): $ source bash-if-trouble.sh Hello /bin/bash 4.2.46(2)-release GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Ok Bye Per @Philippe's suggestion: $ od -a bash-if-trouble.sh 0000000 # ! / b i n / b a s h nl e c h o 0000020 sp " H e l l o " nl e c h o sp " $ 0000040 S H E L L " nl e c h o sp " $ B A 0000060 S H _ V E R S I O N " nl / b i n 0000100 / b a s h sp - - v e r s i o n nl 0000120 nl i f sp [ [ sp - n sp " f o o b a 0000140 r " sp ] ] ; sp t h e n nl sp sp e c 0000160 h o sp " O k " nl f i nl nl e c h o 0000200 sp " B y e " nl 0000207
has comment: http://stackoverflow.com/comment/138266406
has comment: http://stackoverflow.com/comment/138270071
has comment: http://stackoverflow.com/comment/138270196
has comment: http://stackoverflow.com/comment/138265668
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138270239
has comment: http://stackoverflow.com/comment/138267058
has comment: http://stackoverflow.com/comment/138270104

http://stackoverflow.com/a/78420389
type: AcceptedAnswer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78419580
answers question: http://stackoverflow.com/q/78419580
type: Answer
has body: OP is tagged with bash. If you are using bash and do not need to worry about portability, then there is almost never a reason to use test (or [) - just make a habit of using [[...]] (and rather than expr or let, prefer ((...)) for arithmetic evaluations.) See Conditional Constructs for details. On the CLI, test doesn't change your context, so "globs" (*) are processed with filename expansion and replaced by the list of all matches, which is generating too many arguments for test. There are a lot of ways to check strings and files in bash, and some will overlap. As has been mentioned in comments, both [[ and case constructs will use globbing without word splitting or pathname expansion. Given f=fofo.l and x=abcd, $: dotl(){ $1 == *.l* && echo match || echo nope; } $: dotl $f match $: dotl $x nope $: dotl(){ case $1 in *.l*) echo match;; *) echo nope;; esac; } $: dotl $f match $: dotl $x nope If you prefer an actual regex - $: dotl(){ [[ $1 =~ [.]l ]] && echo match || echo nope; } $: dotl $f match $: dotl $x nope If you need portability, and high performance isn't a major concern, there are plenty of widely available programs to which you could farm the test out - grep is the usual go-to for this sort of thing. $: dotl(){ echo $1 | if grep -q '[.]l'; then echo match; else echo nope; fi; } $: dotl $f match $: dotl $x nope If you're just fond of odd structures you can even do "tricks" like this with basic Parameter Expansion (though I generally don't recommend it): $: dotl(){ local tst=${1/#*.l*/}; echo "$1 contains ${tst:+NO }.l"; } $: dotl fofo.l fofo.l contains .l $: dotl ooo.lala ooo.lala contains .l $: dotl abcd abcd contains NO .l Maybe it's an X/Y Problem, and you're asking how to tell if a file has a given string because you plan to walk through all files and do something with each one if it matches - so what you really want is the list of the files that match, instead of the test for each file. For that, a glob handles it all at once: $: touch fofo.l ooo.…
downvote count: 0
score: 1

http://stackoverflow.com/comment/138115498
type: Comment
has text: See https://stackoverflow.com/a/69502302/14122 for an example of using `@sh`. BTW, you might consider trace logging (`bash -x yourscript` or putting `set -x` within that script's text) to be useful here to get a view of what's going on at runtime.
score: 0
comment on: http://stackoverflow.com/q/78342087
type: QuestionComment

http://stackoverflow.com/comment/138094874
has text: Change `-name '*.txt'` to `-name '*.jenkinsfile'`
comment on: http://stackoverflow.com/q/78330348
type: QuestionComment
type: Comment
score: 4

http://stackoverflow.com/q/78405506
has title: Is there a way to optimise/speed up the loading of docker images from tar files?
has comment: http://stackoverflow.com/comment/138232250
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138239020
has comment: http://stackoverflow.com/comment/138230910
has comment: http://stackoverflow.com/comment/138232178
answer count: 2
has answer: http://stackoverflow.com/a/78409085
tagged with: docker
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138232220
has comment: http://stackoverflow.com/comment/138226858
has body: I have a docker.tar file that contains numerous docker images - the size of this file is quite big, sitting at around 44 gigabytes. These images would be loaded from the tar file, retagged, and then pushed to another registry. All-in-all, this entire process could take about 40 minutes due to how many images there are. So far, I've managed to cut this time down to about 20 minutes as I am using xargs to push the images once they have been retagged. The loading of the images is the next thing I want to try and address as this takes some time as well. I have tried using split to split the original tar file into smaller parts, and then using xargs that way to try a docker load however I get some errors saying these new tar files are not created correctly (incorrect header, unexpected EOF, etc.) Apart from that, I haven't found much on the topic besides this: https://forums.docker.com/t/docker-save-load-performance/9245 - but the one comment that provides a possible improvement deals with docker save Is there any other way I can improve the speed of docker load? Ideally, possible improvements would need to be done in bash. UPDATE: Please find the process on how the images are saved, loaded, retagged, and pushed below. If any more info is required, please comment. A Jenkins job is triggered which will pull the Docker images from the internal registry and save these images a docker.tar file This tar file is then packaged alongside bash scripts (which will eventually load, retag, and push these images to a new registry) inside a CSAR package: https://wiki.onap.org/display/DW/Csar+Structure An external user will then be given this package - they will then unzip the CSAR package From here, they will then run the provided script to load the images from the docker.tar file: RED="\033[1;31m" GREEN="\033[1;32m" NOCOLOR="\033[0m" IMAGE_TAR=$1 logger() { echo -e "`date '+%Y-%m-%d %H:%M:%S:'` $@" | tee -a ${LOG_FILE} } logger "Loading [$IMAGE_TAR]..." docker load --input ${IMAGE_TA…
upvote count: 1
has comment: http://stackoverflow.com/comment/138232490
has answer: http://stackoverflow.com/a/78409050
tagged with: bash
type: UnansweredQuestion

http://stackoverflow.com/q/78316829
answer count: 2
score: -1
has answer: http://stackoverflow.com/a/78317198
has comment: http://stackoverflow.com/comment/138072133
tagged with: bash
type: Question
has title: How can I save the output of softwareupdate --list as variable in bash on macOS?
downvote count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138073676
has answer: http://stackoverflow.com/a/78317231
upvote count: 0
tagged with: macos
tagged with: terminal
favorite count: 0
has body: I tried: updates=( $(softwareupdate --list) ) It catches: echo $updates Software Update Tool Finding available software Instead of the full output: Software Update Tool Finding available software No new software available. Have no clue how to solve this problem.

http://stackoverflow.com/comment/138192832
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78386230
score: 0
has text: you could certainly perform the operation in `awk` but you'd need to be careful on the order in which files are fed to `awk`; if you simply feed `cat L00?` to `awk` then `awk` will incur 192 open/close file operations (expensive); if you feed `cat L00? | sort` to `awk` you only perform 48 open/close file operations, but whether that's 'faster' than a comparable `paste | while/cat` operation will likely depend on the size of the `file*_L00?` files; I would expect `cat` to be more efficient than `awk` (effectively) looping on reading/printing lines; having said that ....

http://stackoverflow.com/q/78313378
has body: I am creating a bash command that will allow me to execute a jupyter notebook from the command line. Regardless of which import library I reference first, I get the error "No Module Named 'example'". Below is the code I have in my .sh file #!/bin/bash source /Users/name/Documents/repos/repo_venv/bin/activate cd /Users/name/Documents/repos/project1/project1.1 #this is the directory my notebook is in # Run the Jupyter Notebook file jupyter nbconvert --execute --ExecutePreprocessor.kernel_name=repo_venv --to notebook file1.ipynb deactivate I have used the jupyter kernelspec list command to make sure I am referencing the right kernel in the ExecutePreprocessor function. Also, when I run the following in my notebook import sys print(sys.executable) it returns /Users/name/Documents/repos/repo_venv/bin/python Finally, I've used pip list in repo_venv to make sure I have the libraries installed and they all are. Are there any other reasons this doesn't seem to be referencing the right venv?
tagged with: python
tagged with: command-line
has comment: http://stackoverflow.com/comment/138073643
tagged with: bash
has comment: http://stackoverflow.com/comment/138073693
tagged with: jupyter-notebook
has title: Error: No Module Named 'example' When Executing a Jupyter Notebook from the Command Line with --ExecutePreprocessor.kernel_name
has comment: http://stackoverflow.com/comment/138073347
tagged with: nbconvert
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138071488
has comment: http://stackoverflow.com/comment/138073657
type: UnansweredQuestion

http://stackoverflow.com/comment/138100230
score: 0
type: AnswerComment
has text: Yeah, read the OP title question: `How can I test if a command fails or returns a certain output?`. So if the command exited with an non-zero error code, or if its output matches "string" or "strong", we should execute `doStuffOnError` as asked by OP;
comment on: http://stackoverflow.com/a/78333360
type: Comment

http://stackoverflow.com/a/78336113
type: Answer
answers question: http://stackoverflow.com/q/78336037
upvote count: 5
score: 4
has body: Use a capture group to extract the part of the hostname after mngmnt, then use that in a case statement. $BASH_REMATCH is an array containing the matches for the capture groups. if [[ $hostname =~ ^(mngmnt)?([[:alpha:]]+)[[:digit:]]+$ ]] then case "${BASH_REMATCH[2]}" in presto) memory=23G ;; hadoop) memory=12G ;; kafka) memory=10G ;; *) echo "Unrecognized hostname: $hostname" esac else echo "Unrecognized hostname: $hostname" fi
downvote count: 1

http://stackoverflow.com/comment/138242681
type: Comment
comment on: http://stackoverflow.com/q/78409604
has text: scanning the source code seems the reliable way. running a script doesn't guarantee a relevant code path is taken: one could run it 99 times without the variable being used but then the hundredth time it does get used.
score: 1
type: QuestionComment

http://stackoverflow.com/a/78433914
answers question: http://stackoverflow.com/q/78432948
type: Answer
score: 0
has body: KamilCuk's answer is correct: https://stackoverflow.com/a/78432970/1277576 The same documentation linked in that answer says this: When the shell is waiting, by means of the wait utility, for asynchronous commands to complete, the reception of a signal for which a trap has been set shall cause the wait utility to return immediately with an exit status &gt;128, immediately after which the trap associated with that signal shall be taken. So, the solution is to replace sleep inf with: sleep inf &amp; wait $! # Waits for the completion of the sleep command executed in the background I did some testing and now the traps work both when the script is run in the foreground with ./testtrap.sh and when I run it in the background by starting it with ./testtrap.sh &amp;.

http://stackoverflow.com/comment/138170806
comment on: http://stackoverflow.com/q/78373722
type: QuestionComment
score: 0
has text: That's not an error. It's the normal output when you use the `nohup` command.
type: Comment

http://stackoverflow.com/comment/138250864
has text: @qwr Using `.*` will first match until the end of the string, and will then backtrack to the first occurrence of `u` When you use the character class `[blntam]*` then there is no backtracking from the end of the string, as it can not cross matching the `u`
comment on: http://stackoverflow.com/a/78417692
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78398806
score: 0
tagged with: bash
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138255331
tagged with: ssh
tagged with: hpc
tagged with: rsync
has title: HPC remote server side rsync command limit
answer count: 0
has body: I am currently trying to transfer three different files (that have multiple versions) to directories on a computing cluster via SSH using the rsync command. Two of these files exist in the same local directory, and are transferred in a single rsync command, however, the last files are found in a different directory and require a separate use of rsync. After running the script, it will successfully transfer many of the files, but reliably exits after 5-6 directories with the following errors: ```` ssh: connect to host owlsnest.hpc.temple.edu port 22: Connection refused rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(231) [sender=3.2.7] ``` The relevant code is below: scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" basedir="$(dirname "$scriptdir")" fmriprep_dir=/ZPOOL/data/projects/rf1-sra-data/derivatives/fmriprep bids_dir=/ZPOOL/data/projects/rf1-datapaper-dev/bids destination_server="@owlsnest.hpc.temple.edu" read -p "Enter AccessNet ID: " destination_user for sub in $(cat "${scriptdir}/sublist_new-flip.txt"); do source_fmriprep="$fmriprep_dir/sub-$sub" source_bids="$bids_dir/sub-$sub/func" # Transfer Preproc BOLD files and Confound files rsync -avh --no-compress --progress \ --ignore-existing \ --recursive \ --include='*/' \ --include='*MNI152NLin6Asym_desc-preproc_bold.nii.gz' \ --include='*-confounds_timeseries.tsv' \ --exclude='*' \ "${source_fmriprep}" "${destination_user}${destination_server}:work/rf1-sra-data/derivatives/fmriprep/sub-${sub}/" # Transfer events.tsv files rsync -avh --no-compress --progress \ --ignore-existing \ --recursive \ --include='*/' \ --include='*_events.tsv' \ --exclude='*' \ "${source_bids}" "${destination_user}${destination_server}:work/rf1-sra-data/bids/sub-${sub}/" sleep 10 done exit ``` I have troubleshot with the following methods and results: Commenting out the second rsync command and keeping the sleep 10 delay allows the s…
tagged with: cluster-computing

http://stackoverflow.com/comment/138099588
type: Comment
comment on: http://stackoverflow.com/q/78333123
type: QuestionComment
score: 0
has text: Does this answer your question? [Capturing output and exit codes in BASH / SHELL](https://stackoverflow.com/questions/28902393/capturing-output-and-exit-codes-in-bash-shell)

http://stackoverflow.com/comment/138236825
type: QuestionComment
type: Comment
has text: dude a good trick is often just pipe it through 2 or more regexes
comment on: http://stackoverflow.com/q/78411166
score: 1

http://stackoverflow.com/a/78438129
has body: I tried this with some other approach, However it works only with the lines provided. sed -i -e 's/^/E_/' -e '1s/E_//' -e 's/E_#/#/' file
has comment: http://stackoverflow.com/comment/138291762
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78423090

http://stackoverflow.com/a/78311972
accepted answer of: http://stackoverflow.com/q/78311907
type: Answer
has comment: http://stackoverflow.com/comment/138062031
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78311907
score: 1
downvote count: 0
has body: Maybe you could try: bash -c 'export MY_HOME=/mnt/d ; echo $MY_HOME' If you enter the command in the WSL instance, the command is interpreter by WSL shell (likely bash) and $MY_HOME is replaced by empty string before bash -c receive it. After variable expansion from WSL shell, the command that is launched is: bash -c "export MY_HOME=/mnt/d ; echo "
upvote count: 1

http://stackoverflow.com/comment/138075122
comment on: http://stackoverflow.com/q/78319248
score: 0
type: QuestionComment
type: Comment
has text: Brilliant ... nice to know such a tool exists. And the problem: commas as separators in the bash array <facepalm/>.

http://stackoverflow.com/comment/138254462
comment on: http://stackoverflow.com/q/78419985
type: Comment
has text: please update the question with the output from the ***curl -s "$ics_url"*** call
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138462588
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78355289
has text: @RAREKpopManifesto Thanks for pointing that out; I will look into this, revisiting the sources and all.
type: Comment

http://stackoverflow.com/comment/138137299
type: Comment
type: QuestionComment
has text: @CharlesDuffy the system with atypical behavior is a standard WP Engine host, so there's likely not much I can do to have them change things, but I do wonder why they strip quotes in such an odd way.
score: 0
comment on: http://stackoverflow.com/q/78350497

http://stackoverflow.com/comment/138181949
comment on: http://stackoverflow.com/q/78380184
has text: How would you ever get the "timeout" branch followed after `!` inverts, changing anything nonzero to 0 and 0 to 1?
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/138076756
score: 1
comment on: http://stackoverflow.com/a/78319265
has text: Your command has additional issues including that `$cc1` won't be expanded inside single quotes in `command -v '$cc1'`. Run it through http://shellcheck.net as the [tag:bash] tag you used tells you to do - "For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting them here.".
type: Comment
type: AnswerComment

http://stackoverflow.com/tag/zip
type: Tag
tag name: zip
tags question: http://stackoverflow.com/q/78372933
tags question: http://stackoverflow.com/q/78677918
tags question: http://stackoverflow.com/q/78684459
tags question: http://stackoverflow.com/q/78834215
tags question: http://stackoverflow.com/q/78956029
tags question: http://stackoverflow.com/q/79325829

http://stackoverflow.com/q/78359720
has title: Programatically send data to bash stdin
tagged with: bash
type: Question
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138146588
has comment: http://stackoverflow.com/comment/138242752
score: 0
tagged with: shell
tagged with: linux
has comment: http://stackoverflow.com/comment/138202873
tagged with: stdio
tagged with: process
has body: I want to programatically change user input in shell, similar to how complete shell built in achieves this. So whenver you press TAB unix systems complete built-in appends some data to your input. I want to achieve similar effect, to already running shell. Most of the methods I tried simply display characters in the terminal, but they cannot be interpretted as commands. echo "New input" > /proc/<bashID>/fd/0 - doesn't work, only writes "New input" in the terminal, it cannot be edited or interpreted as command.
linked to: http://stackoverflow.com/q/4819819

http://stackoverflow.com/q/78341846
upvote count: 0
type: UnansweredQuestion
tagged with: xml-parsing
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138114641
tagged with: bash
has body: I have some XML tags names stored in a text file, an XML file in which i want to add the same string as another value for those tags. XML Tags File : name1 name2 name3 XML File : value1 value2 value3 ... value1 value2 value3 ... value1 value2 value3 ... I tried dozens of "sed", "cat" commands but quite a pain in the a*s ... I was expecting that, after I used the script/command, the XML File would look like this : VALUE4 value1 value2 value3 ... VALUE4 value1 value2 value3 ... VALUE4 value1 value2 value3 ... (VALUE4 is the string I want to add, and I want to add it as the first value !) Thanks in advance for the help ! LePousson
has answer: http://stackoverflow.com/a/78342527
downvote count: 1
score: -1
has title: How to add a string between XML tags which value is obtained from a text file ?? (bash)
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/138114941
type: Question

http://stackoverflow.com/q/78368689
type: UnansweredQuestion
tagged with: numbers
has comment: http://stackoverflow.com/comment/138162183
score: 0
has title: Error "Illegal number" in Bash Scripting Linux Vim Editor
answer count: 0
tagged with: linux
tagged with: bash
duplicate of: http://stackoverflow.com/q/45173706
has comment: http://stackoverflow.com/comment/138162186
has comment: http://stackoverflow.com/comment/138162283
linked to: http://stackoverflow.com/q/9581064
tagged with: algorithm
tagged with: while-loop
duplicate of: http://stackoverflow.com/q/9581064
type: Question
has body: I wrote this code in bash scripting and can't figure out what the error is. The terminal say: 15: [:Illegal number: 0+1 This is the code: #!/bin/bash min=999 max=0 n=0 num=0 promedio=0 i=0 echo "Ingrese n" read n while [$i -le $n] ---> LINE 15 IN THE ACTUAL SCRIPT, HERE IS THE ERROR I CANT FIND do echo "Ingrese numero" read num if [$num -lt $min] then min=$num fi if [$num -gt $max] then max=$num fi promedio=$promedio+$num i=$i+1 done media=$promedio/$n echo "Mayor: $max" echo "Menor: $min" echo "Promedio: $media" I tried many things but as I'm not an expert and I couldn't find any solution on the internet I am posting this question.

http://stackoverflow.com/q/78363374
linked to: http://stackoverflow.com/q/10067266
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138152829
has comment: http://stackoverflow.com/comment/138153871
duplicate of: http://stackoverflow.com/q/10067266
tagged with: scripting
has title: How to properly escape/quote the output so it's treated as an escaped input?
score: 0
tagged with: stdout
has comment: http://stackoverflow.com/comment/138152728
tagged with: shell
type: UnansweredQuestion
answer count: 1
has answer: http://stackoverflow.com/a/78363871
has comment: http://stackoverflow.com/comment/138152853
tagged with: stdin
has comment: http://stackoverflow.com/comment/138153612
has body: I've been trying to create a set of aliases or functions, that I can use in conjunction with file operating commands. The idea is to have 1, 2, 3 functions/aliases that will return latest, second-to-latest, third-to-latest filename and use it with file operating command, e.g.: ls `1` Should print the name of the latest file. My initial idea is this: alias 1='/bin/ls -1Atr --color=never | tail -n 1 | head -n 1' However, the problem is with files with whitespaces, e.g: $ /bin/ls -lthr | tail -1 -rw-r--r-- 1 shalak staff 0B 22 kwi 00:37 My test file with spaces.txt $ echo `1` My test file with spaces.txt $ ls `1` "My": No such file or directory (os error 2) "test": No such file or directory (os error 2) "file": No such file or directory (os error 2) "with": No such file or directory (os error 2) "spaces.txt": No such file or directory (os error 2) I tried fixing it like this: alias 1='echo \"$(/bin/ls -1Atr --color=never | tail -n 1 | head -n 1)\"' or alternatively, this: function 1() { local file=$(/bin/ls -1Atr --color=never | tail -n 1) printf "%q" "$file" } But the shell behaves like this: $ echo `1` "My test file with spaces.txt" $ ls `1` "\"My": No such file or directory (os error 2) "test": No such file or directory (os error 2) "file": No such file or directory (os error 2) "with": No such file or directory (os error 2) "spaces.txt\"": No such file or directory (os error 2) So the quotation marks are being escaped when they reach the ls command. I also considered escaping the whitespaces: $ function 1() { /bin/ls -1Atr --color=never | tail -n 1 | sed 's/ /\\ /g' } $ 1 My\ test\ file\ with\ spaces.txt $ echo `1` My\ test\ file\ with\ spaces.txt $ ls `1` "My\\": No such file or directory (os error 2) "test\\": No such file or directory (os error 2) "file\\": No such file or directory (os error 2) "with\\": No such file or directory (os error 2) "spaces.txt": No such file or directory (os error 2) Stumbled upon the same issue. I wonder - why this happens? Is there…

http://stackoverflow.com/comment/138130325
type: Comment
comment on: http://stackoverflow.com/a/78350523
type: AnswerComment
score: 0
has text: But I've simplified the result like that.

http://stackoverflow.com/comment/138234305
has text: What is `whisper`? It looks like it's a Python script, so you to find its calls to `exit()` to see what status it's returning. Python will only set a non-zero exit code by itself if the script crashes due to an uncaught exception.
comment on: http://stackoverflow.com/q/78409475
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78316769
type: Question
type: UnansweredQuestion
tagged with: automation
answer count: 1
tagged with: raspberry-pi3
tagged with: bash
has body: I'm building the google assistant on an old raspberry pi (running on Raspberry Pi OS) with a bluetooth speaker including a microphone: The script itself consists only of activating the env and calling google assistant demo with the corresponding job id etc. I'm able to ask and receive answers, if executing the script from the command line. However, for the systemctl service file, it is failing and I get the status [FATAL:audio_input_stream.cc(47)] Input device could not be opened: default This leads me to believe that there is something wrong with the input device (microphone). pacmd list-sources shows that my bluetooth speaker is indeed the default, and I've checked for the audio profile issues (profile for the speaker/mic is on HSP), so I don't know where the issue is. I'd be really happy, if anybody has some input (pun intended).
tagged with: microphone
has title: Systemctl is unable to detect input device (bluetooth microphone), but script works manually
tagged with: google-assistant-sdk
has answer: http://stackoverflow.com/a/78316783
score: 0

http://stackoverflow.com/comment/138192518
has text: DOS newlines are two character sequences, a CR + a LF; UNIX newlines are LF-only. The CR is thus seen as part of the line you're running as a command when parsed by UNIXy tools. Answers on the linked duplicate tell you how to solve this.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78385269
type: QuestionComment

http://stackoverflow.com/comment/138112757
comment on: http://stackoverflow.com/q/78340874
type: QuestionComment
has text: `works fine` for what input? Can you hardcode and post an exapmle? Please post example execution of the script when it "fails". `Why does the below script fail if` Does the script really _fail_, if so, what is the error mesage? Or does the script _sucseed_ and prints the message `invalid mail id`?
type: Comment
score: 0

fedora
tag name: fedora
tags question: http://stackoverflow.com/q/78342422
tags question: http://stackoverflow.com/q/78335326
type: Tag

http://stackoverflow.com/q/78440219
has comment: http://stackoverflow.com/comment/138288569
has comment: http://stackoverflow.com/comment/138288341
score: 0
type: Question
has answer: http://stackoverflow.com/a/78441170
tagged with: git-bash
accepted answer: http://stackoverflow.com/a/78441170
has body: I am very new to Bash scripting and still at the learning stage. Currently, I am working on CSV files and there has been a requirement that if 2 rows are matched in 2 different CSV files, then the data column should be added. For example, csv_file1.csv: Account,Entity,Data A1101,E101,1000 csv_file2.csv: Account,Entity,Data A1101,E101,2000 A1101,E102,2000 On executing bash script, the expected output should be a new CSV file with rows: Account,Entity,Data A1101,E101,3000 A1101,E102,2000 Since, elements in 1st row of "csv_file1" and elements in 1st row of "csv_file2" are matching, data in the "Data" column should append. The below is the code which I have tried to print the contents of both CSV files. But, I am not able to move forward from here. #!/bin/bash #assigns the CSV file to a variable FILE1="csv_file1.csv" #reads each line and splits it into three variables while IFS=, read -r Account Entity Data; do echo "$Account#""$Entity#""$Data" done < <(tail -n +2 $FILE1) #assigns the CSV file to a variable FILE2="csv_file2.csv" #reads each line and splits it into three variables while IFS=, read -r Account Entity Data; do echo "$Account#""$Entity#""$Data" done < <(tail -n +2 $FILE2) It would be great if you guys can help me with your ideas. please let me know if any additional information is needed. Thanks a lot in Advance!
has title: Adding data if elements from 2 different rows in 2 different CSV files matches using Bash scripting
answer count: 2
has answer: http://stackoverflow.com/a/78440546
tagged with: bash
possible better answer: http://stackoverflow.com/a/78440546
type: AnsweredQuestion
tagged with: http://stackoverflow.com/tag/csv

http://stackoverflow.com/q/78327616
type: UnansweredQuestion
has title: Bashscript failure with divided calculations
has comment: http://stackoverflow.com/comment/138089642
has body: I have a problem with my pocket calculator which is written in polish notation, it can calculate everything up to part by part which results in coma numbers, how can I solve this problem? #!/bin/bash calculate() { num1=$1 num2=$2 operator=$3 if [ "$operator" = "+" ]; then echo $(($num1 + $num2)) elif [ "$operator" = "-" ]; then echo $(($num1 - $num2)) elif [ "$operator" = "x" ]; then echo $(($num1 * $num2)) elif [ "$operator" = "/" ]; then echo $(($num1 / $num2)) else echo "This is not a correct calculation!" fi } while true; do read -p "What is your calculation? (e.g. 7 3 +, -, x, / or 'q' to finish): " num1 num2 operator if | $num2 = "q" || $operator = "q" ; then echo "Script is terminated..." break fi result=$(calculate $num1 $num2 $operator) echo "Result: $result" done
tagged with: bash
has comment: http://stackoverflow.com/comment/138091376
has comment: http://stackoverflow.com/comment/138090067
linked to: http://stackoverflow.com/q/12722095
score: 0
type: Question
answer count: 0
duplicate of: http://stackoverflow.com/q/12722095

http://stackoverflow.com/q/78420308
has body: I have the following: if [[ "${outfile}" == '/dev/stdout' ]]; then "${mysql_cmd[@]}" <"${infile}" >"${outfile}" else "${mysql_cmd[@]}" <"${infile}" | sed -e 's|[[:<:]]NULL[[:>:]]|\\N|g' >"${outfile}" fi The sed is meant to convert NULL to \N so that the output can be used with LOAD DATA LOCAL INFILE. I'd like to make it into a one-liner similar to: "${mysql_cmd[@]}" <"${infile}" | "${transformer_cmd[@]}" >"${outfile}" When transformer_cmd is a "null object" (ie not the sed command), mysql must continue to be interactive (such that a mysql shell is opened in which one can enter in SQL statements). I've tried cat as transformer_cmd and that failed this requirement. Is this possible? If so, how? I'd rather avoid doing something like "${mysql_cmd[@]}" <"${infile}" "${transformer_cmd}" >"${outfile}" such that transformer_cmd includes the | but will do so if there's no other way. ADDENDUM: transformer_cmd including the | doesn't work since for some reason ${transformer_cmd} (without surrounding double quotes) is still being interpreted as an argument to mysql.
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138257865
has comment: http://stackoverflow.com/comment/138253832
has answer: http://stackoverflow.com/a/78433538
score: 0
has title: How to pipe to "null object" in bash?
tagged with: mysql
accepted answer: http://stackoverflow.com/a/78433538
has comment: http://stackoverflow.com/comment/138253724
has comment: http://stackoverflow.com/comment/138255168
has comment: http://stackoverflow.com/comment/138253857
has comment: http://stackoverflow.com/comment/138252993
has comment: http://stackoverflow.com/comment/138253816
has comment: http://stackoverflow.com/comment/138254017
answer count: 1
has comment: http://stackoverflow.com/comment/138252974
has comment: http://stackoverflow.com/comment/138264145
has comment: http://stackoverflow.com/comment/138253714
has comment: http://stackoverflow.com/comment/138266746
has comment: http://stackoverflow.com/comment/138253135
has comment: http://stackoverflow.com/comment/138255193
has comment: http://stackoverflow.com/comment/138268691
has comment: http://stackoverflow.com/comment/138254421
has comment: http://stackoverflow.com/comment/138252927
has comment: http://stackoverflow.com/comment/138253682
has comment: http://stackoverflow.com/comment/138252978
has comment: http://stackoverflow.com/comment/138252961
tagged with: bash
linked to: http://stackoverflow.com/q/2867607
type: Question

http://stackoverflow.com/comment/138105824
has text: Oddly, native bash refuses the above incantation passed by Powershell in favor of `cygpath -u $(PWD)/super_duper_script.sh`. The native shell furthermore runs `eval $(cygpath -u $(PWD)/super_duper_script.sh)` without difficulty. Clearly both shells are trampling on one another.
type: AnswerComment
comment on: http://stackoverflow.com/a/78336467
score: 0
type: Comment

http://stackoverflow.com/comment/138118682
type: Comment
type: AnswerComment
score: 0
has text: Also, while XSLT is the way I and many others would do it, it's not the only option. The most important part of my response is: don't try to manipulate XML as text; always use XML-aware tools. We see so many people on SO who get themselves into a terrible mess by ignoring that advice.
comment on: http://stackoverflow.com/a/78342527

http://stackoverflow.com/comment/138264915
type: AnswerComment
comment on: http://stackoverflow.com/a/78425903
score: 0
has text: @GavinBaumanis, if you have problems with `rename` see [Why is the rename utility on Debian/Ubuntu different than the one on other distributions, like CentOS?](https://unix.stackexchange.com/q/275254/264812).
type: Comment

http://stackoverflow.com/comment/138072481
type: Comment
comment on: http://stackoverflow.com/q/78317514
score: 0
has text: BTW, `echo -e` isn't good practice either -- see the excellent writeup Stephane did over on [unix.se] at [Why is printf better than echo?](https://unix.stackexchange.com/a/65819/3113); the POSIX echo specification itself recommends using printf instead (in https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html, see the APPLICATION USAGE and RATIONALE sections).
type: QuestionComment

http://stackoverflow.com/q/78343975
type: Question
has comment: http://stackoverflow.com/comment/138129534
has answer: http://stackoverflow.com/a/78344012
type: UnansweredQuestion
answer count: 1
has comment: http://stackoverflow.com/comment/138121719
has comment: http://stackoverflow.com/comment/138123415
score: 0
has title: Open a cmd window and init script from git bash on windows
has body: I haven't been able to figure out how to open a cmd window from inside git bash with the following conditions: Target Type = Application Target Loaction = system32 Target = C:\windows\system32\cmd.exe /k ""C:\Users\thebi.espressif\idf_cmd_init.bat" esp-idf-f4096c5fb8232f5ffa980cf1b514d882" Start in location specified. Here's how this usually works. You browse to the folder and double click this, and it opens the cmd window in the starts in folder. Then it runs the idf_cmd_init.bat script. That does loads of useful things for you like set up local environment variables for the version of esp-idf specified in the input argument. Where I am getting stuck is that I'd like to bundle some of this into a shell script. Basically, I'd like to open this cmd window, run idf.py build and then close it again. However, whichever way I try, I can't seem to make it work. My code: # Define the path to the shortcut target command esp_idf_v5_1_init='C:\Users\thebi\.espressif\idf_cmd_init.bat esp-idf-f4096c5fb8232f5ffa980cf1b514d882' # Run the shortcut target command using cmd.exe cmd.exe /k "$esp_idf_v5_1_init" && ( # Run additional commands in the resulting cmd window cmd.exe /k "cd %ESP32_REPO_PROD% && esp-idf.py build" ) What happens is that the cmd window opens and does nothing. I've tried as many variations as I can think of: powershell, /c, /k, echo-ing the cmd stuff to a separate file. But I can't figure it out. It would be nice to be able to remove the manual steps. Update I tried the suggestion from @Phillipe. What I see is this: $ ./test.sh Microsoft Windows [Version 10.0.19045.4291] (c) Microsoft Corporation. All rights reserved. D:\...\temp>call C:\Users\thebi\.espressif\idf_cmd_init.bat esp-idf-f4096c5fb8232f5ffa980cf1b514d882 Setting PYTHONNOUSERSITE, was not set Using Python in C:\Users\thebi\.espressif\python_env\idf5.1_py3.11_env\Scripts\ Python 3.11.2 Using Git in C:\Users\thebi\.espressif\tools\idf-git\2.39.2\cmd\ git version 2.39.2.windows.1 This .bat file is for W…
tagged with: bash
tagged with: cmd
tagged with: batch-file
has comment: http://stackoverflow.com/comment/138133996
has comment: http://stackoverflow.com/comment/138123002

http://stackoverflow.com/a/78603441
upvote count: 0
has body: Reminder: $? stores the exit code/status from last command. As "echo something" is likely to succeed, testing $? after your script is like checking echo command ran ok or not. Here's a snippet to count errors, and exit with non-zero if at least one error occurred: declare -i errors_count=0 # (/bin/true exits with code=0, /bin/false exits with code=1) for result in true true false true false true do if bash -c $result then echo OK else echo failed errors_count+=1 fi done if [ $errors_count -ne 0 ] then echo "Encountered $errors_count failures" exit 1 fi
has comment: http://stackoverflow.com/comment/138596845
has comment: http://stackoverflow.com/comment/138586162
score: -1
has comment: http://stackoverflow.com/comment/138577757
has comment: http://stackoverflow.com/comment/138581754
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78409475

http://stackoverflow.com/comment/138222122
type: Comment
type: AnswerComment
has text: Not directly, but I think it accomplishes a similar purpose (decreasing the number of keystrokes to repeat commands `a`, `b`, and `c`. History substitution would probably be even more useful, as it would allow all three commands to be executed as a group
score: 0
comment on: http://stackoverflow.com/a/78402923

http://stackoverflow.com/comment/138262407
type: Comment
has text: That said, you _really_ shouldn't be putting passwords on the command line. `pwhash='$123' test.sh` (all one command line) is safer -- it puts the hash in the environment where only other processes owned by the same user (or by root) can see it, vs on the command line where it's readable by every process on the entire system.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78424828

http://stackoverflow.com/comment/138192759
has text: Edit - formatting in comments is hard. I moved my results / new code to the OP
comment on: http://stackoverflow.com/q/78385537
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138255956
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78422019
has text: You should use parentheses to group the `||` conditions together in the `if` statement. See https://stackoverflow.com/questions/74971607/how-does-bash-handle-operator-precedence for the precedence rules.
type: QuestionComment

http://stackoverflow.com/q/78364618
has comment: http://stackoverflow.com/comment/138159840
type: AnsweredQuestion
has body: I'm trying to parse a file using awk to return an array of 4 arguments in an applescript, but am not getting the desired result. Here's the awk command: awk -F '%' '{if ($1=="Actions") print ($2 "," $3 "," $4 "," $5)}' "/Users/<my_username>/Desktop/windowInfo.txt" And here's the content of the file: Actions%3773%22%1347%699 Transport%3431%1199%665%97 Undo History%3431%1276%665%164 The best I've been able to do is getting the 4 arguments I want separated by commas, but then it always additionally returns the first argument from the next line after a newline. Even when I use awk -F '%|\n' to include the newline as a separator, it's still returning the same result with the first argument of the following line on a newline. example of the output I'm getting: 3773,22,1347,699 Transport I can't figure out what I'm doing wrong here. Please help! For context, I am trying to call this from an applescript using the following syntax to return window position and size data from a text file based on window name matching: repeat with winName in winNames set shellCommand to "awk -F '%' '{if ($1==\"" & winName & "\") print $2,$3,$4,$5}' " & filePath set {winX, winY, winW, WinH} to (do shell script shellCommand) if (winX is not "") and (winY is not "") and (winW is not "") and (WinH is not "") then tell application process "Finder" set theWindow to (every window whose name is winName) if (count of theWindow) > 0 then set position of theWindow to {winX, winY} set size of theWindow to {winW, winH} end if end tell end if end repeat
linked to: http://stackoverflow.com/q/76408056
has comment: http://stackoverflow.com/comment/138158743
upvote count: 2
has comment: http://stackoverflow.com/comment/138157286
score: 1
tagged with: bash
tagged with: applescript
type: Question
has comment: http://stackoverflow.com/comment/138155162
has comment: http://stackoverflow.com/comment/138159843
downvote count: 1
has title: can't get *only* desired output from awk command
has comment: http://stackoverflow.com/comment/138159865
has comment: http://stackoverflow.com/comment/138155046
tagged with: awk
has answer: http://stackoverflow.com/a/78364778
has comment: http://stackoverflow.com/comment/138159862
tagged with: shell
accepted answer: http://stackoverflow.com/a/78364778
linked to: http://stackoverflow.com/q/19075671
has comment: http://stackoverflow.com/comment/138157298
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/138191095
has text: Is there a reason to store the command first. rather than just using `echo "Search Command curl $mSearchCommand --url '${requestURL}'"; mSearchResponse="$(curl $mSearchCommand --url "$requestURL}")"`?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78383368
type: Comment

http://stackoverflow.com/comment/138329940
comment on: http://stackoverflow.com/q/78442690
type: QuestionComment
has text: But care, as `declare -A "varname=($othervariable)"` is a kind of `eval`, you have to be confident about your input! See [my answer](https://stackoverflow.com/a/78464354/1765658)
type: Comment
score: 1

http://stackoverflow.com/comment/138234234
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78409604
score: 0
has text: AFAIK there's nothing like this in bash. Why not just search for it in an editor?

http://stackoverflow.com/q/78392466
score: 0
linked to: http://stackoverflow.com/q/50528892
answer count: 0
has comment: http://stackoverflow.com/comment/138203987
tagged with: bash
has comment: http://stackoverflow.com/comment/138205300
has title: Writing a bash script to wait for a process on a remote machine to finish
has comment: http://stackoverflow.com/comment/138205306
has comment: http://stackoverflow.com/comment/138203716
tagged with: scripting
linked to: http://stackoverflow.com/q/12498304
tagged with: ssh
type: Question
has comment: http://stackoverflow.com/comment/138203592
tagged with: shell
has body: I'm writing a script to automate some tasks, one of the steps is to wait for a process started on a remote machine to finish execution. My idea is to show a spinner while the process keeps executing, with inspiration from this question. The relevant part of the code is this - spinner_wait_remote() { local pid=$1 local msg=${2-Process $pid still running} local spin='-\|/' local i=0 while ssh "$remote_machine" "kill -0 $pid" 2>/dev/null do local i=$(( (i+1) %4 )) printf "\r${spin:$i:1} $msg" sleep .1 done printf "\n\e[A\e[K" } The problem is, it never enters the while loop, although the $pid exists in the remote machine. I have a similar method that waits for commands launched in the local machine and it works fine. The only difference is the ssh command in the while condition. I also tried running the entire while loop on the remote machine, but it still doesn't seem to enter the while loop. spinner_wait_remote() { pid=$1 msg=${2-Process $pid still running} ssh "$remote_server" " spin='-\|/' i=0 while kill -0 $pid 2>/dev/null do i=$(( (i+1) %4 )) printf \"\r${spin:$i:1} $msg\" sleep .1 done printf \"\n\e[A\e[K\" " }
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138203968
has comment: http://stackoverflow.com/comment/138203683
duplicate of: http://stackoverflow.com/q/50528892

http://stackoverflow.com/q/78419884
has body: When I run my Bash scripts (launchpad.net/linuxha) and (launchpad.net/linuxsoho) in Ubuntu 24.04, I receive the following errors: ./LinuxHA.sh: 175: read: Illegal option -s ./LinuxHA.sh: 355: Syntax error: &quot;(&quot; unexpected (expecting &quot;}&quot;) ./LinuxSOHO.sh: 65: read: Illegal option -s ./LinuxSOHO.sh: 94: Syntax error: &quot;(&quot; unexpected (expecting &quot;}&quot;) These two scripts work just fine in Ubuntu 22.04, so something changed in Bash with the new Ubuntu 24.04 operating system.
has comment: http://stackoverflow.com/comment/138252259
has comment: http://stackoverflow.com/comment/138252148
score: 0
type: Question
duplicate of: http://stackoverflow.com/q/32038974
tagged with: ubuntu
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138252288
tagged with: scripting
has title: Bash scripts do not function correctly in Ubuntu 24.04
answer count: 0
tagged with: bash
linked to: http://stackoverflow.com/q/32038974
has comment: http://stackoverflow.com/comment/138252280

http://stackoverflow.com/q/78400075
tagged with: arrays
accepted answer: http://stackoverflow.com/a/78401596
has body: I am using bash version 5.1.16 I am trying to write a bash script that creates a dynamic number of arrays, each with a dynamic name that will hold some element parts from a declared array. I am attempting to split a single array into multiple arrays that will hold an equal number of elements. dec_array = (abc10 def2 ghi333 jkl mno51 pqr_6) # this array will always have some multiple of three elements but variable in the number of elements num_elem=3 num_arr=0 # will eventually incr and loop once this works for ((i=0; i < ${#dec_array[@]}; i+=num_elem)); do part=( "${dec_array[@]:i:num_elem}" ) echo "Elements in first example: ${part[*]}" dyn_array_${num_arr}=( "${dec_array[@]:i:num_elem}" ) echo "Elements in second example: $dyn_array_${num_arr}[*]}" done output: Elements in first example: abc10 def2 ghi333 Elements in first example: jkl mno51 pqr_6 syntax error near unexpected token `"${dec_array[@]:i:num_elem}"' ` dyn_array_${num_arr}=( "${dec_array[@]:i:num_elem}" )' I need to be able to split dec_array into multiple dyn_array_n, e.g., dyn_array_0: abc10 def2 ghi333 dyn_array_1: jkl mno51 pqr_6 What is the correct syntax to accomplish creating a dynamic number of arrays with dynamic names?
tagged with: bash
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78400214
answer count: 3
score: 4
type: Question
upvote count: 4
downvote count: 0
has title: How to create a dynamic number of arrays with dynamic names in bash?
has answer: http://stackoverflow.com/a/78401596
possible better answer: http://stackoverflow.com/a/78400214
has comment: http://stackoverflow.com/comment/138217199
has answer: http://stackoverflow.com/a/78402352

http://stackoverflow.com/q/78342087
has comment: http://stackoverflow.com/comment/138115297
duplicate of: http://stackoverflow.com/q/10067266
has body: Here is my structure: I am trying to print some values in a JSON file. Here is the service-data.json: { "service_name": "nphies-support.service", "description": "nphies-support-service Spring Boot Application", "user": "aceusr", "working_directory": "/home/aceusr/deployment/nphies/nphies-support", "java_home": "/usr/lib/jvm/jdk-21.0.1", "jar_file": "nphies-support-service.jar" } I am reading this JSON in a bash script using jq: #!/bin/bash echo "$0 script starting" # test if the jq is installed test_json=$(echo "{ }" | jq) if [ "$test_json" != "{}" ]; then echo "jq not installed" exit 1 fi #read json into variable json json=$(cat service-data.json) #converting json objects to bash variable declare $(echo $json | jq -r 'to_entries | .[] | "export \(.key)=\(.value)"') echo "service_name = $service_name" echo "description = $description" echo "user = $user" echo "working_directory = $working_directory" echo "java_home = $java_home" echo "jar_file = $jar_file" #use the -r option to output the result as raw text, without quotes. description1=$(echo $json | jq -r '.description') echo "description1 = $description1" exit 0 This JSON is an object so I am using declare function to convert JSON into bash script variables. For description it is only printing nphies-support-service instead of nphies-support-service Spring Boot Application. Looks like it is breaking on first space. But when I read the same field using the syntax name=$(echo $json | jq -r '.description') it prints the whole text. Why is it not printing the whole text in iteration? What do I do so it prints whole text for description variable?
duplicate of: http://stackoverflow.com/q/48512914
type: Question
has comment: http://stackoverflow.com/comment/138115181
has comment: http://stackoverflow.com/comment/138115225
has comment: http://stackoverflow.com/comment/138115189
has comment: http://stackoverflow.com/comment/138115498
has title: jq not printing full string with spaces in Bash script
linked to: http://stackoverflow.com/q/48512914
tagged with: jq
has comment: http://stackoverflow.com/comment/138115340
linked to: http://stackoverflow.com/q/29378566
score: 0
answer count: 0
linked to: http://stackoverflow.com/q/10067266
has comment: http://stackoverflow.com/comment/138115279
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/29378566
has comment: http://stackoverflow.com/comment/138115204
tagged with: bash

http://stackoverflow.com/comment/138198437
has text: You are correct that it is a little different, but that little difference is acceptable for me. Either way is ok.
type: Comment
comment on: http://stackoverflow.com/q/78378370
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138260506
has text: Did not work 1:1 for me because MacOS does not support Gawk ( I probably should have mentioned that). But i ended up using substr. Thank you for your answer!
comment on: http://stackoverflow.com/a/78420842
type: Comment
type: AnswerComment
score: 0

remote-access
type: Tag
tag name: remote-access
tags question: http://stackoverflow.com/q/78384843

http://stackoverflow.com/q/78374366
tagged with: docker
score: 0
has body: I am trying to make a docker container run off of my docker-compose file: version: '3' services: memory_Backend: build: context: ./ dockerfile: ./project/docker/DockerfileBackend image: memoryapi_ad_img volumes: - ./:/var/lib ports: - 15555:25555 memory_Frontend: build: context: ./ dockerfile: ./project/docker/DockerfileFrontend image: memorywebsite_ad_img volumes: - ./:/var/lib ports: - 15556:25556 but it gives me WARN[0000] /home/dube_arthur/tp4startingpoint/docker-compose.yml: `version` is obsolete [+] Running 2/2 ! memory_Backend Warning pull access denied for memoryapi_ad_img, repository does not exist or may require 'docker login': denied: requested access to the resource is denied 0.8s ! memory_Frontend Warning pull access denied for memorywebsite_ad_img, repository does not exist or may require 'docker login': denied: requested access to the resource is denied 0.8s [+] Building 0.2s (4/4) FINISHED docker:default => [bookapi_frontend internal] load build definition from DockerfileFrontend 0.1s => => transferring dockerfile: 2B 0.0s => [bookapi_frontend internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [bookapi_backend internal] load build definition from DockerfileBackend 0.1s => => transferring dockerfile: 2B 0.1s => [bookapi_backend internal] load .dockerignore 0.1s => => transferring context: 2B 0.1s failed to solve: failed to read dockerfile: open /var/snap/docker/common/var-lib-docker/tmp/buildkit-mount2955977944/DockerfileFrontend: no such file or directory error But, my DockerfileFrontEnd and DockerfileBackEnd is in the /project/docker/ also, they look like this FROM demers/python420w4a COPY ./requirements.txt / RUN pip3 install -r /requirements.txt RUN apt-get update -y RUN apt-get install -y xxd WORKDIR /var/lib CMD ["./run.sh", "./project/main/memoryapi.py", "25555"] and my DockerfileFrontEnd is: FROM demers/python420w4a COPY ./requirements.txt / RUN pip3 install -r /requirements.txt RUN apt-get update -y RUN apt-get install -…
possible better answer: http://stackoverflow.com/a/78374597
has answer: http://stackoverflow.com/a/78380074
has answer: http://stackoverflow.com/a/78421667
type: AnsweredQuestion
tagged with: python
has comment: http://stackoverflow.com/comment/138172415
accepted answer: http://stackoverflow.com/a/78380074
has title: Why does my docker-compose.yml file dont find my Dockerfile*end file
has answer: http://stackoverflow.com/a/78374597
tagged with: linux
tagged with: bash
type: Question
tagged with: docker-compose
answer count: 3

http://stackoverflow.com/comment/138114823
type: QuestionComment
type: Comment
has text: If you want to make the handler happen _immediately_, change your last line to `tail -F test.sh & wait`. Mind, I'd also want to have the signal handler explicitly kill the copy of tail.
score: 1
comment on: http://stackoverflow.com/q/78341760

http://stackoverflow.com/comment/138151869
score: 0
comment on: http://stackoverflow.com/q/78362703
has text: Why do you need to demonstate that? It's common knowledge. Common programming languages like C and C++ create _one_ main thread of execution at startup
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138118719
has text: i'm not ignoring your advice but i'm totally new to all that stuff, and leaving me here in the middle of nowhere will not help me ... And just for you to know, even when I see some part of codes someone would have created for me, i'm always trying to understand it, all the time !! But anyway, as I can't understand and have no time to understand it, i won't be able to use XSLT for now ... If you happen to decide to help me a bit more, I'd be very happy and so grateful ... It's now up to you !
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78342527

http://stackoverflow.com/comment/138251104
type: QuestionComment
type: Comment
score: 0
has text: What @jhnc said! Also regarding "Many of our scripts already begin with set -eu" - most people who've been programming in bash for a while would advise against using `set -e` and instead handling errors appropriately when they occur, see http://mywiki.wooledge.org/BashFAQ/105.
comment on: http://stackoverflow.com/q/78409604

http://stackoverflow.com/comment/138265150
has text: I can reproduce this if the `fi` line ends with a carriage return. Fix the script with `dos2unix`
comment on: http://stackoverflow.com/q/78427118
score: 4
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78330653
type: Question
type: UnansweredQuestion
has title: find : unknow predicate - filesname
has body: this is my script : find */*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path 'stockdress/*' -not -path 'oldstockdress/*' > temp.txt I am getting this error while i'am running this command: find: unknown predicate `- lolodress/2023-09-23_referencenumber.txt How can I handle directory names that start with a dash and space when using the find command to avoid the "find: unknown predicate" error? i tried : find */*/*20* -maxdepth 1 -type f -mmin +$((730 * 1440)) -not -path 'stockdress/*' -not -path 'oldstockdress/*' -exec sh -c 'mv "$0" "temp.txt"' {} \; but i am still having the same error. i want the find command to search for all filesname whith the name 20 in and sent the output as a newline for each filesname found to the tmp.txt files.
duplicate of: http://stackoverflow.com/q/5677558
tagged with: bash
has comment: http://stackoverflow.com/comment/138101044
answer count: 0
linked to: http://stackoverflow.com/q/5677558
has comment: http://stackoverflow.com/comment/138095000
has comment: http://stackoverflow.com/comment/138095024
has comment: http://stackoverflow.com/comment/138095018
score: 0

http://stackoverflow.com/comment/138252259
type: Comment
score: 1
has text: Looks to me from the error that you're using sh to run a script that requires bash. They're two different shells; bash syntax is only guaranteed to work when you're using bash to run the script.
comment on: http://stackoverflow.com/q/78419884
type: QuestionComment

http://stackoverflow.com/q/78321765
tagged with: sudo
has title: Set openvpn username and password via env-variable
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138079677
score: 0
has answer: http://stackoverflow.com/a/78321913
type: Question
has comment: http://stackoverflow.com/comment/138079621
accepted answer: http://stackoverflow.com/a/78321913
answer count: 1
has comment: http://stackoverflow.com/comment/138079708
has body: I have a rather long password that I want to automate using a secret manager, I don't want to store it in plaintext. Judging from this answer, I can achieve this using env-variables, which is great. A quick check using sudo openvpn --config ~/Documents/config.ovpn --auth-user-pass test.txt works, also great! I need sudo, otherwise openvpn doesn't work. But I can't get the command right, I am probably making some trivial mistake. I tried: sudo openvpn --config ~/Documents/config.ovpn --auth-user-pass <(echo -e $VPN_USER"\n"$VPN_PASS) but that results in: 2024-04-13 20:11:43 WARNING: cannot stat file '/proc/self/fd/14': No such file or directory (errno=2) Options error: --auth-user-pass fails with '/proc/self/fd/14': No such file or directory (errno=2) which I think is due to my sudo usage. So I tried something else (I am not exactly a bash-pro): cat <(echo -e $VPN_USER"\n"$VPN_PASS) | sudo /usr/sbin/openvpn --config ~/Documents/config.ovpn --auth-user-pass but that results in: Password entry required for 'Enter Auth Username:' (PID 191957). Please enter password with the systemd-tty-ask-password-agent tool. It's probably an easy question.
has comment: http://stackoverflow.com/comment/138079613
linked to: http://stackoverflow.com/q/13672420
has comment: http://stackoverflow.com/comment/138079619
linked to: http://stackoverflow.com/q/38869427
tagged with: openvpn
tagged with: bash

http://stackoverflow.com/comment/138254705
has text: Is the `-` (dash) after `>&` on line 2 of the script significant? What exactly closes `stdout` before `echo` had a chance to run?
type: Comment
comment on: http://stackoverflow.com/a/78420840
type: AnswerComment
score: 0

http://stackoverflow.com/a/78401558
has body: You can't redirect standard input twice to to the same command. Either it reads the password from standard input, or it reads the here document on standard input. It can't do both. You can use a subshell to separate the two: sudo -S <<<"$password" bash -c 'tee /etc/systemd/system/$1 <<EOF .... your here document EOF ' -s "SERVICE_NAME" If you need literal single quotes inside the here document, a common solution is to use what I like to call "seesaw quoting". A single-quoted string immediately adjacent to a double-quoted string containing a literal single quote are joined by the shell into a single string with a single quote in it. sudo -S <<<"$password" bash -c 'tee /etc/systemd/system/$1 <<EOF [Service] ExecStart=echo "You don'"'"'t say" EOF ' -s "SERVICE_NAME" You might need a double take on that. That's a single-quoted string bash -c '... echo "You don' adjacent to the double-quoted string "'" adjacent to the single-quoted string 't say"...'. Perhaps notice also how this avoids the useless use of cat. sudo can perfectly read standard input from a here document (and doesn't even know that it's coming from one; the shell takes care of all of this). Anyway, as noted in comments, you really really want to avoid embedding your password in a script. Set up sudo with NOPASSWD or run the script as root in the first place (or avoid requiring root privileges if you can).
accepted answer of: http://stackoverflow.com/q/78401442
answers question: http://stackoverflow.com/q/78401442
type: Answer
score: 0
type: AcceptedAnswer

http://stackoverflow.com/q/78372639
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138169201
has answer: http://stackoverflow.com/a/78373052
has comment: http://stackoverflow.com/comment/138170709
score: -1
upvote count: 0
has answer: http://stackoverflow.com/a/78375417
tagged with: bash
has comment: http://stackoverflow.com/comment/138169388
has answer: http://stackoverflow.com/a/78375031
has title: Append value in ascending order using sed
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138169212
has comment: http://stackoverflow.com/comment/138169319
has comment: http://stackoverflow.com/comment/138169205
tagged with: awk
tagged with: sed
has answer: http://stackoverflow.com/a/78373011
answer count: 5
type: Question
has body: I have a configuration file where I need to append the version in ascending order. For this I have written a shell script. The value is getting appended, but the position is not correct. Config file [version] 1.0.0.0, 1.0.1.0, 1.0.2.0, 1.0.3.0, 1.0.3.1, 1.0.4.0, 1.0.4.1, 1.0.5.0, 1.0.5.1, 1.0.6.0, 1.0.6.1, 1.0.6.2, 1.0.7.0, 1.0.7.1, 1.2.2.8, 1.2.2.9, 1.2.2.10, 1.2.2.1, 1.2.3.0, 1.3.0.0, 1.2.3.1, \ Suppose if I pass 1.0.7.2, then it should be appended after 1.0.7.1, basically in ascending order. here is the shell script I wrote to achieve this #!/bin/bash # Define the value to append value_to_append="$1" # Path to the configuration file config_file="app.config" line_number=$(grep -n "\[version\]" "$config_file" | cut -d':' -f1) # Append the value after the line_number sed -i "${line_number}a \ \ \ \ \ \ \ \ $value_to_append," "$config_file" With this script the value is appending at the start and not in the ascending order. What should I change in script to position the value in proper order.
has answer: http://stackoverflow.com/a/78373047
has comment: http://stackoverflow.com/comment/138172221

http://stackoverflow.com/a/78372746
downvote count: 0
type: AcceptedAnswer
score: 2
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/78372273
has body: You can use printf: printf '\%bhello\n' "$C_CYAN" but as @chepner says in his comment it's better to use tput than hardcoding escape sequences: C_CYAN=$(tput setf 3)
has comment: http://stackoverflow.com/comment/138428520
accepted answer of: http://stackoverflow.com/q/78372273

http://stackoverflow.com/q/78418827
score: 0
has comment: http://stackoverflow.com/comment/138250263
tagged with: bash
has body: I'm trying to remove all directories whose path matches a certain pattern from the path, within a script that would be sourced using .. The script prints a warning "Substitution replacement not terminated at -e line 1." when sourced: Edit: including full script. Note that there are multiple errors here! vv=`echo $0 | perl -ne 's/([0-9]+)/ and print $1'` node_home=`ls -d /opt/node$xx* | head -1` PATH=`perl -e 'print join q{:},grep !m{/node-},split(m{[:]},$ENV{"PATH"})'` PATH=$node_home/bin:$PATH But the warning doesn't appear when I enter the first PATH= line into bash interactively.
answer count: 1
has title: Warning "Substitution replacement not terminated", only in sourced shell script
type: Question
has answer: http://stackoverflow.com/a/78419268
type: UnansweredQuestion
tagged with: perl
has comment: http://stackoverflow.com/comment/138250290

http://stackoverflow.com/q/78344372
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138127903
has answer: http://stackoverflow.com/a/78344420
has comment: http://stackoverflow.com/comment/138119455
accepted answer: http://stackoverflow.com/a/78344420
has body: I stumbled across what should be something simple that's turned out to be a brain-teaser. As a not fully accomplished BASH programmer, I naively thought I could read in characters from an interactive terminal window and actually determine what keys were pressed! MOST keys work out just fine, but how to catch "return" is non-obvious. Here's some sample code to illustrate the question: while [ $justRead != "\n" ] ; do # read -e -s -N 1 justRead read -s -N 1 justRead case "$justRead" in \n | "\n" | \r | "\r" | ^M | '^M') echo "return" ;; *) echo -n "$justRead" ;; esac done As can be seen, the code has a line using the Readline library and another that does not. The two behave differently but I've not gotten either to work successfully. I'm SURE it's something I'm doing wrong with my match string. I also noticed that the -s - silent - option appears to be ignored by Readline but not the other library, not that that matters to the question, I was just surprised by that. OBVIOUSLY I'm missing something here! This just has to be simple, right? Please! Just fixing the syntax does NOT help educate! Please explain WHY your fix works.
downvote count: 0
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138119414
has comment: http://stackoverflow.com/comment/138121584
has comment: http://stackoverflow.com/comment/138133878
tagged with: readline
score: 1
has title: How do I catch return characters when using character-at-a-time BASH builtin read with if or a case statement?
answer count: 1

http://stackoverflow.com/q/78388693
tagged with: android
type: Question
tagged with: macos
type: UnansweredQuestion
has title: Why i take this result and how can i solve it?
tagged with: flutter
score: 0
has answer: http://stackoverflow.com/a/78417239
has comment: http://stackoverflow.com/comment/138202394
tagged with: bash
upvote count: 1
answer count: 1
favorite count: 0
downvote count: 1
has body: i use macOS in my internship for mobile developing with flutter. I am suffer from this two problem from last Thursday morning. Flutter device daemon #5 exited (exit code 127), stderr: env: bash: No such file or directory The Flutter device daemon cannot be started. Please check your configuration and restart the IDE. You may need to increase the maximum number of file handles available globally.` When i was try to build APK, android studio was returning NO SDK Environment problem. I tried some terminal codes to solve it. But now i'm suffer from new problems , Android studio doesn't debugs code and returns errors above. And i see like this errors in my terminal when i started it .sdkman/bin/sdkman-init.sh:42: command not found: uname .sdkman/bin/sdkman-init.sh:75: command not found: find .sdkman/bin/sdkman-init.sh:103: command not found: _sdkman_echo_debug .rvm/scripts/rvm:12: command not found: uname .rvm/scripts/rvm:29: command not found: ps and terminal returns command not found: for commands like nano open sudo and when i write flutter returns env: bash: No such file or directory to me
tagged with: system

http://stackoverflow.com/comment/138235436
type: Comment
comment on: http://stackoverflow.com/q/78409475
score: 0
type: QuestionComment
has text: @JohnBollinger I have realised I had two different versions of whisper, which changed this behaviour. Unfortunately, it is the old version that behaves correctly.

http://stackoverflow.com/comment/138101528
type: Comment
type: AnswerComment
score: 1
has text: behavior of bash builtin echo depends on shell options at runtime and configure options at build time
comment on: http://stackoverflow.com/a/78334326

http://stackoverflow.com/comment/138293840
comment on: http://stackoverflow.com/q/78443452
score: 2
type: QuestionComment
type: Comment
has text: It's not the function as such; it's the pipe. **The last component in a pipe is executed in a subshell by default in bash** and thus any variable setting or other changes are not available to the main shell subsequently. Dupe https://stackoverflow.com/questions/2746553/read-values-into-a-shell-variable-from-a-pipe and https://unix.stackexchange.com/questions/143958/in-bash-read-after-a-pipe-is-not-setting-values https://unix.stackexchange.com/questions/9954/why-is-my-variable-being-localized-in-one-while-read-loop-but-not-in-another

http://stackoverflow.com/comment/138244672
type: Comment
comment on: http://stackoverflow.com/q/78415633
score: 0
has text: Read the description of `:?` in parameter expansion. After printing the error message the shell exits.
type: QuestionComment

http://stackoverflow.com/q/78371799
linked to: http://stackoverflow.com/q/34775232
has comment: http://stackoverflow.com/comment/138171982
tagged with: loops
tagged with: bash
type: Question
has answer: http://stackoverflow.com/a/78375522
has answer: http://stackoverflow.com/a/78374414
type: UnansweredQuestion
tagged with: awk
has answer: http://stackoverflow.com/a/78371835
has comment: http://stackoverflow.com/comment/138167489
downvote count: 2
score: 0
answer count: 4
linked to: http://stackoverflow.com/q/23408782
favorite count: 0
has answer: http://stackoverflow.com/a/78372403
linked to: http://stackoverflow.com/q/20796200
has body: I have a directory of approx 100 fastq files. Each file name is LongString.fastq. Each fastq file is organized into separate lines of information. This is long-read data, so there will be hundreds to thousands of reads in each fastq file. I am working in Bash. I need to count the character length of the sequence on every 4th line, starting from and including line 2. The inside of each file looks like this (This is shortened for example): $ head -8 FAX08345_abafd786_a8df7914_1131.fastq &gt;@5741b240-bbb7-463a-a41c-fab01677d2cd &gt;GTGCCCTCTACTCGTTCAGTTCAGGTCCTTGCTGATGCGTCCGGCGTAGAGGATCGAGATCGATCTCGA &gt;+ &gt;&amp;&amp;&amp;%%%%&amp;()*)&amp;%%()++))(()(((((('(23///=;:::9;;&lt;&lt;&lt;&lt;&lt;77788;;;&lt;=A&gt;??? &gt;@5b0dc526-2324-400a-b89b-e4056ea82f75 &gt;CTGTGTGACGCCTTCGTTCATTTTCGTGTGCTTGTTAGCAGCCGGATCTCAGTGGTGGTGGTGGTGGT &gt;+ &gt;#$#$$$$$$$$$%'$%&amp;&amp;&amp;''&amp;&amp;'&amp;&amp;&amp;%%%%'32237@CDEGJJIKKOGIFHSSJSSSILMLSJON I am using this command to count the read length and output into a new file. sed -n '2~4p' FAX08345_abafd786_a8df7914_1131.fastq | awk '{ print length }' &gt; len.text Output file name would be: FAX08345_abafd786_a8df7914_1131.fastq.len Output file content would be: 69 68 Name for the second input file: FAX08345_abafd786_a8df7914_500.fastq New Name for second output file FAX08345_abafd786_a8df7914_500.fastq.len Content of the second input file: &gt;@5741b240-bbb7-463a-a41c-fab01677d2cd &gt;GTGCCCTCTACTCGTTCAGTTCAGGTCCTTGCTGATGCGTCCGGCGTAGAGGATCGAGATCGATCTCGAGATCGATCTCGA &gt;+ &gt;&amp;&amp;&amp;%%%%&amp;()*)&amp;%%()++))(()(((((('(23///=;:::9;;&lt;&lt;&lt;&lt;&lt;77788;;;&lt;=A&gt;??? &gt;@5b0dc526-2324-400a-b89b-e4056ea82f75 &gt;CTGTGTGACGCCTTCGTTCATTTTCGTGTGCTTGTTAGCAGCCGGATCTCAGTGGTGGTGGTGGTGGTGTGGT &gt;+ &gt;#$#$$$$$$$$$%'$%&amp;&amp;&amp;''&amp;&amp;'&amp;&amp;&amp;%%%%'32237@CDEGJJIKKOGIFHSSJSSSILMLSJON content in the second output file: 81 73 I need to automate this for all of the fastq files that I have in my directory. Note, in …
tagged with: sed
has title: creating a read length count for each read in multiple fastqs
upvote count: 2

http://stackoverflow.com/comment/138105847
type: QuestionComment
type: Comment
has text: @JohnBollinger it is related to CI because the CI job can run on any machine and I cannot modify all the `.bashrc`s for all the machines, so sadly modifying the `.bashrc` is sadly out of the question. Without the `-l` option the PATHS to the commands used by the script cannot be found .
comment on: http://stackoverflow.com/q/78336169
score: 0

http://stackoverflow.com/q/78372273
has body: C_CYAN='\033[36m' echo -e "\\${C_CYAN}hello"; Expected: \hello in with the word hello in cyan Actual: \033[36mhello
has comment: http://stackoverflow.com/comment/138178387
accepted answer: http://stackoverflow.com/a/78372746
linked to: http://stackoverflow.com/q/673055
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138168732
tagged with: shell
has answer: http://stackoverflow.com/a/78378158
has title: How do I escape this properly in bash?
tagged with: colors
possible better answer: http://stackoverflow.com/a/78378158
has answer: http://stackoverflow.com/a/78372377
tagged with: bash
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78372746
tagged with: escaping
answer count: 3

http://stackoverflow.com/comment/138173258
comment on: http://stackoverflow.com/q/78375007
score: 0
has text: Can STDIN be replaced for the whole program or does it need to be only replaced for `run-command`?
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78383368
accepted answer: http://stackoverflow.com/a/78383369
linked to: http://stackoverflow.com/q/12136948
type: Question
has answer: http://stackoverflow.com/a/78384589
has comment: http://stackoverflow.com/comment/138197975
has comment: http://stackoverflow.com/comment/138190284
has title: Running a curl command via bash returned "URL rejected: Bad hostname", but works on cmdline
score: 1
has comment: http://stackoverflow.com/comment/138194254
favorite count: 0
has comment: http://stackoverflow.com/comment/138192934
has comment: http://stackoverflow.com/comment/138195725
has comment: http://stackoverflow.com/comment/138188079
answer count: 2
has comment: http://stackoverflow.com/comment/138197979
tagged with: linux
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138198337
upvote count: 1
has comment: http://stackoverflow.com/comment/138191095
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138187761
tagged with: rest
has answer: http://stackoverflow.com/a/78383369
possible better answer: http://stackoverflow.com/a/78384589
tagged with: curl
linked to: http://stackoverflow.com/q/17529220
has body: When I try to run this cmd via bash like this Bash Script mycommand="curl $mycommand --url '${requestURL}'" echo "Search Command $mycommand" myresponse="$(${mycommand})" Output Search Command curl -v -X GET --header Authorization:'Bearer ---very long access token---' -s ' https://my-rest-services:443/mypath/someparameters' * URL rejected: Bad hostname * Closing connection * URL rejected: Port number was not a decimal number between 0 and 65535 * Closing connection When I run the follow command on cmd line, it runs perfectly, and returns my json response curl -v -X GET --header Authorization:'Bearer ---very long access token---' -s ' https://my-rest-services:443/mypath/someparameters' {myjson response}

http://stackoverflow.com/comment/138080172
comment on: http://stackoverflow.com/q/78322081
has text: The issue is that `||` will combine commands, so using it ends the previous command. So, the first command, to the left of the `||`, is `[ ! is_number "$1"` and therefore the `[` command will rightfully complain about a missing `]` in its command line because its invocation syntax is designed to look like a pair of brackets. That's because `[` is not shell grammar, it's a command, either in form of a builtin (like `echo`) or a binary (`/bin/[` or `/usr/bin/[`).
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/138269218
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78427584
has text: @Gordon, Interesting. This never occurred to me, thanks! Unfortunately, it still doesn't work; see my next answer please.

http://stackoverflow.com/comment/138290901
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78441743
has text: (You keep mentioning Bash, but the screenshot(!) shows you running `sh`. They are not the same thing.)
type: QuestionComment

http://stackoverflow.com/comment/138202672
has text: Use `sed` for this.
comment on: http://stackoverflow.com/q/78392006
type: QuestionComment
type: Comment
score: 2

http://stackoverflow.com/comment/138118672
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78342527
has text: My preferred approach in answering this kind of question is to point people in the right direction rather than taking them by the hand and walking them to their final destination. That's partly because my time is limited, but also because I think it's important that you don't implement code that you have blindly copied without understanding it. And also because I have no idea of your overall project requirements or constraints, so recommending a technology that's new to you has to be very tentative.
score: 0

http://stackoverflow.com/comment/138296870
type: QuestionComment
has text: Show the contents of `qtr`
score: 1
type: Comment
comment on: http://stackoverflow.com/q/78444871

http://stackoverflow.com/comment/138102451
score: 0
comment on: http://stackoverflow.com/q/78334722
type: QuestionComment
type: Comment
has text: @Ctx: How do you know it is the pseudoterminal? If a terminal application creates a pseudoterminal, accepts plenty of keystrokes from the keyboard, and writes, say, 10,000 bytes to the pseudoterminal to be read by the connected stream, why wouldn’t the pseudoterminal take bytes until its buffer is full (leaving the writer blocked), make them available to be read, and, when the OP’s program reads them, resume the terminal application’s write operation? It seems more likely to me this is a chosen user interface limit in the terminal application than a lower level limit.

http://stackoverflow.com/comment/138103068
type: QuestionComment
has text: @Ctx: The votes to close started before OP updated with sample input. Given its current state, I might not have voted to close, but, given that it is closed, I will not vote to reopen until it is improved. It says “I looked it up” but does not say where or quote what was looked up. It says “it was because of the max size of the Kernel I/O queues,” but that is dubious. It says “any word that exceeds…”, but it is actually a line that is the issue, not a word. It says “the input gets corrupted,” but that is dubious and should be accompanied by evidence.
type: Comment
comment on: http://stackoverflow.com/q/78334722
score: 0

http://stackoverflow.com/comment/138091765
comment on: http://stackoverflow.com/q/78328611
has text: Is `localfileToExecuteOnDistServ.sh` present on all the servers, in the home directory of `user`? Why put the `commande` in the background? Where is `dbconnect` defined? Why use `< < ( )` instead of a simple `|`?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138089072
type: Comment
type: AnswerComment
score: 0
has text: @Dhruv: See my other comment for `echo`. For the **current** zsh running `declare`, this simply follows from the fact that the local variables survive the exec.
comment on: http://stackoverflow.com/a/78325122

http://stackoverflow.com/comment/138114641
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78341846
has text: Welcome on StackOverflow. StackOverflow is not a free coding service, it is a website where you can find help with **your own code**. Please show your code and explain what is wrong with it such that we can help you fixing it. You could also take a look at the [help center](https://stackoverflow.com/help) and especially at the [asking section](https://stackoverflow.com/help/asking).

http://stackoverflow.com/comment/138103768
type: AnswerComment
has text: Are you sure it is in the package directory and already compiled it?
score: 0
comment on: http://stackoverflow.com/a/78335433
type: Comment

http://stackoverflow.com/q/78409475
has comment: http://stackoverflow.com/comment/138235460
has body: I have a bash script that executes whisper on all sound files in a directory. Whisper uses ffmpeg to decode sound files to a format it can handle. One of the files in the directory was corrupt and caused ffmpeg to fail. The first time I executed my script it returned 1 when it hit that file but when I try to reproduce the error it always returns 0. Here is the log from the first run when 1 was returned: Traceback (most recent call last): File "/Users/db/Library/Python/3.11/lib/python/site-packages/whisper/audio.py", line 48, in load_audio .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/db/Library/Python/3.11/lib/python/site-packages/ffmpeg/_run.py", line 325, in run raise Error('ffmpeg', out, err) ffmpeg._run.Error: ffmpeg error (see stderr output for detail) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/db/Library/Python/3.11/bin/whisper", line 8, in <module> sys.exit(cli()) ^^^^^ File "/Users/db/Library/Python/3.11/lib/python/site-packages/whisper/transcribe.py", line 437, in cli result = transcribe(model, audio_path, temperature=temperature, **args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/db/Library/Python/3.11/lib/python/site-packages/whisper/transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/db/Library/Python/3.11/lib/python/site-packages/whisper/audio.py", line 130, in log_mel_spectrogram audio = load_audio(audio) ^^^^^^^^^^^^^^^^^ File "/Users/db/Library/Python/3.11/lib/python/site-packages/whisper/audio.py", line 51, in load_audio raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e RuntimeError: Failed to load audio: ffmpeg version 4.4.4 Copyright (c) 2000-2023 the FFmpeg developers built with Apple clang version 15.0.0 (cl…
has comment: http://stackoverflow.com/comment/138578100
has comment: http://stackoverflow.com/comment/138235436
has comment: http://stackoverflow.com/comment/138234305
has title: Why does a command in my Bash-script return 0 even when it fails? Python, Whisper, ffmpeg
has comment: http://stackoverflow.com/comment/138236841
score: 0
has comment: http://stackoverflow.com/comment/138233884
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78603441
answer count: 1
has comment: http://stackoverflow.com/comment/138235456
tagged with: python
tagged with: ffmpeg
has comment: http://stackoverflow.com/comment/138236881
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138233916
has comment: http://stackoverflow.com/comment/138235552
has comment: http://stackoverflow.com/comment/138680127
has comment: http://stackoverflow.com/comment/138236816

http://stackoverflow.com/comment/138264145
comment on: http://stackoverflow.com/q/78420308
has text: @user1934428, I've edited the question to make it more obvious how I would like `transformer_cmd` to be used.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78433302
duplicate of: http://stackoverflow.com/q/60842487
downvote count: 3
score: -3
tagged with: bash
has comment: http://stackoverflow.com/comment/138275877
has body: I learned that you can write scripts and run multiple commands by executing a .sh or .ps1 file in Bash and PowerShell respectively. However, when I run my files I get the same error (both in Bash and PowerShell) and I am unable to understand why. Python version I'm running is 3.11.4 OS: Win11 Script I'm trying to run is: python3 -c "print(1)" Command I'm executing In PowerShell: ./test.ps1 In Bash: ./test.sh Error message I receive is: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. When I run it with python, for example: py test.ps1 Or py test.sh I receive the following error: File "D:\python\testing\test.ps1", line 1 python3 -c "print(1)" ^^^^^^^^^^ SyntaxError: invalid syntax The fact that it shows the contents of the file it means it is running it, but I'm unable to figure out what's the problem with the syntax.
has answer: http://stackoverflow.com/a/78433313
answer count: 1
favorite count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78433313
linked to: http://stackoverflow.com/q/35845768
has title: Unable to run .sh and .ps1 file with Python
has comment: http://stackoverflow.com/comment/138275901
tagged with: powershell
type: Question
duplicate of: http://stackoverflow.com/q/35845768
upvote count: 0
tagged with: python

http://stackoverflow.com/comment/138134519
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment
has text: Could you add the minimal repro to the question?

http://stackoverflow.com/q/78444070
score: 0
type: Question
answer count: 1
has body: I have the following script: getip.sh #!/bin/bash int_ip_addr=`/sbin/ifconfig pppoe0 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f1` pb_ip_addr=`curl ipinfo.io/ip` echo "Internal IP Address is $int_ip_addr" echo "External IP Address is $pb_ip_addr" if [ "$int_ip_addr" == "$pb_ip_addr" ]; then echo "PPPoE IP is Public - $int_ip_addr"; else echo "PPPoE IP is not Public - $int_ip_addr"; disconnect interface pppoe0; connect interface pppoe0 fi It works well except for the execution of the commands "disconnect interface pppoe0; connect interface pppoe0" Disconnect and connect have no path if searched with whereis. The commands work fine when using them in the terminal but once i pute them in the script i get this: ./tmp/getip.sh: line 10: disconnect: command not found ./tmp/getip.sh: line 10: connect: command not found I tried breaking the commands down or just trying to execute them stand alone but for some reason those commands are simply unavailable for bash. This is on a linux file system on a USG-3P router from unify. The commands are meant to disconnect and reconnect the PPPoE Interface. The whole scripts purpose is to check if the internal PPPoE interface IP matches the externally seen IP or if it does not. This is a test to see if i got a CGNAT IP or a PUBLIC IP. I'd like to use the script to reconnect until i get a PUBLIC IP.
tagged with: command
tagged with: scripting
tagged with: unify
tagged with: bash
has comment: http://stackoverflow.com/comment/138295157
has answer: http://stackoverflow.com/a/78444399
has title: Execute system commands in bash script - command not found
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78444399
has comment: http://stackoverflow.com/comment/138295124

http://stackoverflow.com/comment/138159862
type: QuestionComment
has text: @Mockman no, this is specific to an issue regarding awk, showing context of a similar Applescript use, but for a different app than Finder (REAPER). Also, for the question you linked I was the OP. :)
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78364618

http://stackoverflow.com/comment/138244717
score: 0
comment on: http://stackoverflow.com/q/78415633
type: QuestionComment
type: Comment
has text: But it does not necessarily exit -- it proceeds to `printf` and then exits with code 0...

http://stackoverflow.com/a/78369881
answers question: http://stackoverflow.com/q/78366773
has body: The test -d detects if the target is a directory, not if it contains a directory component. The test -f is true if the target is a file, so your bash output is as expected. If you want to test if the target contains any directory path at all, I'd use this approach: #!/bin/bash filename=$(basename $1) $1 != $filename && echo "Contains a path component" In short, ask for the filename component of the path and if it isn't the same thing as the filename given, some directory component was stripped by basename. You can try something similar using dirname but it inserts a fake . even if none was given. That makes differentiating foo.txt and ./foo.txt difficult.
score: 0
type: Answer

http://stackoverflow.com/q/78378370
has body: I have a git repository where I am the only contributor and there are zero forks of the repository. This means I can do whatever I want in terms of rebases and forced pushes. The repository has 22503 commits. The history is linear, there are no merge commits. Most commits only change file, github-metrics.svg and a lot of commits only change one line somewhere at the bottom with this text: Last updated $(TIMESTAMP) with lowlighter/metrics@$(VERSION) I would like to "clean up" this repository by removing all commits that only have this change. If a commit has this change and another change, then it should stay. If I had to do this manually for a small number of commits, then I would do git rebase --interactive, and for every commit that only changes the "Last updated", I would change that commit to a fixup. I already tried it manually for about a dozen commits and the results are satisfactory. However I have over 22k commits so it becomes impossible to do manually. How can I automate this? The following questions are similar but different: Git: Remove commits which only changes a timestamp - this completely deletes the line with the timestamp and I don't want that. Can git ignore some specific line from git status? - this approach could work to avoid adding new commits with only timestamp changes but it has 2 problems (1) it doesn't change commits that already exist (2) in requires a file in the .git directory so that means it will only work on my local repository, not for example on a repository on GitHub that is updated by GitHub Actions. Update 01/05/2024 I wrote this shell script: #!/bin/bash -e # Define the metrics file name metrics_file="github-metrics.svg" # Function to validate the number of arguments validate_arguments() { if [ "$#" -ne 1 ]; then echo "Error: Incorrect number of arguments. Usage: $0 <commit>" exit 0 fi } # Function to check if the commit exists check_commit_existence() { git rev-parse --quiet --verify "$1^{commit}" >/dev/null || { echo "Error…
has comment: http://stackoverflow.com/comment/138179364
tagged with: git
has comment: http://stackoverflow.com/comment/138183096
type: UnansweredQuestion
tagged with: git-bash
has comment: http://stackoverflow.com/comment/138179265
linked to: http://stackoverflow.com/q/72593674
has title: Remove all commits that only update timestamp in a file
linked to: http://stackoverflow.com/q/16741142
has comment: http://stackoverflow.com/comment/138198603
downvote count: 0
tagged with: bash
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138198444
score: 7
has comment: http://stackoverflow.com/comment/138198437
linked to: http://stackoverflow.com/q/63818292
has answer: http://stackoverflow.com/a/78432319
upvote count: 7
type: Question
has comment: http://stackoverflow.com/comment/138183023

http://stackoverflow.com/q/78433104
has body: I am finding it difficult to understand how the processes are launched in such a shell script mainscript.sh exec command1 &amp; sleep 10 exec command2 &amp; sleep 10 I understand that exec command does not create a new process it just replaces the bash with the command to be executed, in that case, what happens when it runs with an &amp; Currently I see this is the ps output something like this UID PID PPID C STIME TTY TIME CMD user+ 1 0 0 16:43 ? 00:00:00 bash mainscript.sh user+ 48 1 9 16:43 ? 00:00:04 command1 user+ 133 1 0 16:43 ? 00:00:00 command2
type: Question
tagged with: shell
has title: Multiple exec commands running in the background in shell script
accepted answer: http://stackoverflow.com/a/78433171
has comment: http://stackoverflow.com/comment/138275517
duplicate of: http://stackoverflow.com/q/34468986
score: 0
linked to: http://stackoverflow.com/q/34468986
has answer: http://stackoverflow.com/a/78433171
tagged with: bash
answer count: 1
type: AnsweredQuestion

notion
tag name: notion
tags question: http://stackoverflow.com/q/78436832
type: Tag

http://stackoverflow.com/a/78334773
accepted answer of: http://stackoverflow.com/q/78334722
downvote count: 0
answers question: http://stackoverflow.com/q/78334722
type: Answer
upvote count: 8
has body: To handle input lines longer than 4096 bytes in C, you can switch the terminal to Non-Canonical mode (also known as Raw mode). In Non-Canonical mode, input is available immediately without waiting for a newline, allowing you to process input that exceeds the typical buffer size. Look at your code modified as explained above: #include <unistd.h> #include <termios.h> #include <stdlib.h> #include <stdio.h> void setRawMode(int fd) { struct termios term; tcgetattr(fd, &term); term.c_lflag &= ~(ICANON | ECHO); tcsetattr(fd, TCSANOW, &term); } void setCanonicalMode(int fd) { struct termios term; tcgetattr(fd, &term); term.c_lflag |= (ICANON | ECHO); tcsetattr(fd, TCSANOW, &term); } int main() { setRawMode(STDIN_FILENO); ssize_t r_bytes; char buf[64]; while ((r_bytes = read(STDIN_FILENO, buf, sizeof(buf) - 1)) > 0) { buf[r_bytes] = '\0'; printf("%s", buf); } setCanonicalMode(STDIN_FILENO); return 0; }
has comment: http://stackoverflow.com/comment/138102282
type: AcceptedAnswer
score: 8

http://stackoverflow.com/comment/138072089
has text: Beyond that, though -- signals are delivered asynchronously; it's completely normal for `kill -TERM` to take some time to be enacted, so running `ps` directly after with no delay could give you unexpected results.
score: 0
comment on: http://stackoverflow.com/q/78317514
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138282908
comment on: http://stackoverflow.com/q/78437288
score: 1
has text: Does this answer your question? [How do I set a variable to the output of a command in Bash?](https://stackoverflow.com/questions/4651437/how-do-i-set-a-variable-to-the-output-of-a-command-in-bash)
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78309717
has answer: http://stackoverflow.com/a/78341842
has body: I am trying to check if the current commit has assigned a TAG, locally it works correct tag but within the ignore steps sh script on Vercel it's always undefined. Overall it seems that I can't get any information about tags in this env as I tried to log just list of all existing tags, which is also empty echo "GIT_TAG: $(git name-rev --name-only --tags HEAD)" echo "GIT_TAGS: $(git tag --list)" the output is GIT_TAG: undefined GIT_TAGS: - Build cancelled
tagged with: vercel
type: Question
upvote count: 0
type: UnansweredQuestion
tagged with: bash
tagged with: git
has answer: http://stackoverflow.com/a/78313113
favorite count: 0
downvote count: 1
score: -1
answer count: 2
has title: can't get git tag within vercel ignore steps script

http://stackoverflow.com/q/78405034
tagged with: conditional-statements
has comment: http://stackoverflow.com/comment/138226263
linked to: http://stackoverflow.com/q/4651437
tagged with: bash
tagged with: conditional-operator
type: Question
type: UnansweredQuestion
tagged with: if-statement
has body: The data for this script comes from curl and then I grep a few specific response headers. For this example let's focus on "cf-cache-status". This header has 4 potential values (EXPIRED, HIT, DYNAMIC, MISS). OUTPUT="$(curl -sLIXHEAD https://exampledomain.com)" headers=$(echo "$OUTPUT" | grep -iE 'ki-cache-type|ki-cf-cache-status|cf-cache-status|ki-edge|ki-edge-o2o|x-edge-location-klb') I can use this while loop while IFS=: read -r header value; do echo "$header" echo "$value" done <<< "$headers" and get this output cf-cache-status DYNAMIC And this "if" statement within the loop to do the same while IFS=: read -r header value; do if [ "$header" == "cf-cache-status" ]; then echo "$header" echo "$value" fi done <<< "$headers" For some reason, I cannot use a condition with the $value variable. This condition below does not work as it does for the $header variable. Ideally, I would like to nest if statements, first to find the header and then determine which of the 4 values is present. while IFS=: read -r header value; do if [ "$value" == "DYNAMIC" ]; then echo "$header" echo "$value" fi done <<< "$headers" Thanks in advance!
has comment: http://stackoverflow.com/comment/138226370
has comment: http://stackoverflow.com/comment/138226360
duplicate of: http://stackoverflow.com/q/800030
score: 0
has comment: http://stackoverflow.com/comment/138226237
has comment: http://stackoverflow.com/comment/138226163
answer count: 0
has title: Cannot apply condition to grep output in bash script
has comment: http://stackoverflow.com/comment/138226356
has comment: http://stackoverflow.com/comment/138226250
has comment: http://stackoverflow.com/comment/138226247
duplicate of: http://stackoverflow.com/q/4651437

http://stackoverflow.com/a/78350523
has body: As pointed out in a comment, you can't have two different standard inputs. If the shell gets its stdin from the here-doc, it can't pass the SSH connection as stdin to the tar command. You don't need to send cd and tar as separate command separated by &amp;&amp;. You can use the -C option to tar to have it change directory by itself. This option is in both GNU tar and BSD tar, although it's not in the POSIX specification. With this, there's no quoting needed at all (unless there are spaces in the path you're changing to). tar -pzcf - example.txt | ssh user@198.123.45.678 tar -C /some-path/ -zxf -
downvote count: 0
has comment: http://stackoverflow.com/comment/138129936
has comment: http://stackoverflow.com/comment/138129953
has comment: http://stackoverflow.com/comment/138129954
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138130286
has comment: http://stackoverflow.com/comment/138137153
has comment: http://stackoverflow.com/comment/138137283
has comment: http://stackoverflow.com/comment/138130693
accepted answer of: http://stackoverflow.com/q/78350497
score: 1
has comment: http://stackoverflow.com/comment/138129944
has comment: http://stackoverflow.com/comment/138130303
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78350497
has comment: http://stackoverflow.com/comment/138129980
has comment: http://stackoverflow.com/comment/138129933
has comment: http://stackoverflow.com/comment/138130325

http://stackoverflow.com/comment/138276000
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78433313
has text: I ran the commands: `PS D:\python\testing> set-executionpolicy unrestricted -scope process` `PS D:\python\testing> ./test.ps1` And received the error: `Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.`

http://stackoverflow.com/comment/138286084
type: Comment
has text: Hi, I did that right now. So the files includes: export CWPROOT=/home/felipe/Work/Seismic_Unix_Hub # set the PATH variable export PATH=$PATH:$CWPROOT/bin:. After typing "echo $PATH" the path appears at the end of the output: /home/felipe/miniconda3/bin:/home/felipe/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/bin:.:/bin:.:/bin:.:/bin:.:/bin:.:/bin:.:/bin:.:CWPROOT/bin:.:CWPROOT/bin:.:/home/felipe/Work/Seismic_Unix_Hub/bin:. But "make install" returns CWPROOT environment variable is not set!!
score: 0
comment on: http://stackoverflow.com/q/78438850
type: QuestionComment

http://stackoverflow.com/a/78392246
accepted answer of: http://stackoverflow.com/q/78390318
has comment: http://stackoverflow.com/comment/138203155
type: AcceptedAnswer
upvote count: 3
answers question: http://stackoverflow.com/q/78390318
downvote count: 0
score: 3
has body: You can use the socat utility: socat -v exec:p1 exec:p2 The -v is optional and shows the chatter back and forth for your debugging and enjoyment.
type: Answer

http://stackoverflow.com/comment/138197243
type: Comment
has text: A good idea to solve the first problem is to move the file immediately out of the source directory, then convert it. So if there's overlap, they won't try to process the same files.
score: 0
comment on: http://stackoverflow.com/q/78388939
type: QuestionComment

http://stackoverflow.com/comment/138264822
score: 0
comment on: http://stackoverflow.com/q/78423981
type: QuestionComment
type: Comment
has text: What are you trying to do? Most people would use a compiled language to hide the source code, maybe with an obfuscator. But I've never seen someone go through that effort for a shell script.

http://stackoverflow.com/q/78441613
has title: linux bash -> sed (regex). How to replace all appeared defined sections with "source_dir" and "target_dir" to content which in source_dir section
has answer: http://stackoverflow.com/a/78441717
tagged with: bash
has comment: http://stackoverflow.com/comment/138311511
has comment: http://stackoverflow.com/comment/138312066
has answer: http://stackoverflow.com/a/78443325
has comment: http://stackoverflow.com/comment/138293957
has answer: http://stackoverflow.com/a/78448139
tagged with: sed
has comment: http://stackoverflow.com/comment/138290749
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138312257
type: UnansweredQuestion
tagged with: replace
answer count: 3
has comment: http://stackoverflow.com/comment/138290830
has comment: http://stackoverflow.com/comment/138302137
tagged with: posix
has body: For example I have this text: &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;source_dir&gt;&gt; tesst &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;target_dir&gt;&gt; tes23442141 &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; good safasf &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;source_dir&gt;&gt; tesst241241 &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;target_dir&gt;&gt; tes23442141 &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; safasfas And section is &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;source_dir&gt;&gt; [any text -&gt; first text] &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;target_dir&gt;&gt; [any text -&gt; second text] &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; And I want replace all this section to only first text For example output must be: tesst good safasf tesst241241 safasfas I have this sed : sed -e ':a;N;$!ba;s#&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;source_dir&gt;&gt;\n\(.*\)\n&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;target_dir&gt;&gt;.*&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;#\1#g' &quot;$target_file&quot; But as output I have: tesst &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;target_dir&gt;&gt; tes23442141 &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; good safasf &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;source_dir&gt;&gt; tesst241241 safasfas And question how I can fix it?) I understand the problem but I don't understand how to do it&gt; Please help me!

http://stackoverflow.com/comment/138298041
has text: See also why not parse the result of the `ls` command.
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78445380

http://stackoverflow.com/comment/138129958
type: QuestionComment
type: Comment
has text: ...speaking of which, have you tried inspecting the system with atypical behavior to try to figure out the underlying cause? Any luck in that effort?
comment on: http://stackoverflow.com/q/78350497
score: 0

http://stackoverflow.com/q/78354730
has comment: http://stackoverflow.com/comment/138137574
tagged with: cut
has comment: http://stackoverflow.com/comment/138137582
accepted answer: http://stackoverflow.com/a/78354848
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138137322
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
duplicate of: http://stackoverflow.com/q/46248459
has comment: http://stackoverflow.com/comment/138137488
has title: Using cut command with criterion from a bash variable
has comment: http://stackoverflow.com/comment/138137595
linked to: http://stackoverflow.com/q/4685323
type: Question
has comment: http://stackoverflow.com/comment/138137535
has body: I would like to use the cut command to extract some columns of a csv file. However, instead of having my criterion hard-coded, I would like to take them from a bash variable. Without a variable, my command would look like the following: cut -d';' -f 1-8,20,22 "$input_file" > ANFR_reduced.csv However, when I store the critera -f 1-8,20,22 within a bash variable, my cut command fails to execute correctly (error fields are numbered from 1) criteria_col="-f 1-8,20,22" cut -d';' "$criteria_col" "$input_file" > ANFR_reduced.csv Any ideas to why this is not working, please?
score: 1
has comment: http://stackoverflow.com/comment/138137571
duplicate of: http://stackoverflow.com/q/4685323
has comment: http://stackoverflow.com/comment/138137538
has answer: http://stackoverflow.com/a/78354848

http://stackoverflow.com/comment/138290929
type: QuestionComment
type: Comment
has text: You are touching dangerous grounds: Now you are caring about the use of double quotes used for marking the extent of a whole field, but if this is a general CSV file, you will also have the possibility, that a field itself contains a double quote as value, or a field which contains a newline character. Instead of re-inventing the wheel, just use one of the many CSV parsers.
score: 0
comment on: http://stackoverflow.com/q/78441743

http://stackoverflow.com/q/78422019
has comment: http://stackoverflow.com/comment/138255956
has comment: http://stackoverflow.com/comment/138255959
has comment: http://stackoverflow.com/comment/138265844
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138257814
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138255963
linked to: http://stackoverflow.com/q/74971607
has body: Hi I'm looking at writing a script with the parameters for Teams Classic. Condition do i have Teams Clssic.app and is it running if i have Teams Classic.app and its not running delete it if i have Teams Classic.app and its running stop app then delete it So far I have the following code written out, but can't see how I can use this if statement to meet all my condition if [ -d "/Applications/Microsoft Teams classic.app" ] || [ -d "/Applications/Microsoft Teams.app" ] && [ (ps aux | grep Microsoft\ Teams\ Classic.app | grep -v grep > /dev/null) ] then echo RUNNING killall "Microsoft Teams Classic.app" rm -rf /Applications/Microsoft\ Teams\ Classic.app rm -rf ~/Library/Preferences/com.microsoft.teamsclassic.plist rm -rf ~/Library/Caches/com.microsoft.teamsclassic rm -rf ~/Library/Logs/com.microsoft.teamsclassic else echo STOPPED fi
has comment: http://stackoverflow.com/comment/138265401
tagged with: macos
answer count: 0
has comment: http://stackoverflow.com/comment/138333942
tagged with: bash
has comment: http://stackoverflow.com/comment/138265405
has comment: http://stackoverflow.com/comment/138265402
has title: More than one if statements

http://stackoverflow.com/q/78437863
has answer: http://stackoverflow.com/a/78438177
answer count: 1
type: AnsweredQuestion
score: 0
tagged with: zsh
type: Question
has comment: http://stackoverflow.com/comment/138286795
has comment: http://stackoverflow.com/comment/138286745
tagged with: image-processing
has comment: http://stackoverflow.com/comment/138304693
tagged with: imagemagick
accepted answer: http://stackoverflow.com/a/78438177
has body: To check whether filename extensions of my images are correct, that is, whether my JPEGs are really JPEGs, PNGs are really PNGs, and WebPs are really WebPs, I can use the following ImageMagick command: magick identify -format "%f: %m\n" *.(jp*|png|webp) Or I can use "*.{jp*,png,webp}" instead: magick identify -format "%f: %m\n" "*.{jp*,png,webp}" Note the quotation marks. Otherwise, if your target folder won't contain at least one file of each format, there will be an error. magick identify -format "%f: %m\n" *.{jp*,png,webp} zsh: no matches found: *.webp ImageMagick itself supports both *.(foo|bar|barz) and "*.{foo,bar,baz}" syntaxes, but Zsh on my macOS, and I suppose Bash on Linux and BSD, supports only the first one, with parentheses (). # works file *.(jp*|png|webp) # doesn't work at all. the {} syntax is not # supported by Zsh and probably Bash file *.{jp*,png,webp} Hence my question. Which syntax should we prefer in ImageMagick scripts (for example, when using magick identify): with (), which is supported by both ImageMagick and Zsh/Bash, or with {}, which is supported by ImageMagick only? A summary of my and Fred's (fmw42) tests Bash Zsh magick identify *.(jpg|png) – ✓ magick identify *.{jpg,png} ✓ ✓† magick identify "*.{jpg,png}" ✓ ✓ Bash Zsh file *.(jpg|png) – ✓ file *.{jpg,png} ✓‡ ✓† file "*.{jpg,png}" – – ✓ - Works. You can have a) both JPGs and PNGs or b) PNGs only or c) JPGs only or d) none ✓† - Works, but you must have at least one JPG and one PNG ✓‡ - Works, but if you don't have at least one JPG and one PNG, there will be a warning – - Doesn't work GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23) zsh 5.9 (x86_64-apple-darwin23.0)
has title: ImageMagick vs. Bash/Zsh: Using *.(format1|format2) vs. "*.{format1,format2}"
has comment: http://stackoverflow.com/comment/138284272
tagged with: bash

http://stackoverflow.com/q/78316544
has title: How to write a script for a set of parallel dependent tasks job on slurm?
score: 0
type: Question
answer count: 0
tagged with: parallel-processing
type: UnansweredQuestion
tagged with: bash
tagged with: slurm
has body: I am trying to use slurm to submit a job in which I want to do multiple runs of a set of (task1,task2); task2 needs some results of task1. I want to submit only one job that runs multiple iterations of (task1,task2) in parallel and saves the order of completion for task1 and task2. I know how to do it with two different slurm jobs using dependency but I don't want to sbatch two bash files instead, I want to do it only with a single sbatch, is it possible?

http://stackoverflow.com/a/78375031
has body: This will do what you want using any POSIX awk under the assumptions that: You don't really have a trailing , \ at the end of your line of version numbers. Your version numbers are all on 1 line. No part of your version number will be more than 10 digits long (e.g. you won't have a version number like 1234567890.1.1.1). $ cat tst.awk BEGIN { FS = "[[:space:]]*,[[:space:]]*" OFS = ", " tgtVer = fmtver(add) } inBlock && match($0,/[^[:space:]]/) { indent = substr($0,1,RSTART-1) $0 = substr($0,RSTART) for (i=1; i<=NF; i++) { curVer = fmtver($i) if ( (add != "") && (curVer > tgtVer) ) { $i = add OFS $i add = "" } } $0 = indent $0 (add == "" ? "" : OFS add) inBlock = 0 } $1 == "[version]" { inBlock=1 } { print } function fmtver(ver, out, parts, i, numParts) { numParts = split(ver,parts,".") for ( i=1; i<=numParts; i++ ) { out = (i > 1 ? out "." : "") sprintf("%010d", parts[i]) } return out } $ awk -v add='1.0.7.2' -f tst.awk file [version] 1.0.0.0, 1.0.1.0, 1.0.2.0, 1.0.3.0, 1.0.3.1, 1.0.4.0, 1.0.4.1, 1.0.5.0, 1.0.5.1, 1.0.6.0, 1.0.6.1, 1.0.6.2, 1.0.7.0, 1.0.7.1, 1.0.7.2, 1.2.2.8, 1.2.2.9, 1.2.2.10, 1.2.2.1, 1.2.3.0, 1.3.0.0, 1.2.3.1
downvote count: 0
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78372639

http://stackoverflow.com/q/78390602
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/3811345
duplicate of: http://stackoverflow.com/q/3524978
tagged with: bash
has body: So I have this script: #!/bin/bash # Set the PostgreSQL database connection details db_host="localhost" db_port="5432" db_name="" db_user="" db_password="" # Function to execute psql command psql_exec() { echo "Executing SQL query: $1" PGPASSWORD="$db_password" psql -h "$db_host" -p "$db_port" -d "$db_name" -U "$db_user" -c "$1" local exit_code=$? if [ $exit_code -ne 0 ]; then echo "SQL query exit code: $exit_code" return $exit_code fi } # Check for entry in database user_id=$(psql_exec "SELECT user_id FROM users WHERE <condition>" -tAqx) exit_code=$? if [ $exit_code -ne 0 ]; then echo "SELECT user_id exit code: $exit_code" fi echo "value: $user_id" The flags -tAqx aren't applied to the psql command. Therefore I got the wrong result instead of an empty response. bash test.sh value: Executing SQL query: SELECT user_id FROM users WHERE <condition>; user_id --------- (0 rows) The function will be used in different calls and therefore I don't want to add the flags directly to it. Obviously I could just write down the whole psql command with added flags just for this call, but I wonder if there is a smarter solution? this solutions works but is not as clean as above: user_id=$(PGPASSWORD="$db_password" psql -h "$db_host" -p "$db_port" -d "$db_name" -U "$db_user" -c "SELECT user_id FROM users WHERE ;" -tAqx)
has comment: http://stackoverflow.com/comment/138201620
has comment: http://stackoverflow.com/comment/138201633
tagged with: flags
tagged with: postgresql
linked to: http://stackoverflow.com/q/3524978
has comment: http://stackoverflow.com/comment/138201302
score: 0
tagged with: function
type: Question
has title: bash, postgresql - how to add additional flags to custom psql function
answer count: 0
linked to: http://stackoverflow.com/q/3811345

http://stackoverflow.com/comment/138169117
type: Comment
comment on: http://stackoverflow.com/q/78372779
has text: HI Choroba, thanks for pointing this out. It has now given me the expected output.
score: 0
type: QuestionComment

http://stackoverflow.com/q/78334264
favorite count: 0
type: AnsweredQuestion
has body: According to documentation, single quotes in bash preserve all literal characters, however the following: echo 'a\nb' Outputs: a b (i.e. the literal \ and n have been replaced with a newline) Why is this the case? (what am I missing?) Also, what other characters does this affect? For reference I'm using GNU bash, version 3.2.57(1)-release (arm64-apple-darwin22)
has comment: http://stackoverflow.com/comment/138113311
tagged with: string
has title: Why do bash single quotes interpret "\n" as newlines?
type: Question
tagged with: shell
downvote count: 1
accepted answer: http://stackoverflow.com/a/78334326
has comment: http://stackoverflow.com/comment/138101371
tagged with: escaping
upvote count: 2
has answer: http://stackoverflow.com/a/78334326
score: 1
tagged with: bash
has comment: http://stackoverflow.com/comment/138101361
answer count: 1

http://stackoverflow.com/q/78385195
accepted answer: http://stackoverflow.com/a/78385706
answer count: 1
favorite count: 0
downvote count: 1
tagged with: github
tagged with: ubuntu
has answer: http://stackoverflow.com/a/78385706
tagged with: bash
has title: Replacing file text with github secret values
type: AnsweredQuestion
upvote count: 1
has body: I have a github project that contains a config file with some settings that are supposed to be replaced on building #some_config_file some_setting=foo url=http://<secret_url>:8080/path username=<secret_user> password=<secret_pass> other_setting=bar The <secret_url>, <secret_user> and <secret_pass> values are supposed to be replaced with proper values inside a Github action: name: CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 ... - name: Update Secret URL run: sed -i 's/<secret_url>/${{secrets.SECRET_URL}}/' some_config_file - name: Update Secret Username run: sed -i 's/<secret_user>/${{secrets.SECRET_USER}}/' some_config_file - name: Update Secret Username run: sed -i 's/<secret_pass>/${{secrets.SECRET_USER}}/' some_config_file ... This works for simple strings, but when it comes to the password which is randomly generated with several special characters, it often fails or otherwise breaks in unexpected ways or outputs an incorrect value for the password eg. setting the password to just$Some.p*s&w[0R\d or $ome_|n&3cureV@l*e.\o/ completely breaks it. The password is provided, we cannot change it ourselves and may or may not get changed to contain other special characters. How can I do this replacement while still catering for any special characters that could be part of the password?
score: 0
type: Question

http://stackoverflow.com/q/78419971
has title: Parallel git branches that have the same changes but different commit hashes
upvote count: 2
has comment: http://stackoverflow.com/comment/138253251
tagged with: bash
tagged with: git
favorite count: 0
has body: I have a git repository that looks like this: A1 - B1 - C1 - D1 - E1 \ \ C2 - D2 - F2 The file changes in C1 and C2 are identical. If I run git diff C1 C2 then I get an empty result. Likewise, the file changes in D1 and D2 are identical. The commit messages of C1 and C2 are different, and the commit messages of D1 and D2 are also different. The hashes of C1 and C2 are different. Likewise, the hashes of D1 and D2 are different. The changes in E1 and F2 are completely different. I would like to get a repository that looks like this: A1 - B1 - C1 - D1 - E1 \ \ F2 I already tried git rebase and git rebase --onto and that just keeps the commits C2 and D2. This is a fictional example. Here there are 2 commits that have the same changes. In reality there may be a few dozen or hundreds commits that have the same changes before the code diverges, and there is no simple way to determine how many without examining the entire history in detail.
has comment: http://stackoverflow.com/comment/138258409
has answer: http://stackoverflow.com/a/78420010
type: Question
type: UnansweredQuestion
score: 1
has answer: http://stackoverflow.com/a/78420632
has comment: http://stackoverflow.com/comment/138252279
downvote count: 1
answer count: 2

google-cloud-platform
tags question: http://stackoverflow.com/q/78338056
type: Tag
tags question: http://stackoverflow.com/q/78365034
tag name: google-cloud-platform
tags question: http://stackoverflow.com/q/78359185
tags question: http://stackoverflow.com/q/78366286
tags question: http://stackoverflow.com/q/78513768
tags question: http://stackoverflow.com/q/78456415
tags question: http://stackoverflow.com/q/78646489
tags question: http://stackoverflow.com/q/78834405
tags question: http://stackoverflow.com/q/79247849

http://stackoverflow.com/comment/138256829
score: 0
comment on: http://stackoverflow.com/a/78403450
type: Comment
type: AnswerComment
has text: My apologies, this script is the reporting script. I was explaining about the UPDATE script in my earlier comment.

http://stackoverflow.com/q/78375308
has comment: http://stackoverflow.com/comment/138181371
upvote count: 1
has body: I have a simple expect script running on Ubuntu which I want to automate via cron. The script works fine if I manually run it with my terminal window full screen however if it is smaller than that of the output that's being generated, or via a cron job, then it stops as normally would need interaction each time it hits "--MORE--". All the script does is SSH to a remote piece of network hardware, run several commands and that output is being read into a txt file. #!/usr/bin/expect set timeout 60 spawn ssh user@<remote IP> expect "yes/no" { send "yes\r" expect "*?assword" { send "password\r" } } "*?assword" { send "password\r" } expect "OLT01>" { send "comamnd 1\r" } expect "OLT01>" { send "command 2\r" } expect "OLT01>" { send "command 3\r" } expect "OLT01>" { send "exit\r" } The output where it stops. Uptime : 8 days, 22:06:47 --MORE--master@ubuntu:~/$ I have tried looking online for others with this issue however unless I'm not wording it correctly it seems like it's just me experiencing this. Any ideas very much welcome.
downvote count: 1
answer count: 0
tagged with: linux
has comment: http://stackoverflow.com/comment/138173782
tagged with: bash
has comment: http://stackoverflow.com/comment/138174890
has comment: http://stackoverflow.com/comment/138173891
favorite count: 0
has comment: http://stackoverflow.com/comment/138184262
has comment: http://stackoverflow.com/comment/138173771
score: 0
has comment: http://stackoverflow.com/comment/138173778
type: Question
has comment: http://stackoverflow.com/comment/139252790
type: UnansweredQuestion
has title: Expect script fails when outputting command as getting stuck on "--MORE--"
tagged with: expect

http://stackoverflow.com/q/78415633
answer count: 1
has comment: http://stackoverflow.com/comment/138244737
has comment: http://stackoverflow.com/comment/138244735
tagged with: declare
tagged with: error-handling
has comment: http://stackoverflow.com/comment/138244717
tagged with: strong-typing
has comment: http://stackoverflow.com/comment/138244625
type: Question
has title: How to enforce variable-types in bash?
has comment: http://stackoverflow.com/comment/138244672
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78419189
has comment: http://stackoverflow.com/comment/138244610
score: 0
has body: I'm trying to create an err function to be used by bash-scripts. The function is supposed to emulate BSD's errx(3) -- printing the specified message and exiting with the code specified as the first argument: function err { # set +u # The first argument must be an integer exit-code: if ! declare -i code=${1:?err called with no arguments} then code=70 # Use EX_SOFTWARE by default fi shift if [ -t 2 ] then # Use color -- red -- printing final errors to a terminal: printf "%s: \e[1;31m%s\e[1;0m\n" ${0##*/} "$*" >&2 else printf "%s: %s\n" ${0##*/} "$*" >&2 fi set -x exit $code } This works as expected, when invoked correctly, such as err 1 Date is empty. But, when invoked with no arguments or when the first argument is not numeric, an error in the declare-line is reported, but not handled: depending on whether -u is set, the script either dies right there on the declare-line, or code is initialized with 0, and the script exits with that -- instead of 70. What am I doing wrong?
linked to: http://stackoverflow.com/q/806906
tagged with: bash

http://stackoverflow.com/comment/138208840
comment on: http://stackoverflow.com/q/78390223
score: 0
has text: It looks mistaken that at the beginning of your recipe you use `"${filter}"` (a `make` variable), but everywhere else within you use `$${filter}` (an escaped reference to a shell variable). Even if you're counting on `make` importing `filter` from its environment, I urge you to be consistent here.
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78379828
has title: Project Access Token in GitLab not accessible
score: 0
type: Question
answer count: 0
type: UnansweredQuestion
tagged with: gitlab
tagged with: bash
has body: As nobody was able to answer my question from two weeks ago, I now try to solve my problem differently. Tldr: I need Maven to modify files in the git repository while runnigng a GitLab CI pipeline and push the changes to the repository again, all the while doing better than hacking an SSH key into my project, using a Project Access Token instead. Sadly, it looks like Maven can't be bothered to take in the scm.connection property on the command line. My approach now is to read that from an environment variable: {env.GITREMOTE} In my .gitlab-ci.yml, I have the following bits & pieces: before_script: - > echo " # snipping unnecessary stuff snapshots ${NEXUS_REPO_USERNAME} ${NEXUS_REPO_PASSWORD} " > settings.xml - > echo GIT_REMOTE=scm:git:https://$CI_PROJECT_NAME:$GIT_WRITE@$CI_SERVER_HOST/$CI_PROJECT_PATH.git > .env GIT_WRITE obviously is the name of the aforementioned token. The .env file written in this step later gets sourced, but the funny thing is this: Expanding ${NEXUS_REPO_USERNAME} works, while the last line with scm:git:https://$CI_PROJECT_NAME:$GIT_WRITE@$CI_SERVER_HOST/$CI_PROJECT_PATH.git only yields scm:git:https://pipeline-test:@gitlab.com/grp/pipeline-test.git. While I redacted the actual names, I'd like to draw your attention to the fact that the token is just missing as if the variable was not there. I can verify though that it exists: I haven't found anything in the documentation that helps me, so maybe anyone of you can point me to what I'm missing. Among the things I have tried are the following things: using brackets: ${GIT_WRITE} quoting with single quotes: echo 'GIT_REMOTE=scm:git:https://$CI_PROJECT_NAME:$GIT_WRITE@$CI_SERVER_HOST/$CI_PROJECT_PATH.git' > .env the same with double quotes combinations of the above Is my bash misbehaving? Did I get some concept of tokens wrong? I'm out of my wits here. Help greatly appreciated.
linked to: http://stackoverflow.com/q/78293398

http://stackoverflow.com/comment/138293681
has text: `readarray` is a fantastic command, saved me so many lines and loops already, thank you
comment on: http://stackoverflow.com/q/78437542
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138256816
score: 0
has text: Your expected output isn't valid JSON...
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78422524

http://stackoverflow.com/comment/138269659
score: 0
type: QuestionComment
has text: Thanks to Philippe, John Bollinger, Jonathan Leffler, and Ed Morton for suggestions. I've updated the question body accordingly.
type: Comment
comment on: http://stackoverflow.com/q/78427118

http://stackoverflow.com/comment/138137538
type: Comment
comment on: http://stackoverflow.com/q/78354730
score: 1
type: QuestionComment
has text: capturing the data (from the file) in an array should be (relatively) easy; we'd just need to see a sample file and how you're currently populating `criteria_col`

http://stackoverflow.com/comment/138251376
comment on: http://stackoverflow.com/q/78419450
score: 0
has text: `*` is a wildcard, used for filename generation.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138207933
comment on: http://stackoverflow.com/q/78320604
type: Comment
has text: please update the question with these additional details; having said that .... the `Missing X server or $DISPLAY` error message is the same issue Barmar was referring to ... `crontab -e` is going to edit the crontab of the user running `crontab -e`, while `sudo crontab -e` is going to edit root's crontab; if you're running `crontab -e` under something other than the root login then, yes, you'll get different results
score: 0
type: QuestionComment

http://stackoverflow.com/q/78419810
has body: I have two Github accounts (work + personal), both with their own SSH keys (key_work & key_personal) Projects live in: ~/git/work ~/git/personal I'm trying to set the GIT_SSH_COMMAND up as an environment var such that it looks at the directory the git command is called from, and picks the appropriate ssh key. So far I've tried .zshrc export GIT_SSH_COMMAND='~/git-ssh.sh' ~/git-ssh.sh #!/bin/bash dir=$(pwd); if $dir == *"work"* ; then ssh -i ~/.ssh/key_work -o IdentitiesOnly=yes elif $dir == *"personal"* ; then ssh -i ~/.ssh/key_personal -o IdentitiesOnly=yes else exit 1 fi However when running git clone git@github.com:someorg/repo.git from git/work (or personal) I get git clone git@github.com:someorg/repo.git Cloning into 'repo'... usage: ssh [-46AaCfGgKkMNnqsTtVvXxYa] [-B bind_interface] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-J destination] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-P tag] [-p port] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] destination [command [argument ...]] ssh [-Q query_option] fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. The SSH key has access, and worked before I set GIT_SSH_COMMAND, so there must be an issue with my script. Any ideas?
tagged with: ssh
tagged with: bash
type: Question
has title: Using GIT_SSH_COMMAND to switch SSH key based on current working directory
downvote count: 0
tagged with: git
score: 1
upvote count: 1
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78419867
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78419867

http://stackoverflow.com/q/78444623
has body: I am attempting to grep an inbox for survey results, in which the subject will include the answer to the following question: "The answer to your question is ___" The answered question will take the form of: "Subject: RE: The answer to your question is yes|no|' '" I have tries the following in a bash script: subject=$(cat /var/mail/incoming | grep '^Subject:' | cut -d' ' -f 9) I am expecting output similar to the following: yes no no yes yes no In which there will be spaces where a non-answer occurred, and this is exactly what I see when I grep at the command line. However, when I store the results in a var, the output is: yes no no yes yes no How do I detect a space at the end of my grep command and replace it with "none"? Desired output: yes no no yes none yes no
tagged with: grep
type: Question
linked to: http://stackoverflow.com/q/9084257
upvote count: 1
has answer: http://stackoverflow.com/a/78449265
answer count: 1
score: -2
favorite count: 0
linked to: http://stackoverflow.com/q/29378566
downvote count: 3
tagged with: bash
has title: bash grep can return an empty space, how to substitute the empty space for a string?
has comment: http://stackoverflow.com/comment/138297860
has comment: http://stackoverflow.com/comment/138299179
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78449265
has comment: http://stackoverflow.com/comment/138299424

http://stackoverflow.com/comment/138253832
type: QuestionComment
has text: @BillKarwin, `--pager` is a great idea. Unfortunately, it's documented to work only in interactive mode and `sed` isn't included in the valid commands
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78420308

http://stackoverflow.com/a/78438933
has body: If you want to connect to the standard input and output of a running process you can use a coprocess. Something like coproc ./impostor.py and then you can read queries, modify them, and send to the coprocess while read -rp 'Prompt: ' p; do printf '<|im_start|>user\\\n%s<|im_end|>\n' "$p" >&"${COPROC[1]}"; done To read the responses read from ${COPROC[0]}
type: Answer
answers question: http://stackoverflow.com/q/78436977
score: 0

http://stackoverflow.com/comment/138175724
score: 0
has text: Perhaps the answer should explain in more detail why the OP's attempt was wrong, though?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78376416

http://stackoverflow.com/comment/138244737
comment on: http://stackoverflow.com/q/78415633
type: QuestionComment
type: Comment
has text: Run the script with `set -x` enabled to see a trace of its execution.
score: 0

http://stackoverflow.com/comment/138134725
has text: `which should have been` Why? If you run a command in the background, it can output right away, it can output in a week, it's _in the background_. What exactly is not "correct" in the output? In other words, the output is _unsynchronized_ with the rest of the script. If you want to wait for the background process to finish executing, you can `wait` on it.
score: 2
comment on: http://stackoverflow.com/q/78353316
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78376416
has comment: http://stackoverflow.com/comment/138175813
type: Answer
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138175800
score: 0
has body: Try with: #!/bin/bash xfreerdp /v:"my-IP" /u:"my-user" /p:"pass" -f wait gnome-session-quit Explanation: the wait bash command waits for each just spawned processes to terminate, then goes on with the execution of the next instructions.
accepted answer of: http://stackoverflow.com/q/78376334
has comment: http://stackoverflow.com/comment/138175828
has comment: http://stackoverflow.com/comment/138175724
answers question: http://stackoverflow.com/q/78376334

http://stackoverflow.com/q/78338291
has title: Generate a shellscript menu with hosts addresses from a file and display the options with a "ping status" below each option?
has body: Question: Generate a shellscript menu with hosts addresses from a file and display the options with a "ping status" below each option? Do you have some idea to help? Filename: bssh.sh #!/bin/bash # Display Servers echo "Servers List" echo "" SERVERS="servers_list.txt" while IFS= read -r SERVERS_LINE || -n "$SERVERS_LINE" ; do serveraddress=$(echo $SERVERS_LINE | cut -d"@" -f 2) servername=$(echo $SERVERS_LINE | cut -d"@" -f 1) if ping -c 1 -W 1 $serveraddress >/dev/null 2>&1; then echo -e "$servername [\033[0;32mOnline\033[0m]" echo "" else echo -e "$servername [\033[0;31mOffline\033[0m]" echo "" fi done <"$SERVERS" readarray -t Servers < servers_list.txt PS3=$'\n'"Enter your choice or 0 to exit: " select selection in "${Servers[@]}"; do if $REPLY == "0" ; then echo -e "\033[0;90mPeace Out!\033[0m" >&2 exit else # Modify the way the program is called if -e /usr/bin/ssh ; then echo "" ssh "$selection" #echo "" else echo "" ssh "$selection" #echo "" fi break fi done Filename: servers_list.txt root@127.0.0.1 validusername@127.0.0.1 ufo@nasa.vog
tagged with: bash
type: Question
type: UnansweredQuestion
score: 0
answer count: 0
tagged with: select
tagged with: shell
tagged with: menu

http://stackoverflow.com/comment/138290830
score: 0
comment on: http://stackoverflow.com/q/78441613
type: QuestionComment
type: Comment
has text: @KamilCuk it must be sed

http://stackoverflow.com/q/78422837
tagged with: makefile
type: UnansweredQuestion
answer count: 1
tagged with: bash
has title: set: Illegal option -o pipefail while running make
tagged with: sh
has answer: http://stackoverflow.com/a/78422867
has body: I'm running FreeBSD 10.4-RELEASE and can't upgrade it at the moment. Previously, 'make' was working fine, but recently I've been getting this error- $ sudo make install set: Illegal option -o pipefail *** Error code 2 Stop. make[1]: stopped in /data/usr/ports/lang/perl5.24 *** Error code 1 Stop. make: stopped in /data/usr/ports/lang/perl5.24 $ echo $SHELL /usr/local/bin/bash
score: 0
tagged with: freebsd
type: Question

http://stackoverflow.com/a/78412796
answers question: http://stackoverflow.com/q/78409604
has body: Since you already have set -u in effect for many scripts, I would proceed as this: Say the name of your obsolete variable is obs. I would then define this variable with typeset -rn obs=foobarbaz typeset -n foobarbaz=obs The -r produces an error message (readonly variable), if someone tries to set the variable obs to a new value. If someone tries to read the variable obs, this would produce a warning *(circular name reference)*. If set -u is in effect, reading the variable would in addition produce an error message (unbound variable) and abort the script.
score: 0
type: Answer

http://stackoverflow.com/q/78417099
downvote count: 0
has title: Transfer file via ssh with only echo and cat command
has answer: http://stackoverflow.com/a/78418439
type: UnansweredQuestion
score: 1
has answer: http://stackoverflow.com/a/78417916
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138247641
tagged with: ssh
has answer: http://stackoverflow.com/a/78417457
tagged with: bash
linked to: http://stackoverflow.com/q/45772525
has body: Due to some constraints, i have to transfer local file to remote ssh with only echo and cat command and here-document. I've tried: #!/bin/bash SSH_CMD=xxx # suppose `SSH_CMD` is my ssh command w="$(cat word)" SSH_CMD <<EOF1 cd /data00 touch for-test echo $w >> for-test echo "abc" >> for-test EOF1 And word is a file with multiple lines: #!/bin/bash line1 line2 line3 After i run the script, the /data00/for-test file only contains one line: abc, quite strange.
has comment: http://stackoverflow.com/comment/138250506
answer count: 3
type: Question
tagged with: heredoc

http://stackoverflow.com/comment/138315353
comment on: http://stackoverflow.com/a/78433171
type: Comment
type: AnswerComment
score: 0
has text: Is there a way that i can avoid keeping 48 as mainscript and have the child process replace it? I've tried several options, but I am unable to replace the subshell with the child process

http://stackoverflow.com/comment/138171937
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78373696
has text: If what you are saying is true, "the first bash command terminates the process and it never completes the next commands which should start it again" then that would imply that the "systemctl stop go_service" command is returning a non-zero status. Is there any output from the "systemctl stop go_service" command?

http://stackoverflow.com/q/78333123
type: Question
tagged with: shell
has comment: http://stackoverflow.com/comment/138099140
accepted answer: http://stackoverflow.com/a/78333360
linked to: http://stackoverflow.com/q/36313216
linked to: http://stackoverflow.com/q/28902393
has title: How can I test if a command fails or returns a certain output?
score: 0
has answer: http://stackoverflow.com/a/78333360
answer count: 2
tagged with: bash
has answer: http://stackoverflow.com/a/78342487
has comment: http://stackoverflow.com/comment/138099588
has body: I have a bash script with a command and I want to test if a command fails or returns an output that matches an regex. Something like this: commandOutput = command() if (commandOutput.exitCode = ERROR or commandOutput.matches(string|strong) then doStuffOnError() end How can I do this in a shell script?
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/78342487
has comment: http://stackoverflow.com/comment/138099241

http://stackoverflow.com/comment/138104607
comment on: http://stackoverflow.com/q/78336037
has text: @Judy, `*presto` still matches `master-presto` as a glob rather than as a regex
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138074358
has text: on the + side, this `bash` script is about 4 times faster than my `bash` script; 'course if the order doesn't matter then further speedups could be had by breaking the problem into chunks that are run in parallel :-)
comment on: http://stackoverflow.com/a/78317659
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78390608
has comment: http://stackoverflow.com/comment/138219147
has body: I want to thank everyone for the support here. Each answer drove me bit by bit to the solution. In the end, it was simpler than I had expected: declare $(grep -m1 variable1 &lt;path_to_file&gt;) Using the example file.txt from the answer by @Mark Setchell: declare $(grep -m1 a file.txt) echo $a 3 Later edit: a previous version of this post used export instead of declare, but that is not optimal. You might need it if you want to export the variable in the environment.
has comment: http://stackoverflow.com/comment/138200525
answers question: http://stackoverflow.com/q/78389511
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/138200177
downvote count: 0

http://stackoverflow.com/comment/138183939
score: 2
type: Comment
has text: Just don't quote `$file` if you want it to be exposed to the shell for globbing and filename expansion, you don't need to wrap everything in `bash -c`.
type: QuestionComment
comment on: http://stackoverflow.com/q/78378844

http://stackoverflow.com/comment/138191364
type: QuestionComment
comment on: http://stackoverflow.com/q/78385537
type: Comment
score: 0
has text: I've never used strace or systemd before. I'm not a super experienced Linux dev. Running it by hand is easier in the sense that I actually know how to do it. I'm running the script by typing "sudo ./startNodeServer.sh".

http://stackoverflow.com/q/78329053
downvote count: 3
accepted answer: http://stackoverflow.com/a/78329104
tagged with: bash
linked to: http://stackoverflow.com/q/60005122
type: AnsweredQuestion
answer count: 1
linked to: http://stackoverflow.com/q/42585546
has comment: http://stackoverflow.com/comment/138092493
duplicate of: http://stackoverflow.com/q/60005122
has body: The goal is to verify if the string matches any of list item. This is opposite to CHECK IF VARIABLE EXISTS in the list Code should be similar to: email="john.brown@google.com" list=["app-1", "app-2", "john"] if [ $email -contains $list]; then echo "email contains variable from list" else echo "email does not contain any of list items" fi # Item1: false -> email does not contains "app-1" # Item2: false -> email does not contains "app-2" # Item3: true -> email contains "john"
type: Question
has title: Check if any list item match variable
linked to: http://stackoverflow.com/q/59897745
tagged with: shell
tagged with: linux
has comment: http://stackoverflow.com/comment/138092479
score: -2
upvote count: 1
has answer: http://stackoverflow.com/a/78329104
favorite count: 0

http://stackoverflow.com/a/78374017
answers question: http://stackoverflow.com/q/78372933
downvote count: 0
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138173387
accepted answer of: http://stackoverflow.com/q/78372933
score: 1
type: AcceptedAnswer
has body: Here is a script that will recursively search all the .zip files within the starting .zip file looking for the target file "_dnbr6.tif". #!/bin/bash targetFile="_dnbr6.tif" sandboxDir="sandbox" usage () { cat <<EOF Usage $(basename $0) zipfile This script will extract all the target files ($targetFile) from the provided .zip file, including any that are in embedded in any .zip files included within it. It puts all the files in a sandbox directory name $sandboxDir. This directory must not already exist. EOF } if [ -z "$1" ]; then usage exit 1 fi if [ -d $sandboxDir ]; then echo "Error, the sandbox directory $sandboxDir already exists." echo usage exit 1 fi mkdir $sandboxDir cd $sandboxDir startDir=$(pwd) # Extract the initial .zip file looking for either the target file or additional .zip files. unzip -q ../$1 "*.zip" "*$targetFile" 2>&1 | fgrep -v "filename not matched" # Suppress the "filename not matched" message. zipFiles="../$1" # Just set to get past the first interation of the while loop. # # Loop until there aren't any .zip files anymore. while [ ! -z "$zipFiles" ]; do zipFiles=$(find . -name '*.zip') if [ ! -z "$zipFiles" ]; then # # For each .zip file, extract any .zip files and the target file. for zipFile in $zipFiles; do cd $(dirname $zipFile) unzip -q ${startDir}/$zipFile "*.zip" "*$targetFile" 2>&1 | fgrep -v "filename not matched" rm ${startDir}/$zipFile cd $startDir done fi done echo "The target file '$targetFile' was extracted here:" cd .. find $sandboxDir -name "$targetFile"

pattern-matching
tags question: http://stackoverflow.com/q/78396373
type: Tag
tag name: pattern-matching
tags question: http://stackoverflow.com/q/78827742

http://stackoverflow.com/q/78364647
type: Question
upvote count: 2
type: UnansweredQuestion
tagged with: shebang
answer count: 1
favorite count: 0
score: -2
has body: I like to run my python scripts directly in bash like so $ ./script.py But sometimes I forget the shebang line #!/usr/bin/env python3, and it has the potential to overwrite a file named np if the script has import numpy as np (and if you click a few times when the ImageMagick import command is run). What can I do to avoid such accidental execution of python scripts as bash scripts? Is there a way to block bash from executing a script that has an extension ".py" as a bash script?
downvote count: 4
has comment: http://stackoverflow.com/comment/138155267
has comment: http://stackoverflow.com/comment/138155132
tagged with: bash
has comment: http://stackoverflow.com/comment/138155045
has comment: http://stackoverflow.com/comment/138155107
has comment: http://stackoverflow.com/comment/138155126
has comment: http://stackoverflow.com/comment/138155021
has comment: http://stackoverflow.com/comment/138155073
has title: Avoiding accidental execution of python scripts as bash scripts
tagged with: python
has answer: http://stackoverflow.com/a/78364736
has comment: http://stackoverflow.com/comment/138155034

http://stackoverflow.com/comment/138252863
type: Comment
comment on: http://stackoverflow.com/q/78409604
score: 0
has text: @MikhailT. I understand the theory, hopefully you've read through the FAQ to understand the issues around the reality of the implementation (which the FAQ summarizes with "These rules are extremely convoluted, and they still fail to catch even some remarkably simple cases. Even worse, the rules change from one Bash version to another, as Bash attempts to track the extremely slippery POSIX definition of this "feature". When a SubShell is involved, it gets worse still -- the behavior changes depending on whether Bash is invoked in POSIX mode") and if you're happy with that then go for it
type: QuestionComment

http://stackoverflow.com/comment/138276068
comment on: http://stackoverflow.com/a/78433313
type: Comment
type: AnswerComment
score: 0
has text: Thank you it worked. I used `py.exe` in my PowerShell script. E.g. `py.exe -c "print(1)"`

http://stackoverflow.com/comment/138191336
has text: it's quite simple to create a service in systemd which your linux distro is probably using. Let systemd handle keeping your system service running. you're not making it easier for yourself by running it by hand, you're making it harder.
comment on: http://stackoverflow.com/q/78385537
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78399045
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/78320604
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78320604
type: AcceptedAnswer
has body: Cron isn't appopriate mechanism to automatically start graphical desktop applications. The @reboot entries defined in the crontab file are run when the cron daemon starts, at which time a desktop environment session hasn't been started, and the display server may not yet be running at all. Also, the environment variables required to connect to the display server are not set by default. You can automatically launch the Chromium browser during the startup of your desktop environment by creating a Desktop Application Autostart configuration file ~/.config/autostart/chromium.desktop like this: [Desktop Entry] Type=Application Name=Chromium Exec=chromium-browser Comment=Start Chromium when logging into the desktop

process
tag name: process
tags question: http://stackoverflow.com/q/78359720
tags question: http://stackoverflow.com/q/78324242
type: Tag
tags question: http://stackoverflow.com/q/78617714
tags question: http://stackoverflow.com/q/78864060
tags question: http://stackoverflow.com/q/78823127
tags question: http://stackoverflow.com/q/79125465
tags question: http://stackoverflow.com/q/79155445
tags question: http://stackoverflow.com/q/79215566
tags question: http://stackoverflow.com/q/79155589
tags question: http://stackoverflow.com/q/79284771
tags question: http://stackoverflow.com/q/79423600

http://stackoverflow.com/comment/138170092
score: 0
comment on: http://stackoverflow.com/q/78372933
type: QuestionComment
type: Comment
has text: Thanks... I improved the description of my issue. I guess it's more about matching two patterns, extracting them, and for one pattern recursively run the function/process again.

http://stackoverflow.com/comment/138074290
has text: @markp-fuso, right, order isn't well-defined because of the file descriptor being split, but is that actually a problem? I didn't see any ordering requirement in the spec.
type: AnswerComment
comment on: http://stackoverflow.com/a/78317659
type: Comment
score: 0

http://stackoverflow.com/comment/138086935
comment on: http://stackoverflow.com/q/78324080
has text: *"Maybe its only the math calc"*. Seems very likely. As is, this is way to much to ask readers to plow thru to help debug. Please read about [mcve] AND, more specifically to your problem, read the section [How to turn a bad script into a good question](https://stackoverflow.com/tags/bash/info) If you follow this advice, you are likely to solve the problem yourself. Good luck.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138127648
score: 0
has text: @CharlesDuffy Thanks for pointing out the usefulness of using a version.h. I have gone ahead and done that. I can't remove the version from the source as it is used for metadata on the device. But perhaps my approach is backwards. I was thinking it would be easiest to retrieve current version from the source and use that to create the next git tag. But a less automated way I guess would be to create the git tag manually and then push that to source codes version.h file. I will update the question to give more context to the script I am thinking of.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78337303

http://stackoverflow.com/q/78378844
accepted answer: http://stackoverflow.com/a/78378915
has comment: http://stackoverflow.com/comment/138183939
answer count: 3
has comment: http://stackoverflow.com/comment/138179797
has answer: http://stackoverflow.com/a/78378915
tagged with: data-filtering
tagged with: bash
has answer: http://stackoverflow.com/a/78378936
has answer: http://stackoverflow.com/a/78385408
possible better answer: http://stackoverflow.com/a/78378936
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138179587
has comment: http://stackoverflow.com/comment/138190813
has title: awk: does the placement of the curly brace { matter?
has comment: http://stackoverflow.com/comment/138179574
tagged with: awk
has body: I have two bash scripts that execute some an awk script. It's supposed to filter out blocked users: testawk.sh: #!/usr/bin/bash awk_script_file=$(cat << 'EOF' $0 ~ "User " user ".* blocked" { print } EOF ) # Run awk through bash to get file globbing to work bash -c "awk -v user='${user}' '${awk_script_file}' ${file}" testawk2.sh: #!/usr/bin/bash awk_script_file=$(cat << 'EOF' $0 ~ "User " user ".* blocked" { print } EOF ) # Run awk through bash to get file globbing to work bash -c "awk -v user='${user}' '${awk_script_file}' ${file}" You can see that literally the only difference is the placement of the curly brace { at the end of the regex matchphrase. Now when I run this script against test data (user=evil_user;file=data.csv; . testawk.sh) I get different results. data.csv: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod User evil_user blocked: Limit exceeded ex ea commodo consequat. Duis aute irure dolor in reprehenderit User evil_user blocked: Limit exceeded Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. testawk.sh outpout: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod User evil_user blocked: Limit exceeded User evil_user blocked: Limit exceeded ex ea commodo consequat. Duis aute irure dolor in reprehenderit User evil_user blocked: Limit exceeded User evil_user blocked: Limit exceeded Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. testawk2.sh output: User evil_user blocked: Limit exceeded User evil_user blocked: Limit exceeded And I don't understand why? Note: The indirection of calling bash within the script is to allow filepath globbing expansion for ${file}.
has comment: http://stackoverflow.com/comment/138185696
has comment: http://stackoverflow.com/comment/138183986
score: 0
type: Question

http://stackoverflow.com/comment/138155045
comment on: http://stackoverflow.com/q/78364647
type: Comment
has text: Computers do what you tell them to. If you're making mistakes and do things you didn't want to, there's not all that much the computer will do to protect you from yourself. Just gotta pay more attention.
score: 3
type: QuestionComment

http://stackoverflow.com/comment/138265953
type: QuestionComment
score: 5
type: Comment
has text: Use `&&` instead of `||` (and have a look at [De Morgan's laws](https://en.wikipedia.org/wiki/De_Morgan%27s_laws))
comment on: http://stackoverflow.com/q/78427584

http://stackoverflow.com/q/78399997
upvote count: 1
linked to: http://stackoverflow.com/q/30470079
favorite count: 0
has comment: http://stackoverflow.com/comment/138239294
tagged with: zsh
tagged with: emoji
type: Question
tagged with: macos
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138218096
score: 1
has title: How to find all the files and folders with emoji in the name?
has body: I’m trying to upload files to Box. It doesn’t allow files with emoji in the name to be uploaded. I’m on MacOS. So how can I find all the files, and folders, with emoji in the name? So I can begin uploading uninterrupted. Thank you.
has comment: http://stackoverflow.com/comment/138458189
answer count: 0
downvote count: 0
tagged with: bash

http://stackoverflow.com/q/78419450
tagged with: ubuntu
has comment: http://stackoverflow.com/comment/138251307
tagged with: bash
has comment: http://stackoverflow.com/comment/138251554
type: UnansweredQuestion
answer count: 1
has comment: http://stackoverflow.com/comment/138251248
has answer: http://stackoverflow.com/a/78419600
has comment: http://stackoverflow.com/comment/138251453
linked to: http://stackoverflow.com/q/1353016
has body: I was trying to make a calculator in bash and everything except multiplication works. My script turns "*" into 0 when I try to multiply. There is the code: #!/bin/bash calculator(){ if [ $3 = "+" ] ; then echo [ $1 $3 $2 ] else if [ $3 = "-" ] ; then echo [ $1 $3 $2 ] else if [ $3 = "/" ] ; then echo [ $1 $3 $2 ] else if [ $3 = "*" ] ; then echo [ $1 $3 $2 ] else echo "$3 error" fi fi fi fi } calculator 1 2 *
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138251345
duplicate of: http://stackoverflow.com/q/1353016
has comment: http://stackoverflow.com/comment/138251265
has comment: http://stackoverflow.com/comment/138251376
has comment: http://stackoverflow.com/comment/138251303
has title: Why multiplication sign "*" turns into 0?
tagged with: linux

http://stackoverflow.com/comment/138255331
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78398806
type: Comment
has text: It seems like the second ssh connection failed: `ssh: connect to host owlsnest.hpc.temple.edu port 22: Connection refused`. Try to add a `sleep 10` before the second rsync

http://stackoverflow.com/comment/138120558
type: Comment
has text: Then even: `ssh user@target bash -s <<<"grep -E 'DB_NAME|DB_USER' </some-path/wp-config.php"`
type: AnswerComment
comment on: http://stackoverflow.com/a/78343881
score: 0

http://stackoverflow.com/comment/138283064
type: Comment
comment on: http://stackoverflow.com/q/78437288
score: 1
type: QuestionComment
has text: As I mentioned in [my first comment to your previous question](https://stackoverflow.com/questions/78436568/how-to-pass-bash-variable-from-one-to-another-script#comment138282022_78436568), and as the [tag:bash] tag instructs - **please run your scripts through http://shellcheck.net** and fix the issues it tells you about before posting here.

http://stackoverflow.com/a/78419699
type: AcceptedAnswer
upvote count: 3
has body: ! always applies to exactly one pipeline. In your first example, that pipeline is the (...) command. In your second example, it's the first pipeline cmdA that constitutes the first part of the list defined by &amp;&amp;. If you don't actually want a subshell, but still want to negate the exit status of cmdA &amp;&amp; cmdB, use a command group: if ! { cmdA &amp;&amp; cmdB; }; then doSth fi
has comment: http://stackoverflow.com/comment/138251747
accepted answer of: http://stackoverflow.com/q/78419674
downvote count: 0
has comment: http://stackoverflow.com/comment/138265770
type: Answer
answers question: http://stackoverflow.com/q/78419674
has comment: http://stackoverflow.com/comment/138268321
has comment: http://stackoverflow.com/comment/138257289
score: 3

http://stackoverflow.com/comment/138103212
type: QuestionComment
type: Comment
has text: You are correct, package com.estudio.ejerciciosclase and public class sumScanner. However, that does not resolve the issue.
comment on: http://stackoverflow.com/q/78335326
score: 0

http://stackoverflow.com/comment/138193603
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78385603
has text: @fmw42, The red section is always the same size and text. I need to remove everything before it, leaving a small ridge on top with a black background.
type: Comment

http://stackoverflow.com/comment/138173778
type: QuestionComment
comment on: http://stackoverflow.com/q/78375308
type: Comment
has text: Of course, you can also tell your `expect` command to match (and provide behavior for) more than one string, and you can make one of those strings be `---MORE---`; but better to sidestep the problem altogether.
score: 1

http://stackoverflow.com/q/78341621
has title: bash: grep latest file in a directory over ssh
has comment: http://stackoverflow.com/comment/138122444
has comment: http://stackoverflow.com/comment/138159151
duplicate of: http://stackoverflow.com/q/2374276
score: 0
tagged with: grep
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138207592
type: UnansweredQuestion
has body: I have a code where I can grep a very specific file over ssh: ssh ${username}@${host} << -EOF grep -n ${text} ${filename} EOF which will output the desired text. However, now I want to do the same thing, but only for the latest file in a directory. I have tried several different options including: ssh ${username}@${host} "ls -t ${directory} | head -n 1" | xargs grep "${text}" ssh ${username}@${host} << -EOF grep -n ${text} `ls ${directory} | head -n1` EOF But it seems to try to find the latest file (and, thus, directory) on my local machine and not over ssh. What is missing here?
duplicate of: http://stackoverflow.com/q/59680812
linked to: http://stackoverflow.com/q/59680812
tagged with: ssh
tagged with: bash

http://stackoverflow.com/a/78417692
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/138250864
answers question: http://stackoverflow.com/q/78411166
has comment: http://stackoverflow.com/comment/138250752
upvote count: 1
has body: Using a positive lookahhead, you can optionally match the allowed characters without the u, and then match it to prevent unnecessary backtracking ^(?=[blntam]*u)[bluntam]{4,}$ Regex demo Using gnu grep with -P for a perl style regular expression: grep -iP '^(?=[blntam]*u)[bluntam]{4,}$' /usr/share/dict/words
type: Answer

http://stackoverflow.com/a/78385881
answers question: http://stackoverflow.com/q/78385809
downvote count: 0
has comment: http://stackoverflow.com/comment/138192205
score: 1
upvote count: 1
has body: Many things are bad about that. It is hard to read (and editors won’t syntax-highlight it), hard to reuse, hard to modify safely (once external variables are introduced, which is bound to happen). cmd() { local -ar tokens=(a 'b c' d) local -i i for ((i = 0; i < 3; ++i)); do echo "${tokens[@]^^}" "$i" done } cmd
type: Answer

http://stackoverflow.com/a/78374597
type: Answer
has comment: http://stackoverflow.com/comment/138181596
has body: First, you can run "docker compose up memory_Backend --build" to run only your backend service and check where is wrong. But I believe it could be a problem with not finding your Dockerfile, the dockerfile path that you passed into docker-compose. Whats happen when you run "docker run" into this files?
upvote count: 1
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78374366

http://stackoverflow.com/comment/138270196
type: QuestionComment
type: Comment
has text: Regarding the concern about which instance of `bash` is being used, I'll note that `type -a bash` and `which -a bash` indicate that there is only one instance found, `/bin/bash`.
comment on: http://stackoverflow.com/q/78427118
score: 0

http://stackoverflow.com/comment/138222039
type: Comment
comment on: http://stackoverflow.com/q/78402822
score: 0
has text: I added an answer for `bash`. As this isn't really a programming question, though, you should probably ask at either unix.stackexchange.com or apple.stackexchange.com. (I think my answer applies to `zsh` as well, but there seems to be a slight difference that I haven't been able to pinpoint yet.)
type: QuestionComment

http://stackoverflow.com/q/78396373
has comment: http://stackoverflow.com/comment/138215161
has comment: http://stackoverflow.com/comment/138215756
score: -2
answer count: 3
linked to: http://stackoverflow.com/q/1732348
has title: bash awk: Print lines between two matches and remove newline between two other matches
has comment: http://stackoverflow.com/comment/138210604
linked to: http://stackoverflow.com/q/33120215
tagged with: line-breaks
upvote count: 0
tagged with: bash
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78398734
favorite count: 0
has answer: http://stackoverflow.com/a/78396833
tagged with: pattern-matching
has body: This is my first post here at stack overflow, so if I'm doing something wrong, please tell me! I already searched hours for this and can't find a full solution. I can either get one or the other but not both. I don't want to pipe one awk command to the other. Instead I want to use a single line awk command. I have a curl output of a webpage, which I want to change with awk (regular awk, no gawk, mawk etc). I want to get all lines after the words Downstream Channel Status and before the first occurrence of . Then between the mentioned matches all line breaks should be removed between and . The lines with mentioned matches don't need to be printed. But I can work around it, if a solution cannot This is the (shortened) output of curl (which is saved in a variable). Startup Procedure Procedure Downstream Channel Status Channel Index Channel ID 1 10 2 1 3 2 4 3 Upstream Channel Status Channel Index Channel ID 1 9 2 10 3 11 I almost had a solution, but then my PC crashed and now my bash history is gone. But I tried to combine How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)? and Remove all occurrence of new line between two patterns (sed or awk?) In the end I want to end up with these lines: Channel Index Channel ID 1 193 2 1 3 2 4 3 If you have a solution for me, could you explain how it works? Thank you! EDIT I could find the code, which I thought was lost during the crash. So this is what I came up before posting here: awk '/Downstream Channel Status/,/\/table/ {gsub(/^[[:space:]]+/,"");print}' File | awk '/tr/{a=1;b="\n";next}/^<\/tr/{a=0;print"";next}a{printf b$0;b="";next}1'
tagged with: awk
has comment: http://stackoverflow.com/comment/138215227
linked to: http://stackoverflow.com/q/38972736
downvote count: 2
has comment: http://stackoverflow.com/comment/138216955
has comment: http://stackoverflow.com/comment/138212201
has comment: http://stackoverflow.com/comment/138210737
type: Question
has answer: http://stackoverflow.com/a/78396452

http://stackoverflow.com/a/78433171
has comment: http://stackoverflow.com/comment/138317677
has comment: http://stackoverflow.com/comment/138315353
has body: what happens when it runs with an &amp; First a subshell is created on &amp;. user+ 1 0 0 16:43 ? 00:00:00 bash mainscript.sh user+ 48 1 9 16:43 ? 00:00:04 bash mainscript.sh Then that subshell is replaced by command1. user+ 1 0 0 16:43 ? 00:00:00 bash mainscript.sh user+ 48 1 9 16:43 ? 00:00:04 command1 The whole line, including exec, it run in a subshell. Note: without exec, in this case you will most probably see the same result. This is because Bash has an optimization, that if a (sub-)shell will execute only single process (and there are also some other conditions), then Bash will exec automatically to conserve resources and reduce processes count on the system.
score: 3
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/138318937
downvote count: 0
has comment: http://stackoverflow.com/comment/138320836
has comment: http://stackoverflow.com/comment/138288195
answers question: http://stackoverflow.com/q/78433104
has comment: http://stackoverflow.com/comment/138289310
type: Answer
accepted answer of: http://stackoverflow.com/q/78433104

http://stackoverflow.com/comment/138190241
score: 0
has text: Did nto work curl: (3) URL rejected: Bad hostname curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535 curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
type: Comment
comment on: http://stackoverflow.com/a/78384589
type: AnswerComment

http://stackoverflow.com/comment/138198399
score: 0
comment on: http://stackoverflow.com/a/78389556
has text: Thanks, but that file is not a script and doesn't have a syntax with only such declarations. There are various types of data in there.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138148880
has text: what should it **not** match?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78361035

http://stackoverflow.com/comment/138137043
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78354378
has text: Why `cat input |` instead of just `<input`? Granted, `tr` doesn't try to do anything smarter that would benefit from a seekable handle, but as so many other tools (`sort`, `tail`, `wc`, &c) _do_ benefit, the latter is a better habit to be in.
score: 3

http://stackoverflow.com/q/78372933
has comment: http://stackoverflow.com/comment/138170092
type: Question
has comment: http://stackoverflow.com/comment/138169966
tagged with: shell
accepted answer: http://stackoverflow.com/a/78374017
upvote count: 0
has body: I have a bunch of zip files, with several levels of zip files inside them. I only want to extract files that matches this pattern: "_dnbr6.tif" and they can be located at different levels of the zip/directories hierarchy. One extra hint is that the files I'm looking for are located in directories/zip files (inside zip files) named like "fire_bundle". Lower and upper case changes on different zip/directories. How can I do it without extracting all the files of each of the nested zip files? I guess the idea is to: Iterate over each zip file listing all the files inside, if my file pattern matches then extract it. If not, match my zip pattern (fire_bundle) and extract only that zip file and recursively look for my file pattern (list the files inside that zip, etc.) I still don't know how to do the recursive part, so any help is appreciated.
score: -2
tagged with: http://stackoverflow.com/tag/zip
answer count: 2
tagged with: linux
tagged with: bash
has answer: http://stackoverflow.com/a/78373568
favorite count: 0
possible better answer: http://stackoverflow.com/a/78373568
type: AnsweredQuestion
has title: How can I recursively unzip files that matches a pattern in a group of nested ZIP files?
tagged with: unzip
downvote count: 2
has answer: http://stackoverflow.com/a/78374017

http://stackoverflow.com/comment/138157286
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78364618
type: Comment
has text: Isn't this a duplicate question? [Save/Restore the Bounds of Every Open Window by Path/Name](https://stackoverflow.com/questions/76408056/applescript-save-restore-the-bounds-of-every-open-window-by-path-name)

http://stackoverflow.com/q/78411166
answer count: 3
downvote count: 1
score: 2
tagged with: grep
has comment: http://stackoverflow.com/comment/138240776
has answer: http://stackoverflow.com/a/78417692
has answer: http://stackoverflow.com/a/78412703
tagged with: bash
has comment: http://stackoverflow.com/comment/138238260
has body: In the NYTimes Spelling Bee game, you have to make words (4+ letters long) using a set of 7 letters, one of which must be used in the word. This is fairly trivial to make a regex for: grep '^[bluntam]\{4,\}$' /usr/share/dict/words | grep u (All lowercase to avoid acronyms and proper nouns) Is there a way to combine these into one fancy regex? The issue with putting the required letter in the center, like [bluntam]*u[bluntam]* is that there needs to be another filter to ensure the word length. I'm ok with using PCRE or any other standard bash tools.
has title: Spelling Bee game regex
favorite count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78411195
has comment: http://stackoverflow.com/comment/138236825
upvote count: 3
tagged with: regex
has comment: http://stackoverflow.com/comment/138237221
type: Question
possible better answer: http://stackoverflow.com/a/78412703
has comment: http://stackoverflow.com/comment/138237507
has answer: http://stackoverflow.com/a/78411195

http://stackoverflow.com/a/78420330
answers question: http://stackoverflow.com/q/78420131
type: Answer
has body: Permission denied is written by bash as it attempts to open the file you wanted to redirect output to for writing. You'll never get rid of those errors by redirecting the output of echo itself. If you want stderr to go somewhere other than where it's already going, you'll have to tell it go somewhere else at some point. There are several ways to do that without repeating 2>&1 over and over though. Some options: You can execute the program with redirected outputs. # Execute program with outputs redirected - will apply to any command # within the script that doesn't explicitly override bash myscript >/some/log/file 2>&1 You can change the output destination for the entire program after starting the script with exec: # Use exec to change stdout and stderr exec >/some/log/file 2>&1 echo foo >/file/with/permissions # writes "foo" to /file/with/permissions echo bar >/file/without/permissions # writes Permission Denied to /some/log/file You can change stderr for a set of commands by putting them in a group: # write the stderr for some set of commands to a file { echo foo >/file/with/permissions echo bar >/file/without/permissions } >/some/log/file 2>&1 # also works for a function write_stuff() { echo foo >/file/with/permissions echo bar >/file/without/permissions } write_stuff >/some/log/file 2>&1 # also works for subshells ( echo foo >/file/with/permissions echo bar >/file/without/permissions ) >/some/log/file 2>&1
downvote count: 0
upvote count: 1
score: 1

debian
tag name: debian
type: Tag
tags question: http://stackoverflow.com/q/78444497
tags question: http://stackoverflow.com/q/78373696
tags question: http://stackoverflow.com/q/78454731
tags question: http://stackoverflow.com/q/78594386
tags question: http://stackoverflow.com/q/78697242
tags question: http://stackoverflow.com/q/79025685
tags question: http://stackoverflow.com/q/78943372
tags question: http://stackoverflow.com/q/79277246

http://stackoverflow.com/a/78443325
type: Answer
has body: This might work for you (GNU sed): sed '/^&lt;\+ &lt;&lt;source_dir&gt;&gt;/d;/^&lt;\+ &lt;&lt;target_dir&gt;&gt;/{:a;N;/^&lt;\+$/M!ba;d}' file Delete a line beginning &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;source_dir&gt;&gt;. Delete any lines between a line beginning &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;&lt;target_dir&gt;&gt; and &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;.
score: 0
answers question: http://stackoverflow.com/q/78441613

http://stackoverflow.com/comment/138270915
type: QuestionComment
has text: `unset array[$i]` doesn't work in general. It should be `unset "array[$i]"` (or `unset 'array[i]'`). See [Bash Pitfalls #57 (unset unquoted array element)](https://mywiki.wooledge.org/BashPitfalls#unset_a.5B0.5D). [Shellcheck](https://www.shellcheck.net/) finds this problem, and many other common problems. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78427584

http://stackoverflow.com/a/78320324
upvote count: 1
type: Answer
has body: Yes, we can do this in Bash. For example, here's a recursive method that generates these strings: #!/usr/bin/bash set -eu declare -ar suffix=('' {A..Z}) letter_seq() { local letter digits=$1 prefix="${2-}" if ((digits)) then for letter in "${suffix[@]:0${prefix:+1}}" do letter_seq $((digits-1)) "$prefix$letter" done elif [ "$prefix" ] then echo "$prefix" fi } letter_seq 10 We only brace-expand the initial list, which we use to populate the read-only array. The tricky expansion of ${suffix[@]:0${prefix:+1}} is to eliminate the empty string from the loop when $prefix is non-empty; the rest of the code should be reasonably self-evident. However, this kind of manipulation is slow in shell. Much faster to write and compile a simple C program: #include <stdint.h> #include <stdio.h> #include <stdlib.h> #define DIGITS 10 int main(void) { char buf[DIGITS+2] = { '\0' }; char const *begin = buf+DIGITS; for (;;) { /* increment number */ char *p = buf + DIGITS + 1; while ((*--p)++ == 'Z') { *p = 'A'; } if (*p == 1) { /* prepending another digit */ if (p == buf) { /* finished */ return EXIT_SUCCESS; } begin = p; *p = 'A'; } /* print it */ puts(begin); } } I tried running the shell version with a 4-character limit, and it took more than 12 seconds of user-space CPU time on my machine, whereas the C program was too quick to measure (less than 10 milliseconds). Increasing the output to 6 characters (i.e. 676 times as much work) pushed the C program up to 5.7 seconds; that's well over 1000 times as fast as the shell function. If necessary, you could embed the C program into your shell script thus: #!/bin/sh set -eu file=$(mktemp) gcc -o "$file" -Wall -Wextra -x c - <<EOF #include <stdint.h> #include <stdio.h> #include <stdlib.h> #define DIGITS 10 int main(void) { char buf[DIGITS+2] = { '\0' }; char const *begin = buf+DIGITS; for (;;) { /* increment number */ char *p = buf + DIGITS + 1; while ((*--p)++ == 'Z') { *p = 'A'; } if (*p == 1) { /* prepending another digit */ if (p == buf) {…
downvote count: 0
answers question: http://stackoverflow.com/q/78317617
score: 1

http://stackoverflow.com/q/78411838
tagged with: bash
type: Question
has answer: http://stackoverflow.com/a/78411906
has answer: http://stackoverflow.com/a/78412598
tagged with: http://stackoverflow.com/tag/json
answer count: 3
accepted answer: http://stackoverflow.com/a/78411906
possible better answer: http://stackoverflow.com/a/78412598
has comment: http://stackoverflow.com/comment/138238068
has answer: http://stackoverflow.com/a/78414181
score: 1
has body: I need to loop through a dictionary and append records to a json object file option.json the code I have is for K in "${!MYMAP[@]}"; do opt="{ \"OptionName\":\"${K}\", \"Value\":\"${MYMAP[$K]}\" }," echo $opt >> option.json done But this produce option.json as below { "OptionName": "name", "Value": "test" }, { "OptionName": "age", "Value": "13" } How do i make the option.json a json object and appending each {} inside the object, so my option.json would look like below [ { "OptionName": "name", "Value": "test" }, { "OptionName": "age", "Value": "13" } ]
upvote count: 1
favorite count: 0
tagged with: jq
type: AnsweredQuestion
has title: How to append records to a json object file in bash
downvote count: 0

http://stackoverflow.com/comment/138242627
type: AnswerComment
has text: Updated, forgot to add the anchor to the linked version.
comment on: http://stackoverflow.com/a/78411195
score: 0
type: Comment

recursion
type: Tag
tags question: http://stackoverflow.com/q/78436832
tag name: recursion
tags question: http://stackoverflow.com/q/79329141
tags question: http://stackoverflow.com/q/79505256

http://stackoverflow.com/q/78373696
has comment: http://stackoverflow.com/comment/138171937
has body: I need to restart a go application process on debian, this requires running the following bash file: systemctl stop go_service && other_command && systemctl start go_service I try to use the following code: cmd := exec.Command("bash", scriptPath) // Start the command asynchronously if err := cmd.Start(); err != nil { eError("Error starting command: %v\n", err) return } but the first bash command terminates the process and it never completes the next commands which should start it again any idea how to run the whole bash file ?
tagged with: debian
has comment: http://stackoverflow.com/comment/138172286
tagged with: linux
has comment: http://stackoverflow.com/comment/138173601
has comment: http://stackoverflow.com/comment/138180496
has comment: http://stackoverflow.com/comment/138171180
tagged with: bash
has comment: http://stackoverflow.com/comment/138170724
has comment: http://stackoverflow.com/comment/138180155
has answer: http://stackoverflow.com/a/78466290
has comment: http://stackoverflow.com/comment/138173554
downvote count: 1
has comment: http://stackoverflow.com/comment/138182691
has comment: http://stackoverflow.com/comment/138173612
has comment: http://stackoverflow.com/comment/138173576
has comment: http://stackoverflow.com/comment/138172821
has comment: http://stackoverflow.com/comment/138170633
has comment: http://stackoverflow.com/comment/138180465
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138180559
has comment: http://stackoverflow.com/comment/138170645
has comment: http://stackoverflow.com/comment/138180135
type: UnansweredQuestion
has title: Run a shell script which terminates the go application
upvote count: 1
answer count: 1
favorite count: 0
tagged with: go
has comment: http://stackoverflow.com/comment/138173626
has comment: http://stackoverflow.com/comment/138170622

http://stackoverflow.com/a/78472701
upvote count: 1
type: Answer
score: 0
downvote count: 1
has body: To at least avoid the command hanging your script, you could add a time-out. $file = 'file_path' $PlinkArgs = "-pw password account@server ""rm $file""" Wait-Process (Start-Process plink.exe $PlinkArgs -PassThru).Id -TimeOut 10 #seconds You might also consider using a try - catch statement as well to kill and log any plink commands that doesn't terminate by them self.
answers question: http://stackoverflow.com/q/78444561

http://stackoverflow.com/comment/138225472
comment on: http://stackoverflow.com/a/78404326
score: 2
type: Comment
type: AnswerComment
has text: @Urza_tron Your question says _"I would like a new file"_. Perhaps you should edit the question if a new file is not what you want?

http://stackoverflow.com/comment/138253167
type: Comment
comment on: http://stackoverflow.com/q/78419985
score: 0
type: QuestionComment
has text: standard awk has `substr` which is longwinded but simple

http://stackoverflow.com/q/78369669
has body: I have a tar file original.tar, and I need to untar it and then re-tar it for some reason. I do not want to untar it to disk and then tar from disk. I hope I can untar the file into stdout, and then tar the files from stdin, I tried this command but failed: tar xf original.tar -O | tar cf out.tar -T - But I got plenty of error messages: Is there any method that I can do this correctly?
type: Question
has comment: http://stackoverflow.com/comment/138163910
score: -3
has comment: http://stackoverflow.com/comment/138163916
upvote count: 0
tagged with: linux
type: UnansweredQuestion
tagged with: pipe
tagged with: bash
favorite count: 0
has answer: http://stackoverflow.com/a/78369765
answer count: 1
has comment: http://stackoverflow.com/comment/138164189
tagged with: shell
has title: How could I untar a file and then tar using pipe?
linked to: http://stackoverflow.com/q/2597875
tagged with: http://stackoverflow.com/tag/tar
downvote count: 3

http://stackoverflow.com/comment/138256823
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78403450
has text: This script is actually running correctly as all the values have been updated. The challenge is we need to verify each of the lines manually and with thousands of lines, that will take significant amount of time.
score: 0

text-parsing
tag name: text-parsing
tags question: http://stackoverflow.com/q/78438262
type: Tag

http://stackoverflow.com/comment/138298542
comment on: http://stackoverflow.com/q/78445411
score: 0
has text: Well in both cases but not in my code
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138102619
has text: @TedLyngmo the code snippet I've provided is a simplified version of what I am trying to do (implement bash here document using c) I need to read the user input from the stdin just like a normal here document does.
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78334722

http://stackoverflow.com/a/78340953
type: Answer
answers question: http://stackoverflow.com/q/78340874
has body: The = is not the problem, the dash - is. The dash has a special meaning in a character class: it introduces a range. Place it first or last in the class to make it match the literal dash: if [[ $email =~ ^[a-zA-Z0-9._%=+-]+\@[a-zA-Z0-9.=+-]+\.[a-zA-Z]{2,}$ ]] # ~ ~ For example: while read char; do [[ $char =~ [+-=] ]] && echo "$char matches" done < <(perl -le 'print join "\n", map chr, 32 .. 126') returns + matches , matches - matches . matches / matches : matches ; matches < matches = matches while using [=-+] makes it return nothing.
score: 5
downvote count: 0
upvote count: 5

http://stackoverflow.com/comment/138134740
score: 0
comment on: http://stackoverflow.com/q/78348524
type: Comment
has text: updated question with this testing, ty @Iterokun
type: QuestionComment

http://stackoverflow.com/comment/138189894
has text: You define `REMOTE_FOLDERS` in local and expand it in remote, not sure if there are other problems.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78384843
type: Comment

http://stackoverflow.com/q/78419580
score: 0
type: Question
tagged with: shell
possible better answer: http://stackoverflow.com/a/78419614
has title: How can I control output of the special parameter * in conditional expressions in bash?
answer count: 2
tagged with: syntax
tagged with: linux
has comment: http://stackoverflow.com/comment/138251638
has answer: http://stackoverflow.com/a/78420389
tagged with: bash
has body: I have a filename fofo.l stored in the variable FI. I want to check for ".l" in the file name. If so, command1 is executed. If not, command2 is executed. I used set -x and tried: if test $FI == *.l*; then echo done; else echo fail; fi this is the output: + test fofo.l == esc.txt execve.c fofo. fofo.l foo1.cpp foo2.c foo.c foo.gz foo.l fool.sl foo.save foo.sl foo.xz goo.xz goo.xz.orig mprint.c myecho2.c myecho.c nano.10558.save p1.c pm.c pm.o term.cpp zipT.gz bash: test: too many arguments + echo fail fail As far as I know, bash just replaces * with any amount of characters. There are plenty of matching files. How can I solve this problem?
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78420389
tagged with: conditional-statements
has comment: http://stackoverflow.com/comment/138251584
has answer: http://stackoverflow.com/a/78419614

http://stackoverflow.com/a/78343881
has comment: http://stackoverflow.com/comment/138118342
answers question: http://stackoverflow.com/q/78342895
has comment: http://stackoverflow.com/comment/138120558
has body: Charles Duffy is (as always!) correct, but I wanted to add an example for his comment in case it wasn't clear. Instead of: ssh cloudwaysuser@198.246.246.246 "cat /some-path/wp-config.php | grep -E 'DB_NAME|DB_USER'" You can run this: ssh cloudwaysuser@198.246.246.246 bash -s <<'EOF' cat /some-path/wp-config.php | grep -E 'DB_NAME|DB_USER' EOF (Using <<'EOF' instead of <<EOF suppresses variable expansion in the local shell, which is important for avoiding confusion if your shell uses variables.) By passing the shell script on stdin rather than on the command line, we avoid a number of problems around quoting and tokenization that can otherwise complicate a seemingly simple script.
score: 2
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138137356
has comment: http://stackoverflow.com/comment/138123410
type: Answer
has comment: http://stackoverflow.com/comment/138120535

http://stackoverflow.com/comment/138258107
comment on: http://stackoverflow.com/q/78423157
type: QuestionComment
has text: Does this answer your question? [Why piping input to "read" only works when fed into "while read ..." construct?](https://stackoverflow.com/a/13764018/1765658) or this: [How do I set a variable to the output of a command in Bash?](https://stackoverflow.com/a/41236640/1765658)
type: Comment
score: 0

http://stackoverflow.com/comment/138173071
score: 0
type: QuestionComment
type: Comment
has text: You also need an argument that contains the `env` array.
comment on: http://stackoverflow.com/q/78374908

http://stackoverflow.com/a/78401596
score: 3
has body: With recent version of bash: echo $BASH_VERSION 5.1.4(1)-release There is at least 3 differents ways for this: Using declare -a directly: declare -a "prefix_${midlepart}_suffix[variableIndex]=Content" Using printf in same way: printf -v "prefix_${midlepare}_suffix[variableIndex]" '%s' "Some string" As already suggested elsewhere using nameref: declare -n this="prefix_${midlepare}_suffix";this[variableIndex]=Content By using eval, but ... 1. Using declare simply: 1.1 Strictly answering request: dec_array=(abc10 def2 ghi333 jkl mno51 pqr_6 stu_XYZ) num_elements=${#dec_array[@]} elements_per_array=3 for ((i=0;i<num_elements;i+=elements_per_array)); do declare -a "dyn_array_$(( i / elements_per_array + 1 ))=(${dec_array[*]:i:elements_per_array})" done declare -p ${!dyn_array_*} declare -a dyn_array_1=([0]="abc10" [1]="def2" [2]="ghi333") declare -a dyn_array_2=([0]="jkl" [1]="mno51" [2]="pqr_6") declare -a dyn_array_3=([0]="stu_XYZ") 1.1.1 More robust supporting spaces and other special characters dec_array=(abc10 def2 ghi333 jkl mno51 pqr_6 stu_XYZ hello\ world.) num_elements=${#dec_array[@]} elements_per_array=3 for ((i=0;i<num_elements;i+=elements_per_array)); do part=("${dec_array[@]:i:elements_per_array}") declare -a "dyn_array_$(( i / elements_per_array + 1 ))=(${part[*]@Q})" done declare -p ${!dyn_array_*} declare -a dyn_array_1=([0]="abc10" [1]="def2" [2]="ghi333") declare -a dyn_array_2=([0]="jkl" [1]="mno51" [2]="pqr_6") declare -a dyn_array_3=([0]="stu_XYZ" [1]="hello world.") 1.2 General use answer=42 declare -a "dyn_arr_$((2*21))+=(foo)" declare -a "dyn_arr_$((84/2))+=(bar\ baz)" declare -a "dyn_arr_$answer+=($'Hello\nworld..\n')" declare -a "dyn_arr_$((12))+=({A..I})" Then for quick showing content of all arrays: declare -p ${!dyn_arr_*} declare -a dyn_arr_12=([0]="A" [1]="B" [2]="C" [3]="D" [4]="E" [5]="F" [6]="G" [ 7]="H" [8]="I") declare -a dyn_arr_42=([0]="foo" [1]="bar baz" [2]=$'Hello\nworld..\n') 1.3 Building a matrix: for i in {0..5}; do a=($((RAND…
accepted answer of: http://stackoverflow.com/q/78400075
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/138228290
answers question: http://stackoverflow.com/q/78400075
has comment: http://stackoverflow.com/comment/138226938
downvote count: 0
has comment: http://stackoverflow.com/comment/138224427
has comment: http://stackoverflow.com/comment/138223916
has comment: http://stackoverflow.com/comment/138230168
has comment: http://stackoverflow.com/comment/138234179
type: Answer

http://stackoverflow.com/comment/138115521
has text: `trap _term EXIT` works perfectly. What's the difference?
type: QuestionComment
comment on: http://stackoverflow.com/q/78341760
type: Comment
score: 0

http://stackoverflow.com/comment/138159341
type: Comment
score: 1
has text: You don't need to distinguish it. If there's no directory, `dirname` will return `.`, and `cd "$dirname"` will leave you in the current directory.
comment on: http://stackoverflow.com/q/78366773
type: QuestionComment

http://stackoverflow.com/a/78438177
has comment: http://stackoverflow.com/comment/138288571
type: Answer
has comment: http://stackoverflow.com/comment/138301808
has comment: http://stackoverflow.com/comment/138289250
has comment: http://stackoverflow.com/comment/138287212
accepted answer of: http://stackoverflow.com/q/78437863
has comment: http://stackoverflow.com/comment/138285930
has comment: http://stackoverflow.com/comment/138294004
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138286839
has body: On my M1 Mac OSX Ventura in bash, I get magick identify -format "%f: %m\n" *.(jp*|png|webp) bash: syntax error near unexpected token `(' but magick identify -format "%f: %m\n" "*.{jp*,png,webp}" barn.jpg: JPEG image.png: PNG lena.jpg: JPEG lena.png: PNG mandril3.jpg: JPEG monet2.jpg: JPEG redhat.jpg: JPEG zelda1.jpg: JPEG So it seems to me that the latter is better in bash. In zsh, I get magick identify -format "%f: %m\n" *.(jp*|png|webp) barn.jpg: JPEG image.png: PNG lena.jpg: JPEG lena.png: PNG mandril3.jpg: JPEG monet2.jpg: JPEG redhat.jpg: JPEG zelda1.jpg: JPEG and magick identify -format "%f: %m\n" "*.{jp*,png,webp}" barn.jpg: JPEG image.png: PNG lena.jpg: JPEG lena.png: PNG mandril3.jpg: JPEG monet2.jpg: JPEG redhat.jpg: JPEG zelda1.jpg: JPEG So zsh does a better job than bash with the () notation and the same as in bash with the {} notation In bash for find, I get file *.(jp*|png|webp) bash: syntax error near unexpected token `(' and file "*.{jp*,png,webp}" *.{jp*,png,webp}: cannot open `*.{jp*,png,webp}' (No such file or directory) and For zsh for find, I get file *.(jp*|png|webp) barn.jpg: JPEG image data, JFIF standard 1.01, resolution (DPCM), density 28x28, segment length 16, comment: "bdh 11110000110100001100100011001010110110011100100101001101011011101010101010101011100111011001101001110000011111000101110010", baseline, precision 8, 400x299, components 3 image.png: PNG image data, 314 x 88, 8-bit/color RGBA, non-interlaced lena.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 256x256, components 3 lena.png: PNG image data, 256 x 256, 8-bit/color RGB, non-interlaced mandril3.jpg: JPEG image data, JFIF standard 1.01, resolution (DPCM), density 28x28, segment length 16, baseline, precision 8, 256x256, components 3 monet2.jpg: JPEG image data, baseline, precision 8, 265x333, components 3 redhat.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline,…
has comment: http://stackoverflow.com/comment/138286736
score: 0
answers question: http://stackoverflow.com/q/78437863

http://stackoverflow.com/q/78360964
type: UnansweredQuestion
favorite count: 0
has comment: http://stackoverflow.com/comment/138148497
linked to: http://stackoverflow.com/q/9337489
duplicate of: http://stackoverflow.com/q/9337489
has comment: http://stackoverflow.com/comment/138148487
linked to: http://stackoverflow.com/q/169511
tagged with: bash
type: Question
has title: How to prevent bash to interpret this command as a single argument?
linked to: http://stackoverflow.com/q/19432753
has comment: http://stackoverflow.com/comment/138148469
downvote count: 1
has comment: http://stackoverflow.com/comment/138148549
tagged with: printf
score: -1
has comment: http://stackoverflow.com/comment/138148495
has body: Using bash 4.4 (Git Bash on Windows), I want to display a dynamic amount of characters in the console, using printf. Manually giving this command in the terminal works as expected: $ set -x;printf '%0.1s' -{1..44} + printf %0.1s -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 The -{1..44} expands correctly and the number of dashes displayed in the term is correct. However, in a script, using a variable, expansion is not as I expected it to be, and I do not know how to tell bash to interpret correctly: _calculated_progress=44 printf '%0.1s' -{1..$_calculated_progress} + printf %0.1s '-{1..44}' As you can see above, the argument seems to be interpreted as a single argument and expansion (if the term is correct) does not occur like it did in the first example. Using a variable, how may I make it so that arguments are correctly passed to printf and 44 dashes are displayed in the console?
upvote count: 0
answer count: 0

http://stackoverflow.com/comment/138114941
score: 0
comment on: http://stackoverflow.com/q/78341846
type: QuestionComment
has text: The best way is to use a xml library to modify the file, not an editing tool like sed. XML is not regular and text editors are meant for regular text.
type: Comment

http://stackoverflow.com/comment/138290583
type: QuestionComment
score: 6
type: Comment
comment on: http://stackoverflow.com/q/78440831
has text: [ShellCheck](https://www.shellcheck.net) is your friend.

http://stackoverflow.com/comment/138214151
type: QuestionComment
has text: @Barmar see end of paragraph 3
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78384843

http://stackoverflow.com/comment/138067105
score: 0
type: Comment
has text: Try running the script under `set -xv` to see what values are assigned to variables and what commands are being run.
comment on: http://stackoverflow.com/q/78314716
type: QuestionComment

http://stackoverflow.com/comment/138179797
comment on: http://stackoverflow.com/q/78378844
has text: OK. I think `eval` would be more straightforward; it would at least avoid the extra shell process. And would not be notably more dangerous, since your current approach already leaves you vulnerable to injection attacks via the content of `$file`.
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/q/78374908
type: UnansweredQuestion
score: 1
tagged with: x86-64
has comment: http://stackoverflow.com/comment/138173067
has answer: http://stackoverflow.com/a/78374935
has comment: http://stackoverflow.com/comment/138173234
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138173071
has body: I am very new to assembly and I am trying to call: /bin/bash -c "echo hello; ls -la" I store the "/bin/bash" command as a string and its address in RBX and RDI. 59 on RAX for the execve syscall that I perform at the end. -c on RSI as the second argument with the echo line on the third. Here's what gdb sees on the registers before the syscall line. RBX: 0x4000b3 ("/bin/bash") RCX: 0x0 RDX: 0x4000c8 ("\"echo hello; ls -la\"") RSI: 0x4000c5 --> 0x6f6863652200632d ('-c') RDI: 0x4000b3 ("/bin/bash") RBP: 0x0 RSP: 0x7fffffffe0e0 --> 0x1 RIP: 0x4000a7 --> 0xe8050f0000003bb8 But when I start the executable nothing happens. I thought the registers are used for the argv[] arguments. I debugged the program and I honestly can't tell what's going wrong but then again I am really new so maybe I am not actually giving the arguments to the syscall?
has title: Assembly call bash command with argv[]
upvote count: 1
answer count: 1
favorite count: 0
tagged with: cpu-registers
has comment: http://stackoverflow.com/comment/138173223
has comment: http://stackoverflow.com/comment/138173893
tagged with: assembly
type: Question

http://stackoverflow.com/a/78333360
downvote count: 0
has comment: http://stackoverflow.com/comment/138100334
has comment: http://stackoverflow.com/comment/138101320
score: 1
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138100192
answers question: http://stackoverflow.com/q/78333123
has body: Since you ask specifically for BASH code, I'll use [[]] which is only available in BASH. You can do what you want by using the following code: commandOutput=$(command) if | $commandOutput == *"string"* || $commandOutput == *"strong"* ; then doStuffOnError fi Explanations: $? in shell is the exit code of the previous command we check if it is non-zero (aka it ended with an error) or if the output matches "string" or "strong", if any of those is true then we execute duStuffOnError Note that here the commandOutput only stores what is on stdout. If you want also stderr, consider commandOutput=$(command 2>&1) which redirects stderr to stdout.
has comment: http://stackoverflow.com/comment/138099594
has comment: http://stackoverflow.com/comment/138100230
accepted answer of: http://stackoverflow.com/q/78333123
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138100180

http://stackoverflow.com/comment/138259013
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78423404
has text: Apparently you can specify in the YAML code of the SSM Document a step to output variables: Here is the chunk of code necessary ´´´ outputs: - Name: Status Selector: "$.stdout" Type: String ```

http://stackoverflow.com/comment/138202832
has text: Your answer works, if you write the scripts yourself. If you have existing programs, like `cat` in my suggestion to test, or `nroff` if you dislike `cat`, it will simply not work. With the `tail -f`, it will continue to read. Try it with existing programs instead of your own script.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78390677

http://stackoverflow.com/comment/138192205
has text: Might also want `local i` to avoid the counter from leaking into global scope.
comment on: http://stackoverflow.com/a/78385881
type: Comment
type: AnswerComment
score: 3

comparison
type: Tag
tags question: http://stackoverflow.com/q/78393091
tag name: comparison

http://stackoverflow.com/q/78392006
duplicate of: http://stackoverflow.com/q/8349771
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138202676
has comment: http://stackoverflow.com/comment/138202745
tagged with: tr
score: 3
answer count: 1
upvote count: 3
has comment: http://stackoverflow.com/comment/138202672
has title: replacing double quotes with backslash and double quotes
has body: I am trying to replace a double quotes (") with back slash and double quotes (") however it's not working echo '"hello workd"' | tr '"' '\\""' This gives me \hello workd\ and following does nothing. echo '"hello workd"' | tr '"' '\"'
downvote count: 0
linked to: http://stackoverflow.com/q/8349771
has answer: http://stackoverflow.com/a/78392023
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138202669
favorite count: 0

http://stackoverflow.com/comment/138223189
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78400214
has text: Could be quicker if instead of doing 2 encapsulated loop, you could do one loop and split source array with `${array[@]:stat:length}` syntax! ( See [my answer](https://stackoverflow.com/a/78401596/1765658) ;-)

http://stackoverflow.com/q/78423404
type: Question
answer count: 0
upvote count: 2
tagged with: aws-lambda
type: UnansweredQuestion
tagged with: bash
tagged with: powershell
has body: I´m working on a AWS SSM Document that accepts two parameters as inputs and outputs a string (or something likewise). The purpouse of this document is to check if a service, passed by parameter input, is running on an EC2 instance, also passed by parameter input. It consists of two parts, one designed to work on windows, the other designed to work on linux. This document is being executed by a lambda with python code that runs the document providing it with an instance_ID and a service_Name. I have already worked out the input parameters and how to work with them, but I haven´t found a way to extract a variable string from the execution (the service status basically). Is there a way to get said variable string in the response from the send_command() function of boto3? Or any other way? I´m open to redo everything as this is my first hand-on experience with all of this technologies. Beforehand, thanks for your time and attention. Note: I am completely new in AWS and powershell. This is the SSM Document code that if written so far: description: 'Install status checker scripts with custom dimension' mainSteps: - action: aws:runPowerShellScript inputs: runCommand: - '$serviceName={{serviceName}}' - '$instanceId={{instanceId}}' - '' - '# Check if a service name was provided' - 'param([string]$serviceName,[string]$instanceId)' - 'if (-not $serviceName) {' - ' Write-Host "Usage -> check_service_windows.ps1 -serviceName <service-name>"' - ' exit' - '}' - 'if (-not $instanceId) {' - ' Write-Host "Usage -> check_service_windows.ps1 -serviceName <service-name> -instanceId <InstanceID>"' - ' exit' - '}' - '# Check the status of the service' - '$service = Get-Service -Name $serviceName' - '# Determine the metric value based on the service status' - '$metricValue = if ($service.Status -eq "Running") { 0 } else { 1 }' - '# Display the service status' - 'Write-Host "{\"checked\": \"yes\", \"metricValue\": $metricValue}"' timeoutSeconds: 7200 name: Windows outputs: - Name: Status Se…
favorite count: 0
tagged with: aws-ssm
score: 2
downvote count: 0
has title: How to output data from an execution of a SSM Document
has comment: http://stackoverflow.com/comment/138259013
tagged with: python

http://stackoverflow.com/comment/138190000
has text: the input (as presented in the question) is spread across 4 lines (ie, the data includes 3 embedded linefeeds); because of the embedded linefeeds your code does not actually work (eg, `sb` ends up being empty); I'm *assuming* your input is actually one long line of text; please update the question to confirm the structure and format of the sample input ... multiple lines? one single/long line?
comment on: http://stackoverflow.com/q/78383503
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/138182336
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78380184
has text: @oguzismail You should turn that into an answer or expand on the one posted by axiac: (1) `! <command>` constitutes a pipeline (that was the part that eluded me) (2) `!` in a pipeline negates a command's return code (as described by the documentation, easy to spot once you know that you're actually dealing with a pipeline) (3) `PIPESTATUS` can used to access the command's return code (nice addition/solution)

http://stackoverflow.com/comment/138289310
has text: Then pid 48 will stay and another pid will run as command1.
score: 0
comment on: http://stackoverflow.com/a/78433171
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138224875
type: Comment
type: AnswerComment
has text: @TedLyngmo I believe the 9 and 10 are the line numbers and are not part of the input.
score: 0
comment on: http://stackoverflow.com/a/78404326

ros2
type: Tag
tags question: http://stackoverflow.com/q/78416125
tag name: ros2

http://stackoverflow.com/q/78373722
has title: Expect script frozen when appending output to nohup.out
has answer: http://stackoverflow.com/a/78378849
has comment: http://stackoverflow.com/comment/138176975
has body: This is the first time I have done an expect script. In principle it is a simple script #!/usr/bin/expect set timeout 200 spawn XXX/bin/PROGRAM expect "Choose an option ..." send "1\r" ... The program has several options, and I have made 4 similar scripts with them that have not given problems, in addition, in the option that gives problems I also navigate through a series of submenus without problems. The problem appears at a certain point when the program I have spawned throws the message: nohup: appending output to 'nohup.out' The problem always occurs in an expect-send block where the program kills a number of processes. When I run the program directly from the command line I don't get this problem, so I understand that the problem is related to the output directioning of the process created by spawn, I have tried several ways to solve this but all without success. How can I make the process created by the expect script behave in the same way as in my terminal and avoid the redirecting to nohup? Thank you very much.
type: Question
tagged with: unix
tagged with: expect
score: 0
has comment: http://stackoverflow.com/comment/138178847
tagged with: bash
has comment: http://stackoverflow.com/comment/138170806
answer count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78378849

strong-typing
type: Tag
tags question: http://stackoverflow.com/q/78415633
tag name: strong-typing

http://stackoverflow.com/q/78341760
has comment: http://stackoverflow.com/comment/138115665
tagged with: bash
type: Question
duplicate of: http://stackoverflow.com/q/45590344
answer count: 0
has comment: http://stackoverflow.com/comment/138115521
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138115074
has comment: http://stackoverflow.com/comment/138114823
has comment: http://stackoverflow.com/comment/138115095
score: 0
has title: trap and signals in bash when process is in the background
tagged with: linux
has body: I have the following script _term () { touch hi.txt } trap '_term' SIGINT SIGTERM tail -F test.sh I execute ./test.sh and I press ctr+c and the file is created as expected. I execute ./test.sh & and I execute kill -SIGINT then nothing happens. Can somebody explain me why that is? And what to change for it to work as expected. What I have tried: Different statements like "echo hi" or "exit 0". All seem to not be executed. Diffeent signals sleep 9000 instead of tail -F killing the "tail -F" XD Then surprise the signal handler is executed as expected. fg and then ctr+c works flawlessly tail -F test.sh & wait works but why
has comment: http://stackoverflow.com/comment/138115108
has comment: http://stackoverflow.com/comment/138122427
has comment: http://stackoverflow.com/comment/138115558
has comment: http://stackoverflow.com/comment/138115261

http://stackoverflow.com/a/78466290
has body: I solved this by using: systemctl restart go_service
answers question: http://stackoverflow.com/q/78373696
score: 0
type: Answer

http://stackoverflow.com/comment/138217199
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78400075
has text: Use a language that supports multi-dimensional data structures.
score: 1

http://stackoverflow.com/comment/138206133
type: QuestionComment
comment on: http://stackoverflow.com/q/78393852
type: Comment
has text: Pasted your log there twice my friend. Could you edit and put your script in? Also, what flavour of Linux is your VM?
score: 0

http://stackoverflow.com/comment/138226858
type: Comment
type: QuestionComment
score: 0
has text: What is the source of the tar file, and do you need to load the images into the docker engine? There are multiple tools that work with images without using the docker engine.
comment on: http://stackoverflow.com/q/78405506

http://stackoverflow.com/comment/138169057
score: 1
has text: The comma is added in this line: `current_consumed_contracts+="$(echo "$next_line" | tr -d '[:space:]'),"` If you don't want to add the comma, don't do it.
type: QuestionComment
comment on: http://stackoverflow.com/q/78372779
type: Comment

http://stackoverflow.com/comment/138224427
has text: Yes, but both others are notable: `printf`could offer more accuracy and *nameref* (`declare -n tmpvar`) could add more flexibility...
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78401596

http://stackoverflow.com/comment/138245480
score: 0
has text: BTW, your `while` loop that reads the file can be replaced with the `readarray` command.
type: QuestionComment
comment on: http://stackoverflow.com/q/78416162
type: Comment

http://stackoverflow.com/comment/138203916
comment on: http://stackoverflow.com/q/78392419
type: QuestionComment
type: Comment
score: 1
has text: BTW, I'd strongly suggest `declare -p` instead of `declare --` -- otherwise too much chance of that user input being something that has side effects when run.

http://stackoverflow.com/q/78432948
duplicate of: http://stackoverflow.com/q/45590344
has comment: http://stackoverflow.com/comment/138275411
downvote count: 0
duplicate of: http://stackoverflow.com/q/53367146
has title: Cannot trap SIGINT and SIGTERM when using "sleep infinity"
score: 1
tagged with: bash
type: AnsweredQuestion
duplicate of: http://stackoverflow.com/q/26858344
answer count: 2
duplicate of: http://stackoverflow.com/q/33240221
accepted answer: http://stackoverflow.com/a/78432970
type: Question
has answer: http://stackoverflow.com/a/78433914
has body: My example code: #!/bin/bash LOGFILE="/tmp/example.log" cleanup_function() { echo "Script interrupted by SIGINT, cleaning up..." >> $LOGFILE exit 0 } shutdown_function() { echo "Script terminated by SIGTERM, shutting down..." exit 0 } # Traps to handle SIGINT and SIGTERM trap 'cleanup_function' SIGINT trap 'shutdown_function' SIGTERM echo "Script running. It waits for SIGINT or SIGTERM..." >> $LOGFILE sleep inf Saved as testtrap.sh In a terminal: $ ./testtrap.sh In another terminal: $ ps -A | grep testtrap.sh 28923 pts/2 00:00:00 testtrap.sh $ kill -s SIGINT 28923 $ kill -s SIGTERM 28923 $ ps -A | grep testtrap.sh 28923 pts/2 00:00:00 testtrap.sh SIGINT and SIGTERM are not trapped e testtrap.sh is not killed by them. What's wrong?
has comment: http://stackoverflow.com/comment/138275235
has answer: http://stackoverflow.com/a/78432970
possible better answer: http://stackoverflow.com/a/78433914
linked to: http://stackoverflow.com/q/45590344
upvote count: 1
favorite count: 0

http://stackoverflow.com/q/78393978
type: Question
has comment: http://stackoverflow.com/comment/138206820
has comment: http://stackoverflow.com/comment/138206241
duplicate of: http://stackoverflow.com/q/4286469
linked to: http://stackoverflow.com/q/4286469
has comment: http://stackoverflow.com/comment/138224682
score: 0
linked to: http://stackoverflow.com/q/55023461
answer count: 0
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138206226
has title: Bash script reading from CSV seems to ignore variable values
linked to: http://stackoverflow.com/q/29378566
tagged with: if-statement
has body: I'm not a Bash expert, but I've followed Copilot examples, and the following should work, but it doesn't: # CSV file contents lineNo, column1, column2, column3, column4 1, true, true, true, abc 2, true, false, true, 123 3, false, true, false, xyz 0 Bash script: while IFS=, read -r lineNo column1 column2 column3 column4 do echo $column4 if [ "$column4" = "123" ]; then echo "condition is true" else echo "condition is false" fi done < <(tail -n +2 $setupFileLocation) However, my results are as follows: abc condition is false 123 condition is false xyz condition is false Why are the actual variable values being ignored? They are correct in the echo, but the IF...THEN isn't acknowledging the changing value. I've tested this with making the lineNo #1 the tested value, and it doens't make a difference. All conditions return "false". Why the trailing zero? If it isn't there the read Bash command only returns the header and first two rows. I haven't figured this out yet, but it's a different subject. Are there any wonderful Bash SMEs out there who can assist?

http://stackoverflow.com/comment/138225369
type: AnswerComment
comment on: http://stackoverflow.com/a/78404326
score: 0
has text: Thanks! What if inputfile and output files are the same? Shall I write the same filename twice or do I have to do something a bit different?
type: Comment

http://stackoverflow.com/comment/138270080
has text: Anyhow -- a good place to start might be to try to build a reproducer in an online sandbox. If you can make the same problem happen in https://ideone.com/, that means you've isolated the necessary elements enough that we're not needing to guess about things on your machine (that you may not personally know about yourself).
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78427118

http://stackoverflow.com/comment/138284755
type: QuestionComment
has text: There's no need to pipe `grep` to `awk`, use awk's built-in regexp condition.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78438262

llama
type: Tag
tags question: http://stackoverflow.com/q/78436977
tag name: llama

http://stackoverflow.com/comment/138144237
score: 1
type: QuestionComment
type: Comment
has text: Try `flacfiles=("$1"/*)` then `for filename in "${flacfiles[@]}"`...
comment on: http://stackoverflow.com/q/78358550

http://stackoverflow.com/comment/138202960
type: Comment
comment on: http://stackoverflow.com/a/78390677
type: AnswerComment
has text: I think you're wrong in that: There are no reason to run **both** process in *background*! There are only 1 process to run in background. the second should be run in ***foreground***!!
score: 0

genomics
tag name: genomics
type: Tag
tags question: http://stackoverflow.com/q/78326945
tags question: http://stackoverflow.com/q/78620851

http://stackoverflow.com/comment/138181229
type: Comment
has text: I have modified my question. I hope it is more clear.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78366908

http://stackoverflow.com/comment/138173705
has text: In https://stackoverflow.com/help/how-to-answer, note the section _Answer Well-Asked Questions_ and the bullet point therein regarding questions that have "been asked and answered many times before".
score: 1
comment on: http://stackoverflow.com/a/78373883
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78437427
downvote count: 0
score: 1
upvote count: 1
type: Answer
has body: Scripts and functions in shell produce 2 types of result: output - e.g. from echo 'foo'. exit status - i.e. exit 7 from a script or return 7 from a function. In the calling code you can capture both of those with: out=$(script_or_function) - captures the output in variable out. script_or_function; es="$?" - captures the exit status in variable es Mix and match as you see fit, e.g.: foo() { local out es out=$(script_or_function) || { es="$?"; printf 'script_or_function() failed with exit status "%d" and output "%s"\n' "$es" "$out"; return "$es"; } printf '%s\n' "$out" } The fact that functions in shell use the keyword return to set their exit status when scripts use exit for the same purpose is arguably somewhat unfortunate, especially if you're coming from programming in a language like C where ret=func() stores in ret the value of val from func() { ... return val; }, but functions need some way to distinguish between exiting (returning from) the function vs exiting the process they're called from so you just have to put that behind you and understand that shell is not C and so you should not expect shell syntax or semantics to be like Cs. FWIW having a function call exit, instead of calling return and letting the caller decide to exit or not, is inversion of control (a low level entity making a high level decision) so while it's not the end of the world and there can be reasons to do so, think hard about it if you're considering calling exit from a function. One way to do what you show in your question would be: script1: #!/usr/bin/env bash func_name() { local var123='abcd123' printf '%s\n' "$var123" } func_name script2: #!/usr/bin/env bash var=$(script1) Unix commands idiomatically don't have suffixes btw which is why I removed .sh from your scripts file names. Having a suffix is yet another example of tight coupling and so bad software since you couldn't re-implement script1.sh as a compiled C program, and conscientiously still call it script.sh so you'd need to …
answers question: http://stackoverflow.com/q/78437288

http://stackoverflow.com/comment/138077843
comment on: http://stackoverflow.com/q/78319238
type: QuestionComment
score: 0
has text: It is worth noting that when the script is run with sh/bash, pgrep behaves as expected. It is only when run through `alacritty -e ~/tmux.sh` that this confusing behavior arises.
type: Comment

http://stackoverflow.com/comment/138137388
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78350497
score: 0
has text: Often, sshd_config files are world-readable -- if they have a ForceCommand in there you may be able to read it even from your unprivileged user account.

http://stackoverflow.com/comment/138200525
score: 0
has text: Do you really want your variable to be _in the environment_? Otherwise, use `declare` instead of `export`.
comment on: http://stackoverflow.com/a/78390608
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138073441
score: 2
has text: The downvote isn't mine, and this does what the OP is asking for; but quite frankly, if they don't know python this isn't really good enough w/o a **LOT** of explanatory words. I guess the downvoter thought that code-only answers are useless?
comment on: http://stackoverflow.com/a/78318299
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78319238
has comment: http://stackoverflow.com/comment/138076325
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138078009
answer count: 3
has answer: http://stackoverflow.com/a/78320597
has body: This is the beginning of a script for determining whether to run tmux, it has been modified for debugging purposes: (no tmux instance is ever running in this test example) #!/bin/bash -x if -n "$TMUX" ; then echo "We are inside tmux" exit 1 fi if $(pgrep -c tmux) -ne 0 ; then echo "joining tmux session" tmux a exit 0 fi bash Script run on terminal 1: alacritty -e ~/tmux.sh Output on terminal 2: + -n '' ++ pgrep -c tmux + 1 -ne 0 + echo 'joining tmux session' joining tmux session + tmux a no sessions + bash [user@hostname ~]$ pgrep -a tmux 27220 /bin/bash -x /home/user/tmux.sh I expected the condition to turn false, 0 -ne 0 , pgrep should not(?) recognize /bin/bash -x /home/user/tmux.sh since I'm looking for a tmux process, not the string tmux as some process parameter. Moreover, if on a terminal I run vim ~/tmux.sh, and pgrep -c tmux on another, it returns 0 (while no tmux instance running). So this kind of behavior does not seems to be consistent. Why I'm getting different results? Thanks. Update 1, System info: alacritty 0.13.2 (bb8ea18e) bash 5.2.26(1)-release pgrep from procps-ng 4.0.4 archlinux Update 2: It is worth noting that when the script is run with sh/bash, pgrep behaves as expected. It is only when run through alacritty -e ~/tmux.sh that this confusing behavior arises. Update 3: Also happens when run from a foot or xterm terminal foot ~/tmux.sh. Update 4: video
has comment: http://stackoverflow.com/comment/138077843
tagged with: grep
has answer: http://stackoverflow.com/a/78320229
tagged with: bash
has title: pgrep matches undesired patterns
score: 1
has comment: http://stackoverflow.com/comment/138075276
has comment: http://stackoverflow.com/comment/138076322
favorite count: 0
downvote count: 1
accepted answer: http://stackoverflow.com/a/78321507
has comment: http://stackoverflow.com/comment/138078003
has comment: http://stackoverflow.com/comment/138078016
upvote count: 2
has answer: http://stackoverflow.com/a/78321507
possible better answer: http://stackoverflow.com/a/78320597
type: Question

http://stackoverflow.com/a/78404326
has comment: http://stackoverflow.com/comment/138225433
upvote count: 2
has comment: http://stackoverflow.com/comment/138236718
has comment: http://stackoverflow.com/comment/138225472
has body: You're looking for something like this: sed '9{N;s/\n/ /}' file sed is a stream editor used for text manipulation which executes a sequence of commands to each line of the input file. It has knowledge of two memory blocks. The pattern space is one of those and is by default printed at the end of the command sequence. Here is how it works: begin: load the current line in the pattern space 9{...}: This means that the two commands enclosed between braces, will be applied only to the 9th line. N: This command appends the next line of input to the current pattern space. The line is prepended with a newline character. s/\n/ /: This s command replaces the first newline character \n in the pattern space with a space. end: print the pattern space
has comment: http://stackoverflow.com/comment/138224875
has comment: http://stackoverflow.com/comment/138225369
has comment: http://stackoverflow.com/comment/138225283
answers question: http://stackoverflow.com/q/78404233
has comment: http://stackoverflow.com/comment/138225265
downvote count: 0
type: Answer
score: 2

http://stackoverflow.com/q/78411488
score: 1
answer count: 2
has answer: http://stackoverflow.com/a/78411665
downvote count: 0
tagged with: bash
has answer: http://stackoverflow.com/a/78411741
possible better answer: http://stackoverflow.com/a/78411665
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has title: Print some values based on conditions from all json files
accepted answer: http://stackoverflow.com/a/78411741
tagged with: awk
has body: I have several json files in a folder and subfolders for which I want to print only 3 fields. I use a for loop over all json files, but here to make it simple, the input below represents 3 json files. For each one, I want to print the "Filename" and "Value" only when inside each file appears at least one "Dmo = Path". When a files doesn´t contain a "Dmo = Path" block, then only print the filename. { "Filename": "File_213", "Date": "2024-4-30", "Blocks": [ { "Dmo": "WW", "Value": "23", "String": "", }, { "Dmo": "Path", "Value": "/Files/2024/abd", "String": "", }, { "Dmo": "Path", "Value": "/Files/2024/Ndew", "String": "", } ] } { "Filename": "File_4", "Date": "2024-4-30", "Blocks": [ { "Dmo": "WW", "Value": "45", "String": "", } ] } { "Filename": "File_43", "Date": "2024-4-30", "Blocks": [ { "Dmo": "Path", "Value": "/Files/2023/Roi2", "String": "", } } ] } My current code and current output is like below $ awk '/"Filename":/{fnm=$2} /Dmo/{dmo=$2} /Value/ { val=$2; if (dmo != "") print fnm,val else print fnm fnm=""; dmo="";val=""}' input "File_213", "23", "/Files/2024/abd", "/Files/2024/Ndew", "File_4", "45", "File_43", "/Files/2023/Roi2", My expected output is: File_213, /Files/2024/abd File_213, /Files/2024/Ndew File_4 File_43, /Files/2023/Roi2
type: Question

http://stackoverflow.com/comment/138290945
type: QuestionComment
type: Comment
has text: @Biffen No matter using bash or sh or tcsh or ksh. The problem is caused by cut, not by shell.
score: 0
comment on: http://stackoverflow.com/q/78441743

http://stackoverflow.com/comment/138129050
type: QuestionComment
comment on: http://stackoverflow.com/q/78349529
type: Comment
score: 0
has text: Odd. My version of `watch` (from procps-ng 3.3.15) does not have a `--no-wrap` option and does not result in the `\\n`s being decoded to newlines.

http://stackoverflow.com/a/78442706
score: 2
has body: The [...]=... is part of the syntax of an array assignment; it has to be present and recognized before parameter expansion occurs. Just like you can't do something like equals='='; x${equals}3 in place of x=3, you can't construct a dynamic array assignment like this (without eval, anyway).
answers question: http://stackoverflow.com/q/78442690
upvote count: 2
downvote count: 0
type: Answer

http://stackoverflow.com/comment/138182691
type: Comment
score: 0
type: QuestionComment
has text: To reiterate: The shim should just be verifying signatures on content then starting the newest correctly-signed executable (and think about a one-way ratchet to prevent downgrades so that after you fix a security bug an attacker can't reintroduce it with an older correctly-signed executable). You don't want to make it responsible for downloading those executables, because that requires giving the service enough permissions to rewrite its own files -- put that on the other end of a privilege boundary, performed by a program that's as small, simple, and well-audited as possible.
comment on: http://stackoverflow.com/q/78373696

http://stackoverflow.com/q/78317617
has answer: http://stackoverflow.com/a/78318299
upvote count: 2
has answer: http://stackoverflow.com/a/78346666
has comment: http://stackoverflow.com/comment/138075803
has comment: http://stackoverflow.com/comment/138074335
answer count: 6
has answer: http://stackoverflow.com/a/78318419
has body: I want to start generating from a single length char and generate all possible values till (ZZZZZZZZZZ) 10-Zs. I know I can do something like {A..Z}{A..Z}{A..Z}.... but I want to increment the length of character sequence in the outer loop. Is there any way to implement this in bash? I tried the below script but the problem is that for loop command considers &quot;{A..Z}&quot; literally as a string. #!/bin/bash seq={A..Z} cur_seq=&quot;&quot; for i in {0..10}; do cur_seq=${cur_seq}${seq} for a in $cur_seq; do echo $a ead kk done done
type: Question
has comment: http://stackoverflow.com/comment/138072194
has answer: http://stackoverflow.com/a/78320324
tagged with: linux
downvote count: 0
has answer: http://stackoverflow.com/a/78319702
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78317659
tagged with: bash
has comment: http://stackoverflow.com/comment/138072255
favorite count: 0
has title: How to Generate string of all combination starting from A to ZZZZZZZZ in bash
score: 2

http://stackoverflow.com/a/78375417
answers question: http://stackoverflow.com/q/78372639
has body: This might work for you (GNU sed and sort): value=1.0.7.2 sed '/^\[version\]/{n;s/^/'"$value"', /;s/\\/&&/;s/, /&\n/g s/.*/echo "&"|sort -bV/e;s/\n//g}' file Match the line beginning [version], print and fetch the next line. Insert the value required at the front the list of versions. Quote the last \ and insert newlines for each version. Using substitution and the e flag to evaluate the RHS of the command, echo the versions into the sort command. The sort command ignores leading spaces -b and sorts in version order -V. Remove all the introduced newlines and print the result.
score: 0
type: Answer

http://stackoverflow.com/comment/138202581
has text: Avoid bash loop!! (Have a look at [my answer](https://stackoverflow.com/a/78391874/1765658):-)
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78391686
score: 0

fifo
tags question: http://stackoverflow.com/q/78403621
tag name: fifo
type: Tag
tags question: http://stackoverflow.com/q/78505293
tags question: http://stackoverflow.com/q/78770272

http://stackoverflow.com/comment/138155034
score: 2
comment on: http://stackoverflow.com/q/78364647
type: QuestionComment
has text: Such a vague question. What constraints do you have? Possible answer: you can leave your computer turned off. [ask]
type: Comment

http://stackoverflow.com/q/78444561
answer count: 2
tagged with: linux
has title: plink.exe "hanging" when used in PowerShell script
has comment: http://stackoverflow.com/comment/138299146
tagged with: bash
has comment: http://stackoverflow.com/comment/138299359
has body: I have a script that removes files from a Linux server using PowerShell. The script suddenly stopped working and now it "hangs" when running this command: $file = "file_path" plink.exe -pw password account@server "rm $file" I don't get any error message neither the script finish.
tagged with: powershell
has comment: http://stackoverflow.com/comment/138300676
upvote count: 1
has answer: http://stackoverflow.com/a/78472701
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138300010
score: 0
type: Question
tagged with: plink
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78488238
has comment: http://stackoverflow.com/comment/138375651
has comment: http://stackoverflow.com/comment/138297450
linked to: http://stackoverflow.com/q/21456402

http://stackoverflow.com/a/78444667
answers question: http://stackoverflow.com/q/78444401
has body: Found it! /usr/sbin/system_profiler -json SPHardwareDataType SPSoftwareDataType SPNetworkDataType SPStorageDataType Thanks for the tip choroba
score: 0
type: Answer

http://stackoverflow.com/comment/138202454
score: 0
comment on: http://stackoverflow.com/a/78390677
type: Comment
has text: No, simply: `./ping.sh <namedFifo | ./pong.sh >namedFifo`, have a look at [my answer](https://stackoverflow.com/a/78391874/1765658)!
type: AnswerComment

http://stackoverflow.com/q/78441672
answer count: 1
downvote count: 1
score: -1
has answer: http://stackoverflow.com/a/78441790
tagged with: bash
has body: I would to combine a principal (bash) script Start.sh with another one that is called by the principal into a single script that I will share with the users to execute. I used this command: shar -M -D -Q -q RA_Test/ | sed '/^exit 0/d' > Easy.sh && echo "RA_Test/Start.sh" >> Easy.sh ; sh Easy.sh , but it didn't work. It shows me this message: No such file or directory for the second script when the principal script reaches the line of calling it. Could you help me with this? Thank you.
favorite count: 0
upvote count: 0
has comment: http://stackoverflow.com/comment/138290745
has title: Combine the main script and secondary script into one executable
type: Question
has comment: http://stackoverflow.com/comment/138290793
type: UnansweredQuestion

http://stackoverflow.com/comment/138149248
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78354041
has text: Is there some reason you don't want to use the normal `fortune` program for this?
type: Comment

http://stackoverflow.com/comment/138201302
has text: @rveerd thank you. I'll adapt this knowledge. I found my solution by removing the echo command, see above.
comment on: http://stackoverflow.com/q/78390602
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138072128
has text: *you set updates as an array, but displayed it as a string. It should only display the first word* I bet OP is actually using zsh, not bash, since that's the default shell on Macs and that's how it expands arrays when just the name is given.
comment on: http://stackoverflow.com/a/78317198
type: Comment
type: AnswerComment
score: 1

powershell
tags question: http://stackoverflow.com/q/78423404
tag name: powershell
tags question: http://stackoverflow.com/q/78311907
tags question: http://stackoverflow.com/q/78433302
tags question: http://stackoverflow.com/q/78444561
type: Tag
tags question: http://stackoverflow.com/q/78336169
tags question: http://stackoverflow.com/q/78469350
tags question: http://stackoverflow.com/q/78684611
tags question: http://stackoverflow.com/q/78671977
tags question: http://stackoverflow.com/q/78758715
tags question: http://stackoverflow.com/q/79099308
tags question: http://stackoverflow.com/q/79213205

http://stackoverflow.com/q/78424828
has answer: http://stackoverflow.com/a/78426600
tagged with: unix
answer count: 3
score: 0
has answer: http://stackoverflow.com/a/78425612
tagged with: shell
has comment: http://stackoverflow.com/comment/138261026
has comment: http://stackoverflow.com/comment/138262394
has comment: http://stackoverflow.com/comment/138261542
has comment: http://stackoverflow.com/comment/138262407
has body: I have below shell script test.sh #!/bin/bash var=$1 echo $var It gives un-expected output unless I pass command line argument value $-123 in single quote #./test.sh $-123 himBH123 #./test.sh '$-123' #$-123 I want to pass special character $-123 to this script. I know usual way is to pass it in single quote like '$-123' or backlash \ e.g. test.sh '$123' OR test.sh \$123 Is there anyway to solve this by any change inside shell script. So that user can pass ./test.sh $-123 without single quote. Reason I am asking is, in real time, we are passing multiple arguments to our script. Out of that one argument will be having password which will have this special character. So just mentioning to pass only particular argument inside single quote '' and rest without any single quote will look strange or there are huge chances that customer might miss to pass single quote.
has comment: http://stackoverflow.com/comment/138264300
has comment: http://stackoverflow.com/comment/138260899
tagged with: bash
type: Question
has title: how to pass special characters to shell script using command line, without single quote or \
has comment: http://stackoverflow.com/comment/138261544
has answer: http://stackoverflow.com/a/78429282
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138261037
has comment: http://stackoverflow.com/comment/138260936

http://stackoverflow.com/comment/138170633
has text: That way all you have to do is make your process exit; as long as systemd is configured to restart the service after such exits, it'll make everything else happen on its own.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78373696

http://stackoverflow.com/a/78366908
has comment: http://stackoverflow.com/comment/138181166
answers question: http://stackoverflow.com/q/78365034
has body: Your expectation is correct, containers may delay the shutdown of a pod when the pod has to shutdown. The sidecar container shuts down immediately when a Kubernetes pod is shut down. As per the official GCP blog by Sandeep Dinesh: “Kubernetes waits for a specified time called the termination grace period. By default, this is 30 seconds. It’s important to note that this happens in parallel to the preStop hook and the SIGTERM signal. Kubernetes does not wait for the preStop hook to finish. If your pod usually takes longer than 30 seconds to shut down, make sure you increase the grace period. You can do that by setting the terminationGracePeriodSeconds option in the Pod YAML.” As per the Medium blog written by Marko Lukša, “ If the sidecar container provides an executable file that waits until the sidecar is ready, you can invoke it in the container’s post-start hook to block the start of the remaining containers in the pod.” Note : As per this open github issue comment, this feature is not stable yet. Kubernetes is still taking feedback from the users. Edit1: Kubernetes will wait for all containers to shutdown for the Termination Grace Period including Sidecar Container. So if the main Java container shuts down in 10 seconds but the sidecar is still in the process of shutting down its processes,Kubernetes will wait until the termination grace period (30seconds) runs out for the sidecar container.Only after the grace period runs out, Kubernetes will forcefully terminate the pod. So Scenario 2 will occur for the situation.
downvote count: 0
has comment: http://stackoverflow.com/comment/138181229
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138188748
score: 1
accepted answer of: http://stackoverflow.com/q/78365034
type: AcceptedAnswer

http://stackoverflow.com/comment/138225307
type: QuestionComment
has text: consider reviewing [how to create a minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) then come back and update the question; in particular, show sample test data (line that does not need changed, lines that do need to be changed (1x20char, 1x21char), the code you've tried, the (wrong) output generated by your code and the (correct) expected result
type: Comment
score: 2
comment on: http://stackoverflow.com/q/78404577

http://stackoverflow.com/comment/138104707
score: 0
type: QuestionComment
type: Comment
has text: @Juan check the [documentation](https://docs.oracle.com/en/java/javase/22/docs/specs/man/java.html) of `java` - search for `-classpath`; or try [How the Java Launcher Finds User Classes](https://docs.oracle.com/javase/8/docs/technotes/tools/findingclasses.html#userclass) -- neither my English nor my Spanish are good enough to explain it, sorry
comment on: http://stackoverflow.com/q/78335326

http://stackoverflow.com/comment/138258058
type: QuestionComment
has text: `.NetworkInterfaces` returns the array, `.NetworkInterfaces[]` returns the elements of the array. Similar question from just a few days ago: https://stackoverflow.com/q/78401284/112968
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78422524

http://stackoverflow.com/a/78389737
has comment: http://stackoverflow.com/comment/138200836
score: 0
answers question: http://stackoverflow.com/q/78389511
type: Answer
has comment: http://stackoverflow.com/comment/138200534
has comment: http://stackoverflow.com/comment/138200003
has body: How about sourcing only lines that contain an equals sign? Using this as file.txt: The cat sat on the mat # A comment [An ini-type thing] a=3 Then use: source &lt;(grep = file.txt) echo $a 3

http://stackoverflow.com/comment/138200216
type: QuestionComment
type: Comment
has text: @choroba How I use this?
score: 0
comment on: http://stackoverflow.com/q/78390318

http://stackoverflow.com/q/78409604
has comment: http://stackoverflow.com/comment/138251104
has comment: http://stackoverflow.com/comment/138242681
tagged with: variables
has title: Can bash warn about usage of a variable?
has body: I'm dealing with a large collection of bash scripts, and need to eliminate the use of a variable which no longer makes sense. The variable used to denote a path, and we're currently setting it to /var/empty. Is there a way to declare it in such a fashion that any references to it would cause bash to print a warning but not fail with an error? Sort of like the __attribute__ ((deprecated)) feature of the modern C/C++ compilers. (Many of our scripts already begin with set -eu.)
type: Question
has comment: http://stackoverflow.com/comment/138236487
tagged with: warnings
has answer: http://stackoverflow.com/a/78412796
answer count: 1
has comment: http://stackoverflow.com/comment/138252863
score: 0
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138252367
has comment: http://stackoverflow.com/comment/138234234
has comment: http://stackoverflow.com/comment/138236502

http://stackoverflow.com/comment/138286736
type: AnswerComment
comment on: http://stackoverflow.com/a/78438177
has text: See the added detail for find in my answer.
type: Comment
score: 0

http://stackoverflow.com/comment/138226237
comment on: http://stackoverflow.com/q/78405034
type: Comment
score: 1
type: QuestionComment
has text: FYI, `==` isn't portable in `[`; the standardized operator is just one `=`. `==` will work as long as your script is only run with extended shells, but it's a better habit to be in to use `[[` when you're writing code that isn't expected to be backwards compatible with baseline POSIX (and thus ash/dash/posh/&c)

http://stackoverflow.com/comment/138088426
has text: I don't see at which point the variable should be evaluated. Imagine that you run a program _foo_ by doing `exec foo '$bar'`. The shell of course does not evaluate the variable `bar`, but it sets up the execution of `foo`, passing to it the string `$bar` in its ARGV[1]. `foo` is then doing with this string what it wants to do. Similarily `echo` is just performing its duty and writes the string to stdout, followed by a newline.
comment on: http://stackoverflow.com/q/78325081
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/a/78390328
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78388395
has comment: http://stackoverflow.com/comment/138221300
score: 1
has comment: http://stackoverflow.com/comment/138201392
upvote count: 1
has comment: http://stackoverflow.com/comment/138233347
has body: It is a possible solution that would prevent multiple executions of a script at the same time. First, you would define a fifo: mkfifo /some/directory/fifo Then, you would create a script that reads the fifo: #!/bin/bash tail -f /some/directory/fifo | while read line ; do process "$line" done When a trap arrives, you execute the following script: #!/bin/bash echo "something from the trap" > /some/directory/fifo The script that posts the message on the fifo is lightweight and would therefore produce less of a spike than the whole processing. The processing is now serialized, so only one processing script runs at a given time. You can also nice the processing to give it even less impact. The echo should be atomic enough to prevent interleaved lines most of the time. Another option is to use a lock to prevent multiple copies to execute at the same time. That would look like: #!/bin/bash me=$$ echo $me>>lockfile lockedby=$(head -1 lockfile) while [ "$me" != "$lockedby" ] ; do sleep 1 echo $me>>lockfile lockedby=$(head -1 lockfile) done process the trap rm -f lockfile
has comment: http://stackoverflow.com/comment/138201681
type: Answer
has comment: http://stackoverflow.com/comment/138201249
has comment: http://stackoverflow.com/comment/138242198
downvote count: 0
answers question: http://stackoverflow.com/q/78388395
has comment: http://stackoverflow.com/comment/138247785

http://stackoverflow.com/q/78388698
downvote count: 1
tagged with: bash
type: Question
type: UnansweredQuestion
has title: `/bin/bash: line 1: heroku: command not found` in docker container
tagged with: heroku-cli
upvote count: 1
tagged with: dockerfile
tagged with: docker
score: 0
answer count: 0
has body: I am trying to use the heroku cli in a bun environment. It works locally, but does not work in the docker container. I tried installing it via npm -g too. I tested it in node:current-bullseye and that works. The problem is, that i need to use a bun image for my server, because it is using bun functionality. This is my Dockerfile: FROM oven/bun:1.0.30-debian # Needed for the node:child_process module, TODO: maybe replace it with a bun specific module in the future RUN apt-get update && apt-get install -y build-essential WORKDIR /app COPY package.json . COPY bun.lockb . RUN bun install --production # Install Heroku CLI RUN curl https://cli-assets.heroku.com/install.sh | sh # Add Heroku CLI to the system path ENV PATH="/usr/local/heroku/bin:${PATH}" RUN . ~/.bashrc # Verify Heroku CLI installation RUN heroku --version COPY src src COPY static static COPY tsconfig.json . ENV NODE_ENV production CMD ["bun", "src/index.ts"] EXPOSE 80 RUN heroku --version throws ERROR: failed to solve: process "/bin/sh -c heroku --version" did not complete successfully: exit code: 127
tagged with: bun
favorite count: 0

http://stackoverflow.com/comment/138106161
type: AnswerComment
score: 0
has text: I tried bash 5.1.16 and `-l` does not change dir. Possibly done in one of your rc files.
type: Comment
comment on: http://stackoverflow.com/a/78336467

http://stackoverflow.com/comment/138241478
comment on: http://stackoverflow.com/a/78411906
type: Comment
type: AnswerComment
has text: i think i figured by just hard code the new attributes in the map `map({"NewAttributes": "NewValue", OptionName: first, Value: last})`
score: 0

http://stackoverflow.com/comment/138430914
score: 0
has text: @Barmar but the list of file is obtained by `ls > list_of_files` which suffers from the same issue
type: Comment
comment on: http://stackoverflow.com/q/78445380
type: QuestionComment

http://stackoverflow.com/comment/138236718
score: 0
comment on: http://stackoverflow.com/a/78404326
type: Comment
type: AnswerComment
has text: Thanks everyone, it is working. I just have one last question.. is there a way to stop traversing the file once this operation has been done (or alternatively once the 10th line has been read)? It would save a looot of time since the file is pretty long.

http://stackoverflow.com/comment/138290543
type: AnswerComment
has text: Hi Renaud, Worked wonderfully. Thanks for the help! Out of curiosity, is it possible to arrange data which is enclosed in double quotes? like for Entity column, if there is data like "E101,E102", awk code is ignoring those double quotes.
comment on: http://stackoverflow.com/a/78441170
score: 0
type: Comment

http://stackoverflow.com/comment/138102221
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78334722
has text: @AnassAbidar: I do not notice such a behavior. Stop **describing** the allegedly non-working code and instead provide an **exact copy** of it. Edit the question to provide a [mre]. Also provide a complete description of the input you provide and the output observed so that another person can exactly reproduce the problem.

http://stackoverflow.com/q/78353316
linked to: http://stackoverflow.com/q/4489139
score: 0
type: Question
tagged with: shell
has comment: http://stackoverflow.com/comment/138134725
duplicate of: http://stackoverflow.com/q/4489139
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138139666
has body: So after being refered to this thread and also this thread linked to in the first thread, I still have no solution to my issue. The Goal To make alterations to both stderr and stdout, but maintain their original printing order. Solutions The one that I started out with and which is refered to the most, is the following. command > >(sed 's/.../.../') 2> >(sed 's/.../.../' >&2) This as it turns out causes some race conditions and various portential asynchronous issues. And the order is not garanteed. From the two thread mentioned above, there are some pipe solutions. { { "$@" | sed 's/.../.../' >&3; } 2>&1 \ | sed 's/.../.../' >&2; } 3>&1 The pipe solution is elegant, but it does not maintain the order of the output. It will print stdout and then stderr. This is what everyone refers to as a synchronos solution, but "storing" stderr while printing stdout before dumping all of stderr at the end, is not really a proper synchronos solution. fnc() { echo "This is GOOD text" echo "This is ERROR text" >&2 echo "This is GOOD text" echo "This is ERROR text" >&2 echo "This is GOOD text" echo "This is ERROR text" >&2 } echo "Running test" { { fnc | sed 's/\(.*\)/ \1/' >&3; } 2>&1 \ | sed 's/\(.*\)/ \1/' >&2; } 3>&1 This will output: Running test This is GOOD text This is GOOD text This is GOOD text This is ERROR text This is ERROR text This is ERROR text A solution like command 2>&1 | cannot possibly be the only way to do this? Is there no way to maintain both streams while keeping the order in sync?
has title: Pipe synchronization
answer count: 0
tagged with: linux
has comment: http://stackoverflow.com/comment/138135900
tagged with: bash
linked to: http://stackoverflow.com/q/4497817
has comment: http://stackoverflow.com/comment/138166773
has comment: http://stackoverflow.com/comment/138139710
has comment: http://stackoverflow.com/comment/138136363
has comment: http://stackoverflow.com/comment/138136800
tagged with: scripting
has comment: http://stackoverflow.com/comment/138135990

icalendar
tag name: icalendar
tags question: http://stackoverflow.com/q/78419985
type: Tag
tags question: http://stackoverflow.com/q/79141310

http://stackoverflow.com/comment/138252961
score: 0
comment on: http://stackoverflow.com/q/78420308
type: QuestionComment
type: Comment
has text: As far as I know, `mysql` is only interactive if and only if its standard input is a terminal.

http://stackoverflow.com/comment/138224178
has text: Shouldn't `read` just block instead of failing when there's no data to be read? Whereas if the other side of the FIFO is closed, you'd need to reopen it -- just retrying the read with a stale descriptor will never recover.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78403776
score: 1

http://stackoverflow.com/comment/138155217
has text: hmm, but I realised your hook wouldn't catch if I have arguments to my script
type: AnswerComment
comment on: http://stackoverflow.com/a/78364736
score: 0
type: Comment

http://stackoverflow.com/comment/138120535
has text: Avoid useless use of `cat`! `grep -E 'DB_NAME|DB_USER' </some-path/wp-config.php`!
type: Comment
comment on: http://stackoverflow.com/a/78343881
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138169319
comment on: http://stackoverflow.com/q/78372639
score: 0
has text: @JohnBollinger Some kind of `sed | sort | sed`: (With *GNU sed*): `sed -e '/^\[version\]/{N;s/\n.*//;r /dev/stdin' -e \} < <(sed <config.file '/^\[version\]/{N;s/.*\n//;s/[[:space:]]*//g;s/,/\n/g;s/\\$//g;s/\n*$/\n'"${value_to_append}"'/;p;};d' | sort -V | xargs | sed 's/^/\o11/;s/$/ \\/;s/ /, /g') -i config.file`
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138241061
has text: a pipeline (`cmd1 | cmd2`) runs in a subshell context - changes are discarded when it finishes so `cd` is also undone. even if you get the `xargs` to run, the change won't stick
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78406644

http://stackoverflow.com/comment/138252927
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78420308
has text: Unquoted `|` is part of the syntax of a shell pipeline, not an argument to the first command. (It's closer to think of both commands as "arguments" to `|` instead.)

output-redirect
tags question: http://stackoverflow.com/q/78406644
tag name: output-redirect
type: Tag

http://stackoverflow.com/comment/138192221
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78385809
has text: BTW, in addition to everything else (in the other comments, the linked duplicate, BashFAQ #48, etc) I'd also add that the very fact that you had to add a backslash before each `$` is bad -- it's an extra step that if left out results in potentially-subtle, potentially-security-impacting bugs that folks need to audit for on a code read. One thing that makes a practice bad is _fragility_ -- ease of doing it wrong by mistake.
score: 0

http://stackoverflow.com/a/78364778
has comment: http://stackoverflow.com/comment/138159916
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138157054
answers question: http://stackoverflow.com/q/78364618
has comment: http://stackoverflow.com/comment/138159928
type: Answer
score: 2
upvote count: 2
has body: On Unix/Linux machines, the nominal files end lines with \n. Where on MacOS they are ending with \r. On windows machines, they use \r\n. Since awk has a default record separator of \n it only finds a single record, which is the full file. To solve your issue, you have to add: awk 'BEGIN{RS=ORS="\r";FS="%"; OFS=","}($1=="Actions"){print $2,$3,$4,$5}' /path/to/file
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78364618
has comment: http://stackoverflow.com/comment/138156628

http://stackoverflow.com/a/78389053
answers question: http://stackoverflow.com/q/78388939
score: -1
has body: For your case, you can create a .lock file which will make sure that the file is being processed and shouldn't be processed again, like below, #!/bin/bash source_dir="source" target_dir="target" while true; do # Check for new JPEGs in the source directory new_files=$(find "$source_dir" -maxdepth 1 -type f -iname "*.jpg" -newer "$source_dir" -print -quit) if [ -n "$new_files" ]; then # Process new files for file in $new_files; do # Check if the file is complete (see the next section) if is_file_complete "$file"; then # Process the file jpeg2txt "$file" > "$target_dir/$(basename "$file" .jpg).txt" # Remove the source file rm "$file" fi done fi # Sleep for a minute before checking again sleep 60 done Ensuring complete file uploads: To ensure that you're only processing complete files, you can use a combination of techniques: a. File locking: Before processing a file, create a lock file (e.g., file.jpg.lock) in the same directory. If the lock file already exists, it means the file is being uploaded or processed, and you should skip it. Once processing is complete, remove the lock file. b. Check for open file handles: You can use the lsof command to check if a file is currently open (i.e., being written to). If it is, skip processing it. c. Check for changes: Before processing a file, record its size and timestamp. After a short delay (e.g., 5 seconds), check if the file size or timestamp has changed. If not, assume it's complete and process it. Here's an example of the is_file_complete function that combines these techniques: is_file_complete() { local file="$1" local lock_file="$file.lock" # Check if the lock file exists if [ -f "$lock_file" ]; then return 1 fi # Create the lock file touch "$lock_file" # Check if the file is open if lsof "$file" > /dev/null; then rm "$lock_file" return 1 fi # Record the file size and timestamp size1=$(stat -c%s "$file") time1=$(stat -c%Y "$file") # Wait for 5 seconds sleep 5 # Check if the file size or timestamp has changed size2=$(sta…
downvote count: 1
type: Answer
upvote count: 0

http://stackoverflow.com/comment/138161934
has text: Are you trying to write a script to run on Unix or Windows? In case it's Unix - ```\``` isn't the directory separator in Unix, `/` is. A file name in Unix can contain ```\```.
type: Comment
comment on: http://stackoverflow.com/q/78366773
score: 1
type: QuestionComment

http://stackoverflow.com/q/78359494
has title: how to use sed or awk to add a space before negative or positive decimal number in linux
tagged with: data-manipulation
has body: I have a file that looks like: GENERSID1RSID2VALUE ENSG00000242220rs2826052rs28260520.20961262553802 ENSG00000242220rs2826052rs798932040.00583452893352463 ENSG00000242220rs2826052rs117256228-0.003012912482066 I want to add space between each value so it should look like: GENE RSID1 RSID2 VALUE ENSG00000242220 rs2826052 rs2826052 0.20961262553802 ENSG00000242220 rs2826052 rs79893204 0.00583452893352463 ENSG00000242220 rs2826052 rs117256228 -0.003012912482066 I used this command for sed and I am able to do this much: sed "s/rs/ &/g" Model_training_chr21_covariances.txt > Model_training_chr21_covariances1.txt sed "s/-0/ &/" Model_training_chr21_covariances1.txt > Model_training_chr21_covariances2.txt ENSG00000242220 rs2826052 rs28260520.20961262553802 ENSG00000242220 rs2826052 rs798932040.00583452893352463 ENSG00000242220 rs2826052 rs117256228 -0.003012912482066 Basically the negative -0.003 is now separated but 0.209 and 0.0058 is not, I am only able to add space before -0. value and not 0.? Is there any way to solve this. Thank you
has answer: http://stackoverflow.com/a/78359503
score: 0
has answer: http://stackoverflow.com/a/78359508
has answer: http://stackoverflow.com/a/78366889
type: Question
accepted answer: http://stackoverflow.com/a/78361002
possible better answer: http://stackoverflow.com/a/78359503
downvote count: 1
has answer: http://stackoverflow.com/a/78361002
tagged with: sed
answer count: 4
tagged with: linux
tagged with: bash
upvote count: 1
favorite count: 0
type: AnsweredQuestion
tagged with: awk

http://stackoverflow.com/comment/138320836
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78433171
has text: `I'm running these in a docker` exactly, so who cares about one process. Docker is running tens of processes just to set up itself. My point being, optimizing single count of processes is rather ineffective. `I need command1 to run in the background, and have the subshell (mainscript running as 48) be replaced by command1` that is a contradiction. I still do not follow, this is exactly what happens in your question.

http://stackoverflow.com/q/78326995
has comment: http://stackoverflow.com/comment/138088369
has body: i am trying to make an if statement in a bash script: file_exists=$(psql -h $DB_SERVER -U $DB_USER -d $DB_DATABASE -t -c "SELECT source_file FROM $DB_SCHEMA.cj_metadata WHERE source_file LIKE '%$base%';" | grep "$base") echo "FILE EXISTS: $file_exists $base.jsonl" # Check if the file exists if "$file_exists" == "$base.jsonl" ; then echo "File $base.jsonl is already saved in DB. Exiting function." echo "SELECT source_file FROM cjdb.cj_metadata WHERE source_file = '$base.jsonl';" return fi the issue i am having is, that it never goes in the if statement, even if both values are the same: FILE EXISTS: LoD2_326625712.jsonl LoD2_326625712.jsonl what am i doing wrong here? Why is this if statement not working? thanks a lot!
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78327018
has title: compare two strings in bash if statement
type: Question
answer count: 1
score: 0
accepted answer: http://stackoverflow.com/a/78327018
tagged with: bash

http://stackoverflow.com/comment/138224194
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78403776
has text: (inotify and similar aren't expected to work here; a named fifo is just a handle, there's no actual filesystem activity associated with reads or writes to/from it).

menu
type: Tag
tags question: http://stackoverflow.com/q/78338291
tag name: menu

http://stackoverflow.com/comment/138265711
comment on: http://stackoverflow.com/a/78427475
type: Comment
type: AnswerComment
score: 0
has text: To also exclude numbers written like `000010`, just prefix `0*` to `[0-9]`

http://stackoverflow.com/comment/138255221
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78406219
has text: it worked, I'm using `#!/bin/bash`, probably doesn't matter

http://stackoverflow.com/a/78400214
upvote count: 3
type: Answer
answers question: http://stackoverflow.com/q/78400075
downvote count: 0
has comment: http://stackoverflow.com/comment/138223895
has comment: http://stackoverflow.com/comment/138223189
has comment: http://stackoverflow.com/comment/138224483
score: 3
has body: With bash 4.3+ we can use nameref's to dynamically create variables (including arrays) on the fly. There are a few ways to slice-n-dice this; for this answer I'll figure out the number of new arrays up front and then as we traverse the dec_array[] array we'll fill in the new arrays. ############# # +1 element (stu_XYZ) to demonstrate when element count != multiple of 3: dec_array=(abc10 def2 ghi333 jkl mno51 pqr_6 stu_XYZ) num_elements="${#dec_array[@]}" elements_per_array=3 ############# # we want ceiling(num_elements / elements_per_array): num_arrays="$(( (num_elements + elements_per_array - 1) / elements_per_array ))" index=0 for ((i=1; i<=num_arrays; i++)) do declare -n _arr="dyn_array_$i" # nameref _arr=() # initialize the new array for ((j=1; j<=elements_per_array; j++)) do (( index >= num_elements)) && break 2 # once we run out of elements we break out of both for loops _arr+=( "${dec_array[index]}" ) # append current element to _arr[] (( index++ )) done done Verifying results and showing how to access the arrays later in your script: for ((i=1; i<=num_arrays; i++)) do declare -n _arr="dyn_array_$i" echo "############### ${!_arr}" typeset -p "${!_arr}" # verify results for ((j=0; j<${#_arr[@]}; j++)) # loop through each new array do echo "dyn_array_$i[$j] = ${_arr[j]}" # "${_arr[j]}" ==> individual element reference done done NOTE: the 2nd echo is printing 4 strings: dyn_array_$i[ + $j + ] = + ${_arr[j]} This generates: ############### dyn_array_1 declare -a dyn_array_1=([0]="abc10" [1]="def2" [2]="ghi333") dyn_array_1[0] = abc10 dyn_array_1[1] = def2 dyn_array_1[2] = ghi333 ############### dyn_array_2 declare -a dyn_array_2=([0]="jkl" [1]="mno51" [2]="pqr_6") dyn_array_2[0] = jkl dyn_array_2[1] = mno51 dyn_array_2[2] = pqr_6 ############### dyn_array_3 declare -a dyn_array_3=([0]="stu_XYZ") dyn_array_3[0] = stu_XYZ

lsf
tag name: lsf
tags question: http://stackoverflow.com/q/78392914
type: Tag

http://stackoverflow.com/comment/138213217
comment on: http://stackoverflow.com/a/78396833
type: AnswerComment
has text: Please don't cram all of your code onto 1 line when posting a question or answer as that just makes it much harder for everyone to be able to read and understand it. I added a legible version of your code to the end of your answer and fixed the syntax error where you were calling `printf` without arguments.
score: 0
type: Comment

http://stackoverflow.com/q/78324242
upvote count: 1
downvote count: 1
tagged with: laravel
has comment: http://stackoverflow.com/comment/138084588
score: 0
type: Question
has title: Calling process inside Laravel always returns: command is not recognized on WIndows
answer count: 0
type: UnansweredQuestion
favorite count: 0
has body: Calling process inside Laravel always returns: command is not recognized on WIndows I am trying to execute a bash file ,, and if i'm specified the full path to bash execute.sh,, then java is not found, monkeyC is not found, etc.. But if i run them manually in command prompt is working
tagged with: bash
tagged with: process

http://stackoverflow.com/comment/138216955
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78396373
has text: Thanks for the hint. Luckily I could reconstruct my code, which was gone from the history after the crash. So I added it to the original question to not get more downvotes.
type: Comment

http://stackoverflow.com/comment/138075113
type: Comment
score: 3
type: QuestionComment
has text: Please paste your script at [shellcheck.net](http://www.shellcheck.net/) and try to implement the recommendations made there.
comment on: http://stackoverflow.com/q/78319248

http://stackoverflow.com/q/78390223
answer count: 1
has answer: http://stackoverflow.com/a/78390580
has title: How to break looped command in Bash, specially in make recipe
accepted answer: http://stackoverflow.com/a/78390580
has comment: http://stackoverflow.com/comment/138208700
has comment: http://stackoverflow.com/comment/138200031
tagged with: bash
has comment: http://stackoverflow.com/comment/138208840
has body: I have this make recipe. run_pipelines: @[ "${filter}" ] || ( filter="."; ) && \ filter=$$(echo "$$filter" | sed -e 's/\./.*/g') && echo $${filter}"<3" && \ echo "\033[1;34m#######Running Pipelines for $${filter}#######\033[0m" && \ find v2/services -type f -regex ".*$${filter}.*.jsonnet" -print0 | \ xargs -r -0 -I {} bash -c 'echo -e "\033[1;32mjsonnet {} \033[0m"; jsonnet {} || exit $$?' .PHONY: run_pipelines It loops through all jsonnet files and run jsonnet command. I want to it fail and stop immediately after a single jsonnet command fails. I have tried few things but nothing working.
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138201729
has comment: http://stackoverflow.com/comment/138208926
has comment: http://stackoverflow.com/comment/138200343
has comment: http://stackoverflow.com/comment/138201788
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138200295
tagged with: makefile

http://stackoverflow.com/comment/140216668
has text: Edit 2025 march: Adding integer mathematical fraction during variable assignment, without *loop*!!
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78464354
score: 0

http://stackoverflow.com/comment/138275517
type: QuestionComment
comment on: http://stackoverflow.com/q/78433104
score: 2
type: Comment
has text: if you add an ampersand to your command `exec` will no longer have effect! Job is run in background. U could get his pid in `$!`!

http://stackoverflow.com/comment/138155073
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78364647
has text: @deceze I'm sure people have been bugged by this problem before, and it's good to protect against unintentional mistakes. If not, why is "set -e" a recommended option in bash scripts? also, why have the "noclobber" option, and alias rm="rm -i"? There are just different levels of safety that people tolerate.
score: 0

http://stackoverflow.com/a/78363130
answers question: http://stackoverflow.com/q/78362867
type: Answer
accepted answer of: http://stackoverflow.com/q/78362867
downvote count: 0
score: 1
type: AcceptedAnswer
upvote count: 1
has body: It feels like you want to enforce PermitRootLogin no every time, so just replace the whole line with your setting. sed -i -Ee 's/^#?(PermitRootLogin)[[:space:]].*/\1 no/' /etc/ssh/sshd_config And don't forget to restart sshd afterwards.

http://stackoverflow.com/a/78374935
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/138174809
has comment: http://stackoverflow.com/comment/138173192
answers question: http://stackoverflow.com/q/78374908
has body: Try splitting the command string into seperate arguments and storing their addresses in memory. Also make sure that the last argument in both the "argv[]" and "envp[]" arrays is a NULL pointer to terminate the array.

http://stackoverflow.com/comment/138196767
score: 0
type: QuestionComment
has text: post the code and not the pictures of code. Users need to be able to replicate the problem quickly . Text allows for quick copy and pictures do not. [how to ask](https://stackoverflow.com/help/how-to-ask)
comment on: http://stackoverflow.com/q/78387338
type: Comment

http://stackoverflow.com/comment/138089879
type: Comment
type: AnswerComment
has text: It's not so much about the locals *surviving* the `exec`, as being copied over *in preperation for* the `exec`. `exec` doesn't know or care that the shell that executes it isn't the shell that started the pipeline.
score: 0
comment on: http://stackoverflow.com/a/78325122

http://stackoverflow.com/comment/138208926
comment on: http://stackoverflow.com/q/78390223
has text: Note that `find`'s predicates `-name`, `-iname`, `-path`, and `-ipath` recognize glob-style patterns. If that is sufficient for your needs then I would use it. The `-regex` predicate is less portable, and more prone to error. For example, writing `.jsonnet` where you probably meant `[.]jsonnet` or `\.jsonnet` (stylistically, I prefer the former).
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138306578
type: QuestionComment
comment on: http://stackoverflow.com/q/78445380
has text: You said it works if you redirect `ls` to the file or create it by hand. How did you create the file if it wasn't one of those two methods?
type: Comment
score: 0

http://stackoverflow.com/comment/138231733
type: Comment
score: 1
type: QuestionComment
has text: What have you tried so far?
comment on: http://stackoverflow.com/q/78404577

http://stackoverflow.com/q/78440831
has answer: http://stackoverflow.com/a/78445474
tagged with: scripting
accepted answer: http://stackoverflow.com/a/78445474
has body: I'm a hobbyist media collector and I recently started a project of mine, being a self-hosted media server with my owned media. I've been doing everything manually for a while but started getting into shell scripting for it to automate a lot of typing. In my script for compressing seasons of series I can't get the script to detect spaces and hyphens on the file name. There's my script: echo "Warning! Please ensure before running this script that the files you'd like to convert are in the following format: 'series_name - SXXEYY' and mind that by running this script you're aware that the uncompressed files are goint to be automatically deleted. If you change your mind press 'Ctrl + C' to cancel or press [ENTER] to continue:" read echo "Enter destination of the input folder:" read input echo "Enter series name(how it's written inside the folder):" read series_name echo "Enter season number:" read season_no echo "Enter number of episodes in the season:" read ep_no echo "Enter destination of the output folder:" read output for i in $(seq -f "%02g" 1 $ep_no); do input_file="$input/"$series_name - S${season_no}E${i}.mkv"" output_file="$output/"$series_name - S${season_no}E${i}.mkv"" ffmpeg -i "$input_file" -c:v libx264 -crf 22 -c:a copy -c:s copy -map 0 "$output_file" done rm -rf "$input" clear echo "Done :)" and here's how I save my files: nesco@nesker:~/uncompressed/Rome$ ls 'Rome - S01E01.mkv' 'Rome - S01E02.mkv' I'm currently extracting the raw files again because last time I ran the script it did not detect and erased the folder
tagged with: bash
has comment: http://stackoverflow.com/comment/138293318
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138289831
answer count: 1
has comment: http://stackoverflow.com/comment/138290583
score: 0
type: Question
tagged with: shell
has title: I can't make my shell script detect spaces and hyphens in file names
has comment: http://stackoverflow.com/comment/138293251

http://stackoverflow.com/comment/138155021
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78364647
has text: `if __name__=="__main__"` clause to not have any top level executable code? *Don't* run as `./script.py` and use `python script.py` instead?
type: Comment

http://stackoverflow.com/comment/138258875
type: Comment
comment on: http://stackoverflow.com/a/78423429
type: AnswerComment
score: 0
has text: @tripleee Should be ok now, your awk with sub is also quite nice.

http://stackoverflow.com/q/78445411
tagged with: bash
has body: Basically I have the next code: unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN export AWS_ACCESS_KEY_ID=$(echo $OUTPUT_ROLE | jq -r '.Credentials''.AccessKeyId');\ export AWS_SECRET_ACCESS_KEY=$(echo $OUTPUT_ROLE | jq -r '.Credentials''.SecretAccessKey');\ export AWS_SESSION_TOKEN=$(echo $OUTPUT_ROLE | jq -r '.Credentials''.SessionToken'); echo "AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID" echo "AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY" echo "AWS_SESSION_TOKEN: $AWS_SESSION_TOKEN" in my bash script it starts with: #!/usr/bin/env sh in the console after the script ends I can see the respective env vars with the correct values, such as: AWS_ACCESS_KEY_ID: <value> AWS_SECRET_ACCESS_KEY: <value> AWS_SESSION_TOKEN: <value> But if I do echo $AWS_ACCESS_KEY_ID for example direct in the console, or any other var y got an empty value, it seems like the variables are not set correctly in the current bash session and I am not able to execute new commands related with these vars. Also doing other tests it seems like unset is not working properly neither, any guidance, I'm not able to figure out what is going on. I am executing the script with ./script.sh also with source script.sh and bash script.sh with same results. I am using the git bash console for windows. I did a short example such as: var="Hello" echo "start:$var" # Delete the var unset var echo "final:$var" var="new" echo "new:$var" the output is after execution ./example1.sh is: start:Hello final: new:new But if I do echo $var direct in the console, after the script execution I got empty using both formats #!/usr/bin/env bash and #!/usr/bin/env shh.
answer count: 0
tagged with: environment-variables
has comment: http://stackoverflow.com/comment/138298535
has comment: http://stackoverflow.com/comment/138301521
has comment: http://stackoverflow.com/comment/138297718
duplicate of: http://stackoverflow.com/q/50341391
score: 0
type: Question
has title: Unset env var not working as expected on bash script
linked to: http://stackoverflow.com/q/50341391
has comment: http://stackoverflow.com/comment/138298542
has comment: http://stackoverflow.com/comment/138297709
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138297735
linked to: http://stackoverflow.com/q/29378566
has comment: http://stackoverflow.com/comment/138297720
tagged with: unset

http://stackoverflow.com/comment/138265743
has text: What does `/bin/bash --version` print?
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
score: 2
type: Comment

http://stackoverflow.com/q/78384843
type: Question
tagged with: authentication
tagged with: scp
has comment: http://stackoverflow.com/comment/138189894
has comment: http://stackoverflow.com/comment/138214132
answer count: 0
tagged with: bash
type: UnansweredQuestion
has body: First things first: I am fairly new to bash scripting, so forgive me any crucial oversights. On a remote machine, I have the following folder structure: base_path/ batch1 model1 folder_a folder_b ... model2 ... batch2 ... Whenever a batch is finished, I want to copy some folders to my local machine. Within each model folder, there are many subfolders (folder_a, folder_b, etc...). To reduce the workload and time needed for file transfer, I only want to copy some folders (lets say folder_a and folder_b) of every model of the batch in question to local. However, as the remote machine requires two-factor authentication, I am prompted with a authentication request for every scp command that I initiate on local. I can not create ssh keys as one part of the 2 factor authentication of the remote machine changes every few seconds. I am looking for a solution, where I specify the batch name when executing a shell script that copies folder_a and folder_b of every model in said batch to local. As folder_a and folder_b have identical names, I need to preserve the folder structure of the remote machine. Furthermore, I need to set it up in a way that I am not prompted with an authentication request for every scp command. My last attempt included a cat <<EOF approach, where I tried to scram all commands that I wanted to execute remotely into a variable and then executing it via one ssh command (I redacted USER and HOST information). Furthermore I need to make directories on local according to the file structure on remote which I only know as soon as I am on the remote machine. #!/bin/bash # Remote server details REMOTE_USER="USER" REMOTE_HOST="HOST" REMOTE_DIRECTORY="/smth/smth/smth/$1" REMOTE_FOLDERS=("folder_a" "folder_b") LOCAL_USERNAME=$(whoami) LOCAL_IP=$(hostname -I | awk '{print $1}') LOCAL_DIRECTORY="$PWD/$1" mkdir -p "$LOCAL_DIRECTORY" remote_commands=$(cat <<EOF cd "$REMOTE_DIRECTORY" folders=\$(ls -d */) for folder in \$folders; do for remote_folder in \${REMOTE_FOLDERS[…
score: 1
has comment: http://stackoverflow.com/comment/138214151
tagged with: remote-access
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138189937
has comment: http://stackoverflow.com/comment/138214214
has title: Copying several folders from remote to local via bash script, only authenticating once
downvote count: 0
has comment: http://stackoverflow.com/comment/138192150

http://stackoverflow.com/comment/138102587
score: 0
type: Comment
type: QuestionComment
has text: @EricPostpischil Read the section about canonical mode in termios(3)
comment on: http://stackoverflow.com/q/78334722

http://stackoverflow.com/comment/138260060
type: Comment
score: 0
has text: The parameter expansion substitution doesn't work with regexes, but patterns. They are far simpler than regexes, so using two steps is the only option. Also note that `_$theID_` doesn't do what you think: it uses the variable `$theID_`, you probably need `_${theID}_` instead.
type: QuestionComment
comment on: http://stackoverflow.com/q/78424358

escaping
type: Tag
tag name: escaping
tags question: http://stackoverflow.com/q/78372273
tags question: http://stackoverflow.com/q/78334264
tags question: http://stackoverflow.com/q/78530810
tags question: http://stackoverflow.com/q/78457170
tags question: http://stackoverflow.com/q/78575374
tags question: http://stackoverflow.com/q/78699233
tags question: http://stackoverflow.com/q/78843200
tags question: http://stackoverflow.com/q/78754984
tags question: http://stackoverflow.com/q/78946362
tags question: http://stackoverflow.com/q/79003588
tags question: http://stackoverflow.com/q/79467011
tags question: http://stackoverflow.com/q/79514950

http://stackoverflow.com/a/78427475
answers question: http://stackoverflow.com/q/78356050
has body: Technically this isn't changing the fifth field: sed 's/,[0-9]\{,2\}\(,[^,]*\)$/,none\1/' sample.csv sed -E 's/,[0-9]{,2}(,[^,]*)$/,none\1/' sample.csv Aternatively: sed 's/^\(\([^,]*,\)\{4\}\)[0-9]\{,2\},/\1none,/' sample.csv sed -E 's/^(([^,]*,){4})[0-9]{,2},/\1none,/' sample.csv
has comment: http://stackoverflow.com/comment/138265711
score: 0
type: Answer

inotify
tag name: inotify
tags question: http://stackoverflow.com/q/78359185
type: Tag
tags question: http://stackoverflow.com/q/78576519
tags question: http://stackoverflow.com/q/78525043

http://stackoverflow.com/comment/138105381
has text: I don't have the absolute path of the script. Its running in CI, but following your line of thinking I can write `C:\msys64\usr\bin\bash -lc "cygpath -u '$PWD'/super_duper_script.sh"` but this merely prints the string `/absolute/path/to/super_duper_script.sh`. I've prefixed `eval` i.e. `C:\msys64\usr\bin\bash -lc "eval ${cygpath -u '$PWD'/super_duper_script.sh}"` but for some reason the script isn't run.
type: Comment
comment on: http://stackoverflow.com/a/78336467
type: AnswerComment
score: 0

http://stackoverflow.com/q/78431133
has answer: http://stackoverflow.com/a/78431428
answer count: 1
score: 0
has title: Error in executing gcloud commands in bash script in crontab
linked to: http://stackoverflow.com/q/22743548
type: Question
tagged with: cron
tagged with: gcloud
has comment: http://stackoverflow.com/comment/138272231
has body: I have written a bash script that uses gcloud command to activate service account and gsutil command to move files to GCS bucket. When I run the script using bash command, it executes well.But when I place the script in crontab , it fails with command not found. ==> NOTE: You are uploading one or more large file(s), which would run significantly faster if you enable parallel composite uploads. This feature can be enabled by editing the "parallel_composite_upload_threshold" value in your .boto configuration file. However, note that if you do this large files will be uploaded as `composite objects <https://cloud.google.com/storage/docs/composite-objects>`_,which means that any user who downloads such objects will need to have a compiled crcmod installed (see "gsutil help crcmod"). This is because without a compiled crcmod, computing checksums on composite objects is so slow that gsutil disables downloads of composite objects. Removing file:///file.csv Operation completed over 1 objects/2.7 GiB. /script.sh: line 691: gcloud: command not found /script.sh: line 693: gsutil: command not found What is the mistake here. How do I correct it
tagged with: shell
linked to: http://stackoverflow.com/q/31037279
has comment: http://stackoverflow.com/comment/138272624
tagged with: bash
type: UnansweredQuestion
tagged with: gsutil
linked to: http://stackoverflow.com/q/28373043

http://stackoverflow.com/comment/138101674
type: Comment
comment on: http://stackoverflow.com/a/78334326
type: AnswerComment
has text: @yvs2014 : Which shell option would cause that the `echo` builtin would **not** interpret \n ?
score: 0

http://stackoverflow.com/a/78436154
answers question: http://stackoverflow.com/q/78434093
score: 0
has body: As markp-fuso said, your lines count=$count+1 is the problem. Written like that, it will simply concatenate the string stored in count with the string +1. Therefore, your count value will be 0+1, then 0+1+1, 0+1+1+1, ... You have 2 choices: you change the while loop with for count in {0..2}, and you don't have to update the count value yourself; you use the arithmetic evaluation in BASH, by replacing your lines count=$count+1 with count=((count+1)), or even better: ((count++)).
type: Answer

http://stackoverflow.com/a/78320597
answers question: http://stackoverflow.com/q/78319238
upvote count: 1
type: Answer
has body: I could not reproduce your issue matching tmux in the script name or anything other than tmux. As suggested by @jhnc using pidof is a better option to match process name, especially with the -q switch that will save both running an extra sub-shell and performing an arithmetic comparison. Here is your script rewritten using POSIX shell grammar and pidof: #!/usr/bin/env sh #set -x # Uncomment for debug if [ -n "$TMUX" ]; then printf '%s\n' 'We are inside tmux' >&2 exit 1 fi if pidof -q tmux; then printf '%s\n' 'joining tmux session' tmux a exit 0 fi
downvote count: 0
score: 1

http://stackoverflow.com/q/78336169
answer count: 2
tagged with: pwd
tagged with: bash
tagged with: powershell
possible better answer: http://stackoverflow.com/a/78336467
has comment: http://stackoverflow.com/comment/138105847
type: AnsweredQuestion
has body: I have a Powershell session that creates bash session to run a script like so C:\msys64\usr\bin\bash -lc './super_duper_script.sh Where the super_duper_script.sh is in the cwd of Powershell session. The unfortunately when the bash session starts its cwd is '/home/username' not the cwd of the Powershell session. Here's what I have managed so far: C:\msys64\usr\bin\bash -lc "cygpath -u '$PWD'" echos the cwd of the Powershell session. The problem now is that setting the cwd of the bash session is proving to be a challenge. Here's are just two of my failed attempts: C:\msys64\usr\bin\bash -lc "env --chdir=(cygpath -u '$PWD') C:\msys64\usr\bin\bash -lc "cd {cygpath -u '$PWD'}" Setting the .bashrc is not an option, because this stuff is running in CI, besides various bash scripts can be invoked in different directories.
score: 0
has comment: http://stackoverflow.com/comment/138105981
type: Question
has answer: http://stackoverflow.com/a/78337048
has comment: http://stackoverflow.com/comment/138112381
has answer: http://stackoverflow.com/a/78336467
has comment: http://stackoverflow.com/comment/138105732
accepted answer: http://stackoverflow.com/a/78337048
has title: Keep bash cwd the same directory as cwd of Powershell that spawned it

http://stackoverflow.com/a/78420842
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78419985
has comment: http://stackoverflow.com/comment/138255787
has comment: http://stackoverflow.com/comment/138260506
downvote count: 0
type: Answer
has body: The following update should solve your requirement: # Define the ICS URL of your calendar ics_url="your_url" # Get today's date in YYYYMMDD format today=$(date +%Y%m%d) # Use curl to fetch the ICS data and process it curl -s "$ics_url" | awk -v date="$today" ' BEGIN { inEvent = 0; matched = 0; eventBuffer = ""; } /BEGIN:VEVENT/ { inEvent = 1; matched = 0; eventBuffer = ""; # Reset event buffer at the beginning of a new event } /END:VEVENT/ { if (matched) { print eventBuffer; # Print the event buffer if matched print ""; # Print an empty line after each event } inEvent = 0; } /^DTSTART:/ { if (index($0, date) > 0) { matched = 1; } # Replace "DTSTART" with "start" t = mktime(substr($0,9,4) " " substr($0,13,2) " " substr($0,15,2) " " substr($0,18,2) " " substr($0,20,2) " " substr($0,22,2)) line = "start:" strftime("%Y:%m:%d:%H:%M:%S",t) eventBuffer = eventBuffer "\nstart:" line; } /^DTEND:/ { # Replace "DTEND" with "end" t = mktime(substr($0,7,4) " " substr($0,11,2) " " substr($0,13,2) " " substr($0,16,2) " " substr($0,18,2) " " substr($0,20,2)) line = strftime("%Y:%m:%d:%H:%M:%S",t) eventBuffer = eventBuffer "\nend:" line; } /^SUMMARY|DESCRIPTION/ { eventBuffer = eventBuffer "\n" $0; } ' Testing with the following input: $ cat input.txt BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Example Corp.//iCal4j 1.0//EN CALSCALE:GREGORIAN BEGIN:VEVENT DTSTAMP:20240502T120000Z DTSTART:20240505T090000Z DTEND:20240505T100000Z SUMMARY:Team Meeting DESCRIPTION:Weekly team meeting to discuss progress and upcoming tasks. LOCATION:Conference Room UID:1234567890 SEQUENCE:0 END:VEVENT BEGIN:VEVENT DTSTAMP:20240502T120000Z DTSTART:20240510T140000Z DTEND:20240510T160000Z SUMMARY:Client Presentation DESCRIPTION:Present our latest project updates to the client. LOCATION:Client's Office UID:0987654321 SEQUENCE:0 END:VEVENT END:VCALENDAR The output will be: start:start:2024:05:05:09:00:00 end:2024:05:05:10:00:00 SUMMARY:Team Meeting DESCRIPTION:Weekly team meeting to discuss progress and upcoming tas…
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/138260544
answers question: http://stackoverflow.com/q/78419985
has comment: http://stackoverflow.com/comment/138254588
has comment: http://stackoverflow.com/comment/138255017

http://stackoverflow.com/q/78423157
has title: Reading Json file and calling a post api with each email and token
tagged with: http://stackoverflow.com/tag/json
score: 0
type: Question
answer count: 0
has body: I have a outpout.json file which contains email and token as a key value pair and i want to call a post api for each of these email in a shell script but it is calling the api only once for the first email and token not the next one { "md.arbaaz@deeplogictech.com":"9RN_5atv9F1e0zCKrkjRHQP1IYu1Wknz", "ajay.bhatheja@deeplogictech.com":"2Is864BMgiocY0gveVZZSelB4YT5fP-G" } this is my shell script #!/bin/bash send_email() { local email=$1 local token=$2 echo "Sending email to: $email, Token: $token" # Add logging # Call API using curl with request body only response=$(curl -s -X POST -H "Content-Type: application/json" -d "{\"email\": \"$email\", \"token\": \"$token\"}" http://127.0.0.1:8081/emailIssues) echo "API Response: $response" # Log API response } # Check if output.json exists in the same directory if [ ! -f "output.json" ]; then echo "Error: output.json file not found" exit 1 fi # Read and process JSON data json=$(cat output.json) echo "JSON Data: $json" # Log JSON data echo "$json" | jq -r 'to_entries[] | "\(.value) \(.key)"' | while read -r token email; do echo "Processing: Email: $email, Token: $token" # Log processing of each email and token # Call send_email function with email and token send_email "$email" "$token" done i was expecting that for each email and token it will call the api
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138258107
has comment: http://stackoverflow.com/comment/138258653
linked to: http://stackoverflow.com/q/13763942
linked to: http://stackoverflow.com/q/4651437
has comment: http://stackoverflow.com/comment/138258048
tagged with: bash

http://stackoverflow.com/q/78385269
has body: I have two files which look apparently identical (link here). I don't seem to find any difference between the two. However, on running source env-setup.sh, which is one of the files, bash runs happily. But running source env-setup-ioannis.sh, which is the other file, bash complains with the following error message: : command not found. Can someone please help me find out the issue? I tried source env-setup.sh on one of the files and source env-setup-ioannis.sh with the other. I expected both of them to run fine. However, the latter showed the following error : command not found and also broke the environment variables.
score: 0
type: Question
duplicate of: http://stackoverflow.com/q/39527571
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/39527571
has comment: http://stackoverflow.com/comment/138192518
has comment: http://stackoverflow.com/comment/138191264
answer count: 0
tagged with: linux
tagged with: bash
has title: `source` in bash breaks with one of the apparently identical files
has comment: http://stackoverflow.com/comment/138190590
has comment: http://stackoverflow.com/comment/138190591

http://stackoverflow.com/a/78378158
downvote count: 0
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78372273
has body: Use tput as others have suggested but also reset the color after using it, e.g.: $ c_cyan=$(tput setf 3) $ c_reset=$(tput sgr0) $ printf "\\${c_cyan}hello${c_reset}\n" \hello $ printf "I said ${c_cyan}hello${c_reset} to them\n" I said hello to them Also, don't use all upper case names for non-exported variables, see Correct Bash and shell script variable capitalization.

http://stackoverflow.com/q/78375007
accepted answer: http://stackoverflow.com/a/78375051
upvote count: 1
favorite count: 0
possible better answer: http://stackoverflow.com/a/78375055
has comment: http://stackoverflow.com/comment/138173309
downvote count: 0
score: 1
tagged with: bash
type: AnsweredQuestion
has title: In bash, how to store stdin and stdout file handle in variable?
has answer: http://stackoverflow.com/a/78375055
answer count: 2
has answer: http://stackoverflow.com/a/78375051
has body: I have the following bash script: STDIN='&amp;0' if some-condition; then STDIN=some-filename fi run-command &lt;${STDIN} But that errors with &amp;0: No such file or directory. Similarly for STDOUT. I've tried using eval but haven't gotten that to work, either. What needs to be done to get this to work?
has comment: http://stackoverflow.com/comment/138173258
type: Question

http://stackoverflow.com/a/78421472
upvote count: 0
has comment: http://stackoverflow.com/comment/138255110
has comment: http://stackoverflow.com/comment/138254936
downvote count: 1
score: -1
has comment: http://stackoverflow.com/comment/138255034
has comment: http://stackoverflow.com/comment/138274951
type: Answer
has comment: http://stackoverflow.com/comment/138255184
has comment: http://stackoverflow.com/comment/138256331
has body: I'd try this and check the output. It's probably some path issues. kustomize: stage: kustomize script: - pwd # Print current working directory - ls -la # List all files in the current directory - echo "Running test 1..." - chmod +x refresh.sh - ./refresh.sh
answers question: http://stackoverflow.com/q/78421398

http://stackoverflow.com/comment/138173192
has text: Splitting the command string is wrong in the `bash -c` case. The entire command string needs to be a single argument, any arguments after it are treated as positional parameters.
score: 2
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78374935

http://stackoverflow.com/q/78437542
has title: Bash array has many elements and just one at the same time
tagged with: bash
has comment: http://stackoverflow.com/comment/138293681
type: Question
has comment: http://stackoverflow.com/comment/138283396
has comment: http://stackoverflow.com/comment/138283440
has comment: http://stackoverflow.com/comment/138283489
score: 0
has comment: http://stackoverflow.com/comment/138283461
answer count: 0
duplicate of: http://stackoverflow.com/q/64082460
type: UnansweredQuestion
has body: I am trying to get a list of all collections in Mongo database. It seems successful at first, but the contents of allCollections variable seemed weird to me, because I couldn't get elements separately allCollections=$(mongosh "${sourceConnectionString}" --quiet --eval "db.getCollectionNames().forEach(function(name) { print(name);})") root@ce679cd166d0:/app# echo ${allCollections[1]} root@ce679cd166d0:/app# echo ${#mapped[@]} 1 That's why I decided to reassign it to another array, which should be normal, like that mapped=() while read -r c do echo $c echo "another one" mapped+="${c}" done <<< "${allCollections}" echo ${#mapped[@]} the output root@ce679cd166d0: GameSessionBonuses another one TurnoversByTransactionsHourly another one InteractionTokens another one TurnoversAllowedGameTypes another one AuthTokens another one ..... 1 So nothing changed. The loop says that there are multiple separate elements, but somehow it's still just one element. I have no idea what's actually inside mapped or allCollections and how to properly check it.
linked to: http://stackoverflow.com/q/64082460
has comment: http://stackoverflow.com/comment/138283449
has comment: http://stackoverflow.com/comment/138283456
has comment: http://stackoverflow.com/comment/138283463
has comment: http://stackoverflow.com/comment/138283471

http://stackoverflow.com/q/78386230
has comment: http://stackoverflow.com/comment/138192489
has comment: http://stackoverflow.com/comment/138192862
tagged with: bash
has comment: http://stackoverflow.com/comment/138192832
score: 1
favorite count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78386431
possible better answer: http://stackoverflow.com/a/78386716
upvote count: 2
answer count: 2
has title: How to concatenate files included in files containing names of files
has comment: http://stackoverflow.com/comment/138192602
type: Question
has answer: http://stackoverflow.com/a/78386431
has answer: http://stackoverflow.com/a/78386716
has comment: http://stackoverflow.com/comment/138192422
downvote count: 1
has body: I have 4 txt files containing an ordered collection of names of files e.g file L001 contains file1_L001 file2_L001 file3_L001 .. and so on (48 files), each in a new lane file L002 contains file1_L002 file2_L002 file3_L002 .. and so on (48 files as well) file L003 contains file1_L003 file2_L003 file3_L003 .. and so on (48 files as well) file L004 contains file1_L004 file2_L004 file3_L004 .. and son on with up to 48 file names What I want is to concatenate, creating new files using bash, something like cat file1_L001 file1_L002 file1_L003 file1_L004 &gt; All_file1.file cat file2_L001 file2_L002 file2_L003 file2_L004 &gt; All_file2.file ... cat file48_L001 file48_L002 file48_L003 file48_L004 &gt; All_file48.file That is, to repeat the same process with file2_L001 file2_L002 file2_L003 file2_L004 and so on up to file48 My problem is that I unknow how to call a specific file in order included into the file of names. I can get those names with a cat command, but I don't know how to select one determined of these files to apply, for example, a nested series of for
has comment: http://stackoverflow.com/comment/138192744

http://stackoverflow.com/comment/138072188
has text: Well, as I wrote: i zried Total Commander and it deleted.the file perfectly.
comment on: http://stackoverflow.com/q/78315911
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78326945
type: UnansweredQuestion
score: -2
has answer: http://stackoverflow.com/a/78327512
upvote count: 0
tagged with: bed
tagged with: bash
has title: BASH: How to calculate values between two fields in csv/tsv and return output?
has comment: http://stackoverflow.com/comment/138088316
tagged with: calculation
answer count: 1
favorite count: 0
has body: I was trying to do some operation over 6th 7th column of a large bed-like file, this is the first 100 rows of the file. head -n 100 Sample1.bed chr1 10000 10150 150 0.506667 0.0503 0.0639 chr1 10002 10144 142 0.507042 0.0308 0.0639 chr1 10003 10139 136 0.507353 0.0246 0.0639 chr1 10008 10156 148 0.513514 0.0375 0.0639 chr1 10012 10138 126 0.500000 0.0156 0.0639 chr1 10013 10194 181 0.497238 0.0737 0.0599 chr1 10016 10169 153 0.509804 0.0503 0.0639 chr1 10031 10161 130 0.507692 0.0205 0.0639 chr1 10038 10211 173 0.502890 0.0968 0.0639 chr1 10044 10179 135 0.511111 0.0246 0.0639 chr1 10071 10145 74 0.500000 0.0001 0.0639 chr1 10071 10240 169 0.508876 0.1022 0.0639 chr1 11178 11334 156 0.679487 0.0704 0.0032 chr1 11561 11733 172 0.418605 0.0968 0.0998 chr1 11597 11776 179 0.435754 0.0867 0.0839 chr1 11641 11796 155 0.432258 0.0704 0.0839 chr1 12218 12376 158 0.651899 0.0704 0.0051 chr1 12368 12551 183 0.617486 0.0737 0.0114 chr1 12486 12658 172 0.645349 0.0968 0.0051 chr1 12770 12952 182 0.582418 0.0737 0.0156 chr1 12813 12943 130 0.561538 0.0205 0.0240 chr1 12870 13043 173 0.583815 0.0968 0.0156 chr1 12882 13089 207 0.599034 0.0214 0.0156 chr1 13378 13569 191 0.581152 0.0463 0.0156 chr1 13381 13592 211 0.578199 0.0160 0.0240 chr1 13435 13580 145 0.593103 0.0375 0.0156 chr1 13515 13688 173 0.578035 0.0968 0.0240 chr1 13550 13705 155 0.574194 0.0704 0.0240 chr1 13808 13944 136 0.514706 0.0246 0.0639 chr1 14004 14174 170 0.529412 0.0968 0.0507 chr1 14231 14393 162 0.580247 0.0884 0.0156 chr1 14249 14385 136 0.588235 0.0246 0.0156 chr1 14262 14432 170 0.523529 0.0968 0.0507 chr1 14267 14409 142 0.549296 0.0308 0.0358 chr1 14272 14385 113 0.584071 0.0070 0.0156 chr1 14288 14451 163 0.527607 0.0884 0.0507 chr1 14291 14425 134 0.522388 0.0205 0.0507 chr1 14316 14481 165 0.509091 0.1022 0.0639 chr1 14556 14768 212 0.622642 0.0160 0.0076 chr1 14635 14830 195 0.656410 0.0365 0.0051 chr1 14654 14795 141 0.673759 0.0308 0.0032 chr1 14786 14931 145 0.579310 0.0375 0.0240 chr1 1507…
tagged with: genomics
downvote count: 2
type: Question

http://stackoverflow.com/q/78328611
has comment: http://stackoverflow.com/comment/138091857
tagged with: sqlplus
tagged with: ssh
has comment: http://stackoverflow.com/comment/138100965
tagged with: bash
has comment: http://stackoverflow.com/comment/138098239
type: Question
linked to: http://stackoverflow.com/q/8643403
has comment: http://stackoverflow.com/comment/138091765
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138100178
has comment: http://stackoverflow.com/comment/138098637
answer count: 0
has body: I can't seem to be able to write my script correctly. problem is I don't realy understand how pipes or bash work yet. I have a script to execute on multiple servers an get the result of each back to my machine then format then etc... declare -ra serveurs=("a" "b" ... "x" "y" "z") declare -p result=() echo ${serveurs[@]} # setting up a assynchonous task commande() { ssh user@$1 sqlplus -s -l "$dbconnect" localfileToExecuteOnDistServ.sql } #send tasks to remote servers while read -r line; do #should get all servers responces result+=("$line") done < <(for s in ${serveurs[@]}; do commande "$s" & done) #wait for all subroutines wait echo ${result[@]} I can't send the query from my machine to sqlpus. No such file EDIT : user@srv:~/Path$ ./script.sh bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found bash: sqlplus : command not found
score: 0
has title: sqlplus request on multiple servers
has comment: http://stackoverflow.com/comment/138094025
has comment: http://stackoverflow.com/comment/138091700

http://stackoverflow.com/q/78385603
accepted answer: http://stackoverflow.com/a/78387161
type: Question
has comment: http://stackoverflow.com/comment/138193947
has comment: http://stackoverflow.com/comment/138193603
has body: How can I cut out a title from an image along the border of the lower red background (examples below)? I am planning a batch process, i.e. with hundreds of images with different titles (both with different widths and heights - only their location is constant). I'm using bash. Example 1: Example 2: Desired Output:
has comment: http://stackoverflow.com/comment/138191531
has title: Crop the title (text) on the image to a certain border (by color)
answer count: 1
tagged with: imagemagick
tagged with: ocr
score: 0
tagged with: image-processing
tagged with: bash
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78387161
has comment: http://stackoverflow.com/comment/138191382
tagged with: crop

http://stackoverflow.com/a/78391874
upvote count: 3
downvote count: 0
type: Answer
has body: This is a common task for posix shell!! As I daily repeat: shell is more an execution environment, than a programming language! Intended for running other tasks and make them communicate with each others and/or log thems! I need to connect the p1 output to p2 input, and the p2 output to p1 input For this, I wrote two little programs that use STDERR for showing logs and communique by a simple ping-pong protocol by using STDIN/STDOUT: ping.sh: send ping, wait for an answer, then log waited time. #!/bin/bash while :;do sleep 1 echo ping ping=${EPOCHREALTIME/.} read -r answ elap=00000$(( ${EPOCHREALTIME/.} - ping )) printf >&2 '%.5f %s\n' ${elap::-6}.${elap: -6} "$answ" done pong.sh: wait for a request, send pong as answer, then log waited time. #!/bin/bash while swait=${EPOCHREALTIME/.} read -r req; do echo pong elap=00000$(( ${EPOCHREALTIME/.} - swait )) printf >&2 '%.5f %s\n' ${elap::-6}.${elap: -6} "$req" done Then now: 1. By using named fifo (shell POSIX compatible): This work same by using and POSIX compatible shell, tested unded bash, dash, busybox and ksh. mkfifo namedFifo ./ping.sh < namedFifo | ./pong.sh > namedFifo 0.00009 pong 1.00146 ping 0.00005 pong 1.00115 ping 0.00030 pong 1.00136 ping 0.00042 pong 1.00166 ping 0.00006 pong ^C ... Which could be 1. run in both way, 2. presented differently: ./pong.sh < namedFifo | > namedFifo ./ping.sh 2. By using coproc (bash only): coproc ./pong.sh && ./ping.sh <&${COPROC[0]} >&${COPROC[1]} ( Care, there are two ampersands: &&!! ) [1] 3872333 1.00060 ping 0.00030 pong 1.00189 ping 0.00009 pong 1.00210 ping 0.00007 pong 1.00121 ping 0.00019 pong 1.00156 ping 0.00006 pong 1.00121 ping 0.00006 pong ^C Then, don't miss to close coproc's I/O in order to terminate them: exec {COPROC[1]}>&- exec {COPROC[0]}<&- [1]+ Done coproc COPROC ./pong.sh Same in the other way: coproc ./ping.sh && ./pong.sh <&${COPROC[0]} >&${COPROC[1]} [1] 3895594 1.00140 ping 0.00008 pong 1.00179 ping 0.00006 pong 1.00101 ping 0.00004 pong ^C exec {CO…
answers question: http://stackoverflow.com/q/78390318
score: 3

http://stackoverflow.com/comment/138296668
has text: Always quote your variables: `"file_name_$qtr.csv"`
comment on: http://stackoverflow.com/q/78444871
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138131476
has text: I'm not 100% sure. It runs everything inside the bash window. Is the expectation for it to spawn a new process and hence completely new cmd window? It is not doing that.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78344012

http://stackoverflow.com/comment/138107591
has text: I forgot to capitalize the Class, thank you!
comment on: http://stackoverflow.com/a/78335433
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78389511
type: UnansweredQuestion
has body: I need to get a value from a file where it is defined as variable1=value1. So if I do cat file | grep variable1 I get variable1=value1. I would like to do this inside a script so that variable1 is directly assigned value1. I thought this might do it: cat file | grep variable1 | sh but it doesn't. I know the same can be achieved by additional string processing and declaring variable1 explicitly inside the script, but my idea seems so elegant if I can get it to work. :) And I am 99% sure it's possible, I just can't find the missing bit. Later edit: I should have mentioned this. The file I am trying to parse is not a script and doesn't have only such declarations. It contains all kinds of data with several syntaxes inside. It's similar to an INI/CONFIG file.
tagged with: sh
has answer: http://stackoverflow.com/a/78390608
score: 0
answer count: 4
tagged with: shell
has title: How to use the output of a command as another command (nor an argument of one) in a shell script
has comment: http://stackoverflow.com/comment/138200092
has comment: http://stackoverflow.com/comment/138198692
has answer: http://stackoverflow.com/a/78389737
has answer: http://stackoverflow.com/a/78389556
has comment: http://stackoverflow.com/comment/138198263
has answer: http://stackoverflow.com/a/78390054
tagged with: scripting
has comment: http://stackoverflow.com/comment/138198393
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138198682

http://stackoverflow.com/comment/138180465
score: 0
comment on: http://stackoverflow.com/q/78373696
type: QuestionComment
type: Comment
has text: Your systemd service file can invoke a shim that's responsible for finding the latest correctly-signed downloaded file and then `exec`ing it. (Important to use `exec` so the process your script replaces itself with takes on the script's own PID, so the MainPID that systemd assigned is inherited by the real process when the shim hands over control).

http://stackoverflow.com/q/78428595
has comment: http://stackoverflow.com/comment/138267559
upvote count: 2
has body: Can somebody please help me understand why the second command works as expect, but the first doesn't. # first SESSION=$(curl http://172.21.0.4:4444/status 2>&1 | grep sessionId | cut -d ":" -f2 | tr -d "\r\n\","); echo $SESSION; curl -X DELETE http://127.0.0.1:4444/session/$SESSION # second SESSION=$(curl http://172.21.0.4:4444/status 2>&1 | grep sessionId | cut -d ":" -f2 | tr -d "\r\n\","); echo $SESSION; curl -X DELETE http://127.0.0.1:4444/session/$(echo $SESSION) First command results in 1f7838f7-c2ff-4d5a-90c1-e3ad89e74159 { "value": { "message": "Unable to find session with ID: \nBuild info: version: '4.19.1', revision: 'abe0ee07dc'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.5.0-27-generic', java.version: '17.0.10'\nDriver info: driver.version: unknown", "stacktrace": .. .. "error": "invalid session id" } }curl: (6) Could not resolve host: 1f7838f7-c2ff-4d5a-90c1-e3ad89e74159 The second command works as expected 1f7838f7-c2ff-4d5a-90c1-e3ad89e74159 {"value":null} I'm not sure if relevant, but this is via ssh on a remote machine. Thank you. EDIT: what I have tried. spinning up a local http server with python. Its a different environment but version #1 seems to work just fine. $ python3 -m http.server 9000 Serving HTTP on 0.0.0.0 port 9000 (http://0.0.0.0:9000/) ... .. .. SESSION=bc8bcf9f-a901-440b-af9a-2da8a7fe6f2e .. $ echo $SESSION bc8bcf9f-a901-440b-af9a-2da8a7fe6f2e .. $ curl localhost:9000/test/$SESSION Error response Error response Error code: 404 Message: File not found. Error code explanation: 404 - Nothing matches the given URI. .. # python http server log 127.0.0.1 - - [04/May/2024 12:20:38] "GET /test/bc8bcf9f-a901-440b-af9a-2da8a7fe6f2e HTTP/1.1" 404 - EDIT2: output from curl http://172.21.0.4:4444/status added below. Command #2 already gets me what I need, this is just me being curious as to what the difference might be. Without the stderr redirection I get this $ curl http://10.10.14.70:8000/status | grep sessionID % Total %…
accepted answer: http://stackoverflow.com/a/78429959
has comment: http://stackoverflow.com/comment/138268316
downvote count: 0
linked to: http://stackoverflow.com/q/1955505
has comment: http://stackoverflow.com/comment/138269093
has comment: http://stackoverflow.com/comment/138268996
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78429959
has comment: http://stackoverflow.com/comment/138269099
score: 2
tagged with: scripting
duplicate of: http://stackoverflow.com/q/1955505
has comment: http://stackoverflow.com/comment/138268064
tagged with: curl
has comment: http://stackoverflow.com/comment/138269932
tagged with: bash
has comment: http://stackoverflow.com/comment/138269150
has comment: http://stackoverflow.com/comment/138267523
type: Question
has title: BASH variables and curl
answer count: 1
has comment: http://stackoverflow.com/comment/138269090

http://stackoverflow.com/comment/138271669
score: 0
has text: Thanks @choroba for picking up the error in my env variable. But as you can see from the other answers, it is possible to do it in a single regex statement.
type: QuestionComment
comment on: http://stackoverflow.com/q/78424358
type: Comment

http://stackoverflow.com/tag/tar
tag name: tar
tags question: http://stackoverflow.com/q/78369669
type: Tag
tags question: http://stackoverflow.com/q/78466816
tags question: http://stackoverflow.com/q/78677918
tags question: http://stackoverflow.com/q/78778545
tags question: http://stackoverflow.com/q/79118101

http://stackoverflow.com/q/78444871
has comment: http://stackoverflow.com/comment/138297067
accepted answer: http://stackoverflow.com/a/78480194
has comment: http://stackoverflow.com/comment/138296879
score: -1
tagged with: shell
has comment: http://stackoverflow.com/comment/138296628
has comment: http://stackoverflow.com/comment/138296668
has comment: http://stackoverflow.com/comment/138296870
answer count: 1
favorite count: 0
type: AnsweredQuestion
downvote count: 1
has comment: http://stackoverflow.com/comment/138296896
has comment: http://stackoverflow.com/comment/138307586
has comment: http://stackoverflow.com/comment/138298146
has comment: http://stackoverflow.com/comment/138298156
tagged with: hive
tagged with: bash
has comment: http://stackoverflow.com/comment/138317491
type: Question
upvote count: 0
has body: I'm running a script that will be automated to run every quarter so I would like to include the dynamic date variable in the name of the csv output at the end of this script. Here is the relevant snippet, it works fine without the $qtr in the file name, but when I add it to the filename, the resulting .csv is unreadable. #!/bin/bash qtr=$(date -d "-2 month" +%Y)Q$(( ($(date -d "-2 month" +%-m)-1)/3+1 )) hiveconnector -e "set hive.cli.print.header=true;select * from hivetable;" | tr "\\t" "," >file_name_$qtr.csv Edit: I've tried the following changes to file_name_$qtr.csv: file_name_${qtr}.csv, file_name_"${qtr}".csv, $"file_name_${qtr}.csv" Edit 2: It looks like a line break is getting added between the $qtr var and the plain text, even though an echo of file_name_"${qtr}".csv does not show the line break-- Error message: Can't create file 'C:\...\file_name_2024Q1 .csv' The filename, directory name, or volume label syntax is incorrect. Edit 3 - Solution: I was able to solve by Unix EOL Conversion and calling a new variable that held the whole path/filename.
has comment: http://stackoverflow.com/comment/138296675
has comment: http://stackoverflow.com/comment/138306458
has answer: http://stackoverflow.com/a/78480194
has title: How to include a shell variable in the file name of a csv from hive

http://stackoverflow.com/comment/138072059
comment on: http://stackoverflow.com/q/78317514
score: 1
type: QuestionComment
has text: Please don't include line numbers -- a good [mre] is code we can copy, paste, and run ourselves to see the same problem (and thus test our answers) without needing other changes.
type: Comment

http://stackoverflow.com/comment/138178387
comment on: http://stackoverflow.com/q/78372273
has text: Are you asking how to print a ```\``` in front of `${C_CYAN}` or something else?
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138255193
score: 0
comment on: http://stackoverflow.com/q/78420308
type: QuestionComment
has text: @BillKarwin, `SELECT … INTO OUTFILE` will output the file to the remote machine, not the local one. Refer to https://stackoverflow.com/a/2970539/807037
type: Comment

http://stackoverflow.com/comment/138286155
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78438850
type: QuestionComment
has text: Apologies if this is a "did you turn it off and back on again" suggestion: Likely you'll want to back out and re-enter your shell to pick up the new config. You can also source the files without having to back out so those environment variables are picked up immediately like `source ~/.bashrc` or `source ~/.bash_profile`. Essentially your current shell doesn't know about those new environment variables since it only runs `.bashrc` or `.bash_profile` once when it starts up.

http://stackoverflow.com/q/78416125
upvote count: 1
has body: I'm new to docker and I'm having an issue with the ENTRYPOINT argument in the dockerfile. I'm working on a project called F1Tenth and I am using their premade docker image. I am running it on a jetson nano and I am trying to figure out how to source these two files (/opt/ros/foxy/setup.bash and install/local_setup.bash) for ROS2. After some research I figured the best thing to try was to run a script that sources these and have that script run using ENTRYPOINT. I tried A BUNCH of things but nothing is working, when the container starts I still need to manually source the files in the terminal. I need this to work because the jetson is going to be attached to an RC car and it needs to be headless and no ssh. Here is my entrypoint.sh (its inside of the docker image dir) #!/bin/bash source /opt/ors/foxy/setup.bash source install/local_setup.bash exec "$@" Here is my DockerFile: FROM ros:foxy SHELL \["/bin/bash", "-c"\] # dependencies RUN apt-get update --fix-missing && \ apt-get install -y git \ nano \ vim \ python3-pip \ libeigen3-dev \ tmux \ ros-foxy-rviz2 RUN apt-get -y dist-upgrade RUN pip3 install transforms3d # f1tenth gym RUN git clone https://github.com/f1tenth/f1tenth_gym RUN cd f1tenth_gym && \ pip3 install -e . # ros2 gym bridge RUN mkdir -p sim_ws/src/f1tenth_gym_ros COPY . /sim_ws/src/f1tenth_gym_ros RUN source /opt/ros/foxy/setup.bash && \ cd sim_ws/ && \ apt-get update --fix-missing && \ rosdep install -i --from-path src --rosdistro foxy -y && \ colcon build WORKDIR '/sim_ws' COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["./entrypoint.sh"] CMD ["/bin/bash"] I've tried various other DockerFile setups. Maybe I'm misunderstanding the point of ENTRYPOINT
has answer: http://stackoverflow.com/a/78416883
has comment: http://stackoverflow.com/comment/138245400
has comment: http://stackoverflow.com/comment/138246381
tagged with: bash
type: UnansweredQuestion
score: 1
downvote count: 0
answer count: 1
favorite count: 0
tagged with: ros
has title: Docker ENTRYPOINT not working as intended
tagged with: ros2
tagged with: dockerfile
tagged with: docker
type: Question

http://stackoverflow.com/q/78367681
answer count: 3
has comment: http://stackoverflow.com/comment/138199358
possible better answer: http://stackoverflow.com/a/78367741
has body: I need to get the snmpv3 engineID from about 16,000 devices. I'm working through a script step by step and can read the engine ID So far the working part I have myQuery='snmpget -v3 -l authPriv -u jasmin -a SHA -A MyAuthPhrase -x AES -X MyPrivPhrase '$myIP' SNMP-FRAMEWORK-MIB::snmpEngineID.0' which returns SNMP-FRAMEWORK-MIB::snmpEngineID.0 = Hex-STRING: 80 00 01 3E 03 28 29 86 2F 05 91 I need to extract just the hex string from the result. I tried: ID=$('snmpget -v3 -l authPriv -u jasmin -a SHA -A MyAuthPhrase -x AES -X MyPrivPhrase 'myIP' SNMP-FRAMEWORK-MIB::snmpEngineID.0') eval x=($ID) echo "ID is: ${x[3]}" But all get is: ID is: 80 instead of: 80 00 01 3E 03 28 29 86 2F 05 91 I'm not finding help on what I need to fix in ${x[3]} to get the result I need. Of course I'm open to doing it another way. Regards,
downvote count: 0
accepted answer: http://stackoverflow.com/a/78368630
tagged with: bash
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78367741
has answer: http://stackoverflow.com/a/78368630
has answer: http://stackoverflow.com/a/78390177
type: Question
has title: Trying to extract snmpv3 engineID from snmpget results in bash script
score: 1

http://stackoverflow.com/q/78423090
tagged with: linux
tagged with: bash
type: Question
has title: linux command to prefix a value for all lines in a file except for first line and lines starting with hash symbol
has answer: http://stackoverflow.com/a/78431203
has answer: http://stackoverflow.com/a/78439618
has body: Given a file input.csv as shown below, EMP_ID,EMP_NAME,JOINING_DATE,SALARY 1,T Natarajan,22-APR-2024,6000000 2,Velmurugan,22-JUL-2024,2000000 3,Rowin,21-OCT-2024,5000000 #END_OF_FILE how to prefix "E_" to all lines except for first line and lines starting with hash symbol (#). The expected output is, EMP_ID,EMP_NAME,JOINING_DATE,SALARY E_1,T Natarajan,22-APR-2024,6000000 E_2,Velmurugan,22-JUL-2024,2000000 E_3,Rowin,21-OCT-2024,5000000 #END_OF_FILE Tried this command sed -i -E '/^(#)/! s/^/E_/' input.csv but it's updating the 1st line as well.
has answer: http://stackoverflow.com/a/78423115
possible better answer: http://stackoverflow.com/a/78423240
accepted answer: http://stackoverflow.com/a/78423115
score: 0
tagged with: shell
has answer: http://stackoverflow.com/a/78423240
type: AnsweredQuestion
answer count: 6
has answer: http://stackoverflow.com/a/78438129
tagged with: sed
has answer: http://stackoverflow.com/a/78423429

http://stackoverflow.com/a/78372403
score: 1
has body: Assumptions: all input files contain at least 1 row all filenames are of the format some_long_string_with_no_periods.fastq One awk approach: awk -v start=2 -v inc=4 ' # provide awk with input parameters FNR==1 { close(outf) # 1st record: close previous output file outf = FILENAME ".len" # define output file name i = start # reset line counter } FNR==i { print length($0) > outf # ith record: print length to output file i += inc # increment line counter } ' *.fastq Running against OP's 2x sample input files we get: $ head *fastq.len ==> FAX08345_abafd786_a8df7914_1131.fastq.len <== 70 69 ==> FAX08345_abafd786_a8df7914_500.fastq.len <== 82 74 NOTE: these counts are +1 what OP has shown as the expected output; I'm assuming OP's data files are slightly different from what's shown in the question
upvote count: 1
answers question: http://stackoverflow.com/q/78371799
type: Answer
downvote count: 0

http://stackoverflow.com/q/78391938
tagged with: shell
tagged with: linux
has title: How to add a command to the bash history in my current terminal from python
tagged with: bash
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/54592827
has comment: http://stackoverflow.com/comment/138202591
type: Question
has answer: http://stackoverflow.com/a/78393739
answer count: 1
tagged with: python
has body: I found this soluion to add commands executed with Python in my bash history, but I can't get it to work in my current terminal session. I see the command has been added to the bash history only when I open a new terminal. I would like to see the command added to bash history in my currect terminal session.
score: 0

http://stackoverflow.com/a/78378849
type: Answer
answers question: http://stackoverflow.com/q/78373722
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78373722
score: 0
has body: I managed to find a solution and I answer myself. The error was indeed in the process that the script created for the program, because as I said it behaved differently (someone commented that this is what happened too). To solve it I simply spawned a terminal, and from the terminal I launched the program, so the behaviour is the same. #!/usr/bin/expect set timeout 200 spawn $env(SHELL) match_max 100000 send -- "XXX/bin/PROGRAM\r" expect "Choose an option ..." send "1\r" ... I hope this helps if you encounter a similar problem.

http://stackoverflow.com/comment/138256822
has text: what this script is doing is to go to table tbl_service, get the values in columns config_name, service_description and check_commands that matches the value of vars configname, newcommand and servicename. these values are read from a text file that contains lines where each line have values separated by comma. The purpose of this script is to replace current check commands with the update check commands.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78403450
type: AnswerComment

http://stackoverflow.com/comment/138238287
has text: @Rasec `input_filename` produces the name as provided (try `jq … dir1/dir2/file`), or `"<stdin>"` if the input comes from STDIN (it was redirected `<` or piped `|` into jq rather than a filename arg). Generally speaking, you can probably move the shell loop into jq, so you don't have to redirect/pipe any data (and it'd also be more efficient due to fewer calls from the shell). Alternatively, use jq's `--arg` option to import a single value (the filename), which you can adopt into the JSON structure to persist as real data, even if the actual file reference is lost due to redirection/piping.
type: AnswerComment
comment on: http://stackoverflow.com/a/78411741
score: 1
type: Comment

http://stackoverflow.com/q/78442690
has comment: http://stackoverflow.com/comment/138329940
type: UnansweredQuestion
score: 3
has answer: http://stackoverflow.com/a/78443211
favorite count: 0
has answer: http://stackoverflow.com/a/78442980
answer count: 6
tagged with: arrays
tagged with: associative
has comment: http://stackoverflow.com/comment/138294085
downvote count: 0
has answer: http://stackoverflow.com/a/78464354
tagged with: bash
has answer: http://stackoverflow.com/a/78442965
upvote count: 3
has title: Compound associative array variable assignment in Bash fails when read from variable
linked to: http://stackoverflow.com/q/49030109
has body: I apologise for asking for asking such a trivial question which might have been answered here presumably a dozen times. But I cannot get my head around what effect is preventing Bash from contentedly accepting this assignment. I assume maybe some sort of non awareness of variable content in the forking parent which was assigned in the subshell child? But my tries with process substitution via < <(command_that_parses_value_to_be_assigned) remained futile. Here's what puzzles me. compound=$(lvs --noheadings --units m --nosuffix -o name,size vg_oracle|cut -d. -f1|awk '{printf"[%s]=%d ",$1,$2}') echo $compound [lv_home_oracle]=20480 [lv_home_oracle_app]=40960 [lv_home_oracle_swdepot]=40960 [lv_opt_crs]=40960 unset oralvs; declare -A oralvs oralvs=($compound) -bash: oralvs: $compound: must use subscript when assigning associative array echo ${!oralvs[*]} wheras assigning the array's contents via copy and paste works well, so that I cannot see a syntax error in my intended statement. oralvs=([lv_home_oracle]=20480 [lv_home_oracle_app]=40960 [lv_home_oracle_swdepot]=40960 [lv_opt_crs]=40960) echo ${!oralvs[*]} lv_home_oracle_app lv_opt_crs lv_home_oracle_swdepot lv_home_oracle echo ${oralvs[*]} 40960 40960 40960 20480 Thank you for your kind attention and patience. Was expecting that the array's compound keys-values assignment reading from variable or command substituion would work. P.S. I think Bash: set associative array from variable answers my issue. The easiest for me to comprhende answer was the eval statement put in double quotes, which seems to work for me. e.g. unset oralvs echo ${!oralvs[*]} eval "declare -A oralvs=($compound)" echo ${!oralvs[*]} lv_home_oracle_app lv_opt_crs lv_home_oracle_swdepot lv_home_oracle echo ${oralvs[*]} 40960 40960 40960 20480
has answer: http://stackoverflow.com/a/78444349
tagged with: variable-assignment
type: Question
has answer: http://stackoverflow.com/a/78442706

http://stackoverflow.com/q/78366773
has comment: http://stackoverflow.com/comment/138159341
has answer: http://stackoverflow.com/a/78367275
has comment: http://stackoverflow.com/comment/138174193
tagged with: environment-variables
has answer: http://stackoverflow.com/a/78370087
type: Question
has body: i'm trying to process whether an input contains just a filename or a directory to a file D:\SYSTEM\System\Quality controlled songs\My drip Confession.flac and My drip Confession.flac here is what I constructed #checks if the input is a directory if -d $filename ; then echo "Extracting Filename and Directory: $filename " #this extracts the directory of the input directory=$(dirname "$filename") #this extracts the filename of the input filename=$(basename "$filename") #this makes the rest of the code execute in the input directory cd "$directory" #checks if the input is a file elif -f $filename ; then echo "Extracting Filename: $filename " else echo "Invalid input: $filename " exit 1 fi and when I input D:\SYSTEM\System\Quality controlled songs\My drip Confession.flac it outputs Extracting Filename: $filename when it shouldn't do that since it contains a path so what do I do? I just used parameters -d and -f.
type: UnansweredQuestion
score: 1
tagged with: bash
has answer: http://stackoverflow.com/a/78369881
has comment: http://stackoverflow.com/comment/138161934
answer count: 3
upvote count: 1
favorite count: 0
has title: How to check if a variable contains just a path to a file or just the filename
has comment: http://stackoverflow.com/comment/138159311
has comment: http://stackoverflow.com/comment/138158755
downvote count: 0

http://stackoverflow.com/comment/138270331
comment on: http://stackoverflow.com/q/78429844
score: 0
type: QuestionComment
has text: I set it like this ```env.URL = sh(script: "aws ssm get-parameter --name token_url --profile profile --region us-east-1 --with-decryption | jq -r .Parameter.Value", returnStdout: true)```
type: Comment

http://stackoverflow.com/q/78342422
tagged with: forticlient
answer count: 0
has body: So I need to have forti-client VPN connected all the time in a Fedora machine. Some times it disconnects and I need to connect it again automatically (right now is manual), I have an issue with expect and send, because it does not detect the input request and doesn't input the credentials and approve the connection. So the flow goes like this: Command: forticlient vpn connect {{VPN-NAME}} -u {{USER-NAME}} Input 1: password: Input 2: Confirm (y/n) [default=n]:Confirm (y/n) [default=n]: Then it connects. I built the next bash: #!/usr/bin/expect -d set timeout -1 #Disconnect FortiClient VPN forticlient vpn disconnect # Set variables set username {{USER-NAME}} set password {{USER-PASSWORD}} # Run the FortiClient VPN connection command spawn "forticlient vpn connect {{VPN-NAME}} -u $username" sleep 10 echo 'command executed' # Expect password prompt and send password expect "password:" send "$password"\r expect "Confirm (y/n) [default=n]:Confirm (y/n) [default=n]:" send "y" So not sure what is wrong but the echo 'command executed' goes after the inputs are required, so seems the expect executes after the inputs are requested. Not sure what I am doing wrong, it will be of great help if anyone knows how to fix it. I am expecting that it connects automatically using bash, python or anything...but that I dont need to be manually reconnecting the VPN Thanks in advance!
tagged with: bash
tagged with: vpn
has comment: http://stackoverflow.com/comment/138121814
has comment: http://stackoverflow.com/comment/138122317
has title: Automatically connection forticlient VPN in linux when it disconnects using Python script
score: 0
type: Question
type: UnansweredQuestion
tagged with: fedora
has comment: http://stackoverflow.com/comment/138116159

http://stackoverflow.com/comment/138234179
type: AnswerComment
comment on: http://stackoverflow.com/a/78401596
score: 0
has text: @Hauri, thanks for your response. Yes, I caught that after reading this post late last night and it is now working: https://unix.stackexchange.com/questions/545502/bash-array-of-arrays
type: Comment

http://stackoverflow.com/comment/138072255
score: 4
comment on: http://stackoverflow.com/q/78317617
has text: Even if your code worked in theory, in practice I don't think `{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}` would work: it asks Bash to hold more than a petabyte (a million gigabytes) of data in memory at once.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138107683
score: 0
type: QuestionComment
type: Comment
has text: I tried: "javac SumScanner.java" and then: java SumScanner Not working. I will try and read your comments. Thank you in advance. I will let you know if it works.
comment on: http://stackoverflow.com/q/78335326

http://stackoverflow.com/comment/138206767
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78320604
has text: @markp-fuso thx i tried it and the log was [856:856:0427/103429.042950:ERROR:ozone_platform_x11.cc(243)] Missing X server or $DISPLAY [856:856:0427/103429.043040:ERROR:env.cc(257)] The platform failed to initialize. Exiting.

http://stackoverflow.com/comment/138184009
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78381387
has text: Note that in this case your filter could be further simplified to `.content = $md`.
type: QuestionComment

http://stackoverflow.com/comment/138239894
score: 0
type: QuestionComment
has text: Curiously enough I adjusted the gotopath function to look contain this: `cat /home/user/Documents/save_path.txt | xargs -t cd` and it gives me the following error regardless of whether I try Dominique's suggestion or I stick with the original : **cd /home/x-ngin xargs: cd: No such file or directory**. Do you guys have any idea what might be wrong, I've been raking my brain unsuccessfully ? I understand that we are probably past the point of diminishing returns but I thought this might help someone else.
type: Comment
comment on: http://stackoverflow.com/q/78406644

plink
type: Tag
tags question: http://stackoverflow.com/q/78444561
tag name: plink

http://stackoverflow.com/comment/138266746
type: Comment
has text: If `transformer_cmd` should act like a no-op in the pipe, you could set it to an array containing only the word `cat`. A lone `cat` just copies stdin to stdout, without changing the data.
score: 0
comment on: http://stackoverflow.com/q/78420308
type: QuestionComment

http://stackoverflow.com/q/78402822
has comment: http://stackoverflow.com/comment/138221926
has comment: http://stackoverflow.com/comment/138221875
has comment: http://stackoverflow.com/comment/138222039
has comment: http://stackoverflow.com/comment/138223249
tagged with: history
has body: I enter many commands into the terminal. I enter command a, then b, then c, etc. I'm on command g now but I want to execute a, then b, then c, again. I press up (g), up (f), up (e), up (d), up (c), up (b), up (a), then enter to execute a. I have to press up 7 times again to get to and execute b. Same for c. On Windows, I maintain my position in the command history. So once I get to command a and press enter, I just press up maybe twice to get to b, and maybe twice again to get to c. This makes repeating sequences easier, obviously. The terminal apparently stays at its HEAD position, relative to history. How can the macOS terminal be reconfigured to maintain its position in the command history?
has answer: http://stackoverflow.com/a/78462615
type: Question
tagged with: terminal
has comment: http://stackoverflow.com/comment/138221839
tagged with: zsh
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/138221901
has comment: http://stackoverflow.com/comment/138221987
tagged with: macos
has title: Maintain position in terminal command history on macOS?
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138222168
has answer: http://stackoverflow.com/a/78402923

http://stackoverflow.com/comment/138106753
type: QuestionComment
comment on: http://stackoverflow.com/q/78337303
score: 2
type: Comment
has text: In general, I'd suggest having a separate header to store these values. It's bad form to have automation editing the same files that contain human-maintained source code -- as that means when something fails it has potential to corrupt a file a human wrote. If you have a header that _only_ has the three `#define`s and just include it from your `main.cpp`, the worst-case scenarios for what happens during a botched update are a lot less severe.

http://stackoverflow.com/comment/138149040
score: 0
type: QuestionComment
has text: should `presta九七二` match?
comment on: http://stackoverflow.com/q/78361035
type: Comment

http://stackoverflow.com/comment/138169388
has text: Perhaps, @F.Hauri-GiveUpGitHub. I didn't say that `sed` couldn't be wrangled into doing the job. I said *it isn't the right tool for this job*, and it's not. I wouldn't use `sed` for this any more than I would brush my hair with a toothbrush, though both might be made to work.
score: 4
type: QuestionComment
comment on: http://stackoverflow.com/q/78372639
type: Comment

http://stackoverflow.com/comment/138224682
type: Comment
has text: @GordonDavisson, Thank you. You are correct. This is what happens when you try to make a source file by hand. I appreciate your feedback.
score: 0
comment on: http://stackoverflow.com/q/78393978
type: QuestionComment

heredoc
type: Tag
tags question: http://stackoverflow.com/q/78417099
tag name: heredoc
tags question: http://stackoverflow.com/q/78666131
tags question: http://stackoverflow.com/q/78780721

http://stackoverflow.com/q/78337303
has comment: http://stackoverflow.com/comment/138106753
has title: How to write bash script that uses grep to get current Semantic Version, Update and Replacing?
score: 0
has comment: http://stackoverflow.com/comment/138127648
has comment: http://stackoverflow.com/comment/138109155
tagged with: git-bash
answer count: 1
has body: I am working on automating the creation of release packages but am new to writing bash scripts. I have a file that contains these lines showing the current version for the release: #define VER_MAJOR 1 #define VER_MINOR 8 #define VER_BUILD 5 I need to write a script that can retrieve the three parts of the version number from a file. Increment the build number and then rewrite the new version numbers back to the file at the same line they were retrieved from. I've described the script format below. #Release Creation Script #Retrieve Current Version VERSION_RAW_STRING='grep -n "#define VER_" version.h' #Parse Line Numbers #Parse Major/Minor/Build Numbers VER_MAJOR=1 VER_MINOR=1 VER_BUILD=1 #Increment Build Number VER_BUILD+=1 #Write Updated Version Back to main.cpp at Same Line Number #Create Git Tag $(git tag v${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}) #Get Current Git Information BUILD_TIME=`date +%FT%T%z` GIT_REVISION=`git rev-parse --short HEAD` GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD` GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "✗-"` GIT_TAG_DIRTY=`git describe --exact-match --tags > /dev/null 2> /dev/null || echo "+"` GIT_TAG=`git describe --abbrev=0 --tags` #Concatenate Git info and Echo GITINFO=" buildTime = \"${BUILD_TIME}\" gitRevision = \"${GIT_DIRTY}${GIT_REVISION}${GIT_TAG_DIRTY}\" gitBranch = \"${GIT_BRANCH}\" gitTag = \"${GIT_TAG}\"" echo "$GITINFO" #Create Backup Package of Release $(git archive -o ${GIT_TAG}.zip master) The logic for when to increment the other version numbers is outside the scope of this question. I am really just trying to get a good understanding of how to read from files manipulate the outputs and write it back to a set location. I currently am using grep to retrieve these lines and the line number they are on in the command line: $ grep -n "#define VER_" main.cpp 98:#define VER_MAJOR 1 99:#define VER_MINOR 8 100:#define VER_BUILD 5 Now I am getting stuck on how to go about making this a script where I …
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138106781
tagged with: bash
has answer: http://stackoverflow.com/a/78346403
type: Question
accepted answer: http://stackoverflow.com/a/78346403
has comment: http://stackoverflow.com/comment/138106864

http://stackoverflow.com/a/78421562
downvote count: 0
type: Answer
score: 2
answers question: http://stackoverflow.com/q/78421398
accepted answer of: http://stackoverflow.com/q/78421398
type: AcceptedAnswer
has body: Your first error (file not found) was probably caused by bash not being available in the openpolicyagent/conftest:latest container. When you changed the interpreter to /bin/sh the error now happens because of this line: for y in ${yamls[@]}; do POSIX sh doesn't support array references. And $yamls is not an array anyway, so you probably should use just $yamls instead of ${yamls[@]}.
upvote count: 2

http://stackoverflow.com/a/78335433
has comment: http://stackoverflow.com/comment/138103246
answers question: http://stackoverflow.com/q/78335326
has comment: http://stackoverflow.com/comment/138103768
has comment: http://stackoverflow.com/comment/138107591
downvote count: 0
score: 1
upvote count: 1
has body: As @ the class you shared is called 'sumScanner' , not 'EjerciciosClase'. Your class is in a subdirectory that matches the package structure. If you are commenting the package and it works, then you are executing a class called 'EjerciciosClase' that is at the top of the sources directory instead of a subpackage. To execute a class in a package you need to add the package: java com.estudio.ejerciciosclase.sumScanner. By Java naming convention the class name should start with an uppercase letter but that is unrelated to the issue. You should follow the Java convention so you should rename the class to something like SumScanner, and also the file name to match.
type: Answer
has comment: http://stackoverflow.com/comment/138112430
has comment: http://stackoverflow.com/comment/138107661

http://stackoverflow.com/comment/138067945
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78314716
has text: For debugging such a problem, you have to check what is stored inside your variables. `echo` is an unsuitable command for this. Do a `xxd <<<$status` instead, if you want to see the content of `status`.
type: QuestionComment

http://stackoverflow.com/comment/138079621
type: Comment
comment on: http://stackoverflow.com/q/78321765
score: 0
has text: Mind, there are other options as well -- if you look at the POSIX equivalents to `<()` using `mkfifo` to create a named pipe, those'll work in cases where the `/dev/fd` optimization doesn't.
type: QuestionComment

http://stackoverflow.com/a/78411906
has comment: http://stackoverflow.com/comment/138238565
has comment: http://stackoverflow.com/comment/138241478
has comment: http://stackoverflow.com/comment/138244007
score: 5
has comment: http://stackoverflow.com/comment/138240811
accepted answer of: http://stackoverflow.com/q/78411838
has comment: http://stackoverflow.com/comment/138238192
type: Answer
has comment: http://stackoverflow.com/comment/138239365
downvote count: 0
upvote count: 5
has comment: http://stackoverflow.com/comment/138240990
has body: If you omit the trailing comma in the initial production, you get a stream of inputs that jq can collect into an array using the --slurp (or -s) flag: for k in "${!mymap[@]}"; do opt="{\"OptionName\":\"${k}\", \"Value\":\"${mymap[$k]}\"}" echo "$opt" # no comma here --^ done | jq -s . > option.json However, you can also have jq do the JSON composition in the first place, guaranteeing valid JSON encoding even with challenging values (such as double quotes, etc.). For example, I'd use the --args option to import the bash array's keys and values as positional parameters, and the $ARGS builtin to access them: declare -A mymap=([name]="test" [age]="13") jq -n ' $ARGS.positional | [_nwise(length/2)] | transpose | map({OptionName: first, Value: last}) ' --args "${!mymap[@]}" "${mymap[@]}" > option.json As @oguz pointed out, newer versions of bash can also expand arrays to their keys and values in our desired alternating order by using "${mymap[@]@k}". The full jq filter would then just read: jq -n '$ARGS.positional | [_nwise(2) | {OptionName: first, Value: last}]' \ --args "${mymap[@]@k}"
has comment: http://stackoverflow.com/comment/138238245
answers question: http://stackoverflow.com/q/78411838
type: AcceptedAnswer

http://stackoverflow.com/comment/138108282
score: 0
type: Comment
has text: Great answer! Lots of good tips. Especially the tip about PHP-FPM. I must have missed that option to run it in the foreground. Your assumptions are all correct. The reason I have `/var/www` as a Volume is because I have another `web` container which runs the webserver. `setup.sh` makes a bunch of changes to the application sources, which then needs to be served by the webserver. The only way I knew how that could happen in the right order is with a Volume. Your suggestion is a much cleaner way of doing that, thank you :)
type: AnswerComment
comment on: http://stackoverflow.com/a/78333576

http://stackoverflow.com/a/78393739
upvote count: 1
has body: In most Unix-like operating systems, including Linux, the command history is typically stored in a file called ".bash_history" in the user's home directory. When you run the "history" command, it displays the contents of this file, showing a list of commands that were previously executed in the current shell session. However, the history file is only updated with commands once the shell session terminates. This means that any commands executed in the current shell session won't immediately appear in the history output when you run the "history" command. Instead, they will be appended to the history file once you exit the shell session. The reason for this behavior is to prevent simultaneous or parallel sessions from overwriting each other's command history. Each shell session maintains its own history list in memory, and updates the history file only when the session ends, ensuring that the command history remains consistent and accurate for each session. If you want to immediately update the history file with the latest commands from the current session, you can use the "history -a" command, which tells the shell to append the current session's history to the history file without waiting for the session to terminate. This can be useful if you want to ensure that your command history is saved before exiting the shell session.
type: Answer
answers question: http://stackoverflow.com/q/78391938
downvote count: 0
score: 1

http://stackoverflow.com/a/78373220
accepted answer of: http://stackoverflow.com/q/78348524
answers question: http://stackoverflow.com/q/78348524
type: Answer
has body: Ok, thanks to echo command I showed where pipeline reproduction is skipped execution code. Thanks @Iterokun
score: 0
type: AcceptedAnswer

http://stackoverflow.com/q/78332428
has title: How do you interact with a shared Volume created by Docker Compose in a Dockerfile?
tagged with: dockerfile
tagged with: docker
score: 0
type: Question
tagged with: docker-compose
linked to: http://stackoverflow.com/q/37313780
has comment: http://stackoverflow.com/comment/138098674
answer count: 1
has answer: http://stackoverflow.com/a/78333576
tagged with: bash
has body: I have a Volume shared amongst several containers in my Docker Compose setup. It looks like this in compose.yml: php: volumes: - type: bind source: ./apps target: /var/www I have a bash script which interacts with files in the shared Volume. It's called setup.sh. It's included in php's Dockerfile. What I would like to do is have it run as a RUN command in the Dockerfile: COPY dockerfiles/php/setup.sh /usr/local/bin/setup.sh RUN chmod +x /usr/local/bin/setup.sh RUN /usr/local/bin/setup.sh However, this doesn't work, because the Volume is not mounted until the very last command—the entrypoint. This does work: CMD sh -c /usr/local/bin/setup.sh &amp;&amp; /usr/sbin/php-fpm &amp;&amp; tail -f /dev/null However, the issue with this is that when I spin up the containers with docker compose, it shows as Started, but the script takes a minute or so to run before PHP-FPM is up. There is no easy way to tell when the script is done. So I'd prefer to run the script before the entrypoint so it's just waiting on PHP-FPM to start up (which does not take long). Is there any way to do that?
accepted answer: http://stackoverflow.com/a/78333576
type: AnsweredQuestion

http://stackoverflow.com/comment/138200836
score: 0
has text: @CharlesDuffy I have `GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)` so I guess that's not it. But it doesn't matter, because I found a(nother) way. See my answer below. Thank you for your help, though.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78389737

aws-lambda
type: Tag
tags question: http://stackoverflow.com/q/78423404
tag name: aws-lambda

applescript
tag name: applescript
tags question: http://stackoverflow.com/q/78364618
type: Tag
tags question: http://stackoverflow.com/q/79518619
tags question: http://stackoverflow.com/q/79524263

http://stackoverflow.com/comment/138275901
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78433302
has text: This exact error message will be show if you try to call `python` from inside Python itself.
type: QuestionComment

http://stackoverflow.com/a/78448139
has body: I know you said you wanted a sed solution but sed isn't the best choice for any problem involving multiple lines. The following, for example, will work using any awk (including POSIX) in any shell on every Unix box and IMO couldn't be much simpler/clearer: $ awk '/^&lt;/{type=$2; next} type != &quot;&lt;&lt;target_dir&gt;&gt;&quot;' file tesst good safasf tesst241241 safasfas That just says: /^&lt;/{type=$2; next} - If the current line starts with &lt; then save the string at the end of it, i.e. &lt;&lt;source_dir&gt;&gt; or &lt;&lt;target_dir&gt;&gt; or nothing, in a variable named type then don't do anything else with this line of input. So this sets type and ensures we will not print any line starting with &lt;. type != &quot;&lt;&lt;target_dir&gt;&gt;&quot; - If while reading the current line (which does not start with &lt; as the above statement would handle that) the variable type (which was set when the last line that started with &lt; was read) is set to &lt;&lt;target_dir&gt;&gt; then skip it, otherwise print it. So this tests type to ensure we will not print any lines between the &lt;... &lt;&lt;target_dir&gt;&gt; line and the subsequent &lt; line. If your other text can have lines starting with &lt; then just tweak that /^&lt;/ regexp to be whatever it needs to be to identify your target &lt;&lt;&lt;... lines.
answers question: http://stackoverflow.com/q/78441613
type: Answer
score: 0

http://stackoverflow.com/comment/138078724
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78320229
type: AnswerComment
has text: @CharlesDuffy, you think this is a bug report?

http://stackoverflow.com/comment/138097811
score: 0
has text: @RenaudPacalet I added them to limit the match, so one can't end up with things like `vaulted-vaulted-product-ui-test-creds.json`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78330348

http://stackoverflow.com/a/78374414
answers question: http://stackoverflow.com/q/78371799
type: Answer
score: -2
downvote count: 2
has body: This was the correct answer: for file in *.fastq; do output_file="${file}.len" sed -n '2~4p' "$file" | awk '{ print length }' > "$output_file" done
upvote count: 0

http://stackoverflow.com/comment/138297478
comment on: http://stackoverflow.com/q/78445380
type: QuestionComment
score: 2
type: Comment
has text: Check your file for [DOS/Windows carriage return line terminators](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings).

http://stackoverflow.com/a/78409085
answers question: http://stackoverflow.com/q/78405506
has comment: http://stackoverflow.com/comment/138233373
score: 0
has body: Yes there is. The docker save command has flatten all the layers of an image in order to create the tar. I can be easily verified by extracting the tar. Then the tar is transferred over the network. Then docker load has to unpack all the layers from the archive. This is long. You should use an image registry, either public or private. Even if the image is transfer twice, once for docker push, once for docker pull, layers which where already there, on the source, on the registry or on the destination, are not re-transfer. Meaning updates are fast. More over, layers are downloaded in parallel then extracted without waiting for the last one, which is not possible with a tar. And if the image has to be deployed more than one machine, you save even more.
type: Answer

http://stackoverflow.com/comment/138129330
type: QuestionComment
comment on: http://stackoverflow.com/q/78349366
type: Comment
has text: I don't see a problem description here. What's not working? Are you getting an error? Unexpected behavior? Something else?
score: 0

http://stackoverflow.com/a/78385408
answers question: http://stackoverflow.com/q/78378844
has comment: http://stackoverflow.com/comment/138196707
score: 2
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138202260
type: Answer
has body: The OP already has answers to the question they asked, this isn't an answer it's a response to the OPs comment asking to see how I'd write their code instead of storing the awk script in a variable and then using bash -c to call awk as they are doing. This is what the OP is doing: awk_script_file=$(cat << 'EOF' $0 ~ "User " user ".* blocked" { print } EOF ) some shell code... bash -c "awk -v user='${user}' '${awk_script_file}' ${file}" other shell code... Below are various ways I'd rewrite the OPs script, assuming file contains a globbing pattern such as: file='foo*' If the script is really just to print the line matching the RE: Get rid of the { print } and just call it in-place since it's so brief: some shell code... awk -v user="$user" '$0 ~ ("User " user " .* blocked")' $file other shell code... You could put it in a function if you prefer of course. I removed the unnecessary { print } as that's the default behavior when a condition is true. Note that I added a blank before .* blocked so a user name like johnston wouldn't falsely match a desired user value of john. If there is no blank in that location in the input then do something else dependent on the input format to avoid false matches. The parens are just for clarity (and to stop my left eye twitching as I try to guess/remember if a ~ b c means (a ~ b) c or a ~ (b c) and whether or not the rule for that is portable to all awks :-) ). Assuming we need to do more than just print and so need an action block: Call it in-place: some shell code... awk -v user="$user" ' $0 ~ ("User " user " .* blocked") { print } ' $file other shell code... or store it in a function and call that function in-place: prtuser() { awk -v user="$1" ' $0 ~ ("User " user " .* blocked") { print } ' "${@:2}" } some shell code... prtuser "$user" $file other shell code... In reality I'd concatenate the strings to form the regexp just once at the start of the script: BEGIN { userRe = "User " user " .* blocked" } $0 ~ userRe instead of doing t…

http://stackoverflow.com/comment/138143137
type: Comment
type: AnswerComment
has text: In fact I preferred to use single quote `'` to disable shell expansion (that way I don't need to escape `$`, `\ ` and other symbols with a backslash). Then the VER_BUILD (and last slash `/`) is added to the single quote string (and is safe to use without double quotes `"` since it does contain any space and won't be split in several words). So yeah, it's just personal taste, I could have gone for `"s/^(#define VER_BUILD[[:space:]]+)[0-9]+\$/\\1$VER_BUILD/"` (note the 2 additional backslashes)
comment on: http://stackoverflow.com/a/78346403
score: 0

http://stackoverflow.com/a/78339098
score: 0
has body: In pipeline, each Bash task will have a separate session to run the commands/scripts set on the task. When the task is completed, the session normally will be closed. Some processes started by the task (or by the commands run on the task) also could be stopped. For your case, you can try to add the dependent/associated command lines to one Bash task, instead of separating them to multiple tasks. By this way, all the associated command lines can be executed within the same session.
answers question: http://stackoverflow.com/q/78338056
type: Answer

http://stackoverflow.com/comment/138201788
comment on: http://stackoverflow.com/q/78390223
score: 1
type: QuestionComment
has text: Really, you don't even need xargs at all in that case -- can use `find ... -exec bash -c 'for arg; do ..."$arg"...; done' _ {} +` and let find do the work of xargs splitting the results up into separate commands.
type: Comment

http://stackoverflow.com/comment/138254690
score: 1
comment on: http://stackoverflow.com/q/78420131
type: QuestionComment
type: Comment
has text: `echo` is absolutely not a "trusted primitive building block". `echo "$x"` doesn't work in general, and can fail in multiple ways. See the accepted, and excellent, answer to [Why is printf better than echo?](https://unix.stackexchange.com/q/65803/264812).

http://stackoverflow.com/comment/138115225
type: QuestionComment
type: Comment
score: 0
has text: ...you don't want `"description": "Prevent users from injecting $(rm -rf ~) or '$(rm -rf ~)' into commands"` to actually run `rm -rf ~`
comment on: http://stackoverflow.com/q/78342087

http://stackoverflow.com/comment/138234379
score: 1
type: QuestionComment
has text: Change `while (( 1 ))` to `while pgrep -q -P $proc_main` and get rid of the `if ! ps ...` block.
type: Comment
comment on: http://stackoverflow.com/q/78409749

http://stackoverflow.com/comment/138234485
has text: Why call pgrep _or_ ps? Pass a PID and you can use `while kill -0 "$pid"; do`, which is shell-builtin.
type: Comment
comment on: http://stackoverflow.com/q/78409749
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138073347
comment on: http://stackoverflow.com/q/78313378
type: Comment
has text: @Wayne Yes, `import example` is in my notebook. Regardless of which library I am importing, the first one is referenced in the error. So if I have `import pandas` first, it'll be referenced in the error. If I comment that out and have `import numpy` first, it'll be referenced in the error. Can you clarify the second sentence?
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138258770
comment on: http://stackoverflow.com/a/78423429
score: 1
type: Comment
type: AnswerComment
has text: `!NF` skips empty lines, not the first line.

http://stackoverflow.com/comment/138190813
type: QuestionComment
type: Comment
score: 0
has text: @glades I posted an "answer" showing how I'd write your script at https://stackoverflow.com/a/78385408/1745001. It's not an answer to your question so please don't accept it as one, you already have answers to your question, it's just responding to your comment best I can on this forum.
comment on: http://stackoverflow.com/q/78378844

http://stackoverflow.com/q/78423821
has answer: http://stackoverflow.com/a/78424103
score: -1
tagged with: grep
upvote count: 0
tagged with: bash
has answer: http://stackoverflow.com/a/78423908
has title: How to extract sequence cluster numbers containing a specific string in the ID from a cluster file in bash?
favorite count: 0
downvote count: 1
type: AnsweredQuestion
tagged with: awk
answer count: 3
has body: I have a cluster file for sequences clustering at 100% sequence identity, each containing sequence clusters denoted by cluster numbers followed by IDs. Here's an example of the file format: &gt;Cluster 94 0 416aa, &gt;crgi_XP_019918436.1... * &gt;Cluster 95 0 415aa, &gt;TRINITY_DN19027_c1_g1_i3_77... * &gt;Cluster 96 0 415aa, &gt;TRINITY_DN31043_c0_g1_i1_68... * &gt;Cluster 97 0 414aa, &gt;TRINITY_DN4649_c0_g1_i1_24... * 1 414aa, &gt;TRINITY_DN4649_c0_g1_i2_29... at 100.00% 2 414aa, &gt;TRINITY_DN4649_c0_g1_i3_23... at 100.00% 3 414aa, &gt;TRINITY_DN4649_c0_g1_i4_23... at 100.00% 4 414aa, &gt;TRINITY_DN4649_c0_g1_i5_27... at 100.00% &gt;Cluster 98 0 414aa, &gt;TRINITY_DN11838_c0_g1_i1_77... * &gt;Cluster 99 0 414aa, &gt;TRINITY_DN13974_c0_g1_i1_33... * 1 414aa, &gt;TRINITY_DN13974_c0_g1_i3_29... at 100.00% 2 414aa, &gt;TRINITY_DN13974_c0_g1_i4_34... at 100.00% &gt;Cluster 100 0 414aa, &gt;TRINITY_DN15453_c0_g1_i1_84... * &gt;Cluster 101 0 414aa, &gt;TRINITY_DN23802_c0_g1_i1_50... * &gt;Cluster 102 0 414aa, &gt;TRINITY_DN24921_c0_g1_i1_102... * &gt;Cluster 103 0 414aa, &gt;TRINITY_DN26456_c0_g1_i1_61... * &gt;Cluster 104 0 414aa, &gt;TRINITY_DN49299_c0_g1_i1_30... * &gt;Cluster 105 0 412aa, &gt;TRINITY_DN13974_c0_g1_i2_27... * &gt;Cluster 106 0 411aa, &gt;TRINITY_DN5517_c0_g1_i1_28... * 1 411aa, &gt;TRINITY_DN5517_c0_g1_i2_35... at 100.00% &gt;Cluster 107 0 410aa, &gt;TRINITY_DN9528_c0_g1_i1_30... * 1 410aa, &gt;TRINITY_DN9528_c0_g1_i2_36... at 100.00% 2 404aa, &gt;crgi_XP_011414097.1... at 100.00% &gt;Cluster 108 0 410aa, &gt;TRINITY_DN11082_c0_g1_i1_69... * 1 410aa, &gt;TRINITY_DN11082_c0_g1_i2_69... at 100.00% &gt;Cluster 109 0 410aa, &gt;crgi_XP_011450995.2... * &gt;Cluster 110 0 407aa, &gt;TRINITY_DN4674_c0_g1_i3_24... * &gt;Cluster 111 0 407aa, &gt;TRINITY_DN11077_c0_g2_i1_64... * &gt;Cluster 112 0 407aa, &gt;TRINITY_DN11838_c0_g1_i2_78... * &gt;Cluster 113 0 407aa, &gt;TRINITY_DN11978_c0_g1_i1_33... * &gt;Cluster 114 0 406aa, &gt;TRINITY_DN26600_c0_g1_i1_86...…
type: Question
has answer: http://stackoverflow.com/a/78424119
accepted answer: http://stackoverflow.com/a/78424103
possible better answer: http://stackoverflow.com/a/78424119

http://stackoverflow.com/a/78342487
upvote count: 0
score: -1
has body: The [[]] construct, along with the =~ operator, enables Bash to perform regex matching and return the matched portions. Like this example below - if [[ "$line" =~ [0-9]+ ]]; then
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78333123

http://stackoverflow.com/comment/138206226
type: QuestionComment
has text: Use [tag:nash] *loadable* `csv`: see [my answer](https://stackoverflow.com/a/69514496/1765658)
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78393978

http://stackoverflow.com/comment/138252367
has text: @EdMorton, _unexpected_ errors ought to be fatal -- like exceptions in programs written in other languages. To test exit code after every command is to double the script-size... The _expected_ errors can be handled explicitly.
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78409604

http://stackoverflow.com/comment/138132174
has text: Hi Iterokun, Just silently skips Thanks for your questions
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment
score: 0

http://stackoverflow.com/a/78433538
has body: I wasn't able to find a suitable transformer_cmd but, based on the hint given by @chepner, I was able to come up with the following: mysql_cmd &quot;${mysql_args[@]}&quot; in which mysql_cmd defaults to: function mysql_cmd() { mysql &quot;$@&quot; } and if an option were provided to the script, would be overridden to: function mysql_cmd() { mysql &quot;$@&quot; | sed -e 's|\\\\|\\|g' | tee &quot;${outfile}&quot; }
score: 0
accepted answer of: http://stackoverflow.com/q/78420308
type: Answer
answers question: http://stackoverflow.com/q/78420308
type: AcceptedAnswer

kotlin
tags question: http://stackoverflow.com/q/78402467
tag name: kotlin
type: Tag
tags question: http://stackoverflow.com/q/79126424

http://stackoverflow.com/comment/138298535
has text: it seems like with source is working with #!/usr/bin/env bash format
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78445411
score: 0

http://stackoverflow.com/comment/138103360
type: Comment
comment on: http://stackoverflow.com/q/78324472
score: 0
has text: I expect exactly what you said, a á ã à â ä a å all be sorted as a, including their uppercase variations and the same for other character variations
type: QuestionComment

http://stackoverflow.com/comment/138130303
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78350523
has text: Then we're essentially back to the original command, except that we replaced `cd blah && tar` to `tar -C blah`

http://stackoverflow.com/comment/138278755
has text: How to do that if make clean is broken? There are no .o files in the directory.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78422867
score: 0

http://stackoverflow.com/q/78330326
has answer: http://stackoverflow.com/a/78359047
tagged with: bash
type: Question
has title: Local autocomplete for a bash script
type: UnansweredQuestion
upvote count: 1
has body: I really want to add autocomplete to my scripts for custom options, but all the advice I see online involves updating /etc/bash_completion.d or ~/.bashrc. The problem with this method for me is that this is a global solution (for the system in the case of updating /etc/... and for the user in the case of ~/.bashrc). A lot of times, I have many small scripts only applicable to the directory they're in. Thus, a "global" solution might break if I had distinct scripts with the same name in different directories (which I often do). Thus, I'd like a solution which scopes to the current directory, maybe adding some code to the script itself, or adding an "autocomplete file" alongside a script. Here's an example of what I'd like: ~/working_directory$ cat script.sh #!/bin/bash if "$1" == "opt1" ; then echo "performing action 1" fi if "$1" == "opt2" ; then echo "performing action 2" fi ~/working_directory$ cat script.autocomplete.txt opt1 opt2 ~/working_directory$ ./script.sh op Options from script.autocomplete.txt: opt1 opt2 ~/working_directory$ ./script.sh opt The last 5 lines is what I'd like to see when the user enters tab after typing part of some option. One more feature I'd like is that it works when the script doesn't have the execution bit set (e.g. bash -e script.sh) as sometimes I work in strange bash environments (like termux) where using chmod require arcane knowledge. If no one responds, I think I have an idea for how to do this (there was a post I found to add general and customizable autocomplete) and I'll update this post with my findings.
downvote count: 0
has comment: http://stackoverflow.com/comment/138094891
score: 1
has comment: http://stackoverflow.com/comment/138105939
has comment: http://stackoverflow.com/comment/138094525
answer count: 1
favorite count: 0
tagged with: autocomplete
has comment: http://stackoverflow.com/comment/138094901
has comment: http://stackoverflow.com/comment/138105891

http://stackoverflow.com/comment/138101320
type: AnswerComment
score: 1
has text: I endet up with this solution, thank you! I added `$` to the variables in the if: `$commandOutput == *"string"* || $commandOutput == *"strong"*` - otherwise I got a syntax error.
comment on: http://stackoverflow.com/a/78333360
type: Comment

http://stackoverflow.com/q/78392419
has comment: http://stackoverflow.com/comment/138203688
score: -1
has comment: http://stackoverflow.com/comment/138203882
linked to: http://stackoverflow.com/q/70435677
has title: Handle invalid variable name error in bash indirect references
upvote count: 0
has comment: http://stackoverflow.com/comment/138203501
has body: Take a look at this simple example: x="foo bar" echo ${!x} It erros: -bash: foo bar: invalid variable name. I'm writing a script where a positional argument will indicate a "color name" and we use indirect references to fetch the hex code of the color name. I want the script to keep going if the user passes a color name with space in it or generally an invalid color name (which we will default to white). I also tried this try/catch approach but to no avail: x="foo bar" echo ${!x} || echo error The closes thing I could find was this, but didn't help: Bash reference variable by string name
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138203479
answer count: 1
has comment: http://stackoverflow.com/comment/138203559
favorite count: 0
has answer: http://stackoverflow.com/a/78392620
tagged with: reference
type: Question
has comment: http://stackoverflow.com/comment/138204337
has comment: http://stackoverflow.com/comment/138203582
downvote count: 1
linked to: http://stackoverflow.com/q/22009364
has comment: http://stackoverflow.com/comment/138203916

http://stackoverflow.com/a/78308972
score: 5
downvote count: 0
answers question: http://stackoverflow.com/q/78308913
type: Answer
has comment: http://stackoverflow.com/comment/138057614
has comment: http://stackoverflow.com/comment/138067898
accepted answer of: http://stackoverflow.com/q/78308913
has body: .bashrc function git() { if "$1" = checkout ; then echo 'Use switch or restore!' >&2 return 1 fi command git "$@" }
upvote count: 5
has comment: http://stackoverflow.com/comment/138068285
type: AcceptedAnswer

http://stackoverflow.com/comment/138083938
has text: Add `| sort -f` after `done`?
score: 3
comment on: http://stackoverflow.com/q/78324472
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138121584
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78344372
has text: `[ justRead != "\n" ]` passes to the command with name `[` the four strings `justRead`, `!=`, `\n` and `]` as parameter. Just try the command `printf "%s :: " justRead != "\n" ]` to see the effect. Your `[` will always evaluate to true, because the string _justRead_ (8 characters) is always different from the string _\n_ (2 characters). You would at least need the content of the variable named `justRead` on the left (i.e. `"$justRead"`), and a string consisting of a newline character to the right (i.e. `$'\n'`), but then you still have to fix the other flaws in the code.
type: QuestionComment

http://stackoverflow.com/comment/138586162
has text: The OP is checking `$?` after execution of `whisper`. I don't see where they're checking it after execution of _their script_. Indeed, I don't see anywhere they tell us how they run the script at all.
type: AnswerComment
comment on: http://stackoverflow.com/a/78603441
score: 1
type: Comment

http://stackoverflow.com/q/78393091
tagged with: command
tagged with: scripting
answer count: 0
has body: What is the difference between shell scripting and bash scripting? I can't find any explanations at a reasonable level of familiarity to me. I have read up on past stack overflow posts but they do not seem to directly answer my question.
type: UnansweredQuestion
tagged with: bash
linked to: http://stackoverflow.com/q/5725296
has comment: http://stackoverflow.com/comment/138205087
has comment: http://stackoverflow.com/comment/138204786
has title: What is the difference between shell scripting and bash scripting? (novice level answer)
duplicate of: http://stackoverflow.com/q/5725296
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138204799
has comment: http://stackoverflow.com/comment/138204807
tagged with: comparison
tagged with: shell

http://stackoverflow.com/comment/138260899
has text: No. If it's a password, prompt the user for it and read it from the tty, don't take it as an argument.
score: 3
comment on: http://stackoverflow.com/q/78424828
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138137535
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78354730
has text: then `read -ra criteria_col < textfile` instead of `criteria_col=$(<textfile)`

http://stackoverflow.com/a/78367275
score: 0
answers question: http://stackoverflow.com/q/78366773
type: Answer
has body: If you want to know whether the user has entered a filename or a path name, the script should be called with the option -f. A solution to this would be to verify if the user has entered as a first option -f or not using if[ "$1"="-f"];. Here is a simple solution that I propose to you: #!/bin/bash if [ "$1" = "-f" ]; then if [ -n "$2" ]; then finalname=$(basename "$2") echo "File name is: $finalname " filepath=$(dirname "$2") echo "File path is: $filepath " else echo "Please enter a file name after option -f." fi else echo "Please use -f" fi I hope this answers to your question and I would be glad if anyone could correct my reasoning or add more to this discussion. Happy coding!

http://stackoverflow.com/comment/138247900
type: QuestionComment
type: Comment
score: 0
has text: Thanks for the explanation @jhnc. I think I need to go back and learn a bit more about how the shell itself works too. I definitely learnt a lot from this.
comment on: http://stackoverflow.com/q/78406644

http://stackoverflow.com/comment/138290749
type: Comment
comment on: http://stackoverflow.com/q/78441613
score: 1
type: QuestionComment
has text: So does it _have to_ be sed? Does it have to be posix?

http://stackoverflow.com/comment/138201249
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78390328
has text: Wooo thanks for your wonderfoul answer. It seems not working. In script with the comand tail it says me: ./procesa.sh ./procesa.sh: line 7: syntax error near unexpected token `do' ./procesa.sh: line 7: `tail -f /controlm921/fifo | read line; do'

http://stackoverflow.com/a/78449265
type: Answer
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78444623
downvote count: 0
has body: subject=$( awk '/^Subject:/ { print ($9 ? $9 : "none") }' /var/mail/incoming ) For example: $ cat file Subject: RE: The answer to your question is yes Subject: RE: The answer to your question is no Subject: RE: The answer to your question is no Subject: RE: The answer to your question is yes Subject: RE: The answer to your question is Subject: RE: The answer to your question is yes Subject: RE: The answer to your question is no $ subject=$( awk '/^Subject:/ { print ($9 ? $9 : "none") }' file ) $ echo "$subject" yes no no yes none yes no
score: 1
answers question: http://stackoverflow.com/q/78444623
upvote count: 1

http://stackoverflow.com/q/78423981
has comment: http://stackoverflow.com/comment/138259833
tagged with: bash
has comment: http://stackoverflow.com/comment/138259804
has comment: http://stackoverflow.com/comment/138259620
has comment: http://stackoverflow.com/comment/138264822
score: 0
has answer: http://stackoverflow.com/a/78424463
type: Question
type: UnansweredQuestion
answer count: 1
has body: Please, how can I execute a script (bash) after encrypting it without decrypting it? I would like to give only execute access to a script and make it unreadable. I used this to encrypt my script openssl enc -aes-256-cbc -salt -in test.sh -out test.sh.enc -k $Password
has title: Execute an encrypted script Bash

http://stackoverflow.com/q/78427584
has comment: http://stackoverflow.com/comment/138269343
has answer: http://stackoverflow.com/a/78428119
possible better answer: http://stackoverflow.com/a/78428119
has comment: http://stackoverflow.com/comment/138266148
favorite count: 0
has comment: http://stackoverflow.com/comment/138265953
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78428136
downvote count: 1
has comment: http://stackoverflow.com/comment/138297569
has body: I am attempting to do a != string comparison of the last three characters of each string element in an array, then delete the element if it is not equal, but it is not producing the expected results. I am sure my code is incorrect, so I am looking for some guidance on how to correct. I have tried two examples which use both "==" and "!=" to test my code, as follows: Array: array=(8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t) First run "==" for ((i=0; i<${#array[@]}; i++)); do chomp=${array[i]: -3} echo chomp: $chomp if $chomp == "foo" || $chomp == "bar" ; then echo "i: $i, element: ${array[i]}" delete=${array[i]} echo ${array[@]/$delete} array=( "${array[@]/$delete}" ) fi done array=( "${array[@]}" ) echo "First run: ${array[@]}" Output: (code works as expected, foo/bar elements deleted - but this is not what I want) chomp: foo i: 0, element: 8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t chomp: 45u chomp: bar i: 2, element: 231649bar 86696485745u 23164919a1 8594792682foo 859479268209t chomp: 9a1 chomp: foo i: 4, element: 8594792682foo 86696485745u 23164919a1 859479268209t chomp: 09t First run: 86696485745u 23164919a1 859479268209t # expected result Second run "!=" for ((i=0; i<${#array[@]}; i++)); do chomp=${array[i]: -3} echo chomp: $chomp if $chomp != "foo" || $chomp != "bar" ; then echo "i: $i, element: ${array[i]}" delete=${array[i]} echo ${array[@]/$delete} array=( "${array[@]/$delete}" ) fi done array=( "${array[@]}" ) echo "Second run: ${array[@]}" Output: (code not working as expected) chomp: foo i: 0, element: 8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t chomp: 45u i: 1, element: 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t chomp: bar i: 2, element: 231649bar 23164919a1 8594792682foo 859479268209t chomp: 9a1 i: 3, element: 23164919a1 8594792682foo 859479268209t chomp: foo i: 4, element: 8594792682foo 859479268209t chomp: 09t i: …
accepted answer: http://stackoverflow.com/a/78428136
tagged with: bash
has comment: http://stackoverflow.com/comment/138270915
type: Question
has answer: http://stackoverflow.com/a/78430483
has comment: http://stackoverflow.com/comment/138297581
linked to: http://stackoverflow.com/q/28693737
answer count: 4
has title: How to properly do a "not equal" string comparison in an array, and then delete the element in bash
has comment: http://stackoverflow.com/comment/138269218
has answer: http://stackoverflow.com/a/78429634
upvote count: 1
linked to: http://stackoverflow.com/q/26337003
score: 0
tagged with: arrays

http://stackoverflow.com/comment/138072469
type: QuestionComment
type: Comment
has text: @Barmar Thank you, that makes sense, the & was not described further than "adding it after a command will run it in the background" I was unaware I could run other commands following it
score: 0
comment on: http://stackoverflow.com/q/78317514

http://stackoverflow.com/comment/138236816
comment on: http://stackoverflow.com/q/78409475
type: QuestionComment
score: 0
type: Comment
has text: @JohnBollinger Yes it is a bash script. I want to echo the return value of whisper. Sorry, the heading of the question was ambiguous.

http://stackoverflow.com/comment/138284026
comment on: http://stackoverflow.com/q/78437288
score: 0
type: QuestionComment
type: Comment
has text: See [BashFAQ/084 (How do I return a string \(or large number, or negative number\) from a function? "return" only lets me give a number from 0 to 255.)](https://mywiki.wooledge.org/BashFAQ/084).

http://stackoverflow.com/a/78420010
downvote count: 0
has comment: http://stackoverflow.com/comment/138252283
has comment: http://stackoverflow.com/comment/138252465
has body: This is normal. A git hash is determined not just by its "contents" (or "changes", as you put it) but by its parentage, meaning its place in the topology. Two different commits always have different hashes. Don't worry, be happy. You could do the rebase you are describing by saying git rebase --onto D1 D2 F2 but I really don't see what you think it would gain you. It would not magically delete C2 and D2, nor should it; commits in Git are never deleted, unless they are unreferenced (and even then, it takes a couple of weeks before they are cleaned up). And there would then be two F2 commits, so you would have doubled your (fake) trouble.
type: Answer
score: 2
answers question: http://stackoverflow.com/q/78419971
upvote count: 2

http://stackoverflow.com/comment/138155130
comment on: http://stackoverflow.com/a/78364736
has text: I think OP wants to block execution only if they forgot to add a shebang line, not generally…
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138261026
type: Comment
comment on: http://stackoverflow.com/q/78424828
has text: "solve this by any change inside shell script": No. parameter expansion is done by bash before the script reads it. Quoting is a shell best practice so better teach that to users.
type: QuestionComment
score: 5

http://stackoverflow.com/q/78346697
score: 0
tagged with: jib
type: Question
tagged with: shell
type: UnansweredQuestion
answer count: 1
has body: I try to build my Quarkus app with jib using the following properties: quarkus.jib.base-jvm-image=registry.access.redhat.com/ubi8/openjdk-17:1.19-1 quarkus.jib.jvm-arguments=-Djava.net.preferIPv4Stack=true quarkus.jib.jvm-additional-arguments="-XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=90" I tried with and without , and quotes for the quarkus.jib.jvm-additional-arguments but it throws the following error when i try to run the container: Error: Could not find or load main class -XX:InitialRAMPercentage=50 Caused by: java.lang.ClassNotFoundException: -XX:InitialRAMPercentage=50 During the image build, the containers entrypoint is set correctly with both additional jvm args. Container entrypoint set to [java, -Djava.net.preferIPv4Stack=true, "-XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=90", -jar, quarkus-run.jar] When i build the container manually with the src\main\docker\Dockerfile.jvm image FROM registry.access.redhat.com/ubi8/openjdk-17:1.19-1 ENV LANGUAGE='en_US:en' # We make four distinct layers so if there are application changes the library layers can be re-used COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ COPY --chown=185 target/quarkus-app/*.jar /deployments/ COPY --chown=185 target/quarkus-app/app/ /deployments/app/ COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ EXPOSE 8080 USER root ENV JAVA_OPTS="-XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=90" ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] the errors mentioned above do not occur and the container starts with the given jvm memory properties.
has title: How to specify multiple jvm arguments when building a docker image with jib?
has answer: http://stackoverflow.com/a/78347014
tagged with: bash
tagged with: java
tagged with: quarkus

http://stackoverflow.com/q/78424358
accepted answer: http://stackoverflow.com/a/78424582
has title: Rename a file matching two substrings in Bash with regex
has comment: http://stackoverflow.com/comment/138260060
has comment: http://stackoverflow.com/comment/138273207
favorite count: 0
has body: I need to copy files and rename them. replacing the "N" with another string that I have in an environment variable. For the following file; myFile_N_something.cfc_ I can do this with a for/do/done block, in a bash script using regex; for files in *.cfc_; do cp "$files" "${files/_N_/_$theID_}"; done BUT... I also need to strip out the trailing "_" from the very end of the filename, too, so it ultimately ends up being; myFile_32_something.cfc (assuming i have "32" in the environment variable) I can of course do another separate step... But I am hoping to "UP" my regex skills and do it in one command, if it is possible. As always thanks!
score: 2
upvote count: 2
possible better answer: http://stackoverflow.com/a/78425903
downvote count: 0
tagged with: bash
has answer: http://stackoverflow.com/a/78424582
has answer: http://stackoverflow.com/a/78429509
type: AnsweredQuestion
answer count: 3
has comment: http://stackoverflow.com/comment/138271669
has answer: http://stackoverflow.com/a/78425903
type: Question

http://stackoverflow.com/comment/138255959
has text: other than that, it looks like it should work.
score: 0
comment on: http://stackoverflow.com/q/78422019
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138268996
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78428595
has text: printf '%q\n' "$SESSION"; outputs \ b67e09ac-ef3f-4b01-8aba-353436770fc9 (on a new line) Is that backlash the problem, or merely a side effect of your printf command?
type: QuestionComment

glob
type: Tag
tags question: http://stackoverflow.com/q/78361035
tag name: glob
tags question: http://stackoverflow.com/q/78684611
tags question: http://stackoverflow.com/q/78632760
tags question: http://stackoverflow.com/q/79154368
tags question: http://stackoverflow.com/q/79138869
tags question: http://stackoverflow.com/q/79144100
tags question: http://stackoverflow.com/q/79492388

http://stackoverflow.com/comment/138230910
type: Comment
comment on: http://stackoverflow.com/q/78405506
score: 0
has text: @BMitch the source of the tar file is one I generate using `docker save`. A `docker load` is then ran from a script, so the images are loaded onto the environment/local Docker engine. Another script would then retag and push these images. Important to note: I would be unable to implement anything that pulls the images from the registry directly, as certain environments/users wouldn't have access to the registry the images are pulled from initially - hence the reason for saving the images to a tar, loading the images, and then retagging these images and pushing to a new registry.
type: QuestionComment

http://stackoverflow.com/comment/138251584
score: 1
comment on: http://stackoverflow.com/q/78419580
type: QuestionComment
has text: Try `case $FI in *.l*) echo done;; *) echo fail; esac`
type: Comment

http://stackoverflow.com/comment/138073341
type: QuestionComment
comment on: http://stackoverflow.com/q/78317514
type: Comment
has text: Going back to the job control part -- how are you starting your script? If you're running it with `./scriptname` job control should be off by default unless you explicitly turned it back on with `set -m` or by starting the script with `bash -m`. You might have it on if you were running the script _in your preexisting interactive shell_ by using `. scriptname` or `source scriptname` instead of `./scriptname` -- don't do that.
score: 0

http://stackoverflow.com/comment/138121682
score: 0
type: QuestionComment
type: Comment
has text: It looks as if you are asking 4 questions here. Have a look [here](https://meta.stackoverflow.com/questions/371614/why-isnt-it-good-to-ask-multiple-questions-and-answers-in-one-question), in particular to the answer given by user _Sheshank S._
comment on: http://stackoverflow.com/q/78344853

http://stackoverflow.com/q/78311907
has title: trying to use (WSL) bash -c to execute a command(export variable), but failed
linked to: http://stackoverflow.com/q/6697753
type: Question
duplicate of: http://stackoverflow.com/q/6697753
accepted answer: http://stackoverflow.com/a/78311972
score: 0
has answer: http://stackoverflow.com/a/78311972
tagged with: bash
answer count: 1
tagged with: powershell
type: AnsweredQuestion
has body: on WSL, I am trying to use bash -c to execute a string as command: bash -c "export MY_HOME=/mnt/d ; echo $MY_HOME" but the result shows that $MY_HOME is empty I think it might be that the dollar sign is not recognized, but I dont know how to solve it. I appreciate if anyone could help me. Thank yoU! enter image description here Here's what I tried in powershell

http://stackoverflow.com/a/78378915
upvote count: 6
has body: To answer the title: Yes. In an awk condition/action pair, the action has to start on the same line as the condition; Awk is not a freeform language, as newlines are significant. So when you do this: /whatever/ { something } It is interpreted as the condition /whatever/ with no explicit action (that therefore triggers the default action of "print the record") followed by the action block { something } with no explicit condition (that therefore is triggered on every record). So the program winds up both printing every line that matches /whatever/ and doing the { something } to every single line, whether it matches /whatever/ or not. If part of the { something } is printing out the line, the lines that do match /whatever/ will be printed twice.
accepted answer of: http://stackoverflow.com/q/78378844
score: 6
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78378844
downvote count: 0
type: Answer

http://stackoverflow.com/comment/138139949
comment on: http://stackoverflow.com/q/78356050
type: Comment
score: 2
has text: `sed -E -e 's/,[0-9]{1,2},/,none,/g' < in.csv` but this relies on not having spaces surrounding the commas. It would be clearer to parse the CSV as CSV, and then work on the fields you want to change.
type: QuestionComment

http://stackoverflow.com/comment/138130095
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78350564
has text: `how are the above value expansions implemented?` like so https://github.com/bminor/bash/blob/master/subst.c#L7628 .
type: QuestionComment

http://stackoverflow.com/a/78372901
has body: This looks like you would want to refactor the whole thing to an Awk script. awk '/^Consumed Contracts *:/ { cc=1; consumed = $0; sub(/^Consumed Contracts *: */, &quot;&quot;, consumed); next } /^Provided Contracts *:/ { print consumed; cc = 0 } cc { sub(/^ */, &quot;&quot;); consumed = consumed $0 } END { if (cc) print consumed }' Demo: https://ideone.com/wnXiiN
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78372779
type: Answer
score: 2

http://stackoverflow.com/comment/138155162
has text: I have the strong suspicion that your file does not contain `LF` (`\n`) but only `CR` (`\r`). So it actually sees a single record with many fields of which you only print field 2 till 5 where the fifth field is something like `699\rtransport`. you could consider to define `-v RS="\r"`
type: QuestionComment
comment on: http://stackoverflow.com/q/78364618
type: Comment
score: 1

http://stackoverflow.com/a/78317659
has comment: http://stackoverflow.com/comment/138074239
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/138074290
has comment: http://stackoverflow.com/comment/138074301
has comment: http://stackoverflow.com/comment/138074318
has comment: http://stackoverflow.com/comment/138074465
has comment: http://stackoverflow.com/comment/138074358
has comment: http://stackoverflow.com/comment/138074303
has comment: http://stackoverflow.com/comment/138074347
answers question: http://stackoverflow.com/q/78317617
downvote count: 0
type: Answer
has body: Bash is a very poor choice of languages for this purpose -- I'm going to assume it's an academic exercise. One way to implement this that works around the memory limitations that would break any attempt to generate a brace expansion of the length exposed would look like: maybe_append() { local recurse_count arg line # declare locals so they don't leak recurse_count=$1; shift # pop fixed arguments off our arg list # ...everything we don't shift off will be in $@ while IFS= read -r line; do : line="$line" printf '%s_\n' "$line" # flag first output as needing no further suffix $line = *_ && continue # input with an _ == skip for arg in "$@"; do : arg="$arg" # everything past here goes into the... printf '%s%s\n' "$line" "$arg" # ...recursive pipeline. done done | { if (( recurse_count > 1 )); then # pass output into another copy of this function to append more maybe_append "$((recurse_count - 1))" "$@" else tr -d '_' # done recursing: don't add anything else, just strip '_'s fi } } Given that, a demo using smaller/saner numbers looks like: $ printf '%s\n' {A..C} | maybe_append 2 {A..C} A AA AAA AAB AAC AB ABA ABB ABC AC ACA ACB ACC B BA ...etc; replace {A..C} and 2 to taste to make the logic work with larger ranges. One of the important things about this approach is that we're never trying to store our result list in memory -- each instance of maybe_append (of which there's up to our desired string length minus one) stores at any given time the line of input it's transforming, its recursion depth, and the list of characters it can append; it's split off into separate processes (again, one per digit, so 10 in your example), but thanks to UNIX using copy-on-write following a fork(), most of the memory is shared between them.

http://stackoverflow.com/comment/138198603
has text: `git show -G"Last updated"` would always show every commit because the timestamp is always updated. I want to know when there are no other changes. So if there are other changes, do nothing.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78378370

http://stackoverflow.com/comment/138195933
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78387161
has text: But it cuts to the text outline. Can I do it to trim along the edge of the red section? Just reduce Y?
type: Comment

http://stackoverflow.com/a/78384589
has body: You can just leave the eval out and unquote the final line mycommand="curl $mycommand --url '${requestURL}'" echo "Search Command $mycommand" $myresponse
type: Answer
downvote count: 2
answers question: http://stackoverflow.com/q/78383368
score: -2
has comment: http://stackoverflow.com/comment/138190241
upvote count: 0
has comment: http://stackoverflow.com/comment/138207367

http://stackoverflow.com/comment/138197234
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78388939
has text: Sorry, this isn't a tutoring service. We help you fix the code you've written, we can't provide general guidance on how to write it in the first place.
score: 1

while-loop
type: Tag
tag name: while-loop
tags question: http://stackoverflow.com/q/78434093
tags question: http://stackoverflow.com/q/78368689
tags question: http://stackoverflow.com/q/78456881
tags question: http://stackoverflow.com/q/78525043
tags question: http://stackoverflow.com/q/78649419
tags question: http://stackoverflow.com/q/78620165
tags question: http://stackoverflow.com/q/79111022
tags question: http://stackoverflow.com/q/79372466
tags question: http://stackoverflow.com/q/79392835
tags question: http://stackoverflow.com/q/79446105
tags question: http://stackoverflow.com/q/79530052
tags question: http://stackoverflow.com/q/79431724

http://stackoverflow.com/a/78369765
type: Answer
has body: I do not want to untar it to disk and then tar from disk. I hope I can untar the file into stdout, and then tar the files from stdin [...] Is there any method that I can do this correctly? No, not with the standard tar utility. It does not accept file data on its standard input, because it needs file metadata along with -- permissions, ownership, timestamps, possibly more. It gets that from the filesystem. GNU's implementation of tar will accept names of files to archive from its standard input, as an alternative to taking them on the command line, but it will not accept content that way. You could conceivably write a program to do this, perhaps using something like libtar, though I note that that particular project seems abandoned.
downvote count: 0
answers question: http://stackoverflow.com/q/78369669
score: 2
upvote count: 2

http://stackoverflow.com/comment/138268302
score: 0
type: QuestionComment
has text: You can grep a file without cat, by the way
type: Comment
comment on: http://stackoverflow.com/q/78428782

http://stackoverflow.com/comment/138293318
type: QuestionComment
type: Comment
has text: A couple stlyistic things. Using `clear` can make it more difficult to see the evidence of what went wrong. After you've used your script for 2 yrs, maybe you can uncomment it (-; Pretty much anytime you see `""` in your code (2 dbl-quotes), there is likely a better way (in this case as shown in RP's comment above). And, as you learned the hard way, using `rm -rm something` can be very painful. Again, for the first 2 years of shell development, just `echo rm -rf something` and then after confirming the sanity, copy/paste to execute that command (there are other ways to verify, but got to go).
comment on: http://stackoverflow.com/q/78440831
score: 1

http://stackoverflow.com/comment/138298156
comment on: http://stackoverflow.com/q/78444871
has text: In other parts of your code you're also using using double quotes when you should be using single, and in others still you're using no quotes when you should be using double quotes. It's absolutely crucial to fully understand what types of quotes (single, double, or none) to use in which situations if you're going to do any shell programming - see https://mywiki.wooledge.org/Quotes.
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/q/78387338
score: -1
has title: How to run a python file on a bash terminal in Vscode?
has comment: http://stackoverflow.com/comment/138196767
tagged with: bash
tagged with: visual-studio-code
answer count: 1
favorite count: 0
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/78344829
has answer: http://stackoverflow.com/a/78387469
has body: (https://i.sstatic.net/4O8ajzLj.png) So I saw a tutorial about how to set your vscode to use python. I had to install Anaconda, and on vscode I installed python extension. On the video the guy also sets the terminal to run as bash and not the usual terminal. Buuut when i create a simple function like the photo, after clicking on run, and then, call the function on the bash terminal like hi(), it doesn't even return something. But if I write to print something, it shows on the bash terminal. I tried to run python functions and was not able to call this function in the bash terminal, only prints works. Example: vtorp@blabla ~/OneDrive/Área de Trabalho/Teste python $ x() x() bash: syntax error near unexpected token `x'
type: Question
accepted answer: http://stackoverflow.com/a/78387469
upvote count: 0
tagged with: python
tagged with: anaconda
downvote count: 1

http://stackoverflow.com/comment/138250752
comment on: http://stackoverflow.com/a/78417692
has text: Interesting, is that more efficient than just `.*`?
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/a/78427821
type: Answer
downvote count: 0
has body: This is well documented in the manual: [When -e is set, t]he shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of any command executed in a &amp;&amp; or || list except the command following the final &amp;&amp; or ||, any command in a pipeline but the last, or if the command’s return status is being inverted with !. If a compound command or shell function sets -e while executing in a context where -e is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. Your function does abort in a context where -e is not ignored. For example: $ f(){ set -euo pipefail ; git statu; echo $?; } $ ( f; echo OK ) git: 'statu' is not a git command. See 'git --help'. The most similar commands are status stage stash $
answers question: http://stackoverflow.com/q/78427625
type: AcceptedAnswer
upvote count: 3
accepted answer of: http://stackoverflow.com/q/78427625
score: 3

http://stackoverflow.com/a/78355289
has comment: http://stackoverflow.com/comment/138153327
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/78354041
upvote count: 1
has body: We can easily read the file with Awk using \n%\n as a record separator. We don't know in advance how many records there, are and would like to choose a random one with a equal probability. Let's say that the file is very large, so that we don't want keep the quotes in an array in memory. This very problem in computer science is answered by Reservoir Sampling. We might as well go for the optimal "Algorithm L". Since we only want one quote, and not a random sample of k entries, in other words k is 1, it simplifies: randomInteger(1,k) simplifies to randomInteger(1,1) which simplifies to 1. Here is an attempt to translate the algorithm to a GNU Awk. We have to rearrange the logic because we don't control the loop over the records, and we don't have random access over the input records S[]. Other than that, we will keep the same variable names as used in the Algorithm L description in the referenced Wikipedia page: #!/usr/bin/gawk -f BEGIN { RS = "\n%\n" # seed the PRNG srand(PROCINFO["pid"] + systime()) # select first record to be R i = 1 # initialize random parameter W W = rand() } # we have reached record i NR == i { # replace selection R = $0 # choose next record i += int(log(rand())/log(1 - W)) + 1 # shrink W to lower probability W *= rand() } END { print R } GNU Awk's srand, if not given an argument, uses the time of day as a seed. That has only one second granularity, so we use the process ID and time of day to get different random numbers in consecutive runs that occur within the same second. I seem to have a %-separated Fortunes file on my system, but one specifically for the VLC program, filled with VLC-related quotes, with lots of material from some #videolan IRC channel: $ ./fortunes.awk fortunes.txt < nefrir> btw, anyone *really* opposed to temporary (1 month at most) breakage of video splitter (wall, clone, panoramix) and some vout filters (ie some mode of deinterlacing, opencv, autocrop) in master ? < j-b> NO < j-b> nefrir: seriously, if people care, they …
has comment: http://stackoverflow.com/comment/138463889
type: Answer
has comment: http://stackoverflow.com/comment/138462588
has comment: http://stackoverflow.com/comment/138460238

http://stackoverflow.com/comment/138197975
comment on: http://stackoverflow.com/q/78383368
type: QuestionComment
has text: mSearchResponse="$(curl -v --header Authorization:\'Bearer $accessTokenFromAuthResponse\' --url 'https://myfullurl')" returns >>>> Accept: */* > Authorization:'Bearer > < HTTP/2 401 <<<
type: Comment
score: 0

http://stackoverflow.com/comment/138072078
score: 2
type: Comment
type: QuestionComment
has text: That is, `sleep 900 & sleep_pid=$!` -- no job control needed, no `grep` needed, etc. And if job control is turned off you don't get the message you're asking about.
comment on: http://stackoverflow.com/q/78317514

http://stackoverflow.com/comment/138140349
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78356050
type: Comment
has text: Thank you to Barmar, i dont see his answer and there was in the first comment.

http://stackoverflow.com/comment/138098239
score: 0
has text: It looks like `sqlplus` does not recognise `localfileToExecuteOnDistServ.sql` as a command or that there is an error in that file. Have you tried `ssh user@a sqlplus -s -l "$dbconnect" localfileToExecuteOnDistServ.sql` from the command-line? Does that give the same error?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78328611

http://stackoverflow.com/comment/138153871
score: 1
has text: There is no way to change the shell's rules for when quotes are required, short of moving to a shell with different rules. I hear Zsh does this (which in my book is a reason to avoid it; but you might want to try it for interactive use).
type: QuestionComment
comment on: http://stackoverflow.com/q/78363374
type: Comment

http://stackoverflow.com/comment/138224584
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78404233
has text: See [Merge 16 lines into one line](https://stackoverflow.com/a/47348104/1765658)
type: QuestionComment

http://stackoverflow.com/comment/138163916
type: Comment
score: 0
type: QuestionComment
has text: `-T -` means that the _filenames_ will be read from stdin; not file contents. There might not be a way to do this using just `tar`. For the reasons and a possible workaround see [Is it possible to make a .tar.gz file directly from stdin? Or, I need to tar together already gzipped files](https://unix.stackexchange.com/questions/214542/is-it-possible-to-make-a-tar-gz-file-directly-from-stdin-or-i-need-to-tar-tog/214586#214586) (it is about tgz, not tar, but the reasoning is the same).
comment on: http://stackoverflow.com/q/78369669

http://stackoverflow.com/q/78385537
tagged with: lamp
tagged with: node.js
tagged with: linux
tagged with: bash
has body: I run a webserver on a LAMP stack, which includes a secondary Node.js server running on localhost that some requests get passed off to. I normally start/restart this process manually, using these 3 commands: cd /var/www/html/connect node secondaryServer.js &amp;&gt; output.log &amp; disown I'm trying to migrate this set of commands to a bash script (eventually to be called remotely, via PHP, so I can re-start the Node.js server via an Admin console on the website), so that I just have to call one file instead of typing each line in each time. But I can't seem to get it to work where the Node process survives the end of the script. Most resources I've seen just mention needing to start it in the background, which I'm already doing with the &amp; (to the best of my knowledge). I'm struggling to debug this, as I don't really get any meaningful output aside from knowing that the new process isn't still alive when the script concludes. Any advice on how to get this Node process to survive properly? I tried merging the 'disown' command with the 'node' command like this: disown node secondaryServer.js &amp;&gt; output.log &amp; But that also didn't work. Edit: I changed the script to: #!/bin/bash cd /var/www/html/connect strace -f -o nodejs.log node secondaryServer.js &amp;&gt; output.log &amp; PID=$! echo $PID disown I re-ran it using: sudo ./startSecondaryServer.sh The file nodejs.log is empty though; does that mean the issue is something different than I expected? I get a PID out as output, but when I do ps aux that PID is not present in the table. And the server isn't running.
has comment: http://stackoverflow.com/comment/138191364
has comment: http://stackoverflow.com/comment/138192759
has comment: http://stackoverflow.com/comment/138191336
has comment: http://stackoverflow.com/comment/138192563
has comment: http://stackoverflow.com/comment/138191220
score: 0
type: Question
answer count: 0
has title: How to Start Node Process in Background via Bash Script (and Survive Script's Finishing)
type: UnansweredQuestion

http://stackoverflow.com/comment/138244007
comment on: http://stackoverflow.com/a/78411906
score: 0
has text: @tanfei12345 For a static value, try `jq -n '… {NewAttributes: "NewValue", OptionName: first, Value: last} …' --args …`. To import it from the shell, try `jq -n '… {$NewAttributes, OptionName: first, Value: last} …' --arg NewAttributes "NewValue" --args …`. Also, have a look at the [manual](https://jqlang.github.io/jq/manual/). The options `--arg` and `--args` are explained under [Invoking jq](https://jqlang.github.io/jq/manual/#invoking-jq).
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138245400
type: QuestionComment
type: Comment
score: 0
has text: Why are you escaping `[` and `]` in the `Dockerfile`? This seems unnecessary.
comment on: http://stackoverflow.com/q/78416125

http://stackoverflow.com/comment/138198692
type: QuestionComment
comment on: http://stackoverflow.com/q/78389511
type: Comment
has text: Your attempt `cat file | grep variable1 | sh` finds all the instances of `variable1` but executes them in a new shell, which then exits - so it doesn't help you.
score: 0

http://stackoverflow.com/comment/138214496
comment on: http://stackoverflow.com/q/78398495
score: 0
has text: Oh. You're truncating the `_64` from `x86_64`. Yeah, that won't work without going out of your way to install 32-bit libraries -- you _really do_ have the exact same problem as the person whose question I linked in an above comment. `x86` and `x86_64` are not interchangeable.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138173234
has text: Anyway, look at the man page for execve, https://man7.org/linux/man-pages/man2/execve.2.html . RDI is `const char *pathname`, RSI is `char *const argv[]`, a pointer to an array of pointers.
score: 0
comment on: http://stackoverflow.com/q/78374908
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138173685
comment on: http://stackoverflow.com/a/78375051
has text: @JohnBollinger, Bash treats `/dev/stdin` and `/dev/stdout` (and `/dev/stderr`) specially in redirections. For redirections, they work even on systems that do not have `/dev/stdin` and `/dev/stdout` device files.
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138221300
type: AnswerComment
comment on: http://stackoverflow.com/a/78390328
score: 0
type: Comment
has text: Hi agian. Whith the daemon of while true, the cpu is at 100%. I tried to put in while true a sleep of 3 seconds and CPU has decreased. Do you know if with these fix, always get all traps of fifo file? Thanks

http://stackoverflow.com/a/78419614
downvote count: 0
answers question: http://stackoverflow.com/q/78419580
has comment: http://stackoverflow.com/comment/138251710
has comment: http://stackoverflow.com/comment/138251847
score: 1
upvote count: 1
has body: Wildcard expansion is for finding names of files in the actual file system. To test whether a string contains characters you are interested in, you can use the regular expression matching operator, =~: #!/bin/bash -e function TestIt { if $1 =~ \.l ; then echo "$1 contains \".l\"." else echo "$1 does not contain \".l\"." fi } TestIt "fofo.l" TestIt ".l" TestIt "foo.landmore" TestIt "xl" TestIt "fofoxl" This outputs: fofo.l contains ".l". .l contains ".l". foo.landmore contains ".l". xl does not contain ".l". fofoxl does not contain ".l".
type: Answer

boot
type: Tag
tag name: boot
tags question: http://stackoverflow.com/q/78320604
tags question: http://stackoverflow.com/q/78944308

http://stackoverflow.com/comment/138205306
score: 0
has text: Serializing the function is exactly what I was looking for and it did the job, with just a single ssh connection. Thanks @CharlesDuffy for pointing it out!!
type: QuestionComment
comment on: http://stackoverflow.com/q/78392466
type: Comment

http://stackoverflow.com/comment/138256831
type: Comment
has text: there should be a array to contain the object, I updated it
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78422524

http://stackoverflow.com/comment/138204786
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78393091
has text: Bash really is one shell of many, so it something like "Bash scripting is shell scripting, but shell scripting isn't necessarily Bash scripting". A more important distinction is sometimes to be made between Bash and POSIX shell scripting; [Difference between sh and Bash](https://stackoverflow.com/q/5725296/3266847) talks about that.

http://stackoverflow.com/comment/138307586
type: QuestionComment
has text: .txt gives me the same error
comment on: http://stackoverflow.com/q/78444871
type: Comment
score: 0

http://stackoverflow.com/comment/138200092
type: QuestionComment
has text: @MarkSetchell I got it! It was this last comment that turned on the light bulb. The solution turns out to be simpler than I ever expected. `export $(grep -m1 variable1 <path_to_file>)` (m1 because the declaration actually shows up more than once in the file). And it works as expected. Thank you for your help.
comment on: http://stackoverflow.com/q/78389511
type: Comment
score: 0

http://stackoverflow.com/comment/138159916
score: 0
comment on: http://stackoverflow.com/a/78364778
type: Comment
type: AnswerComment
has text: @tripleee in my case, I've been using the same old Mac and OS for a "long time" (MBP Retina, macOS Sierra, since 2017), so old conventions still apply for me.

http://stackoverflow.com/comment/138261542
type: Comment
has text: ok thanks @LMC for confirmation. This answers, basically I wanted to confirm if there is any other way.
score: 1
comment on: http://stackoverflow.com/q/78424828
type: QuestionComment

http://stackoverflow.com/comment/138209147
comment on: http://stackoverflow.com/q/78393852
score: 0
type: QuestionComment
type: Comment
has text: sorry, I've edited my post, using OS Debian Bullseye 11

http://stackoverflow.com/comment/138196707
has text: Thx I adapted my script and it seems to work just as fine :)
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78385408
score: 1

http://stackoverflow.com/comment/138072445
type: QuestionComment
type: Comment
has text: @CharlesDuffy Also what is the half after the & do in this `sleep 900 & sleep_pid=$!` I don't entirely understand this is not how the professor showed us and nor was job control mentioned, it has to run on the school server and I don't have much privilege on that server
score: 0
comment on: http://stackoverflow.com/q/78317514

http://stackoverflow.com/comment/138265668
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
has text: I'm petty sure there are no stray CR characters in the script. 1) I authored the script on the same macOS system. 2) `grep ^M bash-if-trouble.sh` produces no output. 3) My editor indicates LF line endings.
type: Comment
score: 0

http://stackoverflow.com/a/78412703
has body: grep (without perl regex) is not the best tool to and-combine regular expressions. sed or awk would be easier to use. Example with GNU sed (for the case-insensitive I modifier): sed -En '/u/I{/^[bluntam]{4,}$/Ip}' /usr/share/dict/words Or with any sed that supports extended regex: sed -En '/[uU]/{/^[bluntamBLUNTAM]{4,}$/p}' /usr/share/dict/words With GNU awk (for the case-insensitive IGNORECASE variable): awk -v IGNORECASE=1 '/u/ &amp;&amp; /^[bluntam]{4,}$/' /usr/share/dict/words Or, with any awk: awk '/[uU]/ &amp;&amp; /^[bluntamBLUNTAM]{4,}$/' /usr/share/dict/words
score: 2
answers question: http://stackoverflow.com/q/78411166
type: Answer
upvote count: 2
downvote count: 0

http://stackoverflow.com/a/78403450
has comment: http://stackoverflow.com/comment/138366860
has body: As John mentioned, there are a couple issues with this script. I think the biggest issue is that the error output from the mysql command is not going to show up in the "Error.log" file since the error output isn't captured from the mysql command itself. I would recommend not setting the "output" variable to the output of the mysql command, but instead doing the following: echo "$sqlquery;" | mysql --host=localhost --user=sqluser --password='sqlpwd' sqldb1 >> Output.log 2>> Error.log Note, that I also have it append to the files, as opposed to truncating them for each run. This is important, since the invocation of mysql is in a loop and therefore the only thing that could be possible be in either of the files would be from the last run and not from all the runs. Having said all this, here's an alternative to the script: #!/bin/bash while read line; do configname=$(echo "$line" | cut -d, -f1) servicename=$(echo "$line" | cut -d, -f2) # oldcommand=$(echo "$line" | cut -d, -f3) # Never used. newcommand=$(echo "$line" | cut -d, -f4) sqlquery="SELECT config_name,service_description,check_command FROM tbl_service WHERE config_name='$configname' and check_command='$newcommand' and service_description='$servicename'" echo "$sqlquery" # Not really sure the purpose of this line. echo "$sqlquery" >> Output.log echo "$sqlquery;" | mysql --host=localhost --user=sqluser --password='sqlpwd' sqldb1 >> Output.log 2>> Error.log done < "$1" Note that I changed out all the variable=$(echo -e "some string with other variables") to just variable="some string with another variables". The -e option does cause "echo" to interpret certain sequence of characters to output control characters, but I don't see how any of those would be used here so I got rid of them. You might also note that I added a echo "$sqlquery" >> Output.log since I didn't know what good it did to just output that string to standard out, and I could see adding it to the file, so you could tell when each run began. Obvious…
score: 0
has comment: http://stackoverflow.com/comment/138256822
has comment: http://stackoverflow.com/comment/138256823
has comment: http://stackoverflow.com/comment/138366890
has comment: http://stackoverflow.com/comment/138256779
has comment: http://stackoverflow.com/comment/138256804
has comment: http://stackoverflow.com/comment/138352430
has comment: http://stackoverflow.com/comment/138263391
answers question: http://stackoverflow.com/q/78402103
has comment: http://stackoverflow.com/comment/138256843
has comment: http://stackoverflow.com/comment/138256829
type: Answer

http://stackoverflow.com/comment/138240776
type: Comment
comment on: http://stackoverflow.com/q/78411166
has text: Please [edit] your question to include a [mcve] with concise, testable sample input and expected output. Make sure to cover the most difficult cases for the regexp you want to match and, more importantly, not match despite being very similar to matching input. Without that to test against to prove it works, its hard to say just by reading any given ""fancy regex" if it actually works or not.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138284821
score: 1
comment on: http://stackoverflow.com/q/78438262
has text: `awk '!/local_address/ && $2~ /^845DA8C0:/ { ... }'`
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/138203155
score: 0
has text: Fun, I had completely forgotten `socat`! But today I don't use them longer (I prefer `ssh`;-)... Not always installed, doable simply under shell... Even `bash`could resonably replace `netcat` wth `/dev/tcp` in a lot of cases.
comment on: http://stackoverflow.com/a/78392246
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138139967
score: 0
type: QuestionComment
has text: i know but i have to learn first to do that with a sed script, i cant use awk since next month.
comment on: http://stackoverflow.com/q/78356050
type: Comment

http://stackoverflow.com/comment/138211322
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78396452
type: Comment
has text: Found the issue for the empty line at the start. I removed a lot of lines for the example curl output I posted. Unfortunately I also removed one ` ` from the example. So after `Startup Procedure` there is a line which starts with ` `.

http://stackoverflow.com/comment/138256331
has text: Ah. FYI, @Tate_87, editing questions in ways that invalidates preexisting answers isn't allowed, and if nobody had added an answer to the new form of the question before this came to attention I would have rolled back your question to its original version and asked you to add a new/separate question for your new/separate problem.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78421472

http://stackoverflow.com/comment/138137551
comment on: http://stackoverflow.com/q/78350497
type: Comment
score: 0
type: QuestionComment
has text: BTW, if you prepend `set -x;` to the remote command, as in, `tar -pzcf - example.txt | ssh user@198.123.45.678 "set -x; tar -C ${root_path@Q} -xzf -"`, is that honored? (It should cause the remote shell to print a log message describing the arguments it passed to `tar`).

http://stackoverflow.com/q/78336037
answer count: 2
has comment: http://stackoverflow.com/comment/138104336
tagged with: hostname
type: AnsweredQuestion
has title: How can I cleanly do a lookup of a value with a substring extracted from a hostname in bash?
has answer: http://stackoverflow.com/a/78336259
tagged with: lookup
has comment: http://stackoverflow.com/comment/138104324
has body: the following bash regex will set the memory variable according to machine hostname name we have in the lab many machines with different name as following small example presto01 presto02 hadoop01 hadoop02 mngmnthadoop01 mngmnthadoop01 . . . for example if hostname - is contain the presto name or mngmntpresto name , then following bash code will set the variable memory to 23G hostname=$( hostname -s ) [[ $hostname =~ (^|^mngmnt)presto[[:digit:]]+$ ]] &amp;&amp; memory=23G [[ $hostname =~ (^|^mngmnt)hadoop[[:digit:]]+$ ]] &amp;&amp; memory=12G [[ $hostname =~ (^|^mngmnt)kafka[[:digit:]]+$ ]] &amp;&amp; memory=10G . . . but as I know case in bash not support regular expressions but doing my code as I explained isn't so elegant , and I am wondering if we can do it better ?
accepted answer: http://stackoverflow.com/a/78336259
tagged with: case
type: Question
has answer: http://stackoverflow.com/a/78336113
tagged with: linux
downvote count: 0
score: 1
tagged with: bash
possible better answer: http://stackoverflow.com/a/78336113
upvote count: 1
has comment: http://stackoverflow.com/comment/138104607
favorite count: 0

http://stackoverflow.com/comment/138197979
type: Comment
has text: echo on $accessTokenFromAuthResponse returns the full token.. what am I missing.. ? $accessTokenFromAuthResponse is data
comment on: http://stackoverflow.com/q/78383368
score: 0
type: QuestionComment

http://stackoverflow.com/q/78349529
has comment: http://stackoverflow.com/comment/138129206
has comment: http://stackoverflow.com/comment/138137511
type: Question
tagged with: shell
has answer: http://stackoverflow.com/a/78350302
downvote count: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/78350302
has comment: http://stackoverflow.com/comment/138134595
has title: why does `watch` skip every other line when --no-wrap in enabled and all the lines are short
has comment: http://stackoverflow.com/comment/138129313
has comment: http://stackoverflow.com/comment/138129042
has comment: http://stackoverflow.com/comment/138129050
score: 2
upvote count: 2
tagged with: bash
has comment: http://stackoverflow.com/comment/138137470
favorite count: 0
has comment: http://stackoverflow.com/comment/138129459
has comment: http://stackoverflow.com/comment/138129224
has body: If I run this command: watch --no-wrap 'echo 0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9' I get this output: Every 2.0s: echo 0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9 dave: Thu Apr 18 18:06:55 2024 0 2 4 6 8 Which seems very strange. As the documentation in --help says the following: -w, --no-wrap turn off line wrapping These are not long lines, and shouldn't require wrapping. And even if they did, we should still see the beginning of each line... For comparison, here is the output without the --no-wrap Every 2.0s: echo 0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9 dave: Thu Apr 18 18:10:32 2024 0 1 2 3 4 5 6 7 8 9 Some relevant info about my setup: % watch --version watch from procps-ng 3.3.17 % echo $LINES $COLUMNS 45 143
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138129617

http://stackoverflow.com/comment/138271677
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78425903
score: 0
has text: I Did initially get it working with rename. rename -E "s/\_N\_/_"$theID"_/" -E "s/\.cfc_/.cfc/" *.cfc_; I just wanted to be able to do it in Regex. But thanks very much for the suggestion.

http://stackoverflow.com/a/78364736
answers question: http://stackoverflow.com/q/78364647
type: Answer
has comment: http://stackoverflow.com/comment/138155217
downvote count: 1
has body: You can trap the "DEBUG" signal to inspect the command before execution. Then a simple extension check can block .py files but nothing else. You can also test the first line with head -n1 to see if it's the shebang. Here's a proof of concept: shopt -s extdebug; stop_cmd () { [ -n "$COMP_LINE" ] && return # not needed for completion [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # not needed for prompt local this_command=$BASH_COMMAND; if $this_command == *.py && "$(head -n 1 $this_command)" != '#!"* ; then echo "Blocking execution of Python script without shebang: $this_command" return 1 else return 0 fi }; trap 'stop_cmd' DEBUG
has comment: http://stackoverflow.com/comment/138155197
upvote count: 4
has comment: http://stackoverflow.com/comment/138155148
score: 3
has comment: http://stackoverflow.com/comment/138155130
has comment: http://stackoverflow.com/comment/138155179

http://stackoverflow.com/a/78488238
downvote count: 0
has body: I suggest plink.exe is not returning because it oppened some kind of an interactive shell on the linux host... Therefore waiting on a prompt. If there was any networking issue, you would get an error after 120 sec. Suggesting to run the plink.exe command interactively in PowerShell terminal, and see what happens. Suggesting to inspect the relevant plink.exe documentation, especially options -v and -batch
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78444561

http://stackoverflow.com/comment/138072074
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78317514
has text: That said, there's a lot that's odd about this code. Job control is generally turned off _altogether_ in noninteractive shells. The general Right Thing is to store the PID of your jobs directly, not to try to pull them out of `jobs -l`.
score: 0

http://stackoverflow.com/a/78370087
has body: -d $filename tests if $filename is a directory, not if $filename contains a directory part. You can declare a function that uses a bash conditional expression with the =~ operator (regex matching) and the BASH_REMATCH array to do the test and to separate the path components: do_my_stuff() { filename=$1 if ! -f $filename ; then printf '%s: file not found\n' "$filename" return 1 fi if $filename =~ ^(.*)\\(.*) ; then directory=${BASH_REMATCH[1]} cd "$directory" || return 1 filename=${BASH_REMATCH[2]} fi printf 'Extracting Filename: %s\n' "$filename" } And then: do_my_stuff 'D:\SYSTEM\System\Quality controlled songs\My drip Confession.flac' We first test the existence of file $filename and return with status 1 (error) if $filename does not exist or if it is not a file. Then we use =~ to test if there is a directory part in $filename. If yes we separate the components, we try to cd to the directory and return with status 1 if it fails. Note: thanks to the returned status you can use the function in a test: if do_my_stuff "some file name"; then <cool> else <oops> fi
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78366773

http://stackoverflow.com/q/78438850
has title: How can I set a path to a variable in the bash shell?
score: 0
has comment: http://stackoverflow.com/comment/138286084
type: Question
has comment: http://stackoverflow.com/comment/138288811
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138288821
has comment: http://stackoverflow.com/comment/138285884
tagged with: ubuntu-22.04
has body: I'm following the documentation for Seismic Unix software to install it on Ubuntu 22.04. However, I'm having trouble properly setting the path to a specific variable in the bash shell. According to the documentation, the first step is to create a folder for installing the software, with I did on the path "/home/felipe/Work/Seismic_Unix_Hub". Then, I placed the file cwp_su_all_44R28.tgz in this folder and executed the command "tar -xvf cwp_su_all_44R28.tgz", which created a directory tree with "src" inside the mentioned folder. The next step was to navigate to "/home/felipe" in the terminal to edit/create the files .bashrc and .bash_profile. The first file already exists, so I appended the following to the end of it: # set the CWPROOT variable export CWPROOT=/home/felipe/Work/Seismic_Unix_Hub # set the PATH variable export PATH=$PATH:$CWPROOT/bin:. I created the second file and pasted the same content into it. Following the tip from "F. Hauri - Give Up GitHub" I removed the "$" from export CWPROOT. Now, when I entered ". .bashrc" in the terminal no errors appears. If I entered "echo $PATH" now I receive the following: "/home/felipe/miniconda3/bin:/home/felipe/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/bin:.:/bin:.:/bin:.:/bin:.:/bin:.:/bin:.:/bin:.:CWPROOT/bin:.:CWPROOT/bin:.:/home/felipe/Work/Seismic_Unix_Hub/bin:." It apears that CWPROOT path is set, but typing "make install" I received the error "CWPROOT environment variable is not set!!". Here is the link to the official documentation that I'm following:text. I checked previous questions to avoid duplicating content, and it seems that none of them address the same issue I'm facing, at least from my beginner understanding of shell. I appreciate all the help. Thanks in advance.
duplicate of: http://stackoverflow.com/q/13245649
has comment: http://stackoverflow.com/comment/138286155
linked to: http://stackoverflow.com/q/13245649
tagged with: bash
has comment: http://stackoverflow.com/comment/138303462

http://stackoverflow.com/comment/138272134
score: 0
comment on: http://stackoverflow.com/q/78429844
type: QuestionComment
has text: Are you using `echo` to enable you to write to the `json.xctestplan` file in the same command? Simply redirecting the output from `jq` will result in an empty output file.
type: Comment

http://stackoverflow.com/comment/138297569
score: 0
type: QuestionComment
type: Comment
has text: Does this answer your question? [Why does non-equality check of one variable against many values always return true?](https://stackoverflow.com/questions/26337003/why-does-non-equality-check-of-one-variable-against-many-values-always-return-tr)
comment on: http://stackoverflow.com/q/78427584

http://stackoverflow.com/a/78684526
has body: I've written something a while back when I wanted to log the data going through a pipe for a histogram. It's a pretty quick an dirty C program but It-work-for-me (tm). You can just put it somewhere in your pipe and the data going through it just passed along unaltered. JSON is outputted to stderror, or to a file with the -o switch. Here's an example: { echo -n A; sleep 3; echo -n B; sleep 6; echo -n C; } | ./pipe_histo2 -z 2>&1 >/dev/null | jq . { "measurements": [ [ 0, 1 ], [ 2, 1 ], [ 8, 1 ] ], "min": 0, "max": 1, "avg": 0.333336, "total": 3, "start_time": "2024-06-28 23:31:34.338997847", "start_epoch": "1719610294", "end_time": "2024-06-28 23:31:43.338917382", "end_epoch": "1719610303", "elapsed": 8, "total_readable": "3B", "elapsed_readable": "08s" } Here's the C code. Copy this into a file called pipe_histo2.c /* To compile: gcc -Wall -o pipe_histo2 pipe_histo2.c Examples: { echo -n A; sleep 3; echo -n B; sleep 3; echo -n C; } | ./pipe_histo 2>&1 >/dev/null | jq . ls -als /dev | ./pipe_histo2 */ /***************************************************************************/ /** Includes **/ #include <stdio.h> #include <stdlib.h> // atexit #include <sys/time.h> // select #include <sys/types.h> // select #include <unistd.h> // select #include <time.h> // clock_gettime #include <string.h> // strlen char *output_file = NULL; FILE *output_fd; unsigned int omit_zero_measurements = 0; unsigned int omit_seconds = 0; unsigned int only_output_json = 0; unsigned int print_graph = 0; void die(char *S) { printf("%s\n", S); exit(1); } void Usage(char *Argv0) { printf("\n" "Usage: <some process> | %s [options] [| <some process>]\n" "\n" " -o Output JSON to a file\n" " -z Omit zero measurements. If value == 0, do not print\n" " -s Omit seconds. Only print values in the JSON\n" " -j Only print JSON. Does not output what has been read, only prints JSON\n" " -g Output an ASCII art graph\n" " -h This help text\n" "\n" "Example: { echo -n A; sleep 3; echo -n B; sleep 6; echo -n C; } …
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78445450

http://stackoverflow.com/a/78417239
score: 0
answers question: http://stackoverflow.com/q/78388693
has body: I used this command. Then the terminal started to accept commands like sudo nano, at the last I installed android studio as administrator mode. export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" Now I can use all of them again
type: Answer

http://stackoverflow.com/comment/138158245
has text: Re "*without breaking other functionalities*", It "breaks" `read`, but you could restore IFS for that command.
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78363871
type: Comment

http://stackoverflow.com/comment/138252465
type: Comment
type: AnswerComment
has text: You might want to read my https://www.biteinteractive.com/picturing-git-conceptions-and-misconceptions/ to get a better sense of what Git is.
score: 0
comment on: http://stackoverflow.com/a/78420010

http://stackoverflow.com/comment/138254158
has text: Thanks. Where did the sub-string `foo` come from and why exactly did the script that you listed fail?
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78420840

http://stackoverflow.com/a/78344420
answers question: http://stackoverflow.com/q/78344372
has comment: http://stackoverflow.com/comment/138119259
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138119698
accepted answer of: http://stackoverflow.com/q/78344372
has comment: http://stackoverflow.com/comment/138119764
score: 2
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/138119249
upvote count: 2
has body: The solution is to use the ANSI C quoting method that can be found here. The dollar-sign followed by a single-quoted string is a special case, as documented there and is apparently used in BASH. while [ justRead != "\n" ] ; do # read -e -s -N 1 justRead read -s -N 1 justRead case "$justRead" in $'\n') echo "return" ;; *) echo -n "$justRead" ;; esac done

http://stackoverflow.com/comment/138101816
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78334609
has text: Although the pipeline is yaml, that condition is not yaml so I would still need some text edit tool. I need to replace only that 'refs/heads/development' with 'refs/heads/main'

http://stackoverflow.com/comment/138175828
comment on: http://stackoverflow.com/a/78376416
type: Comment
score: 0
type: AnswerComment
has text: Regardless of the wrong `if` syntax, it would not work to close session after the `xdrp` session, so I provided a complete solution to the posted use case.

http://stackoverflow.com/comment/138245487
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78416162
has text: And your `for` loop can be simplified to `for file in "${myarray[@]}"`
type: QuestionComment

http://stackoverflow.com/a/78380074
type: Answer
type: AcceptedAnswer
has body: My dockerfile path, in the docker-compose.yml file, are called .../DockerfileBackend and Frontend my files names are... FrontEnd and BackEnd.. just realised it by following the instruction of @Lucas Begnini, and also by changing them in all lowercase, since Docker run (the command) do not accept uppercase naming i guess docker: invalid reference format: repository name (project/docker/DockerfileBackend) must be lowercase. See 'docker run --help'.
accepted answer of: http://stackoverflow.com/q/78374366
answers question: http://stackoverflow.com/q/78374366
score: 0

http://stackoverflow.com/comment/138254768
comment on: http://stackoverflow.com/q/78421398
type: QuestionComment
type: Comment
score: 0
has text: Try using the full path to the script instead of depending on the current directory.

http://stackoverflow.com/comment/138090146
comment on: http://stackoverflow.com/a/78325122
type: Comment
has text: I just ran `exec eval echo '$a'` and it printed nothing. `eval` is a builtin without any path, so it should be run in the same environment, right? So, why wasn't 2 printed?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138118342
has text: I'd pass `bash -s` (on the ssh command line) as an explicit command _just in case_ the remote default is something bizarre.
comment on: http://stackoverflow.com/a/78343881
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/comment/138167489
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78371799
type: Comment
has text: A good start would be reading https://stackoverflow.com/questions/20796200/how-to-loop-over-files-in-directory-and-change-path-and-add-suffix-to-filename or https://stackoverflow.com/questions/23408782/loop-through-files-in-a-given-directory or https://stackoverflow.com/questions/34775232/bash-script-to-extract-all-tgz-in-directory

http://stackoverflow.com/comment/138293035
comment on: http://stackoverflow.com/a/78441790
score: 0
type: Comment
has text: @RACHIDOUBELK : Did you notice the use of `./` pre-pended to `Easy.sh`. It should work that way. You could also try `echo .... >/tmp/Easy.sh ; /tmp/Easy.sh ; /bin/rm /tmp/Easy.sh`. Good luck.
type: AnswerComment

http://stackoverflow.com/comment/138132249
has text: Never seen Jenkins skipping steps before, not unless there was an error on some previous step. How do you "invoke" one pipeline from another?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78348524
score: 0

http://stackoverflow.com/comment/138257503
type: AnswerComment
comment on: http://stackoverflow.com/a/78422867
score: 0
has text: `$ gmake Makefile:36: *** missing separator. Stop.`
type: Comment

http://stackoverflow.com/comment/138170452
type: Comment
has text: You have homedir already, use it
comment on: http://stackoverflow.com/q/78371491
score: 0
type: QuestionComment

http://stackoverflow.com/q/78308913
has body: I want to teach my hands to use the new git switch and git restore instead of using git checkout for everything (see What's the difference between 'git switch' and 'git checkout' <branch>?). What would be a good way to configure my Linux terminal (Bash) to remind me, or even complain, whenever I use the old style? I know that one way would be to write a bash function, but I was wondering if there are also better / more standard ways, such as a configuration in Git to not use deprecated commands. In that sense, not necessarily a duplicate question.
has answer: http://stackoverflow.com/a/78308972
has comment: http://stackoverflow.com/comment/138058883
has comment: http://stackoverflow.com/comment/138067888
accepted answer: http://stackoverflow.com/a/78308972
score: 0
upvote count: 2
downvote count: 2
tagged with: git
answer count: 1
favorite count: 0
linked to: http://stackoverflow.com/q/57265785
duplicate of: http://stackoverflow.com/q/25373595
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138068037
has title: Make Git remind me to use switch / restore instead of checkout
type: AnsweredQuestion

http://stackoverflow.com/a/78373047
score: 1
upvote count: 1
has body: Using any awk and sort -V Get rows until version to print the first part of the file a) Extract the version numbers, pass them to sort -V b) Format the sorted numbers back into the original form and cat both into one file value_to_append="1.0.7.2" cat \ <(awk 'set != 1{print} /version/{set=1}' file) \ <(awk -F ',' -v val="$value_to_append" ' set == 1{ for(i=1;i<=NF;i++){ sub(/ */, "", $i) print $i} print val} /version/{set=1}' file | sort -V | awk '{NR == 1 ? $1 = "\t"$1 : $1 = ", "$1 printf("%s", $1)} END{print ""}') output Config file [version] 1.0.0.0, 1.0.1.0, 1.0.2.0, 1.0.3.0, 1.0.3.1, 1.0.4.0, 1.0.4.1, 1.0.5.0, 1.0.5.1, 1.0.6.0, 1.0.6.1, 1.0.6.2, 1.0.7.0, 1.0.7.1, 1.0.7.2, 1.2.2.1, 1.2.2.8, 1.2.2.9, 1.2.2.10, 1.2.3.0, 1.2.3.1, 1.3.0.0, \ Data % cat file Config file [version] 1.0.0.0, 1.0.1.0, 1.0.2.0, 1.0.3.0, 1.0.3.1, 1.0.4.0, 1.0.4.1, 1.0.5.0, 1.0.5.1, 1.0.6.0, 1.0.6.1, 1.0.6.2, 1.0.7.0, 1.0.7.1, 1.2.2.8, 1.2.2.9, 1.2.2.10, 1.2.2.1, 1.2.3.0, 1.3.0.0, 1.2.3.1, \
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/78372639

http://stackoverflow.com/comment/138094891
score: 0
type: QuestionComment
has text: [so] is for programming questions, not questions about using or configuring Unix and its utilities. [unix.se] or [su] would be better places for questions like this.
type: Comment
comment on: http://stackoverflow.com/q/78330326

http://stackoverflow.com/comment/138172221
has text: Does that backslash at the end of the list of version numbers in your input mean that the list could be continued onto the next line?
comment on: http://stackoverflow.com/q/78372639
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138254017
score: 0
has text: If you need to use the output as input to `INFILE`, then you should use `SELECT INTO OUTFILE`. I think this question counts as an [XY Problem](https://xyproblem.info/).
type: QuestionComment
comment on: http://stackoverflow.com/q/78420308
type: Comment

http://stackoverflow.com/a/78318419
score: 2
answers question: http://stackoverflow.com/q/78317617
type: Answer
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138073752
has body: Using brace expansions for this exercise is problematic for a few reasons: it's not easy to parameterize brace expansions the final expansion works out to 26^10 (141,167,095,653,376) entries which ... will likely consume a LOT more memory than your machine has available and ... bash will need to first build that list of entries which means 100% cpu utilization for several days? weeks? months? I propose replacing the brace expansion with an array to hold the list of letters, eg: letters=( {A..Z} ) Assumption: the output is to be sorted: all 1-char strings (sorted), then ... all 2-char strings (sorted), then ... ... all 10-char strings (sorted) One idea using a bash recursive function: generate() { local curr_level in_string letter curr_level=${1:-1} in_string="$2" [[ "${curr_level}" -eq 0 ]] && { echo "${in_string}"; return; } for letter in "${letters[@]}" do generate $(( curr_level - 1 )) "${in_string}${letter}" done } The top level script then looks like: letters=( {A..Z} ) max_level=10 for ((level=1; level<=max_level; level++)) do generate "${level}" done Taking for a test drive with a reduced data set (letters=( {A..C} ); max_level=2): A B C AA AB AC BA BB BC CA CB CC As already pointed out in comments, doing this type of operation in bash is going to be (excruciatingly) slow, especially as you increase the number of characters (aka max_level). Any number of tools (eg, perl, python, ruby, awk, etc) are going to be much faster. One awk approach that implements the same logic as the (above) bash script: awk -v max_level="${max_level}" ' function generate(curr_level, in_string, i) { if (curr_level == 0) { print in_string return } for (i=1; i <= letter_count; i++) generate( curr_level-1, in_string letters[i] ) } { letters[++letter_count] = $1 } # store (bash array) letters in awk array letters[] END { for (level=1; level <= max_level; level++) generate( level, "" ) } ' <(printf "%s\n" "${letters[@]}") # feed bash array letters[] to awk in the form of a single letter …

http://stackoverflow.com/comment/138116718
score: 3
has text: _As for the immediate problem_ -- strings you passed are parsed by the remote shell; your local client-side system doesn't have much control over which shell that is. One thing you _can_ do is `ssh hostname 'bash -c' <<'EOF'` and then feed the code to run on stdin -- that way you _know_ it'll be processed by bash, at least if what you're getting is a "real" shell and bash is itself available.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78342895

http://stackoverflow.com/comment/138074318
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78317659
score: 0
has text: @markp-fuso, ...well -- regardless, it's easy enough to fix the ordering if we pass content through to the end of the pipeline; say, append a space, an `=`, or another distinct character on the end to mark something "done", and then have later pipeline phases recognize content and pass it through without further iteration when that sigil is present (until the very last pipeline phase, stripping the sigil there).

http://stackoverflow.com/comment/138074347
comment on: http://stackoverflow.com/a/78317659
score: 0
has text: @markp-fuso, ...amended as described in the comment above; ordering now should be consistent between invocations.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138103092
score: 0
comment on: http://stackoverflow.com/a/78334765
has text: Thank you for pointing me out. For regular ADO pipelines (the example array is located under key `stages`) I needed to update the command little bit: `yq '(.stages.[] | select(.stage == "qa").condition) |= sub("refs/heads/development"; "refs/head/main")'`
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78431101
downvote count: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/78406644
answers question: http://stackoverflow.com/q/78406644
has comment: http://stackoverflow.com/comment/138274988
type: AcceptedAnswer
upvote count: 1
score: 0
has body: Try this: #!/bin/bash SAVEPATH=$HOME/Documents/save_path.txt savepath () { pwd &gt; $SAVEPATH } gotopath () { cd `cat $SAVEPATH` } The original implementation tried to pass the saved path via stdin. This is not the way that cd works: it needs the target directory as an argument. Using this approach the content of the file is substituted as an argument.
has comment: http://stackoverflow.com/comment/138284613

http://stackoverflow.com/a/78387161
has comment: http://stackoverflow.com/comment/138196029
score: 3
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/138195872
has comment: http://stackoverflow.com/comment/138195970
answers question: http://stackoverflow.com/q/78385603
downvote count: 0
has comment: http://stackoverflow.com/comment/138196023
accepted answer of: http://stackoverflow.com/q/78385603
has comment: http://stackoverflow.com/comment/138196005
type: Answer
has body: You have not said what you platform is nor what version of Imagemagick you are using. So I will assume Imagemagick 6 on a Unix-like system (Linux, Mac OSX or Windows 10/11 unix). This is the approach suggested by Mark Setchell in his comment above. (Make everything that is not red into black. Then trim to the red box bounds and find the top of the red box. Then chop off the top of the image down to the red box. Then add some black padding to the top of the image.) Here is the manual way in case you are on Windows. Sorry, I do not know how to deal with variables. Get the top of the red box, shave it off, then splice back a 20 pixel high black region on the top as pad. convert image1.png -fuzz 1% -fill black +opaque "rgb(237,28,36)" -format "%@" info: That returns the WxH+X+Y and we just want Y 364x28+256+182 Then chop of the top 182 and splice back 20 pixel tall blacktop the top of the image. convert image1.png +repage -gravity north -chop 0x182 -background black -splice 0x20 new_image1.png Here is the more automated way in Unix syntax. top=$(convert image1.png +repage -fuzz 1% -fill black +opaque "rgb(237,28,36)" -format "%@" info: | tr "x" "+" | cut -d+ -f4) convert image1.png -gravity north -chop 0x$top -background black -splice 0x20 new_image1.png Here is the result of either sets of commands above: If on Imagemagick 7, just change convert to magick.
has comment: http://stackoverflow.com/comment/138195933

http://stackoverflow.com/a/78346666
type: Answer
score: 0
has body: Not quite 5.7 seconds for 6-char combos, but I did get awk to crank them out in 8.17 secs, which is really quite decent for non-compiled non-JIT interpreted scripting code - Instead of recursion or memoization/caching, it performs string squaring instead - it's exactly like binary squaring, performed over strings and chars instead of numbers. Binary doubling is relatively inadequate. As long as the input string is pre-sorted, then all generated combos are also pre-sorted. Ideally it should act differently according to the odd/even bits for the input value. For now, it's simply a few hard-coded speed ups for powers of 2. 5-char combos got benchmarked at 0.327 secs for __ in $( jot 15 -3 ) ; do ( time ( echo "$__" | mawk2 ' function ________(__, _, ___, ____, _____, ______) { if ((__ = int(__)) < !__) return else if (__ == index(___ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", _ = "")) { gsub(/./, ",&", ___) return substr(___, ++_+_) } else if ((_ += ++_)^((_+_+_)^_-_) < length(___)^__) return ERRNO = "ERR_OUPUT_OVER_34_BITS" gsub(".", "\\&&", ___) ______ = "&[^&]+" if (__ == _ || __ == _+_ || __ == _*_*_ || __ == _^_^_) { do gsub(______, ___, ___) while (_ <= (__/=_)) } else if (__ == _+_+_) { ____ = ___ gsub(______, ____, ___) gsub(______, ____, ___) gsub(______, ___, ___) } else { ____ = ___ while (--__) gsub(______,____,___) } gsub(/&/, ",", ___) return length(___) } ($++NF = ________($_))' ) | pv ) | gcat -b; echo "\f\t$__ done ...."; done out9: 0.00 B 0:00:00 [0.00 B/s] [0.00 B/s] [<=> ] ( echo "$__" | mawk2 ; ) 0.00s user 0.01s system 83% cpu 0.008 total -3 done .... out9: 0.00 B 0:00:00 [0.00 B/s] [0.00 B/s] [<=> ] ( echo "$__" | mawk2 ; ) 0.00s user 0.00s system 65% cpu 0.004 total -2 done .... out9: 0.00 B 0:00:00 [0.00 B/s] [0.00 B/s] [<=> ] ( echo "$__" | mawk2 ; ) 0.00s user 0.00s system 68% cpu 0.004 total -1 done .... out9: 0.00 B 0:00:00 [0.00 B/s] [0.00 B/s] [<=> ] ( echo "$__" | mawk2 ; ) 0.00s user 0.00s system 74% cpu 0.003 total 0 done .... out9: 54.0 B 0:00:0…
answers question: http://stackoverflow.com/q/78317617

http://stackoverflow.com/comment/138577757
type: AnswerComment
comment on: http://stackoverflow.com/a/78603441
has text: Where _exactly_ in the OP's code are they checking `$?` after running `echo`?
score: 2
type: Comment

http://stackoverflow.com/a/78387469
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78387338
score: 0
answers question: http://stackoverflow.com/q/78387338
has body: Check out this SO question. The reason you are not able to run your program is because you are not running you're program. I'll elaborate. Also, just letting you know, bash is the usual terminal. VSCode probably uses bash. Here is an askubuntu question about that. Anyway, to run the program, run it from the python interpreter: bash$ python(3) &gt;&gt;&gt; from file import x &gt;&gt;&gt; x() or run it from the file itself. def x(): ... x() Run that file with python(3) {{file_name}}. Note that you have to be in the same directory as the file. Happy Coding!!
has comment: http://stackoverflow.com/comment/138195049
type: Answer

http://stackoverflow.com/comment/138277313
type: QuestionComment
has text: `count=$count+1` doesn't do what you think it does; enable debug mode (`set -xv`) or add `typeset -p count` (after the `count=$count+1`) to see what's being saved in `count`; a couple alternatives for incrementing `count`: `count=$((count+1))` or `((count++))`
comment on: http://stackoverflow.com/q/78434093
type: Comment
score: 4

http://stackoverflow.com/comment/138301590
comment on: http://stackoverflow.com/q/78445380
score: 1
type: QuestionComment
type: Comment
has text: If you know that the file exist, don't test the existence, just copy. If the file really is not there, `cp` will complain about it. For debugging, do a `xxd <<<$file` to check that the variable indeed has a reasonable value.

http://stackoverflow.com/comment/138164189
type: QuestionComment
comment on: http://stackoverflow.com/q/78369669
type: Comment
has text: [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551)
score: 1

http://stackoverflow.com/a/78325122
has comment: http://stackoverflow.com/comment/138089072
has comment: http://stackoverflow.com/comment/138089860
has comment: http://stackoverflow.com/comment/138090159
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138090182
answers question: http://stackoverflow.com/q/78325081
has comment: http://stackoverflow.com/comment/138088868
has body: Yes, $a is expanded first, then exec receives the arguments echo and 2. With single quotes, exec receives the arguments echo and $a. In bash, exec declare -p should fail, as declare is a shell built-in command, not an executable. In zsh, using the built-in declare does not cause exec to fail, but is executed in the current shell, and then the current shell exits. (Because you used a pipeline, though, the current shell is a subshell that "copied" the parent, and that's what exits.) You can consider that inheritance if you like, but it's special zsh behavior, not related to the POSIX definition of exec. From man zshbuiltins: exec [ -cl ] [ -a argv0 ] [ command [ arg ... ] ] Replace the current shell with command rather than forking. If command is a shell builtin command or a shell function, the shell executes it, and exits when the command is complete.
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/138090174
type: Answer
has comment: http://stackoverflow.com/comment/138090146
has comment: http://stackoverflow.com/comment/138090055
has comment: http://stackoverflow.com/comment/138089879
accepted answer of: http://stackoverflow.com/q/78325081
downvote count: 0

http://stackoverflow.com/comment/138265093
score: 4
has text: Works for me in the crufty bash 3.2 MacOS ships with, in bash 5.2, and even in zsh.
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
type: Comment

http://stackoverflow.com/comment/138286795
comment on: http://stackoverflow.com/q/78437863
has text: @fmw42 A lowercase V indicates a checkmark (that is, the syntax is supported); a hyphen means a dash (that is, the syntax is not supported). The question marks are what I cannot test myself (and what I'm asking you to help me with).
type: QuestionComment
type: Comment
score: 0

declare
type: Tag
tags question: http://stackoverflow.com/q/78415633
tag name: declare
tags question: http://stackoverflow.com/q/78645192
tags question: http://stackoverflow.com/q/79320464
tags question: http://stackoverflow.com/q/79301929

http://stackoverflow.com/comment/138201633
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78390602
has text: As for "why" -- logs need to go to stderr, not stdout, to keep them separate from output. Put `>&2` on any `echo` line intended to be information for users as opposed to output proper.
score: 0

http://stackoverflow.com/comment/138090067
type: QuestionComment
comment on: http://stackoverflow.com/q/78327616
type: Comment
has text: I don't know what kind of precision you need for decimals, but if you are happy with the usual floating point arithmetic, consider writing the script in zsh (which can do floats). If you need real "decimal" arithmetic (instead of floats), I suggest using a programming language which has support for this (for instance `bc`, as choroba suggested, or Ruby, which has the data type `BigDecimal` ).
score: 0

http://stackoverflow.com/comment/138088493
type: Comment
score: 0
has text: `exec declare -p` does not work in bash. I think bash can't exec, if the "program" to run is an internal command. In zsh, it works. My impression is that zsh, recognizing that `declare` is internal, just reuses its current shell, executes the `declare` (which then shows the local variable, since it is the same process), and terminates: `zz=888; exec declare -p` shows the value for zz.
type: QuestionComment
comment on: http://stackoverflow.com/q/78325081

http://stackoverflow.com/comment/138129488
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78349366
has text: @DavidMaze No, the proxy is not part of this container. This container just contains chrome and has slenium and undetected chrome_driver installed. I actually have a custom hook that essentially allows me to start the driver remotely. However, what the iptables and redsocks does is route all traffic to to another container with the proxy because setting the proxy in the driver options wasn't working for me. When I use docker exec, it is to run the iptables commands and restart redsocks.

http://stackoverflow.com/comment/138162872
has text: Yeah, but the whole idea behind this gimmick was to be fast, just like `!$`/`!!` is. If I have to set it up beforehand, and then roll the `IFS` change back afterwards, it defeats the purpose.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78363871

http://stackoverflow.com/q/78409095
tagged with: matillion
tagged with: python
score: 0
has title: Passing a Date Variable, into another variable value in Matillion
type: Question
has body: We are calling secured API profiles through Matillion Query profile. I wanted to pass the date value to a filter. That date variable will be used in another variable value. But I am not finding any possibilities to do that, can you please help me with this if you can. I tried by adding the bearer token to bash script and filter variable value. However, I was unable to get any positive sign to pass the date variable
type: UnansweredQuestion
tagged with: bash
answer count: 0
has comment: http://stackoverflow.com/comment/138233131

http://stackoverflow.com/a/78417916
has comment: http://stackoverflow.com/comment/138257990
answers question: http://stackoverflow.com/q/78417099
score: 1
has body: It's more reliable to pass the definition of w to remote machine: SSH_CMD=(ssh ...) # suppose `SSH_CMD` is my ssh command w="$(cat word)" { declare -p w cat <<'EOF1' cd /data00 touch for-test echo "$w" >> for-test echo "abc" >> for-test EOF1 } | "${SSH_CMD[@]}"
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/comment/138375651
type: Comment
score: 0
has text: What happens when you run the command interactively?
comment on: http://stackoverflow.com/q/78444561
type: QuestionComment

http://stackoverflow.com/comment/138306554
has text: I'm with @thatotherguy This sounds suspiciiously like a CRLF problem. Use `dos2unix filename` to fix the input file.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78445380
score: 0

http://stackoverflow.com/comment/138275971
score: 1
has text: Thanks for the extra context. You're trying to using Python to execute PowerShell code. Python can only execute Python code. To run the PowerShell script from a PowerShell terminal, just run `./test.ps1`.
comment on: http://stackoverflow.com/a/78433313
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138115297
has text: ...looking back again, that failure to use `@sh` is the _immediate_ cause of your problem -- it's not making it clear that the spaces that are data need to be literal data rather than syntax.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78342087
type: QuestionComment

http://stackoverflow.com/comment/138330017
type: AnswerComment
has text: @F.Hauri-GiveUpGitHub the OP wants to parse the output of a command, not the contents of a file so as I said in my answer "obviously I'm using `cat file` here instead of `lvs...` just for demo purposes".
comment on: http://stackoverflow.com/a/78444349
score: 0
type: Comment

http://stackoverflow.com/comment/138202676
score: 3
type: QuestionComment
type: Comment
has text: Why are you doing this? Are you implementing `printf "%q"`? Are you trying to like "double" quote a string for some other command?
comment on: http://stackoverflow.com/q/78392006

terraform-provider-gcp
tags question: http://stackoverflow.com/q/78366286
type: Tag
tag name: terraform-provider-gcp

http://stackoverflow.com/comment/138137524
has text: _If your remote shell were bash_ (and your local shell were bash 5.0 or later), I'd suggest `tar -pzcf - example.txt | ssh user@198.123.45.678 "cd ${root_path@Q} && tar -zxf -"`. Or, better, `tar -pzcf - example.txt | ssh user@198.123.45.678 "tar -C ${root_path@Q} -xzf -"`
type: QuestionComment
comment on: http://stackoverflow.com/q/78350497
type: Comment
score: 0

http://stackoverflow.com/comment/138137499
type: Comment
comment on: http://stackoverflow.com/q/78350497
score: 0
type: QuestionComment
has text: BTW, once you have an answer that was correct _for the question as it was asked when that answer was written_, it's improper to edit the question in a way that invalidates the answer later (you may find people here referring to questions that change in such ways as "chameleon questions"). Click the accept button, and ask a new question for the new case.

http://stackoverflow.com/a/78342527
has comment: http://stackoverflow.com/comment/138118719
answers question: http://stackoverflow.com/q/78341846
type: Answer
has comment: http://stackoverflow.com/comment/138118682
has comment: http://stackoverflow.com/comment/138116035
has comment: http://stackoverflow.com/comment/138116152
has body: The tool for this job is XSLT. <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSLTransform" version="3.0" expand-text="yes"/> <xsl:variable name="tags" select="tokenize(unparsed-text('tags-file.txt'))"/> <xsl:mode on-no-match="shallow-copy"/> <xsl:template match="Category[@name=$tags]/text()"> <xsl:text>VALUE4 {.}</xsl:text> </xsl:template> </xsl:transform> I've used XSLT 3.0 here. 1.0 processors are more widely available but that makes the code a lot more verbose. Don't try to do this with text-based tools. As you've discovered, it's a pain to get it right, and when you succeed, your code will fail as soon as someone supplies an XML file that's very slightly different from the one you tested on.
score: 0
has comment: http://stackoverflow.com/comment/138118672
has comment: http://stackoverflow.com/comment/138118517
has comment: http://stackoverflow.com/comment/138117463

http://stackoverflow.com/comment/138137574
score: 1
has text: Another way is to simply remove douple quotes: `cut -d';' $criteria_col "$input_file" > ANFR_reduced.csv`. But I won't recommand this way!
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78354730

http://stackoverflow.com/comment/138119259
type: AnswerComment
has text: OH! The single-quote ALSO matters?! I'd heretofore used single and double, ' and ", interchangeably so long as they're paired! Please clarify!
score: 0
comment on: http://stackoverflow.com/a/78344420
type: Comment

http://stackoverflow.com/a/78396452
upvote count: 1
answers question: http://stackoverflow.com/q/78396373
has comment: http://stackoverflow.com/comment/138210812
has comment: http://stackoverflow.com/comment/138210760
downvote count: 0
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/138211322
has body: This works for your input. Obviously, any change in the number of Downstream Channel Status will break the functionality. Basically set values for each given marker and count their occurrences with set1 for Downstream Channel Status and set2 for Within the wanted block substitute the spaces and printf the lines Also within the block, every time is found print a breaking line % awk '/<\/table>/ && set1 == 1{set1--} /Downstream Channel Status/{set1++} set1 == 1 && set2 > 0 && !/tr.*>/{sub(/^ */,"",$0); printf("%s", $0)} set1 == 1 && set2 > 0 && /<.tr>/{print ""} / /{set2++}' fhtml Channel Index Channel ID 1 10 2 1 3 2 4 3 Data % cat fhtml Startup Procedure Downstream Channel Status Channel Index Channel ID 1 10 2 1 3 2 4 3 Upstream Channel Status Channel Index Channel ID 1 9 2 10 3 11

http://stackoverflow.com/comment/138139957
type: QuestionComment
type: Comment
has text: look the desired response, i only want to replace the numbers lower than 100 in the five group of the csv, named km
comment on: http://stackoverflow.com/q/78356050
score: 0

http://stackoverflow.com/comment/138078003
type: Comment
comment on: http://stackoverflow.com/q/78319238
type: QuestionComment
has text: @jhnc, ...aside: I'd suggest making a habit of `>/dev/null` instead of `>&-` -- you don't want a failed write to stdout to return a falsey result by way of error reporting when the check would otherwise be true.
score: 1

http://stackoverflow.com/comment/138089860
comment on: http://stackoverflow.com/a/78325122
score: 0
type: Comment
has text: The shell can (and probably did) find `/bin/echo` (or similar), so executed that in place of the built-in. `declare` is *only* a built-in (built-in by necessity, rather than for efficiency).
type: AnswerComment

http://stackoverflow.com/a/78359503
type: Answer
score: 3
has body: You can combine all of the regular expressions into one sed command to save some processing time. sed -e 's/rs/ &amp;/g' -e 's/-*0\./ &amp;/' \ Model_training_chr21_covariances.txt \ &gt; Model_training_chr21_covariances1.txt -* 0 or more - characters 0 a literal '0' \. a literal '.'
answers question: http://stackoverflow.com/q/78359494
upvote count: 3
downvote count: 0

http://stackoverflow.com/a/78327512
type: Answer
answers question: http://stackoverflow.com/q/78326945
has body: The field separator in your .bed file is an arbitrary number of whitespaces; which is not consistent with the comma separator -F, you specify to awk in your bash script. Try removing the -F, awk delimiter option, which would be useful for a CSV (comma separated values) file but not for your ".bed" file. This way you instruct awk to use it's default field separator (any sequence of space or tab characters).
score: 0

http://stackoverflow.com/comment/138109155
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78337303
has text: @Jab00p – Why do you insist to do it laboriously with `grep`?
type: Comment

http://stackoverflow.com/q/78322081
has comment: http://stackoverflow.com/comment/138080246
has comment: http://stackoverflow.com/comment/138080049
has comment: http://stackoverflow.com/comment/138080034
duplicate of: http://stackoverflow.com/q/8934012
duplicate of: http://stackoverflow.com/q/3826425
tagged with: bash
type: Question
duplicate of: http://stackoverflow.com/q/49849957
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/3826425
score: 0
has comment: http://stackoverflow.com/comment/138080172
answer count: 0
has body: I have the following bash script (here's part of it): 0 #!/bin/bash 1 2 ARGS=2 3 E_BADARGS=85 4 5 is_number() 6 { 7 if [[ "$1" =~ ^[0-9]+$ ]];then 8 return 0 9 fi 10 return 1 11 } 12 13 [ $# -ne $ARGS ] && { 14 echo "must have two args!" 15 exit $E_BADARGS 16 } 17 18 [ ! is_number "$1" || ! is_number "$2" ] && { 19 echo "both must be numbers" 20 exit $E_BADARGS 21 } I'm just vomiting code into my editor that I'll cleanup later and so I'm avoiding the use of ifs and thens and just using conditionals. I'm not sure why: 13 [ $# -ne $ARGS ] && { 14 echo "must have two args!" 15 exit $E_BADARGS 16 } works, but: 18 [ ! is_number "$1" || ! is_number "$2" ] && { 19 echo "both must be numbers" 20 exit $E_BADARGS 21 } gives me an error, can anyone explain? The error I get is: ./GCD.sh: line 19: [: missing `]' but the string: "both must be numbers" is printing... I ran the script like so: ./GCD.sh 12 s
linked to: http://stackoverflow.com/q/806906
has title: bash script conditional not working as expected

http://stackoverflow.com/a/78362284
downvote count: 0
score: 1
upvote count: 1
has body: Using read and parameter expansion hostname='presto-data1-01' IFS='-' read pr data id <<< "${hostname}" echo "$pr '${data%%[0-9]}' $id" if [ "${data%%[0-9]*}" == 'data' ];then echo "data host" else echo "other" fi result presto 'data' 01 data host
type: Answer
answers question: http://stackoverflow.com/q/78361035

http://stackoverflow.com/comment/138205087
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78393091
has text: A [sub-answer to the closing duplicate](https://stackoverflow.com/a/28406783/620097) explains `shell` vs `sh` vs `bash`. But, @buggles, if you're really interested in scripting and all the features that are available (and the distinctions to be found), you'll do well to save a link to the main answer, and come back and reread as you learn more. Good luck.

http://stackoverflow.com/comment/138136417
score: 2
type: Comment
has text: https://askubuntu.com/questions/36523/creating-a-fortunes-file
comment on: http://stackoverflow.com/q/78354041
type: QuestionComment

http://stackoverflow.com/comment/138192563
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78385537
has text: Give it a try. Prepend `strace -f -o nodejs.log ` to your node.js command and run the script again. Then open nodejs.log, scroll to the bottom and tell us why it terminates.
score: 0

http://stackoverflow.com/comment/138115181
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78342087
score: 0
has text: `json=$(cat service-data.json)`; 1) no need for this, just pass it as arg to jq: `jq 'some-filter' service-data.json`

http://stackoverflow.com/a/78357565
type: Answer
downvote count: 0
has body: This might work for you (GNU sed): sed -E 's/[^,]+/\n&amp;\n/5;s/\n.{,2}\n/none/;s/\n//g' file Erect some newline scaffolding around the fifth field. Use pattern matching to replace one or two digits only in the fifth field with none i.e. 100 or more have three or more digits. Remove the scaffolding.
score: 1
answers question: http://stackoverflow.com/q/78356050
upvote count: 1

http://stackoverflow.com/q/78349366
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138128689
favorite count: 0
has comment: http://stackoverflow.com/comment/138129460
has comment: http://stackoverflow.com/comment/138129339
has title: What am I missing in my attempts to automate the iptables and redsocks setup inside a docker container?
has body: I am using a script to setup custom iptables and restart redsocks. It works when I manually run inside a running container, but I want the container to automatically set it up. I thought I could do this with CMD in my dockerfile, but it's not working. What am I missing? Here is the Dockerfile: # Dockerfile # https://github.com/ultrafunkamsterdam/undetected-chromedriver/discussions/1600 ARG CHROME_VERSION FROM selenoid/chrome:${CHROME_VERSION:-latest} as selenoid_chrome FROM python:3.10-bookworm as patcher RUN pip install undetected-chromedriver COPY --from=selenoid_chrome /usr/bin/chromedriver /usr/bin/chromedriver COPY patch_driver.py . RUN python3 patch_driver.py FROM selenoid_chrome USER root RUN apt-get update RUN apt-get upgrade -qy RUN apt-get install iptables redsocks curl wget lynx -qy COPY --from=patcher /usr/bin/chromedriver /usr/bin/chromedriver COPY redsocks.conf /etc/redsocks.conf COPY iptables-config.sh /etc/iptables-config.sh RUN chmod +x /etc/iptables-config.sh CMD [ "bash", "/etc/iptables-config.sh" ] ENV DRIVER_ARGS="--headless=new --start-maximized --window-size=1024,1620 --disable-dev-shm-usage --remote-debugging-pipe --no-sandbox --user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' --verbose" RUN AAA=$(echo '#!/bin/bash\necho $DRIVER_ARGS' ; cat /entrypoint.sh ; ) && echo "$AAA" > /entrypoint.sh USER selenium And here is the shell script I am trying to run: #!/bin/bash #https://medium.com/@jogarcia/breaking-the-proxy-walls-with-redsocks-in-linux-f4c1bfb6fb6a # Configura iptables para que todo el trafico local vaya directamente y el resto # siempre que tenga autorizacion (grupo socksified) vaya a internet a traves de redsocks # Create new chain iptables -t nat -N REDSOCKS # Ignore LANs and some other reserved addresses. # See http://en.wikipedia.org/wiki/Reserved_IP_addresses#Reserved_IPv4_addresses # and http://tools.ietf.org/html/rfc5735 for full list of reserved networks…
tagged with: bash
has comment: http://stackoverflow.com/comment/138129333
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/138129488
has comment: http://stackoverflow.com/comment/138129330
tagged with: docker
score: 0
type: Question
answer count: 0

http://stackoverflow.com/comment/138259620
type: QuestionComment
has text: You can't execute a script without decrypting it. You can decrypt it to standard input of a shell, but then your user can use something else than a shell to save the decrypted code.
type: Comment
comment on: http://stackoverflow.com/q/78423981
score: 1

http://stackoverflow.com/comment/138152853
score: 1
comment on: http://stackoverflow.com/q/78363374
has text: Escape sequences aren't processed in the result of command substitution. You must put it in quotes to begin with: `ls "$(1)"`
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138269343
score: 0
has text: @pmf, thanks for the link, very informative.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78427584

http://stackoverflow.com/comment/138285080
type: AnswerComment
has text: "Improving readability by squeezing out all unnecessary white space:" :-).
comment on: http://stackoverflow.com/a/78438409
score: 3
type: Comment

http://stackoverflow.com/a/78441717
downvote count: 0
upvote count: 1
has body: The simplest solution would be to exclude the character < from regex: sed -e ':a;N;$!ba;s#<<<<<<<<< <<source_dir>>\n\([^<]*\)\n<<<<<<<<< <<target_dir>>[^<]*<<<<<<<<<#\1#g' "$target_file" Output: tesst good safasf tesst241241 safasfas Please note, that if text contains character <, this would no work.
answers question: http://stackoverflow.com/q/78441613
score: 1
type: Answer

http://stackoverflow.com/comment/138251265
type: Comment
score: 0
has text: This is a pretty weird way of making a calculator. But to answer your specific question - put `$3` in double quotes like so`"$3"` to prevent it being glob-expanded. And do what the previous comment said as well.
comment on: http://stackoverflow.com/q/78419450
type: QuestionComment

http://stackoverflow.com/a/78409972
answers question: http://stackoverflow.com/q/78409749
downvote count: 0
score: 1
upvote count: 1
type: Answer
has body: The big inefficiencies here are the external command invocations -- ps and tput. You don't need either to be within your loop; kill -0 can check whether a process is still running using only shell-builtin functionality, and you can store tput's output after calling it once to reuse as many times as you need. tput_rc=$(tput rc) tput_cuu=$(tput cuu1) tput_ech25=$(tput ech25) # note that we require proc_main to be a PID, not a process name while kill -0 "$proc_main"; do for (( i=0; i<25; i++ )); do printf '*' sleep 0.010 done printf %s "$tput_rc" "$tput_cuu1" "$tput_cuu1" "$tput_ech25" sleep 0.1 done echo " Process Completed ! "

http://stackoverflow.com/a/78438016
has body: In the absence of a bash bug, it looks like something is causing the then or fi commands to be ignored. Perhaps there is a rogue alias that is trumping the shell built-in? What do you get with just alias to see all of the aliases?
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78427118
type: Answer
accepted answer of: http://stackoverflow.com/q/78427118
downvote count: 0
has comment: http://stackoverflow.com/comment/138287252
type: AcceptedAnswer

http://stackoverflow.com/a/78351708
accepted answer of: http://stackoverflow.com/q/78351657
upvote count: 6
has body: From man bash: man bash | grep -A3 PIPESTATUS PIPESTATUS An array variable (see Arrays below) containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command). man bash | sed -e '/^ *? /{N;q};d' ? Expands to the exit status of the most recently executed fore‐ ground pipeline. So, $PIPESTATUS holds the result of the last forked command (false in this case), $? contains the status of the last script command (while ...;do ...;done). Then if ! :; then :;fi ; echo ${?@Q} ${PIPESTATUS[@]@Q} '0' '0' while ! :; do :;done ; echo ${?@Q} ${PIPESTATUS[@]@Q} '0' '0' if /bin/false; then :;fi ; echo ${?@Q} ${PIPESTATUS[@]@Q} '0' '1' while false; do :;done ; echo ${?@Q} ${PIPESTATUS[@]@Q} '0' '1' More at this difference of $? and ${PIPESTATUS[0]} @ lists.gnu.org. $? is POSIX, while PIPESTATUS is a bash array... if ls /wrong/path | wc | sed 'w/wrong/path' >/dev/null ; then echo Don't print this' fi ; echo ${?@Q} ${PIPESTATUS[@]@A} ls: cannot access '/wrong/path': No such file or directory sed: couldn't open file /wrong/path: No such file or directory '0' declare -a PIPESTATUS=([0]="2" [1]="0" [2]="4") Where $PIPESTATUS hold result of all 3 commands ls, wc and sed. if ls /wrong/path | wc | cat - /wrong/path | sed 'w/wrong/path' >/dev/null ; then echo Don't print this' fi ; echo ${?@Q} ${PIPESTATUS[@]@A} $(( $? ${PIPESTATUS[@]/#/+} )) ls: cannot access '/wrong/path': No such file or directory cat: /wrong/path: No such file or directory sed: couldn't open file /wrong/path: No such file or directory '0' declare -a PIPESTATUS=([0]="2" [1]="0" [2]="1" [3]="4") 7 The group command if ... then ...(elif ... then ) ... (else ... then) ... fi was executed successfully. His result code is 0, but ls's result code was 2, wc's result code was 0, cat's result code was 1 and sed's result code was 4. until ls -ld / | wc | cat - | sed -n '/[a-z]/p' ; do echo Don't print this' done ; echo ${?@Q} ${PIPESTATUS[@]@A} $((…
downvote count: 0
has comment: http://stackoverflow.com/comment/138139393
answers question: http://stackoverflow.com/q/78351657
type: Answer
score: 6
type: AcceptedAnswer

http://stackoverflow.com/comment/138204799
score: 0
comment on: http://stackoverflow.com/q/78393091
type: QuestionComment
type: Comment
has text: @pjh That's not a good duplicate. "shell" doesn't mean "sh".

http://stackoverflow.com/comment/138280556
type: QuestionComment
comment on: http://stackoverflow.com/q/78435782
has text: @VenkatV Thank you! It makes script work as expected
type: Comment
score: 0

ksh
tags question: http://stackoverflow.com/q/78443452
tag name: ksh
type: Tag

http://stackoverflow.com/q/78314716
has comment: http://stackoverflow.com/comment/138067543
duplicate of: http://stackoverflow.com/q/39527571
answer count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138067090
has comment: http://stackoverflow.com/comment/138067414
has comment: http://stackoverflow.com/comment/138067105
has comment: http://stackoverflow.com/comment/138067533
has comment: http://stackoverflow.com/comment/138068055
has title: Why it (the IF statement) worked?
has comment: http://stackoverflow.com/comment/138067945
has body: There is a file with three columns. By default, status_column 3 has the status UP. But for some reason, the if statement does not work correctly. while IFS=";" read -r ip_column1 name_column2 status_column3 do status=$status_column3 if (ping -c 3 -W 1 $ip_column1 &> /dev/null) then status_column3="UP" echo $ip_column1$"-"$"success" else status_column3="DOWN" echo $ip_column1$"-"$"error" fi echo $status echo $status_column3 if $status != $status_column3 then echo "Status is changed!" fi done < <(tail -n +2 IP_test.csv) RESULT: 10.1.0.218-success UP UP Status is changed! => WHY IT WORKED? 10.21.0.102-error UP DOWN Status is changed I tried to write code in different ways, but the essence did not change. It worked out as well.
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138067010
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/39527571

http://stackoverflow.com/comment/138098637
score: 0
type: QuestionComment
type: Comment
has text: If I understand well, you're saying that I must have a copy of the query file on each server (which I don't). I can't use a local file to send queries ?
comment on: http://stackoverflow.com/q/78328611

http://stackoverflow.com/comment/138196029
type: AnswerComment
comment on: http://stackoverflow.com/a/78387161
score: 0
type: Comment
has text: If you have an input PNG that does not work as above in my example, post that image and I will look at it and see why that might be.

http://stackoverflow.com/comment/138169500
has text: Sorry, buddy, this is not an interactive troubleshooting session. You ask a question and if your original question is answered you close it and we all move on.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment

http://stackoverflow.com/comment/138221901
has text: Valid, don't think there is a way to let history act like that. I've always used the number with `!` from history, and then keep incrementing that. So if (a) is `!10`, run that, then `!11`, `!12` etc...
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78402822
type: QuestionComment

http://stackoverflow.com/comment/138076799
type: AnswerComment
comment on: http://stackoverflow.com/a/78320229
has text: I think you've misunderstood the question. As pointed out in pgrep(1), the "pattern is normally only matched against the process name". What is the process name in `/bin/bash -x /home/user/tmux.sh`? If it includes the **arguments**, when why is there a `-f` option?
score: 1
type: Comment

vcenter
type: Tag
tags question: http://stackoverflow.com/q/78344853
tag name: vcenter

http://stackoverflow.com/comment/138148469
type: Comment
has text: `i=0; while [ "$i" -lt "$progress" ]; do printf -; i=$((i+1)); done`
score: 0
comment on: http://stackoverflow.com/q/78360964
type: QuestionComment

http://stackoverflow.com/a/78419189
score: 0
has comment: http://stackoverflow.com/comment/138252757
type: Answer
has comment: http://stackoverflow.com/comment/138252309
answers question: http://stackoverflow.com/q/78415633
has body: As is typical for a script, your script is executing in a shell that isn't interactive (i.e. isn't reading commands from it's input and executing them) and so the following applies (from https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html): ${parameter:?word} If parameter is null or unset, the expansion of word (or a message to that effect if word is not present) is written to the standard error and the shell, if it is not interactive, exits.... Note the "if it is not interactive, exits" at the end of that. declare won't be called in this scenario because the parameter substitution happens first and causes the shell to exit. Just do [[ $1 =~ ^[0-9]+$ ]] or similar to test for integer input instead of calling declare, e.g.: err() { local code=70 if [[ $1 =~ ^[0-9]+$ ]]; then printf 'err() called with valid argument\n' >&2 code=$1 shift elif (( $# == 0 )); then printf 'err() called with no arguments\n' >&2 else printf 'err() called with invalid argument %s\n' "$1" >&2 fi #... exit "$code" } You should also consider using tput to produce colors, e.g.: printf "%s: %s%s%s\n" "${0##*/}" "$(tput setaf 1)" "$*" "$(tput sgr0)" >&2 rather than hard-coding escape sequences as the former will try to produce the right color codes for the currently running terminal type while YMMV with the latter.

http://stackoverflow.com/q/78422072
tagged with: http://stackoverflow.com/tag/csv
type: Question
has title: Bash do...done loop ignores last line in CSV file
answer count: 0
has comment: http://stackoverflow.com/comment/138256062
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138256085
duplicate of: http://stackoverflow.com/q/4165135
linked to: http://stackoverflow.com/q/4165135
score: 0
has body: I'm using Bash to iterate through a comma-delimited CSV file. There are no trailing blank spaces in each CSV line; however there is a carriage return after lines 1 (header), 2 (...ghi) and 3 (...789). Issue to solve: The do..done is skipping the last line in the CSV. Test1.csv file --> lineNo,column1,column2,column3 1,abc,def,ghi 2,123,456,789 3,test1,test2,test3 Test1 Bash script: setupFileLocation=test1.csv while IFS=, read -r lineNo column1 column2 column3 do echo $lineNo # skip the header line done < <(tail -n +2 $setupFileLocation) Desired result: 1 2 3 Actual result: 1 2 My short-term fix is to add a 4th line only containing a zero. Test2.csv file --> lineNo,column1,column2,column3 1,abc,def,ghi 2,123,456,789 3,test1,test2,test3 0 Test2 Bash script: setupFileLocation=test2.csv while IFS=, read -r lineNo column1 column2 column3 do echo $lineNo # skip the header line done < <(tail -n +2 $setupFileLocation) Test2.csv results in: 1 2 3 If I eliminate any complexity caused by the "tail -n +2" in test 1 ... setupFileLocation=test1.csv while IFS=, read -r lineNo column1 column2 column3 do echo $lineNo done < $setupFileLocation ... then I get: lineNo 1 2 Related posts that do not give answer using while IFS... and do..done: Iterating through a csv file how to iterate through consecutive lines of a csv file why is this simple FOR LOOP in my Linux bash not working?
tagged with: loops
has comment: http://stackoverflow.com/comment/138256050
tagged with: bash
linked to: http://stackoverflow.com/q/21370059
linked to: http://stackoverflow.com/q/67199557
linked to: http://stackoverflow.com/q/29559042

http://stackoverflow.com/comment/138286490
type: Comment
type: AnswerComment
score: 0
has text: `if "$username"="$myusername" && "$password"="$mypassword"` contains several syntax errors. Spaces after ``, before ``, and around `=` are not optional.
comment on: http://stackoverflow.com/a/78438921

http://stackoverflow.com/comment/138225433
comment on: http://stackoverflow.com/a/78404326
type: Comment
type: AnswerComment
has text: @Urza_tron you can try `sed -i '9{N;s/\n/ /}' file`. It works on most platforms
score: 0

http://stackoverflow.com/comment/138098674
type: QuestionComment
type: Comment
has text: RUN statements are executed during the build phase of the image and volumes are not available at that time. Volumes are only available at run-time.
comment on: http://stackoverflow.com/q/78332428
score: 0

http://stackoverflow.com/a/78419268
upvote count: 1
answers question: http://stackoverflow.com/q/78418827
has body: The error actually comes from the first line of the script. I meant to do a pattern-match, m//, not a substitution, s///. But that line actually doesn't do what I wanted anyway. I wanted to install the script in a certain directory under several linked names, e.g. node16vars node18vars node20vars but $0 inside a sourced script is actually the name of the shell, e.g. -bash. Since my shell is bash, I can instead use the line node_major_version=`echo $BASH_SOURCE | perl -ne 'm/([0-9]+)/ and print $1'` to pull the first number out of the as-installed script name.
score: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/78334765
score: 1
accepted answer of: http://stackoverflow.com/q/78334609
upvote count: 1
downvote count: 0
has body: For structured data, use structure-aware processors, not text processors that can only manipulate the textual representation without seeing/understanding the underlying logic). Although the pipeline is yaml, that condition is not yaml so I would still need some text edit tool. You could use the YAML processor mikefarah/yq, which also has text-processing capabilities (applicable to the condition): yq 'map(select(.stage == "qa").condition |= sub("refs/heads/development"; "refs/heads/main"))' - stage: 'qa' dependsOn: - build condition: | and ( condition1, condition2, ..., startswith(variables['Build.SourceBranch'], 'refs/heads/main') ) # This needs to stay the same - stage: 'uat' dependsOn: - dev condition: | and ( condition1, condition2, ..., startswith(variables['Build.SourceBranch'], 'refs/heads/development') )
type: Answer
has comment: http://stackoverflow.com/comment/138103092
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78334609

http://stackoverflow.com/q/78366286
has comment: http://stackoverflow.com/comment/138159396
tagged with: ubuntu
tagged with: bash
score: 1
tagged with: google-cloud-platform
tagged with: terraform-provider-gcp
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78367150
has answer: http://stackoverflow.com/a/78450931
has body: Been trying to trouble shoot this for two days. Not sure if it is a terraform or GCP issue. Or my code. I'm trying to create a VM and run some installs. It then creates a file in /var/run called flag.txt. If that file is present the startup script should exit and not run on reboots. I wrote a python script to write the date and time to the flag.txt file so I could test. However, everytime I reboot the time and date are updated in the flag.txt file showing that the startup script is running. Here is my metadata_startup_script code metadata_startup_script = <<-EOF #!/bin/bash if [ ! -f /var/run/flag.txt ]; then sudo apt-get update sudo apt-get install -y gcloud echo '${local.script_content}' > /tmp/install_docker.sh echo '${local.flag_content}' > /tmp/date_flag.py chmod +x /tmp/install_docker.sh chmod +x /tmp/date_flag.py #Below command is just to show root is executing this script #whoami >> /usr/bin/runner_id bash /tmp/install_docker.sh /usr/bin/python3 /tmp/date_flag.py else exit 0 fi EOF } Here is the date_flag.py file that creates the flag.txt file import datetime current_datetime = datetime.datetime.now() formatted_datetime = current_datetime.strftime("%Y-%m-%d_%H-%M-%S") file_name = f"{formatted_datetime}.txt" with open("/var/run/flag.txt", "w") as file: file.write("This file was created at: " + formatted_date Any thoughts or suggestions are welcome. This is really driving me crazy.
accepted answer: http://stackoverflow.com/a/78367150
answer count: 2
has comment: http://stackoverflow.com/comment/138159503
has title: Terraform metadata_startup_script for GCP runs even though file is present to prevent it from running
type: Question
has comment: http://stackoverflow.com/comment/138159606
has comment: http://stackoverflow.com/comment/138159320
downvote count: 0
tagged with: terraform
possible better answer: http://stackoverflow.com/a/78450931
upvote count: 1

http://stackoverflow.com/comment/138333942
score: 0
comment on: http://stackoverflow.com/q/78422019
type: QuestionComment
type: Comment
has text: as @Barmar asked, why check for the `-d` directory, check for the file `-f` instead

http://stackoverflow.com/comment/138258821
type: AnswerComment
has text: That's still not correct; the first line has `NR==1`. But I updated my answer with an Awk solution now.
comment on: http://stackoverflow.com/a/78423429
score: 1
type: Comment

windows
tag name: windows
type: Tag
tags question: http://stackoverflow.com/q/78416162
tags question: http://stackoverflow.com/q/78520208
tags question: http://stackoverflow.com/q/78669861
tags question: http://stackoverflow.com/q/78648632
tags question: http://stackoverflow.com/q/78840846
tags question: http://stackoverflow.com/q/78954119
tags question: http://stackoverflow.com/q/79224813
tags question: http://stackoverflow.com/q/79197404
tags question: http://stackoverflow.com/q/79155042
tags question: http://stackoverflow.com/q/79073850
tags question: http://stackoverflow.com/q/79119057
tags question: http://stackoverflow.com/q/79396722
tags question: http://stackoverflow.com/q/79419170
tags question: http://stackoverflow.com/q/79530394

http://stackoverflow.com/comment/138102301
type: Comment
has text: @EricPostpischil no, it is indeed because of the pseudoterminal buffer capacity, independent from the actual terminal software
comment on: http://stackoverflow.com/q/78334722
score: 0
type: QuestionComment

reference
tag name: reference
tags question: http://stackoverflow.com/q/78392419
type: Tag

http://stackoverflow.com/comment/138295911
has text: `which` doesn't know anything about aliases (it's an external executable, not part of bash, so it can't see into shell internals). Use `type python3` to see what's actually in use. (Also, note that aliases are only honored by default in interactive shells; during shell script execution -- which is more on-topic here than interactive use is -- aliases have no effect).
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78444497
type: Comment

http://stackoverflow.com/comment/138104336
comment on: http://stackoverflow.com/q/78336037
type: Comment
score: 0
has text: what in case presto is with diff name as master-presto , then we need the regex
type: QuestionComment

http://stackoverflow.com/comment/138068055
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78314716
has text: Thank you all for the answers. I found a solution for myself: `status=\`tr -d "[:cntrl:]" <<< $status_column3\``. The question can be closed.

http://stackoverflow.com/a/78390177
type: Answer
has body: Bash splits arrays on whitespace (or more properly on whatever the value of IFS is at the time the expression is evaluated) but the array assignment seems like just a complication anyway. snmpget -v3 -l authPriv -u jasmin -a SHA \ -A MyAuthPhrase -x AES -X MyPrivPhrase '$myIP' \ SNMP-FRAMEWORK-MIB::snmpEngineID.0 | sed 's/.*Hex-STRING: //' If you want to assign the result to a variable, it should be obvious how to do that; but of course, if all you want to do is display the result, capturing it in a variable so that you can then immediately echo it back is just a waste of memory. x=$(snmpget -v3 -l authPriv -u jasmin -a SHA \ -A MyAuthPhrase -x AES -X MyPrivPhrase '$myIP' \ SNMP-FRAMEWORK-MIB::snmpEngineID.0 | sed 's/.*Hex-STRING: //') If you want to remove the spaces between the hex values, you can add ;s/ //g to the end of the sed script. Tangentially, don't store commands in strings. If you want to store the code for easy retrieval, put it in a function. Perhaps see also https://mywiki.wooledge.org/BashFAQ/050
answers question: http://stackoverflow.com/q/78367681
score: 0

http://stackoverflow.com/comment/138222181
has text: You might also want to look at the `fc` command. `fc -e - -7 - 5` should execute `a`, `b`, and `c` directly.
type: AnswerComment
comment on: http://stackoverflow.com/a/78402923
score: 1
type: Comment

http://stackoverflow.com/a/78418439
downvote count: 0
type: Answer
score: 3
has body: No need for your convoluted loading of source file in a variable. # suppose SSH_CMD is my ssh command SSH_CMD 'cat > /data0/for-test; echo "abc" >> /data0/for-test' < word Here is how it works: < word: Feeds the word file to ssh cat > /data0/for-test; echo "abc" >> /data0/for-test: Commands executed at the remote host: cat > /data0/for-test: Redirects the input stream to the /data0/for-test file locally on the remote server. echo "abc" >> /data0/for-test: Adds abc to the /data0/for-test file. As a bonus, it can transfer binary files as well.
answers question: http://stackoverflow.com/q/78417099
upvote count: 3

http://stackoverflow.com/comment/138137322
type: QuestionComment
type: Comment
score: 4
comment on: http://stackoverflow.com/q/78354730
has text: Try: `criteria_col=(-f 1-8,20,22)`, then `cut -d\; "${criteria_col[@]}"`

http://stackoverflow.com/q/78362867
has answer: http://stackoverflow.com/a/78362961
downvote count: 0
score: 1
upvote count: 1
answer count: 2
has answer: http://stackoverflow.com/a/78363130
tagged with: bash
has body: I currently use the following in my bash file to change the SSH configuration from #PermitRootLogin yes to PermitRootLogin no. However, sometimes the SSH configuration file has #PermitRootLogin no and I just want to uncomment it. How can I update my command to work in both cases? #! /bin/sh sed -i -e "s/#PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
possible better answer: http://stackoverflow.com/a/78362961
favorite count: 0
has title: How to change PermitRootLogin to no in SSH configuration file using a bash file?
accepted answer: http://stackoverflow.com/a/78363130
type: AnsweredQuestion
type: Question

http://stackoverflow.com/comment/138247641
type: Comment
comment on: http://stackoverflow.com/q/78417099
score: 4
has text: Why not just `SSH_CMD 'cat > /data00/for-test' < word`? You can use a 2nd command for `"abc"` within a heredoc the same way. Or just `echo "abc" | SSH_CMD 'cat >> /data00/for-test'`. Or even just `SSH_CMD 'echo "abc" >> /data00/for-test'` for the second part. (this assumes your `SSH_CMD` is equivalent to `ssh user@host`)
type: QuestionComment

http://stackoverflow.com/q/78444401
has answer: http://stackoverflow.com/a/78444667
type: Question
type: UnansweredQuestion
answer count: 1
has comment: http://stackoverflow.com/comment/138295716
has title: Bash script not working when running in php page but works in terminal
score: 0
has comment: http://stackoverflow.com/comment/138296089
tagged with: bash
tagged with: apache
tagged with: php
has comment: http://stackoverflow.com/comment/138295640
tagged with: xampp
tagged with: terminal
has body: Hey all I am trying to get a bash script to fire off when I visit my php page. I am using XAMPP that is hosting my php on my MacOS. Here is my php code: <?php ob_implicit_flush(true); ob_end_flush(); $cmd = "bash sysinfo1.sh"; $descriptorspec = array( 0 => array("pipe", "r"), //stdin pipe will read from 1 => array("pipe", "w"), //stdout pipe will write to 2 => array("pipe", "w") //stderr pipe will write to ); $process = proc_open($cmd, $descriptorspec, $pipes, realPath('./'), array()); if (is_resource($process)) { while ($s = fgets($pipes[1])){ echo $s; } } echo ']'; ?> And this is the bash script code: #!/bin/bash system_profiler -json SPHardwareDataType SPSoftwareDataType SPNetworkDataType SPStorageDataType When visiting the php page (192.168.1.15:87) it loads the page just fine but has no output on the page other than the "]". I changed the $pipes[1] to $pipes[2] and got the error: sysinfo1.sh: line 4: system_profiler: command not found ] I chmod 755 the bash script as well. And the .sh file is located in the same directory as the php file. The .sh script runs just fine in terminal (./sysinfo1.sh). What could I be missing?

http://stackoverflow.com/a/78419717
type: Answer
score: 2
answers question: http://stackoverflow.com/q/78419674
upvote count: 2
has body: ! will only invert one command. The whole subshell is one command, but without the parentheses, cmd_A is one command and cmd_B is another. However, your emphasis on a subshell is also likely confusing you. { cmd_A &amp;&amp; cmd_B; } is also a single compound command, and not a subshell. ! { cmd_A &amp;&amp; cmd_B; } would usually have a similar behavior to ! ( cmd_A &amp;&amp; cmd_B ), at least as far as the exit status goes. Other compound commands are available, starting with {, [[, ((, for, select, case, if, while, and until. So you can invert the result of an entire if expression, or for loop, if you want.
downvote count: 0
has comment: http://stackoverflow.com/comment/138252532

netbeans
tag name: netbeans
tags question: http://stackoverflow.com/q/78335326
type: Tag

raspberry-pi
tags question: http://stackoverflow.com/q/78320604
tag name: raspberry-pi
type: Tag
tags question: http://stackoverflow.com/q/79485736

http://stackoverflow.com/q/78346345
upvote count: 0
tagged with: shell
has title: Write shell command to find long if statements within a directory of php files
has comment: http://stackoverflow.com/comment/138123656
answer count: 1
has comment: http://stackoverflow.com/comment/138122626
favorite count: 0
score: -2
has comment: http://stackoverflow.com/comment/138122513
has answer: http://stackoverflow.com/a/78347012
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138122486
tagged with: php
type: UnansweredQuestion
has body: I have a nested directory of files in php, some of them may have if and else conditions within them if (condition) { // ~100 lines of code } I want to quickly find those [files/start of if or else condition] within files that have long bodies within if or else conditions. Say &gt; 100 lines within the flower brackets Eg: File1: if (condition) { // &gt;100 lines of code } else { // 50 lines of code } ... if (condition) { // 10 lines of code } File2: if (condition) { // 2 lines } should return the line number of the first if condition from File1 because it has 100+ lines within its opening and closing brackets. There could be nested if conditions as well
has comment: http://stackoverflow.com/comment/138122545
tagged with: awk
tagged with: unix
downvote count: 2
has comment: http://stackoverflow.com/comment/138126152
has comment: http://stackoverflow.com/comment/138122525

http://stackoverflow.com/q/78443452
has body: The following script mimics a problem I met in a larger script. loop-break-example-functions.sh: #!/bin/ksh #!/bin/bash function loop_function { echo_function | while read one two three do echo $one $two $three echo "in loop 1 onefound = $onefound" if $two == "BB" then onefound=$one echo "in loop in if onefound = $onefound" break fi echo "in loop 2 onefound = $onefound" done echo "end onefound = $onefound" } function echo_function { while read line do echo $line done <<EEE A B C AA BB CC AAA BBB CCC EEE } loop_function I works well in ksh but not in bash. When the shell is bash, the value of variable $onefound is lost in the end. With ksh # ./loop-break-example-functions.sh A B C in loop 1 onefound = in loop 2 onefound = AA BB CC in loop 1 onefound = in loop in if onefound = AA end onefound = AA # Switching the 2 first lines to work with bash: # ./loop-break-example-functions.sh A B C in loop 1 onefound = in loop 2 onefound = AA BB CC in loop 1 onefound = in loop in if onefound = AA end onefound = # Can somebody explain the difference? How can I make it work in bash? I tried giving onefound an initial value in the beginning of the function. I saw that there is no problem when the input is more straighforward (not coming from a function). The following version is OK with both shells: #!/bin/ksh #!/bin/bash function loop_function { while read one two three do echo $one $two $three echo "in loop 1 onefound = $onefound" if $two == "BB" then onefound=$one echo "in loop in if onefound = $onefound" break fi echo "in loop 2 onefound = $onefound" done <<EEE A B C AA BB CC AAA BBB CCC EEE echo "end onefound = $onefound" } loop_function
linked to: http://stackoverflow.com/q/2746553
tagged with: bash
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138294083
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138293840
score: 0
tagged with: ksh
linked to: http://stackoverflow.com/q/13726764
has title: Variable value lost in bash when input comes from a function
has comment: http://stackoverflow.com/comment/138295317
duplicate of: http://stackoverflow.com/q/13726764

http://stackoverflow.com/comment/138251453
type: Comment
has text: @Discussian fwiw ... `1 2 *` is [reverse polish notation (RPN)](https://en.wikipedia.org/wiki/Reverse_Polish_notation); it was quite common (at least a few decades ago) to find RPN calculators (eg, HP) in use in engineering and scientific circles (certainly in use by a lot of STEM students at my college)
comment on: http://stackoverflow.com/q/78419450
score: 1
type: QuestionComment

http://stackoverflow.com/q/78348524
has comment: http://stackoverflow.com/comment/138134147
type: Question
has comment: http://stackoverflow.com/comment/138132641
has comment: http://stackoverflow.com/comment/138132009
score: 1
answer count: 1
favorite count: 0
has body: i have a pipeline1 that execute a bash script block success and run ok,BUT when i invoke this pipeline1 from pipeline2 the bash script block didn't executed. Other sh individual line commands yes run ok and it showed output but into block script not be are executing Any idea? I am referencing to this: pipeline1 steps { script{ sh "echo Hello1 world" sh '''#!/bin/bash sh "echo Hello2 world" <commands> ''' } } pipeline2 steps { build (job: '../../folfer1/pipeline1', parameters: [ ... ], wait: true) } Then, the output on pipeline2 showed echo 'Hello1 World' echo 'Hello2 World' but not executing sh block bash and not showed any error, only showed Hello1 world sh "echo Hello1 world" sh '''#!/bin/bash sh "echo Hello2 world" <commands> ''' reproduction [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/lib/jenkins/workspace/folder1/pipeline1 [Pipeline] { [Pipeline] ansiColor [Pipeline] { [Pipeline] stage [Pipeline] { (Executing playbook playbook1) [Pipeline] withEnv [Pipeline] { [Pipeline] script (hide) [Pipeline] { [Pipeline] echo Hello1 world [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // ansiColor [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS Resume: if i invoke this pipeline1 from pipeline2 commands into block script not be are executing but, if I running pipeline1 alone the result and all executions are ok!) Regards, Edu < allways learning
tagged with: jenkins-groovy
has comment: http://stackoverflow.com/comment/138134740
has comment: http://stackoverflow.com/comment/138134976
has comment: http://stackoverflow.com/comment/138132249
has title: bash block script step pipeline no executing on a pipeline1 called from other pipeline2
has comment: http://stackoverflow.com/comment/138132174
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138167794
upvote count: 1
has answer: http://stackoverflow.com/a/78373220
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138135140
has comment: http://stackoverflow.com/comment/138169500
has comment: http://stackoverflow.com/comment/138132379
has comment: http://stackoverflow.com/comment/138169601
accepted answer: http://stackoverflow.com/a/78373220
has comment: http://stackoverflow.com/comment/138168145
has comment: http://stackoverflow.com/comment/138134519
tagged with: jenkins-pipeline
has comment: http://stackoverflow.com/comment/138134780

http://stackoverflow.com/comment/138173309
type: QuestionComment
type: Comment
has text: `&0` is not a file handle. `0` is the file handle, which could be used as an "argument" for either of the distinct redirection operators `<` or `<&`.
comment on: http://stackoverflow.com/q/78375007
score: 0

http://stackoverflow.com/comment/138122486
has text: What have you tried? How did it fail?
comment on: http://stackoverflow.com/q/78346345
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/138153933
has text: Does this answer your question? [storing binary data in mysql](https://stackoverflow.com/questions/1098681/storing-binary-data-in-mysql)
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78363909
score: 3

http://stackoverflow.com/comment/138130314
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78350497
score: 0
has text: If the problem is with quotes, why is the original command having problems? There are no quotes in the command you're sending over SSH.

http://stackoverflow.com/comment/138224483
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78400214
score: 0
has text: ( Note: You could replace `echo "dyn_array_$i[$j] = ${_arr[j]}"` by just: `echo "${_arr[j]@A}"` ! ;-)

http://stackoverflow.com/comment/138194254
comment on: http://stackoverflow.com/q/78383368
score: 0
type: QuestionComment
has text: Oh, I didn't notice that `$mSearchCommand` *also* contains shell syntax (which causes the exact same problems). How is that variable set, and why is it in a variable rather than just being separate options to the actual command?
type: Comment

http://stackoverflow.com/q/78412927
tagged with: bash
type: UnansweredQuestion
favorite count: 0
tagged with: github-actions
has comment: http://stackoverflow.com/comment/138240530
has title: How to preserve input with double quotes in a run step (bash) in GitHub Actions?
has comment: http://stackoverflow.com/comment/138269965
score: 0
type: Question
has body: This question is a GitHub Actions challenge, but afaik I should probably be solved with a run command (bash). Background I have a json file (see below) to automatically populate a DNS zone in my DigitalOcean environment. dns-records.json { "records": [ { "key": "@", "type": "CNAME", "ttl": "600", "value": "<WEBSITE_NAME>.<HOSTING_DOMAIN>" }, { "key": "www", "type": "CNAME", "ttl": "86400", "value": "@" }, { "key": "@", "type": "CAA", "ttl": "86400", "value": "0 issue \"letsencrypt.org\"" }, { "key": "assets", "type": "CNAME", "ttl": "86400", "value": "<WEBSITE_NAME>.<DO_SPACES_REGION>.cdn.digitaloceanspaces.com" } ] } In my GitHub Actions workflow, I use a matrix approach to trigger the doctl CLI command for the creation of the DNS records. Within the called creation job, the values are accessible as ${{ inputs.RECORD_DATA }}. Challenges I do want to alter the RECORD_DATA in a specific case: if the record type is CNAME and the record value is not '@' (a '@' key is fine!), then I have to add a dot ('.') to the end of the string - but only if the most right character isn't a dot yet. Since GitHub Actions has no support for conditional / ternary operators (if-else statements), I use a bash run step for the if-else. Pseudo code: RECORD_DATA_LAST_CHAR="insert magic here?" if [ RECORD_TYPE == 'CNAME' && $RECORD != '@' && $RECORD_DATA_LAST_CHAR != '.' ]; then echo "MANIPULATED_RECORD_DATA=$RECORD_DATA." >> $GITHUB_OUTPUT ese echo "MANIPULATED_RECORD_DATA=$RECORD_DATA" >> $GITHUB_OUTPUT fi PS1: The echo to $GITHUB_OUTPUT is the GHA way to reuse variables in later workflow steps. PS2: I usually use a step-level environment variable for the input, so bash can use this instead of the GHA ${{}}. env: RECORD_DATA: ${{ inputs.RECORD_DATA }} My first question: how can I get the last character of ${{ inputs.RECORD_DATA }} in my bash run command, in such a way that is also works on the CAA example in the json with both spaces and double quotes in it? My second question: I have to us…
tagged with: digital-ocean
linked to: http://stackoverflow.com/q/72487161
answer count: 1
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/78430002
has comment: http://stackoverflow.com/comment/138240508

http://stackoverflow.com/q/78342895
downvote count: 1
has body: I'm trying to create a reusable script that will grep some config values for a remote WordPress site, but strings appear to be escaping differently depending on the server I'm connecting to. How can I create a command that works the same way everywhere? For instance, on Host 1, the following outputs what I'm after, which is some_database_name\nsome_database_user: ssh cloudwaysuser@198.246.246.246 "cat /some-path/wp-config.php | grep -E 'DB_NAME|DB_USER'" But, on Host 2, the same command is not working because it outputs DB_NAME: command not found\nDB_USER: command not found as if it's trying to execute the string after the grep -E command: ssh wpenginesuser@198.123.123.123 "cat /some-path/wp-config.php | grep -E 'DB_NAME|DB_USER'" Though escaping the single quotes doesn't seem necessary in my mind, when I do escape them, I get the exact opposite behavior, so on Host 1 I get the "command not found" errors: ssh cloudwaysuser@198.246.246.246 "cat /some-path/wp-config.php | grep -E \'DB_NAME|DB_USER\'" and on Host 2 I get the results I'm after: ssh wpenginesuser@198.123.123.123 "cat /some-path/wp-config.php | grep -E \'DB_NAME|DB_USER\'" How can these two commands run differently depending on the server they're ran on, and how do I normalize them to have one command that works on both hosts? EDIT: As a simpler example, on Host 1, ssh cloudwaysuser@198.246.246.246 "echo \"'TEST'\"" outputs 'TEST' as I'd expect, but for Host 2 ssh wpenginesuser@198.123.123.123 "echo \"'TEST'\"" outputs TEST without the single quotes. Why might that be the case and how do I make these behave the same? Edit 2: Note though my script is much more complex than just what's shown above, which is minimal reproduction of the issue. In my script I have multiple .json files, each with all details for connecting to a different server, and this script reads that into a bunch of variables that backup and launch the files and database (with custom rsync excludes, database URL find-and-replacements, etc.…
score: -1
has comment: http://stackoverflow.com/comment/138120689
has title: Shell string escaping over SSH behaves differently on different servers
linked to: http://stackoverflow.com/q/78350497
upvote count: 0
tagged with: shell
has comment: http://stackoverflow.com/comment/138116718
type: UnansweredQuestion
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78343881
has comment: http://stackoverflow.com/comment/138117388
has comment: http://stackoverflow.com/comment/138116701
tagged with: bash
type: Question

http://stackoverflow.com/comment/138288571
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78438177
has text: It is confusing if you tag your question bash and zsh; if you need answers for both shells, ask two questions. For zsh, I would simply write `magick identify -format "%f: %m\n" *.{jp*,png,webp}(N)`. The `(N)` ensures that it works even if you don't have files of that type.

jenkins-pipeline
type: Tag
tags question: http://stackoverflow.com/q/78376379
tags question: http://stackoverflow.com/q/78348524
tag name: jenkins-pipeline
tags question: http://stackoverflow.com/q/78956880
tags question: http://stackoverflow.com/q/79264431
tags question: http://stackoverflow.com/q/79402707

http://stackoverflow.com/a/78402352
type: Answer
has body: You can use : !/bin/bash Define the array dec_array=(abc10 def2 ghi333 jkl mno51 pqr_6) Define the number of elements per chunk num_elem=3 Initialize the counter for dynamic array names num_arr=0 Loop through the original array in chunks of num_elem elements for ((i=0; i < ${#dec_array[@]}; i+=num_elem)); do Extract a chunk of elements : part=( "${dec_array[@]:i:num_elem}" ) Print the elements in the chunk: echo "Elements in first example: ${part[*]}" Create a dynamic array using the counter: declare -a dyn_array_${num_arr}=( "${dec_array[@]:i:num_elem}" ) Print the elements of the dynamic array: echo "Elements in second example: ${dyn_array_${num_arr}[*]}" Increment the counter: ((num_arr++)) done Output : Elements in first example: abc10 def2 ghi333 Elements in second example: abc10 def2 ghi333 Elements in first example: jkl mno51 pqr_6 Elements in second example: jkl mno51 pqr_6
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78400075
downvote count: 0

http://stackoverflow.com/q/78356154
score: 0
has title: Montreal Forced Aligner won't install, and instead results in the error "metadata-generation-failed" and "Path not writable or missing."
type: Question
has comment: http://stackoverflow.com/comment/138140515
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/47400675
tagged with: pip
linked to: http://stackoverflow.com/q/47400675
tagged with: conda
has body: I have been trying to install montreal forced aligner via command line and it won't work. I use a mac, and have put in: conda create -n aligner kaldi pynini It installed conda, then I put in conda activate aligner and then pip install git+https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner.git It gave me the error "subprocess-exited-with-error", and said this: Collecting git+https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner.git Cloning https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner.git to /private/var/folders/s5/v7w0tcn146s5dcch213_nkdw0000gn/T/pip-req-build-_f8yhwwt error: subprocess-exited-with-error × git version did not run successfully. │ exit code: 1 ╰─> [2 lines of output] xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × git version did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. I tried the other way they say to install it on their website and tried "pip install montreal-forced-aligner" on both terminal's normal mode and after activating python because it said something about using python, and it didn't work for that either. It also says "path not writable" a bunch. Is that important? Basically, what do these errors mean, and what recourse do you recommend. I have been trying to install montreal forced aligner via command line and it won't work. I use a mac, and have put in: conda create -n aligner kaldi pynini It installed conda, then I put in conda activate aligner and then pip install git+https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner.git It gave me the error "subprocess-exited-with-error", and said this: Collecting git+https://github.com/MontrealCorpusTools/Mon…
answer count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138159370

http://stackoverflow.com/comment/138226250
type: QuestionComment
type: Comment
has text: `set -x` is your friend to turn on trace logging -- that'll make the arguments to the `[` command running the comparison visible, exposing whitespace, carriage returns, and other unexpected content.
score: 1
comment on: http://stackoverflow.com/q/78405034

http://stackoverflow.com/comment/138192233
comment on: http://stackoverflow.com/q/78385809
type: QuestionComment
type: Comment
has text: ""eval" is a common misspelling of "evil". "
score: 0

http://stackoverflow.com/comment/138315462
comment on: http://stackoverflow.com/a/78444615
score: 0
type: Comment
type: AnswerComment
has text: Boo, hiss: Jenkins is a CI system. CI jobs are run with noninteractive shells, so they ignore aliases completely. Instructing the OP to set up aliases for Jenkins is thus not something that's going to help when Jenkins is actually running a job.

http://stackoverflow.com/q/78422398
has answer: http://stackoverflow.com/a/78422422
has title: why my bash PS1 prompt writing over same line
score: 0
type: Question
type: UnansweredQuestion
answer count: 1
tagged with: prompt
tagged with: ps1
has body: export PS1=&quot;\e[32;40m\]\$?\[\e[35;40m\]\$(date +%d%H%M)\[\e[36;40m\]\W&gt;\[\e[38;5;113;40m\]&quot; not return at the end of line and same line...
tagged with: bash
has comment: http://stackoverflow.com/comment/138265959

http://stackoverflow.com/comment/138214466
comment on: http://stackoverflow.com/q/78398495
score: 0
type: QuestionComment
has text: (See [bash claims executable file does not exist when trying to execute it but it does](https://stackoverflow.com/questions/56754859/bash-claims-executable-file-does-not-exist-when-trying-to-execute-it-but-it-doe) -- not that it's really a bash problem; the error comes from the OS kernel, not from the shell, and bash is just relaying it).
type: Comment

http://stackoverflow.com/comment/138188748
has text: Hi @rishav, I have updated the answer, please check **Edit1** in the answer.
comment on: http://stackoverflow.com/a/78366908
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/138208700
score: 0
type: QuestionComment
type: Comment
has text: The way you're actually using `$filter`, you don't even need a default value. Or at least, using `.` as the default value does nothing for you. Also, you don't need `sed` for simple string replacement operations. Consider `filter="${filter//./.*}"`.
comment on: http://stackoverflow.com/q/78390223

http://stackoverflow.com/comment/138088369
type: QuestionComment
has text: According to your log (`FILE EXISTS: LoD2_326625712.jsonl LoD2_326625712.jsonl`, which is more or less `FILE EXISTS:\space\spaceLoD2_326625712.jsonl\spaceLoD2_326625712.jsonl`, I think that `$file_exists` starts with a space, hence " LoD2_326625712.jsonl" != "LoD2_326625712.jsonl"
comment on: http://stackoverflow.com/q/78326995
type: Comment
score: 1

http://stackoverflow.com/a/78392620
upvote count: 2
answers question: http://stackoverflow.com/q/78392419
downvote count: 0
type: Answer
score: 2
has body: This may be the error handling you need : test -v "$x" || echo error

http://stackoverflow.com/comment/138127771
type: QuestionComment
score: 1
has text: `source ~/.bashrc` will directly affect only the specific shell process in which it is run. The modified `~/.bashrc` will be accessed directly by some other shells that you start after making the modifications. Other shells that were already running will not see the changes, and new login shells might or might not do so. To avoid confusion around which shells are affected and which not, (1) ensure that `~/.bash_profile` reads `~/.bashrc`, and (2) log out and back in.
comment on: http://stackoverflow.com/q/78348089
type: Comment

http://stackoverflow.com/comment/138134402
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78344853
has text: One more point: You say that you don't know bash. Why don't you implement it in one of the programming languages you already know. I don't see why you would **need** bash here.

http://stackoverflow.com/comment/138284825
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78438262
has text: You don't need grep when you're using awk, btw, so show us the **input** to `grep -v "local_address" --no-filename "/proc/net/tcp" "/proc/net/tcp6"`, not the output from it, as there won't be any grep command in a good solution, it'll just be a single awk script that parses whatever input that grep command is running on and produces the final output you need given that input.

http://stackoverflow.com/comment/138226999
type: Comment
comment on: http://stackoverflow.com/q/78404233
score: 0
type: QuestionComment
has text: If there are only 9 lines in the input should the output end with a newline character or a blank character or just whatever character was before the newline on the 9th input line?

http://stackoverflow.com/comment/138100965
score: 0
has text: OK so with some testing and tweeking I found that the ```/etc/profile``` and ```. ~/.profile``` where not loaded.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78328611

http://stackoverflow.com/comment/138229294
has text: If you need to save the path only for the duration of the script, why not save it in a variable instead of a file? `saved_path=$PWD` and `cd -- "$saved_path"` might do the trick. And then there are `pushd` and `popd` builtins to push and pop a directory.
type: Comment
comment on: http://stackoverflow.com/q/78406644
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138262767
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78422524
has text: Did you double-quote the variable reference (i.e. echo "$NETWORK_INTERFACE" instead of just echo $NETWORK_INTERFACE) and/or change IFS? Failing to double-quote and changing `IFS` are both invitations to problems; doing both basically guarantees problems. shellcheck.net will point out at least some of these common mistakes.

http://stackoverflow.com/comment/138134255
has text: Title says Bash, shebang says sh, code says Bash, tags say both. Which is it?
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78353017

http://stackoverflow.com/comment/138285930
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78438177
type: Comment
has text: Could you also test with `file ...`? See the summary table I have added.

http://stackoverflow.com/comment/138074301
type: AnswerComment
comment on: http://stackoverflow.com/a/78317659
has text: @markp-fuso, ...to be clear, the OP asks for code to start with `A`, not to start with `AAAAAAAAAA`, so I read the output of truncated values as a deliberate portion of the spec.
type: Comment
score: 0

http://stackoverflow.com/comment/138088316
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78326945
has text: `awk` can everything in one command, don't club `bash` into this. You need to show expected output and describe the logic to get it.
type: QuestionComment

http://stackoverflow.com/comment/138193947
score: 0
comment on: http://stackoverflow.com/q/78385603
type: QuestionComment
has text: What is your platform and Imagemagick version?
type: Comment

http://stackoverflow.com/comment/138283440
type: Comment
has text: As Toby said -- your current code is appending to item 0, not adding new array items.
comment on: http://stackoverflow.com/q/78437542
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138149016
comment on: http://stackoverflow.com/q/78361035
type: QuestionComment
type: Comment
has text: so `presto99abc` should match?
score: 0

http://stackoverflow.com/comment/138276265
comment on: http://stackoverflow.com/q/78433528
score: 1
has text: And don't build JSON with string interpolation, use a tool that's specifically implemented to handle JSON, such as `jq`. Using string interpolation will fail as soon as you have quotes or other reserved characters in your values.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138233916
comment on: http://stackoverflow.com/q/78409475
score: 0
has text: Certainly the shell snippet at the end of the question does not exit with a failure status that depends on the success of the `whisper` command within. It doesn't exit *at all*, except by reaching the end of the script, which produces a success status. If you want to abort as soon as you notice a `whisper` failure then `exit 1` at that point. If you want to keep running but eventually report a failure status then you need to record the fact that one or more `whisper` commands failed, and use that to determine the exit status when the script eventually terminates.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/138159840
has text: @Renaud Pacalet command is slightly different due to lack of sleep/human error, and because I simplified the command for the first example instead of showing the iterative context first.
comment on: http://stackoverflow.com/q/78364618
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138238245
comment on: http://stackoverflow.com/a/78411906
type: Comment
type: AnswerComment
score: 1
has text: @oguz That's a good improvement, thank you.

http://stackoverflow.com/comment/138265148
has text: Can you post the result of the command `od -a your-script` ?
type: Comment
comment on: http://stackoverflow.com/q/78427118
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138148965
comment on: http://stackoverflow.com/q/78361035
score: 0
type: QuestionComment
type: Comment
has text: here is example of full match - presto-data+([[:digit:]])?(-)+([[:digit:]]) , its works but as I explained we want true on partial match

http://stackoverflow.com/comment/138214447
comment on: http://stackoverflow.com/q/78398495
score: 0
type: QuestionComment
type: Comment
has text: Aside: Instead of `a && b && c && d && e && ...`, consider `a || exit` as one command, `b || exit` as a second, etc -- considerably better readability that way, without the bugs introduced by `set -e`.

http://stackoverflow.com/a/78341268
answers question: http://stackoverflow.com/q/78340874
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/138116913
has body: A couple tips aside the character class issue explained by @choroba: Sometimes wrapping regex testing in a function gives code clarity, especially when reading it months/years later or by someone-else. Also here, bash dialect is not really needed (if you think of it, it is often not needed at all but a shell compatibility problem). #!/usr/bin/env sh isValidMail(){ printf %s "$1" | grep -qE '^[a-zA-Z0-9._%=+-]+@[a-zA-Z0-9.=+-]+\.[a-zA-Z]{2,}$' } printf 'Enter an email address: ' read -r email if isValidMail "$email" then echo "Valid mail id" else echo "invalid mail id" fi
has comment: http://stackoverflow.com/comment/138113498
type: Answer

http://stackoverflow.com/a/78424463
answers question: http://stackoverflow.com/q/78423981
type: Answer
upvote count: 2
has body: Write your secret bash script: secret.sh #!/usr/bin/env bash printf 'Hello the world from my secret encrypted bash script!\n' Encrypt your secret.sh: openssl enc -aes-256-cbc -salt -in secret.sh -out secret.sh.enc -k "$Password" Write a loader that will be able to decode and execute its embedded encrypted bash script separated by a null character: secret-loader.sh #!/usr/bin/env bash read -rsp 'Enter password: ' password echo { IFS= read -rd '' # Read through launcher until null character and leave binary blob if ! openssl enc -d -aes-256-cbc -k "$password" > /dev/null 2>&1; then printf 'Invalid password!\n' >&2 exit 1 fi } < "${BASH_SOURCE[0]}" { IFS= read -rd '' openssl enc -d -aes-256-cbc -k "$password" 2> /dev/null | bash } < "${BASH_SOURCE[0]}" exit Combine the loader and the encrypted payload: { cat secret-loader.sh; printf '\0'; cat secret.sh.enc;} > encrypted chmod +x encrypted Now run your new encrypted bash script: ./encrypted
score: 2
downvote count: 0

cut
tag name: cut
type: Tag
tags question: http://stackoverflow.com/q/78354730
tags question: http://stackoverflow.com/q/79155048
tags question: http://stackoverflow.com/q/79447335

http://stackoverflow.com/comment/138201392
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78390328
has text: oops. A `while` was missing. Sorry.
score: 0

http://stackoverflow.com/q/78402103
has comment: http://stackoverflow.com/comment/138222442
score: 0
has body: I inherited this bash script from previous admin which takes input from a CSV file. I am modifying it to output the output and error message to a text file. However, I am getting an output file with blank lines only. Would like to ask if anyone know why it is behaving this way. Thanks in advance for your help. #!/bin/bash while read line; do configname=$(echo "$line" | cut -d, -f1) servicename=$(echo "$line" | cut -d, -f2) oldcommand=$(echo "$line" | cut -d, -f3) newcommand=$(echo "$line" | cut -d, -f4) part1=$(echo -e "SELECT config_name,service_description,check_command FROM tbl_service") part2=$(echo -e "WHERE config_name='$configname' and check_command='$newcommand' and service_description='$servicename'") sqlquery=$(echo -e "$part1 $part2") echo "$sqlquery" output=$(echo "$sqlquery;" | mysql --host=localhost --user=sqluser --password='sqlpwd' sqldb1) echo "$output" > Output.log 2> Error.log done < "$1" I'm not sure what is wrong with this script and why it's outputting blank lines.
type: Question
type: UnansweredQuestion
has title: MySQL Output Redirection only output blank lines
has comment: http://stackoverflow.com/comment/138222340
answer count: 1
has comment: http://stackoverflow.com/comment/138222077
tagged with: bash
tagged with: mysql-cli
has comment: http://stackoverflow.com/comment/138222621
has answer: http://stackoverflow.com/a/78403450

http://stackoverflow.com/a/78423908
downvote count: 0
answers question: http://stackoverflow.com/q/78423821
has comment: http://stackoverflow.com/comment/138259322
has body: From your example file it's clear that you need to just check if first column is greater than 0, like this: $ awk '/crgi/{if ($1&gt;1) {print $0}}' test.file 2 404aa, &gt;crgi_XP_011414097.1... at 100.00% With cluster: $ awk '/&gt;Cluster/{cluster=$2};/crgi/{if ($1&gt;1) {print cluster}}' test.file 107 Occasionally, the ID containing the desired string might be positioned where the cluster number in the first column is labeled as 0. In this case code will be slightly bigger: awk ' /&gt;Cluster/{id=$2} /crgi/{found[id]=$0} {cluster[id]++} END{ for(i in found){ if(cluster[i]&gt;2){print i} } }' test.file 107
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/comment/138269093
comment on: http://stackoverflow.com/q/78428595
has text: Use `jq` to parse json instead of grep
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138273207
comment on: http://stackoverflow.com/q/78424358
type: Comment
score: 0
type: QuestionComment
has text: It's not a regex. Also, in `"${files%%_N_*}_${theID}_${files//!(*.*)_}cfg"`, the substitution is used twice, not once.

http://stackoverflow.com/a/78350302
type: AcceptedAnswer
score: 4
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/78349529
has body: rebuild your version with this patch https://gitlab.com/procps-ng/procps/-/commit/8a65a30#6d88a78 or update to a newer version than that
type: Answer
accepted answer of: http://stackoverflow.com/q/78349529

http://stackoverflow.com/comment/138113311
score: 0
has text: It looks like this can be reproduced, depending on the shell options. Certainly @user1934428's answer is valuable, so I think this should not be closed.
type: Comment
comment on: http://stackoverflow.com/q/78334264
type: QuestionComment

http://stackoverflow.com/comment/138156181
type: AnswerComment
comment on: http://stackoverflow.com/a/78363871
has text: I see. So it's basically impossible, without breaking other functionalities. Bummer :/ I find the `!$` and `!!` really handy shurtcuts, I was hoping to implement something that is just as easy to type and would produce the name of the latest file. I guess I could use `PROMPT_COMMAND` and populate e.g. a `Q1` variable, that way I could go with `ls $Q1` or something like that... Thank you for your input!
score: 0
type: Comment

http://stackoverflow.com/a/78367741
answers question: http://stackoverflow.com/q/78367681
score: 0
has body: x=($ID) (NOTE: in this case there's no need for the eval) will populate an array with elements where white space is the delimiter. You can see the entire contents of x[] as follows: $ typeset -p x declare -a x=([0]="SNMP-FRAMEWORK-MIB::snmpEngineID.0" [1]="=" [2]="Hex-STRING:" [3]="80" [4]="00" [5]="01" [6]="3E" [7]="03" [8]="28" [9]="29" [10]="86" [11]="2F" [12]="05" [13]="91") Notice that each hex tuple is stored as separate array elements. You can tell bash to split ID based on something other than white space, eg, split on :: $ IFS=':' x=( $ID ) $ typeset -p x declare -a x=([0]="SNMP-FRAMEWORK-MIB" [1]="" [2]="snmpEngineID.0 = Hex-STRING" [3]=" 80 00 01 3E 03 28 29 86 2F 05 91") Now we see that x[3] holds the entire hex string (plus a leading space)
has comment: http://stackoverflow.com/comment/138161861
type: Answer

http://stackoverflow.com/comment/138238068
comment on: http://stackoverflow.com/q/78411838
has text: Note that using string concatenation to generate structured data is error-prone -- as soon as your value has characters that need to be escaped to be valid JSON you'll start generating invalid syntax as output. Far better to use a tool like `jq` that understands JSON syntax and can do escaping on your behalf.
type: QuestionComment
type: Comment
score: 4

http://stackoverflow.com/comment/138157298
has text: Does this answer your question? [AppleScript: Save/Restore the Bounds of Every Open Window by Path/Name](https://stackoverflow.com/questions/76408056/applescript-save-restore-the-bounds-of-every-open-window-by-path-name)
type: QuestionComment
comment on: http://stackoverflow.com/q/78364618
score: 0
type: Comment

http://stackoverflow.com/comment/138301488
score: 0
comment on: http://stackoverflow.com/q/78445450
type: QuestionComment
has text: You can program `monitor` in pretty any language you want - Python, Lisp, bash, awk, ... you name it. However, you can only log the time when the data arrives at `monitor`, which is not necessarily the same as when `app` writes it. You could consider making `app` write to stdout unbuffered, in order to get more accurate times. BTW, I don't quite see in which respect an implementation in Python would be significantly more complicate than one in bash.
type: Comment

http://stackoverflow.com/comment/138245472
has text: Your file has CRLF line breaks. Fix it with `dos2unix`.
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78416162

http://stackoverflow.com/comment/138257289
type: AnswerComment
score: 0
has text: @fluter : yes, cmd groups are nice. Be sure to make it a habit to include the `;` char before the closing `}`. Good luck.
comment on: http://stackoverflow.com/a/78419699
type: Comment

http://stackoverflow.com/a/78411741
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/138238287
has comment: http://stackoverflow.com/comment/138238392
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78411488
has comment: http://stackoverflow.com/comment/138238226
has comment: http://stackoverflow.com/comment/138237897
upvote count: 2
has comment: http://stackoverflow.com/comment/138237903
downvote count: 0
answers question: http://stackoverflow.com/q/78411488
has body: For structured data, like JSON, you'd be better off using tools that are aware of that structure, like the JSON parser jq. It can process multiple inputs in a single invocation, e.g. with this straight-forward approach: jq -r ' if any(.Blocks[]; .Dmo == "Path") then .Filename + (.Blocks[] | ", " + select(.Dmo == "Path").Value) else .Filename end ' input .Filename, .Blocks, .Dmo, and .Value access the respective field values, and with [] attached, iterates over the values of that array any produces true if at least one of the values provided matches a given condition, while select filters its input values according to a given condition The -r flag decodes the JSON string results into raw texts (essentially, stripping the double quotes) This produces File_213, /Files/2024/abd File_213, /Files/2024/Ndew File_4 File_43, /Files/2023/Roi2 Demo As an alternative, one could deduplicate some of the code by transforming the .Blocks array into one with pre-generated result values, and then test for its emptiness using variables for reference: jq -r ' [.Blocks[] | ", " + select(.Dmo == "Path").Value] as $a | .Filename + if $a == [] then "" else $a[] end ' input Demo Another one would be using the // operator to produce an alternative value that is triggered on missing inputs when iterating over that pre-generated array. (This relies on the apparent secondary constraint that all values of .Value are actually strings, i.e. not false or null.) jq -r '.Filename + (.Blocks | map(", " + select(.Dmo == "Path").Value)[] // "")' Demo

http://stackoverflow.com/comment/138129894
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78350497
has text: The here-doc is being processed on the local system, not the remote system. It's providing input to the local `tar` command, but it's not reading from stdin.
type: Comment

http://stackoverflow.com/comment/138072486
comment on: http://stackoverflow.com/q/78317514
type: QuestionComment
type: Comment
has text: @CharlesDuffy Thank you so much for the help! This all makes sense, I will fix up my script as best as I can while still following the directions.
score: 0

http://stackoverflow.com/comment/138159320
comment on: http://stackoverflow.com/q/78366286
has text: In your tests where do you see this failing? ... is the `flag.txt` created as intended? ... `if [ ! -f /var/run/flag.txt ];` is that working if you test locally?
type: QuestionComment
type: Comment
score: 1

snmp-trap
tags question: http://stackoverflow.com/q/78388395
tag name: snmp-trap
type: Tag

http://stackoverflow.com/comment/138233392
score: 1
comment on: http://stackoverflow.com/q/78406644
has text: Alternatively, look at `xargs` to convert STDIN to command line arguments.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138284788
score: 0
has text: Why are you having trouble matching the address with `awk`? Use the `~` operator to match a regexp.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78438262

http://stackoverflow.com/comment/138297741
comment on: http://stackoverflow.com/q/78445450
type: QuestionComment
has text: If it's binary data you should use python
type: Comment
score: 0

http://stackoverflow.com/q/78338056
tagged with: bash
tagged with: azure-pipelines
tagged with: google-alloydb
tagged with: google-cloud-platform
tagged with: postgresql
has body: I want to start alloydb auth proxy in one of the steps in my pipeline. I'm using bash. The problem is that the proxy starts but then it never pass to the next step. When I was using cloud sql proxy, I use the following command to run the proxy in the background: ./cloud-sql-proxy $(instance_connection_name) --address IPADDRESS --port 5432 --impersonate-service-account $(iac_deployer_email) &amp;&gt;/dev/null&amp; But it seems this don't work for alloydb auth proxy. How can I escape and run the proxy in backuground so in next step in my pipeline I can connect using psql?? This is how my azure pipeline looks: Thanks.
has answer: http://stackoverflow.com/a/78339098
score: 0
type: Question
type: UnansweredQuestion
answer count: 1
has title: how to run alloydb auth proxy in background in a pipeline?

http://stackoverflow.com/q/78404577
has answer: http://stackoverflow.com/a/78404605
has title: Conditionally inserting commas in variable-length lines
accepted answer: http://stackoverflow.com/a/78404605
answer count: 1
favorite count: 0
score: -2
type: AnsweredQuestion
tagged with: awk
tagged with: sed
has comment: http://stackoverflow.com/comment/138231733
downvote count: 2
tagged with: bash
type: Question
upvote count: 0
has body: I have a file that used to contain two CSV columns but has had its commas removed so that each line is one full "record". I need to separate these into two records again by adding a comma, but the lines are between 20 to 21 characters and need to be processed accordingly - if the line is 20 characters the comma needs to be added at the 16th position, and if the line is 21 characters the comma needs to be added at the 17th position. If I've done my maths right this would result in a second column that has 5 characters on all lines. What's the best way to accomplish this using Bash and GNU tools?
has comment: http://stackoverflow.com/comment/138225307

http://stackoverflow.com/comment/138218096
comment on: http://stackoverflow.com/q/78399997
type: QuestionComment
type: Comment
has text: Apparently [Box only allows](https://support.box.com/hc/en-us/community/posts/360049217254-Allowed-characters-in-files-and-folders) characters from the [Unicode Basic Multilingual Plane](https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane). You may have better luck ensuring names have only characters in that range instead of trying to track down [all of the emojis](https://stackoverflow.com/questions/30470079/emoji-value-range).
score: 0

http://stackoverflow.com/comment/138079114
type: Comment
score: 0
type: AnswerComment
has text: @jhnc, what makes you say that? Both in your answer and in mine, the output for `pgrep -a` is identical to `cmdline` with spaces, and in the source code we see in `src/prgep.c` that `task_cmdline = PIDS_GETSTR(CMDLINE);` There are other references to `cmdline` in the code there too.
comment on: http://stackoverflow.com/a/78320229

http://stackoverflow.com/comment/138215744
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78396833
has text: You're welcome. `printf` with no arguments can never work, it's a syntax error because `printf` requires at least 1 argument, a format string. `printf $0` would be wrong as it'd treat `$0` as the format string and so would fail if `$0` contained formatting chars such as `%s`, so to print `$0` without a newline at the end you need to write `printf "%s", $0`. Just try a) `echo '10% off' | awk '{printf}'`, b) `echo '10% off' | awk '{printf $0}'` and c) `echo '10% off' | awk '{printf "%s", $0}'` to see the differences.
type: Comment

http://stackoverflow.com/comment/138317491
score: 0
has text: You should post the solution below in **Your Answer**, not in the question.
type: Comment
comment on: http://stackoverflow.com/q/78444871
type: QuestionComment

http://stackoverflow.com/comment/138224225
has text: How did you test? In particular, is the write side open or closed when you see the read end fail? (Failing is expected after the writer closes its handle, but not before; when that happens, though, the reader needs to reopen to get a new handle, it can't just block and then read again from the handle it already has).
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78403776

http://stackoverflow.com/comment/138162186
score: 1
has text: Also, `i=$i+1` should be `i=$(( i + 1 ))`; your current code stores `1+1` when what you want to store is `2`. The same is true for all the other places you want to do arithmetic operations.
type: QuestionComment
comment on: http://stackoverflow.com/q/78368689
type: Comment

http://stackoverflow.com/a/78375051
score: 1
answers question: http://stackoverflow.com/q/78375007
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/138173685
has comment: http://stackoverflow.com/comment/138173414
has comment: http://stackoverflow.com/comment/138174674
has body: STDIN='/dev/stdin' # Default to stdin if some-condition; then STDIN='some-filename' fi # Similarly, for STDOUT STDOUT='/dev/stdout' # Default to stdout if some-other-condition; then STDOUT='some-other-filename' fi run-command <"$STDIN" >"$STDOUT"
type: Answer
accepted answer of: http://stackoverflow.com/q/78375007
downvote count: 2

http://stackoverflow.com/comment/138240755
type: AnswerComment
score: 1
has text: Until you get a value like `arr[key3]='foo "bar \ bar"'`, then you have invalid JSON
comment on: http://stackoverflow.com/a/78412598
type: Comment

http://stackoverflow.com/q/78445380
type: Question
has comment: http://stackoverflow.com/comment/138301643
tagged with: shell
has comment: http://stackoverflow.com/comment/138430914
has comment: http://stackoverflow.com/comment/138298084
linked to: http://stackoverflow.com/q/39527571
has comment: http://stackoverflow.com/comment/138298901
score: 0
answer count: 0
has comment: http://stackoverflow.com/comment/138306554
has title: Bash script does not recognize filenames read from file while copying
has body: I'm using a bash script to copy specific files listed in a file, into another directory. The issue is that those filenames are not being recognized as such and i get an error ' ' 'file not found' The files do exist and I am in the correct directory. Thing is if I use a list of filenames obtained by ls > list_of_files it works no issue (though this gives me all files and I only want specific ones). This also works if I write the filenames in by hand. To the naked eye both file lists look the same, what could be the issue here? It kind of seems like it only reads part of the string as a filename or a space? The structure of filenames is a such AAA-000.a_a.png Below is the copying part of the script while IFS= read -r file;do if [ -f "$file" ]; then cp "$file" "$destination" else echo "file '$file' not found" fi
has comment: http://stackoverflow.com/comment/138298041
tagged with: bash
has comment: http://stackoverflow.com/comment/138306578
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138306562
has comment: http://stackoverflow.com/comment/138297478
has comment: http://stackoverflow.com/comment/138301590

http://stackoverflow.com/comment/138274951
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78421472
score: 0
has text: Totally agree and apologies for the confusion. Copy that moving forward :)

http://stackoverflow.com/q/78361451
has comment: http://stackoverflow.com/comment/138150343
tagged with: termux
has comment: http://stackoverflow.com/comment/138150274
has comment: http://stackoverflow.com/comment/138150381
has comment: http://stackoverflow.com/comment/138149867
tagged with: bash
has comment: http://stackoverflow.com/comment/138150390
has comment: http://stackoverflow.com/comment/138149885
tagged with: termux-linux
has comment: http://stackoverflow.com/comment/138150056
upvote count: 1
answer count: 1
favorite count: 0
has body: I'm trying to run a very straightforward "Hello world" batch script in Termux, but it reports the error line 1: #!/data/data/com.termux/files/usr/bin/env: No such file or directory Here's the script, saved as test.sh: #!/data/data/com.termux/files/usr/bin/env bash echo "Hello World" The shebang line (above) has already been fixed using termux-fix-shebang (the file modified timestamp was updated when it ran). Termux-exec is also installed and up to date (although still didn't seem to work with the standard #!/bin/bash shebangs) When I try to run the script by typing bash test.sh at the command line, it says: test.sh: line 1: #!/data/data/com.termux/files/usr/bin/env: No such file or directory Hello World I guess I should be relieved that the "Hello World" does get displayed, but what is causing the error on line 1? And how do I get rid of it? (I have already worked through a number of suggestions from other similar questions and answers here on Stack Overflow - apologies if I've missed something!) Edit: Adding outputs as requested in comments (here, so the formatting is readable) ~/.../journal/nginx_config $ od -t x1 <test.sh 0000000 ef bb bf 23 21 2f 64 61 74 61 2f 64 61 74 61 2f 0000020 63 6f 6d 2e 74 65 72 6d 75 78 2f 66 69 6c 65 73 0000040 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 62 61 73 0000060 68 0a 65 63 68 6f 20 22 48 65 6c 6c 6f 20 57 6f 0000100 72 6c 64 22 0000104 ~/.../journal/nginx_config $ type env env is /data/data/com.termux/files/usr/bin/env ~/.../journal/nginx_config $
has answer: http://stackoverflow.com/a/78362140
has title: Termux reports "No such file or directory" for bash even after using termux-fix-shebang
has comment: http://stackoverflow.com/comment/138150021
has comment: http://stackoverflow.com/comment/138150013
tagged with: android
downvote count: 0
type: Question
type: UnansweredQuestion
score: 1

http://stackoverflow.com/comment/138101371
type: Comment
score: 0
has text: Not sure what was written in bash3 documentation, probably xpg compat is set somewhere in env (firstly check it out with `shopt xpg_echo`). And compare `shopt -u xpg_echo && echo 'a\nb'` vs `shopt -s xpg_echo && echo 'a\nb'`
comment on: http://stackoverflow.com/q/78334264
type: QuestionComment

expect
tags question: http://stackoverflow.com/q/78373722
tag name: expect
tags question: http://stackoverflow.com/q/78375308
type: Tag
tags question: http://stackoverflow.com/q/78545397
tags question: http://stackoverflow.com/q/78854389
tags question: http://stackoverflow.com/q/79023478
tags question: http://stackoverflow.com/q/79013914
tags question: http://stackoverflow.com/q/78948937
tags question: http://stackoverflow.com/q/79031975
tags question: http://stackoverflow.com/q/78949960
tags question: http://stackoverflow.com/q/79116401
tags question: http://stackoverflow.com/q/79145790
tags question: http://stackoverflow.com/q/79404066
tags question: http://stackoverflow.com/q/79351008
tags question: http://stackoverflow.com/q/79537887

http://stackoverflow.com/comment/138149665
score: 0
comment on: http://stackoverflow.com/q/78361173
type: QuestionComment
has text: See [How can I debug a Bash script?](https://stackoverflow.com/q/951336/4154375).
type: Comment

http://stackoverflow.com/comment/138201620
has text: Do not edit answers into questions. Instead, add the answer _as an answer_ below; clicking the checkbox next to that answer will mark the question solved (editing "solved" into titles is similarly against our rules).
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78390602
type: Comment

http://stackoverflow.com/comment/138158743
comment on: http://stackoverflow.com/q/78364618
score: 0
has text: Don't let any variable, shell or otherwise, e.g. `winName` in the script at the bottom of your question, expand to become part of an awk script. See https://stackoverflow.com/questions/19075671/how-do-i-use-shell-variables-in-an-awk-script for how to pass the **value** of a variable to awk.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138301643
type: QuestionComment
type: Comment
score: 0
has text: In addition, do a `pwd` before entering the loop to verify, that you are looking into the right directory.
comment on: http://stackoverflow.com/q/78445380

http://stackoverflow.com/q/78420131
tagged with: echo
tagged with: bash
has comment: http://stackoverflow.com/comment/138252797
has comment: http://stackoverflow.com/comment/138252720
has comment: http://stackoverflow.com/comment/138252567
tagged with: error-handling
has comment: http://stackoverflow.com/comment/138252627
answer count: 2
type: Question
tagged with: linux
downvote count: 0
has comment: http://stackoverflow.com/comment/138252768
type: UnansweredQuestion
has title: Does the echo command in Bash shell ever write anything to stderr without an explicit redirect of the output?
score: 1
has answer: http://stackoverflow.com/a/78420330
has body: Plenty of other commands/binaries would (for example wc --wrong-flag) but is echo one of them? Context: I am maintaining somebody else's Bash script, looking at the following section of it (slightly redacted for security): log_file_path="logs/some_prefix_redacted.$(date +%Y-%m-%d_%H_%M_%S).log" echo "Running Step 1 - Deleting files from S3 recursively" >> "${log_file_path}" 2>&1 aws s3 rm --recursive s3://s3_path_redacted >> "${log_file_path}" 2>&1 step_1_exit_code="${?}" echo "Step 1 - Deleting files from S3 recursively finished with exit code ${step_1_exit_code}." >> "${log_file_path}" 2>&1 I am wondering if I need these: 2>&1 at the end of the echo commands. They pipe stderr to stdout before piping stdout to a log file, and in general this is what we do want in this case - we do not want to lose any relevant info. However, in the case of the echo command specifically, is it necessary? Would the echo command ever send something to stderr without an explicit redirect? It looks like, if I were to try to redirect echo's stdout and stderr to the same file that the current user does not have permissions for, then the error will be just dumped into the regular stderr. In any case, it seems that trying to redirect stderr to stdout to a file when using echo command is useless. Hopefully not, hopefully echo is a ... "trusted primitive building block" for the lack of better words. Our goal is to a) retain as much relevant info as possible for the purposes of debugging, and b) keep the code clean, not write any dead or useless code. What I tried: I can cause echo to output some text to stderr if I redirect either stdout or stderr to a file that I do not have write permissions for, but I am still not sure if it is possible to get echo to output something to stderr without an explicit redirect. I suppose this is a separate question, but what if the echo command itself fails? For example, for some reason there are insufficient permissions to create or write to the log file. $ e…
favorite count: 0
tagged with: io-redirection
has comment: http://stackoverflow.com/comment/138254690
upvote count: 1
has answer: http://stackoverflow.com/a/78420840

http://stackoverflow.com/comment/138129949
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78350497
has text: now, if you had a normal-ish shell we could copy the original stdin off to a different fd before setting up a remote heredoc, but because this whole thing came into play because you have an unusual shell all bets are off unless we can identify that shell to reason about its specific behavior.
score: 0

gcloud
tags question: http://stackoverflow.com/q/78431133
tag name: gcloud
type: Tag
tags question: http://stackoverflow.com/q/78513768
tags question: http://stackoverflow.com/q/78834405
tags question: http://stackoverflow.com/q/79028351
tags question: http://stackoverflow.com/q/79247849

http://stackoverflow.com/comment/138297576
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78429634
has text: Please read [answer] and take the [tour] and note well that this is **not a discussion forum**. Do not use the answer section to provide "updated" information. If you wish to go back and forth with others to figure out a solution to your problem, please use a different site. If you wish to use Stack Overflow, you are expected to ask one, specific, properly focused question at a time - and it is your responsibility before posting to isolate a proper [mre] for debugging issues or specification for how-to questions.
type: Comment

http://stackoverflow.com/comment/138299359
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78444561
score: 0
has text: Does this answer your question: [plink won't return to command prompt](https://stackoverflow.com/a/21621713/1701026)?

http://stackoverflow.com/comment/138075276
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78319238
has text: I'm having trouble reproducing your error. What version of `pgrep` are you using? What is your OS? Specifically with `pgrep from procps-ng 3.3.17` your test line of `pgrep -a tmux` returns nothing. You can try maybe `pgrep -c ^tmux`, but maybe that will also depend on the version?
type: QuestionComment

http://stackoverflow.com/a/78431428
answers question: http://stackoverflow.com/q/78431133
score: 0
has comment: http://stackoverflow.com/comment/138339711
type: Answer
has body: The issue is with the PATH. Thanks to below answer. It worked after explicitly exporting gcloud path with in the script. gcloud command not found - while installing Google Cloud SDK export PATH="~/google-cloud-sdk/bin:$PATH"

http://stackoverflow.com/comment/138155267
comment on: http://stackoverflow.com/q/78364647
score: 0
type: QuestionComment
type: Comment
has text: All `*.py` file in current dir, that not begin by a *shebang*: `find . -type f -name '*.py' -exec sed -sne '1{\,^#!,!F}' {} +`

http://stackoverflow.com/comment/138234503
comment on: http://stackoverflow.com/q/78409749
score: 0
type: QuestionComment
type: Comment
has text: BTW, [`echo -e` is bad form](https://unix.stackexchange.com/a/65819/3113); use `printf '*'` or `printf '\n'` (or, for the latter, just `echo` with no arguments at all) to improve portability / compatibility across different shells and shell configurations (even with the exact same version of bash, the `xpg_echo` flag -- which can be set via environment variable -- will change how `echo -e` works, so it's not reliable even if you're 100% sure which shell your script will be run with).

http://stackoverflow.com/comment/138269099
score: 1
comment on: http://stackoverflow.com/q/78428595
type: QuestionComment
has text: And there are tools to parse JSON (`jq`). Using grep+cut+tr is _really_ brittle and will lead exactly to the problems that you are encountering. `"sessionId": "b67e09ac-ef3f-4b01-8aba-353436770fc9"` has a space after the `:` (your field delimiter with cut), and you never remove it. Use the right tool for the job and you can avoid such issues.
type: Comment

http://stackoverflow.com/comment/138075141
type: QuestionComment
has text: You may want to review the shell guide by Google: https://google.github.io/styleguide/shellguide.html - there are a few issues in your script that might cause unexpected problems later ....
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78319248

http://stackoverflow.com/comment/138198337
type: Comment
score: 0
type: QuestionComment
has text: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/257539/discussion-between-gordon-davisson-and-siddharth).
comment on: http://stackoverflow.com/q/78383368

http://stackoverflow.com/comment/138230168
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78401596
has text: *nameref* is useful for *functions* (Answer edited.)

http://stackoverflow.com/a/78403471
type: Answer
score: 0
has body: I'm not familiar with RPM repos or zypper, so there might be a better way to do it, but maybe something like this will work: zypper --terse packages -r "$MY_REPO" \ | awk -F '|' 'NR>4{gsub(/ /,"");print $3 "-" $4 "." $5 ".rpm"}' > available.list comm -23 <(sort required.list) <(sort available.list) The zypper command outputs all packages available in the repo, but the format is terrible, so we need AWK to format it correctly. It skips the first 4 lines (NR>4) that in my testing looked like this: Loading repository data... Reading installed packages... S | Repository | Name | Version | Arch ---+------------+------+---------+------- Then splits the rest by the | character (-F '|'), removes all whitespace from the line (gsub(/ /,"")), and finally joins the columns of the rest of the output together, so that the available.list file (for MY_REPO="Main Repository") looks like this: 0ad-0.0.26-bp155.1.6.x86_64.rpm 0ad-data-0.0.26-bp155.1.5.noarch.rpm 2ping-4.5.1-bp155.3.7.noarch.rpm 3omns-0.2-bp155.3.11.x86_64.rpm 4pane-8.0-bp155.1.6.x86_64.rpm ... Then, with required.list that you provided as an example: expat-2.4.4-150400.3.17.1.x86_64.rpm filesystem-15.0-11.8.1.x86_64.rpm fillup-1.42-2.18.x86_64.rpm findutils-4.8.0-1.20.x86_64.rpm fontconfig-2.13.1-150400.1.4.x86_64.rpm fonts-config-20200609+git0.42e2b1b-150000.4.10.1.noarch.rpm gawk-4.2.1-150000.3.3.1.x86_64.rpm The output of the comm command will be: expat-2.4.4-150400.3.17.1.x86_64.rpm fonts-config-20200609+git0.42e2b1b-150000.4.10.1.noarch.rpm gawk-4.2.1-150000.3.3.1.x86_64.rpm Which means that these 3 packages aren't available in the OpenSuse Leap version that I tested this on :)
answers question: http://stackoverflow.com/q/78385555

http://stackoverflow.com/comment/138222881
has text: Looking at Coretto's download page, they call x86_64 "x64". (That's a little confusing because that's a name that _used_ to be used primarily to refer to Itanium). So just truncating you is taking you to the wrong page.
comment on: http://stackoverflow.com/q/78398495
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138074335
comment on: http://stackoverflow.com/q/78317617
has text: does the output need to be in any particular order (eg, all 1-char strings (sorted), then all 2-char strings (sorted), then all 3-char strings (sorted)) or does order not matter as long as all possible strings are generated?
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138299146
type: QuestionComment
has text: Does it output anything? Would it output anything, if you add `-v`?
type: Comment
comment on: http://stackoverflow.com/q/78444561
score: 0

http://stackoverflow.com/comment/138267559
type: Comment
comment on: http://stackoverflow.com/q/78428595
score: 0
has text: sorry, which faulty tag do you mean? it's bash (echo $SHELL -> /bin/bash.). I'm not sure if curl is relevant here, but I would have expected for both commands to do the same thing.
type: QuestionComment

http://stackoverflow.com/comment/138234677
score: 0
has text: (Another performance note -- it'd be more efficient to just call your various `tput` commands that are used in the loop _once_ before the loop starts _and store their output in variables_; you can then write those variables multiple times without the overhead of starting an external process).
type: Comment
comment on: http://stackoverflow.com/q/78409749
type: QuestionComment

http://stackoverflow.com/comment/138163910
type: QuestionComment
comment on: http://stackoverflow.com/q/78369669
type: Comment
score: 0
has text: https://stackoverflow.com/questions/2597875/how-can-i-build-a-tar-from-stdin might provide some options

http://stackoverflow.com/comment/138123656
type: Comment
comment on: http://stackoverflow.com/q/78346345
has text: In all questions, please provide a [mcve] that includes concise, testable sample input and expected output covering all of your use-cases (e.g. nested `ifs`) that we can copy-paste to test a potential solution against. Obviously then don't make your target range 100 lines, make it 5 or 10 or something else reasonable to post in a question.
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138159370
type: QuestionComment
comment on: http://stackoverflow.com/q/78356154
score: 0
type: Comment
has text: FYI, this package already provides a Conda Forge build (see [Installation documentation](https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner?tab=readme-ov-file#installation)). The documentation further outlines what packages should installed in the environment when building from source, which extends beyond what is tried here. Nevertheless, the duplicate marking seems appropriate: the errors indicate that the XCode Command Line Tools need to be installed.

http://stackoverflow.com/comment/138303462
comment on: http://stackoverflow.com/q/78438850
type: Comment
has text: Hello all, thanks for the help. I managed how to solve the problem following the tip to set it manually from user1934428.
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138180496
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78373696
has text: (if you want to write _the shim itself_ in Go, you'll want to use https://codeberg.org/msantos/execve; the built in os/exec module always forks off a subprocess before the exec, vs replacing the existing process in-place as done by an exec with no preceding fork)

http://stackoverflow.com/comment/138173067
comment on: http://stackoverflow.com/q/78374908
type: QuestionComment
score: 2
type: Comment
has text: There should be a single register that contains the address of the `argv` array. That should be an array of pointers to the individual arguments. And make sure that `argv[0]` contains `"bash"` or `"/bin/bash"`

http://stackoverflow.com/comment/138203592
has text: if it worked you'd be launching a new ssh connection ten times each second. seems a very resource-intensive way to draw a few characters
type: QuestionComment
type: Comment
score: 3
comment on: http://stackoverflow.com/q/78392466

http://stackoverflow.com/comment/138101068
comment on: http://stackoverflow.com/q/78330348
score: 0
has text: What is the strange `-r` doing at the end of your grep command? Do you really have a file of this name?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138088852
type: QuestionComment
type: Comment
has text: Isn't `echo` a built-in as well?
comment on: http://stackoverflow.com/q/78325081
score: 0

http://stackoverflow.com/a/78356251
has body: I solved this based on Barmar's comment. In the last group, I had to change \([^,]*\) to \(,[^,]*\). The solution is: # Replace s/\([^,]*,[^,]*,[^,]*,[^,]*,\)\(0\|[1-9][0-9]\{0,1\}\)\([^,]*\)/\1none\3/
answers question: http://stackoverflow.com/q/78356050
downvote count: 0
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/comment/138167457
has text: you may also use two commands `"other command ; cp /root/.bash_profile /home/postgres/.bash_profile"`
comment on: http://stackoverflow.com/q/78371491
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138078016
has text: That is all to say, I'd argue that best-practice use of tmux (with named sessions and possibly named sockets, both of which you can check for separate from the presence of a tmux process itself) would leave you with no reason to use pgrep in the first place, mooting this question.
comment on: http://stackoverflow.com/q/78319238
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/138122525
has text: Don't tell me that you are trying to write a PHP parser in bash and awk???
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78346345
type: Comment

http://stackoverflow.com/a/78391686
has comment: http://stackoverflow.com/comment/138202581
answers question: http://stackoverflow.com/q/78390318
score: 2
downvote count: 0
type: Answer
upvote count: 2
has body: If you've got Bash 4.0 (released in 2009), and the data going from p2 to p1 is textual (no ASCII NUL characters), line-oriented, and low in volume (no more than kilobytes per second); then you could possibly do what you want with a Bash coprocess. Try this Shellcheck-clean code: #! /bin/bash -p coproc { p1 | p2; } while IFS= read -r line; do printf '%s\n' "$line" >&"${COPROC[1]}" done <&"${COPROC[0]}" See the Coprocesses section of the Bash Reference Manual for information about Bash coprocesses. Coprocesses were introduced in Bash 4.0. The loop reads lines from the output of the coprocess (which is the output of p2) and writes them to the input of the coprocess (which is the input of p1).
has comment: http://stackoverflow.com/comment/138203085

http://stackoverflow.com/comment/138088361
comment on: http://stackoverflow.com/q/78325081
type: QuestionComment
has text: Hey @user1934428, my shell prints `$a` as well. I have two doubts. First, like `eval echo '$a'` prints the value of `a`, shouldn't `exec echo '$a'` also look for variable `a`? Also, as `declare` command is printing the variable name, does the variable really exist in the replaced process as well?
type: Comment
score: 0

http://stackoverflow.com/comment/138117463
has text: Either find someone who still knows how to code in XSLT 1.0 (I last used it twenty years ago) or download an XSLT 3.0 processor such as Saxon (my company's product).
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78342527

http://stackoverflow.com/comment/138129333
score: 0
has text: @DavidMaze Well, I'm able to start the container (actually using docker-compsoe) and if I docker exec and run the script, it works manually.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78349366

http://stackoverflow.com/a/78390677
has comment: http://stackoverflow.com/comment/138201857
has body: There are several options using a fifo. With one fifo: mkfifo fifo tail -f fifo | p1 | p2 &gt; fifo &amp; With two fifos: mkfifo fifo1 mkfifo fifo2 tail -f fifo1 | p1 &gt; fifo2 &amp; tail -f fifo2 | p2 &gt; fifo1 &amp; A reason to use 2 fifos could be, that it is possible to add something in the stream for both p1 and p2.
score: 1
has comment: http://stackoverflow.com/comment/138202454
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78390318
has comment: http://stackoverflow.com/comment/138202851
has comment: http://stackoverflow.com/comment/138202960
has comment: http://stackoverflow.com/comment/138201919
downvote count: 0
has comment: http://stackoverflow.com/comment/138202832
has comment: http://stackoverflow.com/comment/138202908
has comment: http://stackoverflow.com/comment/138201899
has comment: http://stackoverflow.com/comment/138201951

http://stackoverflow.com/comment/138233373
has text: This may be relevant for another person but unfortunately not for my situation - there could be multiple registries that the images would need to pushed. Also, I wouldn't have access to these registries the same way I would with my internal registry, hence the need for the tar file.
score: 0
comment on: http://stackoverflow.com/a/78409085
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138091857
type: Comment
has text: like i said in the description I don't know well bashscript. so I don't know how to use `|` localfileToExecuteOnDistServ.sql is a file on my computer
score: 0
comment on: http://stackoverflow.com/q/78328611
type: QuestionComment

http://stackoverflow.com/comment/138101689
score: 0
has text: as it's written above it depends on `xpg_echo` option
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78334326

http://stackoverflow.com/a/78403776
has comment: http://stackoverflow.com/comment/138224429
has comment: http://stackoverflow.com/comment/138224178
has comment: http://stackoverflow.com/comment/138224202
has body: not optimally performant but while true; do if ! read linea; then sleep 0.1 else initialice PintaInfo "$linea" fi should do the trick. (ideally inotifywait should be used instead of sleep, but I couldn't get inotifywait to trigger on fifo writes when testing locally ‍♂️ also tried read -t timeout to reduce cpu usage, but it didn't.)
has comment: http://stackoverflow.com/comment/138224194
has comment: http://stackoverflow.com/comment/138224225
upvote count: 1
has comment: http://stackoverflow.com/comment/138224439
has comment: http://stackoverflow.com/comment/138224380
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/138228162
type: Answer
has comment: http://stackoverflow.com/comment/138224351
answers question: http://stackoverflow.com/q/78403621

http://stackoverflow.com/comment/138256085
type: QuestionComment
type: Comment
has text: Also see the [My text files are broken! They lack their final newlines!](https://mywiki.wooledge.org/BashFAQ/001#My_text_files_are_broken.21__They_lack_their_final_newlines.21) section of [BashFAQ/001 (How can I read a file \(data stream, variable\) line-by-line \(and/or field-by-field)?)](https://mywiki.wooledge.org/BashFAQ/001).
score: 0
comment on: http://stackoverflow.com/q/78422072

http://stackoverflow.com/comment/138283471
comment on: http://stackoverflow.com/q/78437542
has text: Yes, `readarray` is a better choice.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78318299
has body: Perhaps python offers a better alternative, and you can do something like this #! /usr/bin/env python3 from itertools import product from string import ascii_uppercase from functools import partial f = partial(product, ascii_uppercase) n = range(1, 11) for s in (&quot;&quot;.join(r) for p in map(lambda r: f(repeat=r), n) for r in p): print(s)
score: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/138073441
downvote count: 1
answers question: http://stackoverflow.com/q/78317617
has comment: http://stackoverflow.com/comment/138073622
type: Answer

http://stackoverflow.com/q/78383503
tagged with: awk
downvote count: 2
has comment: http://stackoverflow.com/comment/138190000
type: AnsweredQuestion
has title: get values of a line, suggestion about performance
has comment: http://stackoverflow.com/comment/138189610
has body: I have code in bash scripting to extract some values in variables. Text is: ct: I al: 3669619 dc: SERVERA mn: CAR or: 19qrh sv: R st: Not_Noticed stt: 2024 0411151219 lu: lt: ms: THAT'S MESAGE run_as: USER sb : TRADE ap: APPLICATION. jb: JDFSSS ho: HOSTA al: R closed_from_em: nb: cn: 00000000001 Text is a trap that send to a script, so all the line it pass like argument. My code is: line=$(echo $*) jo=$(echo $* | awk '{print $6":"$9}') dc=$(echo $* | awk '{print $6}') aid=$(echo $* | sed 's/.* al:\(.*\) dc.*/\1/' | sed 's/^ //g') or=$(echo $* | sed 's/.* or:\(.*\) sv.*/\1/' | sed 's/^ //g') jb=$(echo $* | sed 's/.* jb:\(.*\) ho.*/\1/' | sed 's/^ //g') ms=$(echo $* | sed 's/.* ms:\(.*\) run_as.*/\1/' | sed 's/^ //g') callType=$(echo $* | sed 's/ct:\(.*\) al.*/\1/' | sed 's/^ //g') sv=$(echo $* | sed 's/.* sv:\(.*\) st.*/\1/' | sed 's/^ //g') st=$(echo $* | sed 's/.* st:\(.*\) stt.*/\1/'| sed 's/^ //g') sendTime=$(echo $* | sed 's/.* stt:\(.*\) lu.*/\1/' | sed 's/^ //g') ru=$(echo $* | sed 's/.* run_as:\(.*\) sb.*/\1/' | sed 's/^ //g') sb=$(echo $* | sed 's/.* sb:\(.*\) ap.*/\1/' | sed 's/^ //g') ap=$(echo $* | sed 's/.* ap:\(.*\) jb.*/\1/' | sed 's/^ //g') ho=$(echo $* | sed 's/.* ho:\(.*\) al.*/\1/' | sed 's/^ //g') al=$(echo $* | sed 's/.* al:\(.*\) closed_from.*/\1/' | sed 's/^ //g') Problem is I execute these code a lot of times simultaneously and I need to improve the performance. Do you know how to modify code to improve perfomance? Thanks
has answer: http://stackoverflow.com/a/78383746
upvote count: 1
score: -1
type: Question
accepted answer: http://stackoverflow.com/a/78383746
has comment: http://stackoverflow.com/comment/138189493
tagged with: sed
tagged with: bash
has comment: http://stackoverflow.com/comment/138187570
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138187703

http://stackoverflow.com/comment/138286839
has text: I have answered there. Also please note that for the `{}` syntax there should be quotation marks: `file "*.{format1,format2,format3}"`
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78438177

http://stackoverflow.com/comment/138161861
type: AnswerComment
comment on: http://stackoverflow.com/a/78367741
has text: If you use `IFS=':' read -r -a x <<<"$ID"` instead of `IFS=':' x=( $ID )` then `$ID` won't be exposed unquoted to the shell for globbing, etc. Try both starting with `ID='a:*:b'` to see a difference in behavior.
score: 0
type: Comment

http://stackoverflow.com/comment/138192052
comment on: http://stackoverflow.com/q/78385809
has text: A lot of the discussion on [why not parse ls](https://unix.stackexchange.com/questions/128985/why-not-parse-ls-and-what-to-do-instead) is equally relevant here. The wiki doesn't say putting commands in variables is bad because it's impossible, it says that because it's very hard to write quality code that way (readable, maintainable, safe in the face of malformed/malicious input) and there's no benefit to it over putting that code into a function.
type: QuestionComment
type: Comment
score: 3

http://stackoverflow.com/comment/138304693
type: Comment
score: 1
has text: @jsx97 `magick identify *.{jpg,png}` works for me in bash and produces the usual list of JPG and PNG files. I have no WEBP files in that directory.
comment on: http://stackoverflow.com/q/78437863
type: QuestionComment

http://stackoverflow.com/q/78365034
tagged with: bash
type: Question
upvote count: 0
has body: I have a sidecar container running along with a Java service container in a Kubernetes pod. The job of this sidecar container is to transfer heapdump to a GCP bucket when the Java service container restarts due to OOM crash. This is how the sidecar does it: - name: heapdump-sidecar image: google/cloud-sdk:latest command: - /bin/sh - -c - | while true; do heap_dump_file="/appdata/java/heapdumps/heapdump.hprof"; gs_bucket="gs://namespace-non-prod/heap-dump-{{ .Values.environment }}-bucket/"; if [ -f "$heap_dump_file" ]; then echo "Heap dump file found. Uploading to GCS..."; gsutil cp "$heap_dump_file" "$gs_bucket{{ .Chart.Name }}-$(date +%Y-%m-%d-%H-%M-%S).hprof"; if [ $? -eq 0 ]; then echo "Heap dump uploaded successfully."; rm -rf /appdata/java/heapdumps/*; else echo "Heap dump upload failed"; fi; else echo "Heap dump file not found. Waiting..."; fi; sleep 5; done There are two scenarios; Scenario 1: The pod receives SIGTERM signal and starts the process of shutdown. The sidecar container is shutdown immediately and the pod waits for the main Java service container to shut down. it shutsdown in 10 seconds, and so the pod is killed in 10 seconds. Scenario 2: The pod receives SIGTERM signal and starts the process of shutdown. The sidecar container is NOT shutdown immediately. The Java service container shuts down in 10 seconds but the pod has to wait for the sidecar container(which is not shutting down). The grace time runs out after 30 seconds and the pod along with container is killed, So the pod shutdown is 30 seconds. What scenario would it actually be?
has title: Will the sidecar container shutdown immediately when a Kubernetes pod is shutdown?
score: -1
tagged with: kubernetes
tagged with: google-cloud-platform
answer count: 1
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78366908
tagged with: heap-dump
downvote count: 1
accepted answer: http://stackoverflow.com/a/78366908

http://stackoverflow.com/comment/138226938
type: AnswerComment
comment on: http://stackoverflow.com/a/78401596
has text: @Hauri, I am trying to use nameref to access the above dynamic arrays, but am getting nowhere: `for ((i=1; i<3; i++)); do arrvar="array_$i" echo Array: "${arrvar}" for ((j=1; j<4; j++)); do read -r value <<<"${arrvar[i]}" echo "Value: ${value}" done done` This just gives me: `Array: array_1 Value: Value: Value: Array: array_2 Value: Value: Value:` How do I access the arrays? I can access them explicitly, but as I will never know how many dynamic arrays are present, I need to loop through them...
score: 0
type: Comment

http://stackoverflow.com/comment/138275877
has text: Works for me. Can you [edit] your question and add a [mcve]?
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78433302

http://stackoverflow.com/comment/138288341
type: Comment
type: QuestionComment
score: 0
has text: Why not use `awk`? ` -k --csv Enable special processing for files with comma separated values (CSV). See Working With Comma Separated Value Files. This option cannot be used with --posix. Attempting to do causes a fatal error. ` `-F fs --field-separator fs`
comment on: http://stackoverflow.com/q/78440219

http://stackoverflow.com/comment/138286745
type: Comment
comment on: http://stackoverflow.com/q/78437863
has text: What do the v, -, and ? mean in your table?
score: 0
type: QuestionComment

http://stackoverflow.com/q/78373828
has comment: http://stackoverflow.com/comment/138170895
has title: Why does && make its left hand side not fail?
type: Question
duplicate of: http://stackoverflow.com/q/45600958
has comment: http://stackoverflow.com/comment/138170875
duplicate of: http://stackoverflow.com/q/73245842
has comment: http://stackoverflow.com/comment/138171671
downvote count: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/78373883
upvote count: 1
has comment: http://stackoverflow.com/comment/138170934
has comment: http://stackoverflow.com/comment/138171884
has comment: http://stackoverflow.com/comment/138173719
has comment: http://stackoverflow.com/comment/138173708
tagged with: shell
tagged with: bash
has body: This script: #!/usr/bin/env bash set -e ( set -e idontexist echo "launch the missiles" ) && echo "no errors" prints: line 7: idontexist: command not found launch the missiles no errors with gnu bash 5.2. Why is that? I was under the assumption that set -e would cause the idontexist line to fail with the failure bubbling out.
score: 1
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78373883
linked to: http://stackoverflow.com/q/73245842
duplicate of: http://stackoverflow.com/q/42519169

automation
type: Tag
tags question: http://stackoverflow.com/q/78316769
tags question: http://stackoverflow.com/q/78422524
tag name: automation
tags question: http://stackoverflow.com/q/78598733
tags question: http://stackoverflow.com/q/78776633
tags question: http://stackoverflow.com/q/78944308
tags question: http://stackoverflow.com/q/79321546
tags question: http://stackoverflow.com/q/79347119
tags question: http://stackoverflow.com/q/79356217
tags question: http://stackoverflow.com/q/79258583
tags question: http://stackoverflow.com/q/79543504

lookup
type: Tag
tag name: lookup
tags question: http://stackoverflow.com/q/78336037

http://stackoverflow.com/comment/138205300
type: QuestionComment
has text: Thank you for all the suggestions. To answer @jhnc, yes it's overkill to launch ssh just to show a few moving characters, but I was trying it out to see if it was possible to do so. (Still learning).
type: Comment
comment on: http://stackoverflow.com/q/78392466
score: 0

http://stackoverflow.com/comment/138102202
type: Comment
score: 0
has text: @EricPostpischil I know the code is generally correct but in the case of let's say 5000 character text you'll notice that it will only read 4096 character no matter what the input is or the buffer size is. sorry for the confusion.
comment on: http://stackoverflow.com/q/78334722
type: QuestionComment

http://stackoverflow.com/comment/138285598
comment on: http://stackoverflow.com/a/78438419
type: Comment
type: AnswerComment
has text: Searching for `845DA8C0` in `"/proc/net/tcp6"` will never match!!
score: 0

http://stackoverflow.com/a/78383369
answers question: http://stackoverflow.com/q/78383368
has comment: http://stackoverflow.com/comment/138187838
has comment: http://stackoverflow.com/comment/139018693
type: AcceptedAnswer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78383368
downvote count: 0
score: 1
type: Answer
has body: I modified my bash script to the below and it started to work. "eval" was the way to run it. mycommand="curl $mycommand --url '${requestURL}'" echo "Search Command $mycommand" eval "$mycommand" Edit, as per amazing advice from @Gordon I am adding a better answer. Use of eval is not adviced. Do not use strings for commands, only for data This is what I did to get things working. function callingMyAPI { requestURL="$1" accessTokenFromAuthResponse="$2" #My REQUEST callingMyAPI=$(curl --header "Authorization: Bearer $accessTokenFromAuthResponse" $requestURL) } callingMyAPI "$url" $accessToken This worked.

http://stackoverflow.com/comment/138173626
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78373696
has text: Again, everything you're asking for is _possible_. I'm just advising (as a grumpy greybeard who's spent time as the dev lead for self-updating security products) that a lot of it is _unwise_. (What I'd argue is an _ideal_ architecture -- and one I've actually used in real-world products -- is one where you've got a dm_verity-esque read-only, signed root filesystem, and an "upgrade" consists of rebooting into a new kernel using a new root fs; make your firmware check the signature over the kernel and you get a chain of trust going all the way back).
type: Comment

http://stackoverflow.com/a/78428119
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78427584
has body: It's a simple error in your algorithm: Since chomp can't be foo and bar at the same time, the command $chomp != "foo" || $chomp != "bar" will always be true. If you had written $chomp != "foo" && $chomp != "bar" you would select elements which are neither foo nor bar. This derives from the formula from boolean algebra: A ∨ B = ¬A ∧ ¬B
score: 3
upvote count: 4
has comment: http://stackoverflow.com/comment/138269338

http://stackoverflow.com/a/78354378
has comment: http://stackoverflow.com/comment/138137043
upvote count: 1
downvote count: 0
has body: I would have posted a comment, but I do not have permission yet, so I added this rough answer. Assuming that the percentage % char is used for "quotation" separator, you can have themreplaced with newlines, and newlines replaced by another unused character (for example the caret ^ could be a good choice) storing the results in a temporary file cat memorable_citations.txt | tr '[\n%]' '[^\n]' > /tmp/$$ then you can use the shuf tool you mentioned on the temporary file /tmp/temp$$ ($$ is the PID of the shell so in general /tmp/temp$$ should be a safe name) and save the random quote in a RANDOM_QUOTE variable, then delete the temporary file /tmp/temp$$ and finally send RANDOM_QUOTE to the screen after performing the inverse transformation echo "$RANDOM_QUOTE" | tr '^' '\n' P.S.: I know that the usage of a temporary file should be avoided whenever possible, but this solution was just a draft
score: 1
answers question: http://stackoverflow.com/q/78354041
type: Answer

http://stackoverflow.com/comment/138195049
comment on: http://stackoverflow.com/a/78387469
has text: Thank you very much!! It worked!! What I noticed is that I can call print(x()) and it will print what the function returns. Again, thank you very much for the response and have a nice day!
score: 0
type: Comment
type: AnswerComment

line-breaks
tag name: line-breaks
tags question: http://stackoverflow.com/q/78396373
type: Tag

http://stackoverflow.com/comment/138079118
score: 0
has text: not what it outputs, what it searches for; note the output in my answer when searching for "gotcha" - which does not appear anywhere in `cmdline`
type: Comment
comment on: http://stackoverflow.com/a/78320229
type: AnswerComment

mysql-cli
type: Tag
tags question: http://stackoverflow.com/q/78402103
tag name: mysql-cli

http://stackoverflow.com/comment/138244625
score: 0
comment on: http://stackoverflow.com/q/78415633
has text: I'd still love to understand, why `declare`'s failure is not handled here :(
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/138224632
type: QuestionComment
type: Comment
score: 0
has text: You question is unclear! On which base do you want to merge lines? Every 9th line? by pair? On some word or *regex* found? ... Or just once: One modification AT line 9??
comment on: http://stackoverflow.com/q/78404233

http://stackoverflow.com/comment/138252112
type: Comment
type: AnswerComment
has text: Schoolboy error, thank you for highlighting
score: 0
comment on: http://stackoverflow.com/a/78419867

http://stackoverflow.com/q/78350564
linked to: http://stackoverflow.com/q/41791071
downvote count: 0
linked to: http://stackoverflow.com/q/61129461
favorite count: 0
has title: How does indirect expansion support further expansions?
has comment: http://stackoverflow.com/comment/138153669
upvote count: 3
tagged with: bash
type: Question
has body: The bash manual states that the expanded value of an indirect parameter expansion undergoes further expansions. I'm not finding that to be true. Can someone explain how it works? 3.5.3 Shell Parameter Expansion: The value is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion. Considerations that clearly don't work: > a='$(echo b)'; echo "${!a}" bash: $(echo b): invalid variable name > a='b'; b='$(echo c)'; echo "${!a}" $(echo c) > a="b"; b="c"; echo "${!$a}" bash: ${!$a}: bad substitution > a="b"; b="c"; echo "${!!a}" bash: ${!!a}: bad substitution > a='$b'; b='c'; echo "${!a}" bash: $b: invalid variable name > a='!b'; b='c'; echo "${!a}" bash: !b: invalid variable name Another post shows that array indices are indeed expanded, e.g. x='a[$(ls>&2)]' echo "${!x}" So how are the above value expansions implemented? Are they indeed limited to the 'value' of indirect parameter expansions, as it is described in the paragraph about it? Or perhaps does this further value expansion apply to all parameter expansions? Or is this strictly limited to array indices? What am I missing in understanding here? I'm failing to find examples of any value being expanded unless it's an array index. Side note, if this works (a='b[@]'; echo "${!a}"), I would think a='!b'; echo "${!a}" should work, but doesn't. Apparently this has to be used (a="${!b}"; echo "${!a}").
linked to: http://stackoverflow.com/q/12691121
answer count: 0
type: UnansweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/138130181
has comment: http://stackoverflow.com/comment/138130472
has comment: http://stackoverflow.com/comment/138130095

http://stackoverflow.com/comment/138132379
has text: @Iterokun ``` steps { build (job: '../../folfer1/pipeline1', parameters: [ ... ], wait: true) } ```
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment

http://stackoverflow.com/comment/138253816
type: QuestionComment
type: Comment
score: 0
has text: https://unix.stackexchange.com/a/406521/133219 may help you along with `| cat`.
comment on: http://stackoverflow.com/q/78420308

http://stackoverflow.com/comment/138155107
has text: A solution would require some hook that intercepts any and all invocations of executables, and inspects them for their file extension and whether they have an appropriate shebang line. I'm not sure such a hook exists (but it might, wouldn't be surprised if it did), but even if it did, that seems like a lot of hassle to deal with your own forgetfulness, and will probably have side effects in other situations.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78364647
type: Comment

http://stackoverflow.com/comment/138078732
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78320229
has text: it's much more obscure; I'm hoping someone else will write up an answer. basically, the "process name" is set by the execve() call. but text files can't be run directly. so behind the scenes the kernel notices the `#!` path and invokes the appropriate interpreter. but it doesn't change the ps comm value

http://stackoverflow.com/comment/138134147
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment
has text: I added 2 `echo` before and after the sh block bash and both i showed them

http://stackoverflow.com/comment/138136363
type: QuestionComment
type: Comment
score: 0
has text: @vdavid true, but the answer also deals with asynchronous processes and this is exactly what is going on here.
comment on: http://stackoverflow.com/q/78353316

http://stackoverflow.com/comment/138153327
has text: Thank you! I'll use your \n%\n with the other awk response, since I can more easily understand it
type: AnswerComment
comment on: http://stackoverflow.com/a/78355289
score: 0
type: Comment

http://stackoverflow.com/comment/138256050
score: 0
type: QuestionComment
type: Comment
has text: I'll bet the file doesn't have a newline at the end. Fix that.
comment on: http://stackoverflow.com/q/78422072

http://stackoverflow.com/comment/138200177
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78390608
score: 0
has text: Thanks for putting your solution as an answer.

http://stackoverflow.com/q/78361035
possible better answer: http://stackoverflow.com/a/78362284
has comment: http://stackoverflow.com/comment/138149016
answer count: 2
has title: bash case glob in order to match part of hostname and ignore last characters
tagged with: linux
has answer: http://stackoverflow.com/a/78362284
tagged with: bash
has comment: http://stackoverflow.com/comment/138149068
has answer: http://stackoverflow.com/a/78361839
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138148880
accepted answer: http://stackoverflow.com/a/78361839
has comment: http://stackoverflow.com/comment/138148965
has comment: http://stackoverflow.com/comment/138148920
has body: we tested the following script - script.sh on machine hostname - presto-data1-01 , but seems the regex presto-data+([[:digit:]]) isn't good enough machines hosts are as example: presto-data1-01 presto-data1-02 presto-data1-03 or presto-data2-01 presto-data2-02 presto-data2-03 etc my script and example more /tmp/script.sh #!/usr/bin/env bash hostname=$(hostname -s) shopt -s extglob case $hostname in presto+([[:digit:]])) bash /home/presto.sh;; presto-data+([[:digit:]])) bash /home/presto-data.sh;; *) echo "Unrecognized hostname $hostname" ;; esac bash /tmp/script.sh Unrecognized hostname presto-data1-01 my machine name : [root@presto-data1-01 # hostname -s presto-data1-01 what we need to fix in regex - presto-data+([[:digit:]]) , in order to match as example the presto-data1 and ignore the characters after presto-data1 as "-01"
tagged with: glob
has comment: http://stackoverflow.com/comment/138149052
score: 0
type: Question
tagged with: shell
has comment: http://stackoverflow.com/comment/138148944
has comment: http://stackoverflow.com/comment/138149040
tagged with: switch-statement

http://stackoverflow.com/q/78351058
answer count: 2
has body: I'm working on a series of bash scripts to automate directory and file creation in a project. I have a limited working proficiency in shell scripts. This is the basic project directory structure: -> --> applications/ ----> sub_dir1/ --> classes/ ----> sub_dir1/ ------> file1 ------> file2 ----> sub_dir2/ ----> sub_dir3/ ----> sub_dir4/ Currently, my script navigates to classes/ and executes this catchall select code, which I cribbed from here. select d in */; do test -n "$d" && break echo ">>> Invalid Selection" done This dynamically lists ALL of the sub-directories under classes/, as expected. If I add sub_dir5/ under classes/ and rerun the script with this code snippet, sub_dir5/ is populated, which is what I want... ...except there is a static group of sub-directories that I would like to exclude from this select, while preserving the functionality of dynamically generating newly added sub-directories. I've tried creating an array of the static directories to exclude (e.g. directoriesToExclude=("sub_dir2" "sub_dir4"), but I don't know how to incorporate that variable into the select above. I've looked at examples using find and prune and not, various loops, and various conditionals, and I can't figure it out... Helpfully (or maybe not), there are seven sub-directories with the same prefix (e.g thing-*) that I'd like to exclude, along with three other sub-directories that do not share that prefix. I know there is a way to lump directories/files with the same naming convention together, but again, I'm at a loss. Edit 4/25/2024 (more robust solution) For anyone who might stumble upon this question in the future, here is how this shook out ultimately. # Start script cd classes/ PS3="Which directory should this class be initialized in? Enter the corresponding number. " shopt -s extglob # START FILTER LOGIC # assign all directories in classes/ to dirs array dirs=(./*) # find all directories with a package.json file one-level deep in dirs array files=($(find . "${dirs[@…
tagged with: shell
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138131091
type: UnansweredQuestion
score: 1
has comment: http://stackoverflow.com/comment/138137195
upvote count: 1
favorite count: 0
tagged with: conditional-statements
has answer: http://stackoverflow.com/a/78351090
type: Question
has title: Dynamically include specific directories and exclude others in Bash select
linked to: http://stackoverflow.com/q/48632436
has comment: http://stackoverflow.com/comment/138131318
linked to: http://stackoverflow.com/q/3200252
has answer: http://stackoverflow.com/a/78351159

http://stackoverflow.com/comment/138283461
has text: `declare -p mapped` would be a better way of printing the content of `mapped` but your problems all stem from creating `allCollections` as a scalar instead of an array. [edit] your question to describe the format of and show us sample output of `mongosh "${sourceConnectionString}" --quiet --eval "db.getCollectionNames().forEach(function(name) { print(name);})")` and show us what you need your final output to be given that input so we can help you. Make sure your [mcve] covers rainy day cases too, not just sunny day, so you don't end up with a solution that fails for rainy day cases.
comment on: http://stackoverflow.com/q/78437542
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138173782
score: 1
type: QuestionComment
type: Comment
has text: ...speaking of which, have you looked up whether the hardware in question has a command you can send to disable paging explicitly? (You haven't told us what it is, so we can't look that up ourselves; but for anything from a longstanding/established manufacturer I'd expect that to be available; search for "pager" or "paging" in the docs as the keyword most likely to be a hit).
comment on: http://stackoverflow.com/q/78375308

http://stackoverflow.com/comment/138116035
comment on: http://stackoverflow.com/a/78342527
has text: Thanks Michael for answering ... But I'm damn a noob with manipulating XML files (except manually of course !!). Could you help me a bit with the syntax of "xsltproc" to apply this script to my xml file ??
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/138259833
comment on: http://stackoverflow.com/q/78423981
type: QuestionComment
type: Comment
score: 1
has text: How would the script even know that it's executed by a "real" bash and not some other program pretending to be bash?

http://stackoverflow.com/comment/138117388
type: Comment
score: 2
has text: I'd investigate Host 2 (and the account you're logging into on it) to find out why it's doing this. What shell is it using for ssh logins? Does it have a ~/.ssh/rc and/or /etc/ssh/sshrc script? If you're authenticating against a public key, does the relevant entry in ~/.ssh/authorized_keys have a `command` option (i.e. a script to run to pre-process the command sent over ssh)? Alternately, if the file isn't too big and/or the connection too slow, you could run `grep` locally: `ssh wpenginesuser@198.123.123.123 "cat /some-path/wp-config.php" | grep -E 'DB_NAME|DB_USER'`
comment on: http://stackoverflow.com/q/78342895
type: QuestionComment

http://stackoverflow.com/q/78393852
upvote count: 1
favorite count: 0
has body: I use this script to install docker on my Azure VM, OS Debian Bullseye 11: echo "** Updating package lists..." sudo apt update echo "** Installing dependencies..." sudo apt install -y apt-transport-https ca-certificates curl gnupg software-properties-common echo "** Adding Docker GPG key..." curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - echo "** Adding Docker repository..." sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian bullseye stable" echo "** Updating package lists again..." sudo apt update echo "** Installing Docker..." sudo apt install -y docker-ce echo "** Docker installation complete!" If I run this script manually (1 line at a time) it works, however when I use it as Custom Data so it would execute on VM initialization, it gives errors, here's the var/logs/cloud-init-output.log: ** Updating package lists... WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... E: Could not get lock /var/lib/apt/lists/lock. It is held by process 700 (apt-get) E: Unable to lock directory /var/lib/apt/lists/ ** Installing dependencies... WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... Building dependency tree... Reading state information... Package gnupg is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'gnupg' has no installation candidate E: Unable to locate package software-properties-common ** Adding Docker GPG key... E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation (23) Failed writing body ** Adding Docker repository... sudo: add-apt-repository: command not found ** Updating package lists again... WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... E: Could not get lock /var/…
has comment: http://stackoverflow.com/comment/138209147
answer count: 2
tagged with: bash
possible better answer: http://stackoverflow.com/a/78396041
has answer: http://stackoverflow.com/a/78406219
downvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138206133
tagged with: azure
has answer: http://stackoverflow.com/a/78396041
has title: install docker bash script doesn't work when used as Custom Data for Azure VM
accepted answer: http://stackoverflow.com/a/78406219
score: 0
type: Question
tagged with: azure-virtual-machine

http://stackoverflow.com/comment/138067898
score: 0
has text: This would still mean that if I call a valid checkout command, I still get the warning, right? (which is fine, as most of the time I don't need to explicitly call checkout)
type: Comment
comment on: http://stackoverflow.com/a/78308972
type: AnswerComment

http://stackoverflow.com/comment/138180559
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78373696
has text: ...well, I say that. https://pkg.go.dev/syscall#Exec is wrapping an older interface, but in a fair set of cases it's good enough. (Passing paths around and not pre-resolved file descriptors makes it a little harder to protect against some classes of vulnerabilities -- like TOCTOU attacks that change a symlink to point to a different target between signature-checking time and execution time -- but as long as you're thinking about those attacks and have other ways to mitigate them...)
score: 0

http://stackoverflow.com/a/78423115
type: AcceptedAnswer
upvote count: 2
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/78423090
score: 2
answers question: http://stackoverflow.com/q/78423090
has body: You are doing nothing to exclude the first line. You can combine two conditions with braces: sed '/^#/!{;1!s/^/E_/;}' input.csv or perhaps sed '2,${;/^#/!s/^/E_/;}' input.csv or you can turn around the logic to skip those lines; sed '/^#/b;1b;s/^/E_/' input.csv (The b command says "jump to this point in the script"; without a label, it jumps to the end, skipping the rest of the script for the current input line.) I took out the -i option; put it back once you are satisfied that the results match your expectation. Also, the parentheses were not contributing anything, so I removed them too. With that, the script no longer uses any ERE syntax, so I took out the -E option as well. The semicolons next to the braces are optional in some dialects, but probably necessary in others. If you want this in Awk instead, that should be easy. awk 'FNR > 1 && !/^#/ { sub(/^/, "E_") } 1' file >newfile Standard Awk does not have any option like the -i option in (non-standard) sed; but GNU Awk offers -i inplace

http://stackoverflow.com/comment/138339711
score: 0
has text: Don't put the `~/` inside quotes, it causes problems depending on exactly how the command is invoked. Use either `export PATH=~/"google-cloud-sdk/bin:$PATH"` or `export PATH="$HOME/google-cloud-sdk/bin:$PATH"`. See ["tilde expansion when evaluating `$PATH`"](https://stackoverflow.com/questions/28373043/tilde-expansion-when-evaluating-path).
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78431428

http://stackoverflow.com/comment/138072133
comment on: http://stackoverflow.com/q/78316829
type: QuestionComment
score: 2
type: Comment
has text: Are you sure you're using bash?

http://stackoverflow.com/comment/138156628
comment on: http://stackoverflow.com/a/78364778
type: Comment
type: AnswerComment
has text: It's been a long time since MacOS used this convention for text files. If this works, great; but it seems like basically a no repro.
score: 1

http://stackoverflow.com/a/78368630
type: Answer
downvote count: 0
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78367681
has body: There are, of course, a lot of different way to solve this. I think a quick way is to know that the 'read' command will put all the "left over" arguments into the last variable. So, if you do something like: read dc1 dc2 dc3 hex < <(snmpget -v3 -l authPriv -u jasmin -a SHA -A MyAuthPhrase -x AES -X MyPrivPhrase $myIP SNMP-FRAMEWORK-MIB::snmpEngineID.0) It will put "SNMP-FRAMEWORK-MIB::snmpEngineID.0" in dc1 (that is short for "don't care 1"). It will put the equal sign in dc2. It will put "Hex-STRING:" into dc3 and the entire hex string into hex. Here's an example, where I am using "echo" to simulate running your snmpget command: $ read dc1 dc2 dc3 hex < <(echo "SNMP-FRAMEWORK-MIB::snmpEngineID.0 = Hex-STRING: 80 00 01 3E 03 28 29 86 2F 05 91") $ echo $dc1 SNMP-FRAMEWORK-MIB::snmpEngineID.0 $ echo $dc2 = $ echo $dc3 Hex-STRING: $ echo $hex 80 00 01 3E 03 28 29 86 2F 05 91 Note it is important to have the redirection exactly as it is above (i.e. a less than sign followed by a space, followed by another less than sign with the open parenthesis immediately adjacent to it.)
has comment: http://stackoverflow.com/comment/138529187
accepted answer of: http://stackoverflow.com/q/78367681
score: 1

variable-assignment
type: Tag
tag name: variable-assignment
tags question: http://stackoverflow.com/q/78442690
tags question: http://stackoverflow.com/q/78721219
tags question: http://stackoverflow.com/q/79270352

http://stackoverflow.com/q/78363909
has comment: http://stackoverflow.com/comment/138154188
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138154134
tagged with: mysql
has body: I am having trouble stuffing a small image into a MySQL table, from a bash shell script. Please, no "You shouldn't do that" lectures. I'm just storing small thumbnails, and also storing a path to the big image. I've stored images in databases before from PHP, but I'm able to re-use a lot of existing code before this snippet, so I'd prefer to do it from the MySQL CLI, if I possibly can. Here's the code snippet that isn't working: … # Store a thumbnail of the image file, together with path and image name. tmp="/tmp/$1" /usr/local/bin/magick \ "$1" \ -thumbnail 256x256 \ -unsharp 1.5x1+0.7+0.02 \ ${tmp} thumb=`cat $tmp` fullpath=`realpath $1` dirpath=`dirname "${fullpath}"` basename=`basename "${fullpath}"` sql="INSERT INTO Bird_Images SET \ \`Master_Guide\` = \"${handle}\", \ \`Thumb\` = \"${thumb}\" \ \`Path\` = \"${dirpath}\", \ \`Filename\` = \"${basename}\"" echo $fullpath echo $dirpath echo $basename #echo $sql /usr/local/bin/mysql \ --user=GPS_User \ --password=ReSu_SpG \ --host=localhost \ --database=Personal \ --execute="${sql}" When I run this, the diagnostic echos have the right contents. The $tmp file is only 45,164 bytes. I can manually store that image file into the proper field using a GUI database tool (Sequel Pro, Querius). If I delete the image field from the SQL, the other fields get stored properly, so it isn't a syntax error. I get the same results if I use a $tmp file or if I output the image into a variable and feed that to mysql. ERROR at line 1: Unknown command '\l'. This produces the same error if I use bash to manually stuff the image in a variable and feed it to mysql manually. The variable is quoted in my script, so I can only assume there was another quote in the image data that broke things. I can't protect it with "strong" single quotes without the variable being interpreted as a literal string. Any ideas? Because my next idea is to re-write the whole thing in a proper programming language, which I'd rather not do at this point! (There's…
type: UnansweredQuestion
tagged with: bash
tagged with: image
answer count: 0
has comment: http://stackoverflow.com/comment/138153933
has title: How to store an image in MySQL via the command-line interface?
linked to: http://stackoverflow.com/q/1098681

http://stackoverflow.com/comment/138102072
comment on: http://stackoverflow.com/q/78334722
score: 1
has text: Maybe it's a shell limitation. But anyway, are you typing 4097 characters into the terminal? Are you piping a file into your executable? Please [edit] and tell us more. What **exactly** are you doing?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138224602
type: Comment
has text: Try this: `sed '9{N;s/\n10//}' <<<$'1\n2\n3\n4\n5\n8\n7\n8\n9 hello\n10 world\n11 foo\n'`
score: 0
comment on: http://stackoverflow.com/q/78404233
type: QuestionComment

http://stackoverflow.com/comment/138139961
has text: This would be much easier in `awk`. `$5 < 100 { $5 = "none" }`
comment on: http://stackoverflow.com/q/78356050
type: QuestionComment
score: 6
type: Comment

http://stackoverflow.com/comment/138080246
score: 0
type: Comment
has text: Vomiting code into your editor that you will clean up later is definitely the best way to approach any coding problem. :)
comment on: http://stackoverflow.com/q/78322081
type: QuestionComment

http://stackoverflow.com/a/78353326
answers question: http://stackoverflow.com/q/78353017
downvote count: 0
has body: I believe the main issue with your script is the improper use of bash arrays. Firstly, you shebang is for sh. It does not support arrays so the script should have an error about it. Since you did not mention it, I will assume you run the script using bash command or the sh in your OS is bash. test_it "$info" $type $files "$options" $optdesc "$precond" In this line, the variable files, options and precond are arrays, but you expended them as regular variable. As a result, only the first value is replaced. This is the argument test_it actually receive: test_it info2 termination tests/termination/example7.c condtermAST "x > 6" Since options is an empty array and was expended unquoted, so no argument are passed to test_it. This might explain why an argument is at the wrong index. Since it is difficult the provide multiple arrays to a function as arguments, I think you should change the logic of you script to move the loop outside of the function test_it. For example, something like: #!/usr/bin/env bash test_it() { info="$1" type="$2" file="$3" optdesc="$4" precond="$5" options=("${@:6}") # all arguments after the sixth one filename="log/$type/$file-$optdesc.log" # typo in $file variable ? if ! -f "$filename" ; then touch "$filename" # quote all variables to prevent word splitting! fi # it is not necessary to check if options is empty ./prog "$file" "${options[@]}" -precondition "${precond}" > "$filename" # quote all variables to prevent word splitting! } # all variable definitions... for i in "${!files[@]}" # move loop here do test_it "$info" "$type" "${files[i]}" "$optdesc" "${precond[i]}" "${options[@]}" # options is moved the back so we can pass any number of parameters done An other way would be to directly access array variables in test_it without setting them from function arguments
type: Answer
score: 5
upvote count: 5

http://stackoverflow.com/comment/138265640
has text: both awk above are wrong - Barmar's doesn't print lines that match, Léa Gris' doesn't set OFS. : `awk '$5>=100 || $5="none"' FS=, OFS=, sample.csv`
comment on: http://stackoverflow.com/q/78356050
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78432970
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78432948
type: Answer
accepted answer of: http://stackoverflow.com/q/78432948
has body: From https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html : When a signal for which a trap has been set is received while the shell is waiting for the completion of a utility executing a foreground command, the trap associated with that signal shall not be executed until after the foreground command has completed. Your shell is executing sleep inf. The trap will not be executed until sleep inf finishes. You send the signal only to bash process, not to sleep. There should be the similar documentation in bash manual and also check man bash.
has comment: http://stackoverflow.com/comment/138277011
type: AcceptedAnswer
upvote count: 1

http://stackoverflow.com/q/78434093
upvote count: 0
has body: I am just trying to prompt for the username and password and have the while loop end after three incorrect tries. I think that it has something to do with the way I incremented the count. My code returns the "please enter a username and a password portion and then goes into an infinite loop. #!/bin/bash myusername="cloud_user" mypassword="userisawesome" count=0 echo "Enter Username: " read username echo "Enter Password: " read password while [ $count -lt 3 ] do if [ -z "$username" ] || [ -z "$password" ]; then echo "Please enter a username and password" count=$count+1 elif "$username"= "$myusername" && "$password"= "$mypassword"; then echo "$HOME $TERM" else count=$count+1 fi done
has answer: http://stackoverflow.com/a/78436154
type: UnansweredQuestion
has title: Having trouble with my while loop being infinite for this bash script
favorite count: 0
has answer: http://stackoverflow.com/a/78438921
has comment: http://stackoverflow.com/comment/138282106
has comment: http://stackoverflow.com/comment/138278444
answer count: 2
score: -1
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138277911
downvote count: 1
tagged with: scripting
has comment: http://stackoverflow.com/comment/138277313
tagged with: while-loop

http://stackoverflow.com/comment/138105939
score: 0
has text: You can flag it and ask the mods to move it.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78330326

http://stackoverflow.com/comment/138154188
type: Comment
comment on: http://stackoverflow.com/q/78363909
has text: @BerndBuffen GOT IT! Thanks to you. The user I'm doing this under did not have FILE privilege! If you write this as an answer, I'll up-vote it and mark it solved! Thanks again for steering me in the right path!
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138253682
score: 0
comment on: http://stackoverflow.com/q/78420308
type: QuestionComment
has text: Not the problem you're asking about but having a variable named `STDOUT` that sometimes is not stdout seems like a bad idea. Maybe name it `OUTFD` or similar (but also stop using all upper case variable names for non-exported variables of course).
type: Comment

http://stackoverflow.com/q/78429844
tagged with: groovy
type: Question
upvote count: 0
has comment: http://stackoverflow.com/comment/138272178
answer count: 1
tagged with: jq
score: -2
accepted answer: http://stackoverflow.com/a/78431169
has comment: http://stackoverflow.com/comment/138270280
has title: Correctly escape environment variable to be used in Jenkins jq script
has comment: http://stackoverflow.com/comment/138270331
has body: I have the following JSON: { "defaultOptions" : { "environmentVariableEntries" : [ { "key" : "OS_VERSION", "value" : "13" } ] } } on Jenkins I have a step that writes some environment variables and in another step I need to insert those variables to environmentVariableEntries in the json above, here is my code: sh(script: "echo \$(jq --arg url \"$URL\" '.defaultOptions.environmentVariableEntries += [{\"key\": \"URL\", \"value\": \$url}]' json.xctestplan) > json.xctestplan", returnStdout: true) this kind of works but have 2 issues: it adds \n to the end of the replaced URL In some cases (special character ?) it throws: ++ jq --arg url 'https://redacted ' '.defaultOptions.environmentVariableEntries += [{"key": "URL", "value": [$url]}]' json.xctestplan jq: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 2, column 1 + echo I tried to wrap the variable in [] without success.
tagged with: jenkins
downvote count: 2
tagged with: bash
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138272134
has comment: http://stackoverflow.com/comment/138271175
has answer: http://stackoverflow.com/a/78431169

http://stackoverflow.com/q/78315911
tagged with: android
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138072188
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138072430
has title: File deletion in Termux bash leads to dangling/stale entry in directory as seen on Android shared storage
tagged with: termux
has comment: http://stackoverflow.com/comment/138069552
tagged with: bash
has body: I'm experiencing a weird problem: I have a file on Android shared storage (/storage/emulated/0) which I delete with Termux bash's "rm" command. First it seems to work as expected. The file is gone in bash and File Explorer. But if Android wants to create a new file with the same name as the file deleted by bash, it behaves as if the file is still there. Even more weird is, that if you use the File Explorer's search function (for that name), the file appears in the list, but is displayed with a folder-icon as directory (0 bytes size). If you tap on it, it tries to open it, but also tells you "Operationn failed", so it is not really a directory. You can now use the File Explorer to delete the file, which puts in the wastebasket (where it finally can be deleted). I made several approaches to circumvent the problem: use other commands instead of rm, such as mv or unlink. Resulted in same behaviour; use a C-program using the OS's remove call {stdio), same behaviour. manually delete the file using another file manager/explorer. Resulted in successful file deletion, but there's no way to script this. Btw., Termux version is 0.118.0, for phone software-info see the screenshot at the end of this post. Here are some screenshots. For demonstration I used an empty file created as /storage/emulated/0/TestDir/test.txt. Here it is: Android explorer showing the file Now look in File Explorers details: Explorer showing file Now delete using bash: Commands in termux bash (the second rm proves the deletion as Termux sees it) Check with File Explorer again: Empty directory No files in this view, but if .. you now expiicitly search for test.txt in the File Explorer - pooooooof - it apoears and you go for the details ...: Explorer search for file ... just to find that there is now a directory in the same location: And this prohibts creating a new file named test.txt using Android apps. (If you re-create test.txt using bash - e. g. with "touch /storage/emulated/0/TestDir/test.txt" - your …
tagged with: file

http://stackoverflow.com/comment/138206932
type: Comment
score: 0
has text: also I noticed "crontab -e" and "sudo crontab -e" are two different things, and at boot it executes what i set in "sudo crontab -e". do you know why ?
comment on: http://stackoverflow.com/q/78320604
type: QuestionComment

http://stackoverflow.com/a/78433313
has body: You're running the command in a Python REPL. This is evident by the error you get - it's treating the command you wrote as Python code, which is not valid syntax. You need to run that command in a shell. Open your regular, plain-old terminal and run the command in there.
has comment: http://stackoverflow.com/comment/138276068
type: Answer
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138275959
answers question: http://stackoverflow.com/q/78433302
score: 0
has comment: http://stackoverflow.com/comment/138276042
accepted answer of: http://stackoverflow.com/q/78433302
has comment: http://stackoverflow.com/comment/138276000
has comment: http://stackoverflow.com/comment/138275971

http://stackoverflow.com/a/78396833
has comment: http://stackoverflow.com/comment/138221477
downvote count: 0
has comment: http://stackoverflow.com/comment/138213217
upvote count: 1
has comment: http://stackoverflow.com/comment/138215763
type: Answer
has body: OK. After looking at Andre Wildbergs answer I got an idea how to modify/extend the idea/part solution which I posted in my original post. This is the line of awk which is working fine and can be used for Downstream and Upstream by exchanging the first part of the awk command: awk '/Downstream Channel Status/{a=1} /<\/table>/{a=0} /<tr/&&a{b=1;next} b && /<\/tr>/{b=0;print""} b{gsub(/^ +/,"");printf "%s", $0}' /Downstream Channel Status/{a=1} if Downstream Channel Status was matched set var a to 1 (true) /<\/table>/{a=0} if was matched set same var a back to 0 (false) /<tr/&&a{b=1;next} if <tr was matched and var a is 1 (true) set var b to 1 (true); then starts the next cycle: next - this is only necessary, because otherwise it would print an empty line first b && /<\/tr>/{b=0;print""} if var b is 1 (true) and was matched set var b to 0 (false); then print an empty line: print"" b{gsub(/^ +/,"");printf "%s", $0} replace/remove leading white space; then print line: printf "%s", $0 - printf is used so all line breaks are removed This does exactly what I need for my technical setup, where no XML/HTML parser is available. EDIT: here is the above code formatted legibly by gawk -o-: awk ' /Downstream Channel Status/ { a = 1 } /<\/table>/ { a = 0 } /<tr/ && a { b = 1 next } b && /<\/tr>/ { b = 0 print "" } b { gsub(/^ +/, "", $0) printf "%s", $0 } ' file
has comment: http://stackoverflow.com/comment/138213865
has comment: http://stackoverflow.com/comment/138215744
has comment: http://stackoverflow.com/comment/138214663
has comment: http://stackoverflow.com/comment/138216882
score: 1
answers question: http://stackoverflow.com/q/78396373

http://stackoverflow.com/q/78444497
tagged with: bash
has body: In Debian 11 based docker container, I'm a bit confused as to why root and jenkins users' python3 command is pointing to the same binary but have different versions: sh-5.1$ whoami jenkins sh-5.1$ python3 --version Python 3.9.2 sh-5.1$ which python3 /usr/bin/python3 sh-5.1$ exit root@c5891e24911a:/home/jenkins# root@c5891e24911a:/home/jenkins# whoami root root@c5891e24911a:/home/jenkins# which python3 /usr/bin/python3 root@c5891e24911a:/home/jenkins# python3 --version Python 3.8.16 I tried changing version in .bachrc to 3.10 but I guess it wouldn't work because that's for non-login shells: How can I make jenkins user's python3 command to point to version 3.10 permanently?
has comment: http://stackoverflow.com/comment/138295911
tagged with: debian
score: 0
type: Question
tagged with: shell
has title: Upgrading to Python 3.10, different users - python3 alias points to same binary but shows different versions
tagged with: linux
type: UnansweredQuestion
answer count: 1
tagged with: python
has answer: http://stackoverflow.com/a/78444615
has comment: http://stackoverflow.com/comment/138295927

http://stackoverflow.com/comment/138250263
comment on: http://stackoverflow.com/q/78418827
type: QuestionComment
score: 2
type: Comment
has text: Are you sure this is exactly the line causing problems? I can source it without errors.

http://stackoverflow.com/comment/138221875
has text: Not from the perspective of ease and overall keystrokes to repeat the same sequence of commands.
type: QuestionComment
comment on: http://stackoverflow.com/q/78402822
type: Comment
score: 0

http://stackoverflow.com/comment/138115558
comment on: http://stackoverflow.com/q/78341760
type: Comment
score: 1
type: QuestionComment
has text: `foo & && wait` is invalid syntax. I meant what I said when I suggested `foo & wait` with no added `&&`. As for the "why", does the linked duplicate not explain it adequately?

http://stackoverflow.com/comment/138214450
type: Comment
has text: Anyhow -- use `ldd` to list the library dependencies of the file. Almost certainly one of them is missing.
comment on: http://stackoverflow.com/q/78398495
score: 0
type: QuestionComment

http://stackoverflow.com/a/78480194
downvote count: 2
answers question: http://stackoverflow.com/q/78444871
upvote count: 0
has body: Solution: I was able to solve by Unix EOL Conversion and calling a new variable that held the whole path/filename.
score: -2
type: Answer
accepted answer of: http://stackoverflow.com/q/78444871
type: AcceptedAnswer

http://stackoverflow.com/comment/138195725
has text: I'll refactor the code as per the advice and get back.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78383368

http://stackoverflow.com/q/78402467
has title: Android Kotlin proot/bash execution
tagged with: android
tagged with: bash
type: Question
answer count: 0
type: UnansweredQuestion
tagged with: kotlin
score: 0
has body: I am rather new to mobile develoipment, can somebody tell me how exactly I can allow files to run on Android? I want to run proot commands with bash like it's done in Termux I took proot from here and build binary like in instructions. It looks fine I took bash binary from here I add my binary proot and bash to assets and in code I transfer them with escalation of permissions assets.open(filename).use { inputStream -&gt; FileOutputStream(file).use { outputStream -&gt; inputStream.copyTo(outputStream) } } file.setExecutable(true) Then I use them from that file dir try { val prootCommand = &quot;${filesDir}/proot -0 -b /dev -b /proc -b ${filesDir}:/data /bin/sh -c \&quot;$command\&quot;&quot; val process = Runtime.getRuntime().exec(prootCommand) val results = process.inputStream.bufferedReader().use { it.readText() } } catch (e: IOException) { e.printStackTrace() } I always get the permission error 13.

http://stackoverflow.com/a/78373883
score: 2
has comment: http://stackoverflow.com/comment/138173705
has body: From the man page: -e Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see SHELL GRAMMAR above), exits with a non-zero sta‐ tus. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test following the if or elif reserved words, part of any command executed in a &amp;&amp; or || list except the command following the final &amp;&amp; or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !. If a com‐ pound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit. A trap on ERR, if set, is executed before the shell exits. This option applies to the shell envi‐ ronment and each subshell environment separately (see COMMAND EXECUTION ENVIRON‐ MENT above), and may cause subshells to exit before executing all the commands in the subshell. If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body will be affected by the -e setting, even if -e is set and a command returns a failure status. If a compound command or shell function sets -e while execut‐ ing in a context where -e is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. In particular If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body will be affected by the -e setting, even if -e is set and a command returns a failure status.
type: Answer
upvote count: 2
accepted answer of: http://stackoverflow.com/q/78373828
downvote count: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78373828

http://stackoverflow.com/comment/138258409
type: QuestionComment
has text: @RomainValeri two contributors have cherry-picked the same range of commits in their own branch that was based on the same commit in main. The commits from contributor A are merged, and merging B's branch as-is would result in a history that is messier than needed.
type: Comment
comment on: http://stackoverflow.com/q/78419971
score: 0

http://stackoverflow.com/comment/138179265
score: 3
has text: Sounds like you can use `git filter-branch --commit-filter` and call `skip_commit "$@";` in the filter command when you detect that `$GIT_COMMIT` contains only a timestamp change.
type: Comment
comment on: http://stackoverflow.com/q/78378370
type: QuestionComment

http://stackoverflow.com/comment/138301808
score: 0
comment on: http://stackoverflow.com/a/78438177
type: Comment
has text: Now we have two neat comparison tables, see above.
type: AnswerComment

http://stackoverflow.com/comment/138311511
type: Comment
score: 0
has text: @Ed Morton Yes it can be posix too. I just need the best solution.
type: QuestionComment
comment on: http://stackoverflow.com/q/78441613

http://stackoverflow.com/comment/138288569
type: Comment
has text: With PHP, I build an array with Account and Entity as Index. When the Array Key does not exist, create, otherwise add the value.
comment on: http://stackoverflow.com/q/78440219
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138102151
score: 0
has text: @yvs2014 : Ah, thanks. I will update my answer accordingly.
type: Comment
comment on: http://stackoverflow.com/a/78334326
type: AnswerComment

http://stackoverflow.com/comment/138236841
type: QuestionComment
score: 1
has text: Can you factor out the potential for bugs in `whisper` and show us a problem that's unambiguously a bash issue? If `whisper` is returning a nonzero exit code and bash is quashing it, then you should be able to reproduce that issue with code that runs `if false; then` or `if (exit 99); then` instead of `if whisper; then`. Whereas if whisper is actually returning 0 when it shouldn't, that's not a problem bash can fix but is instead something you need to bring up with whisper's authors.
type: Comment
comment on: http://stackoverflow.com/q/78409475

http://stackoverflow.com/comment/138578100
type: QuestionComment
type: Comment
has text: Strange: you have output syntax `exit: 1` which doesn't match any of your syntaxes (you have two, which are slightly different). Also, in another case, nothing is printed at all, which is impossible with the code you posted. Are you using a different version of code? If yes, please [edit] your question and post the code you use.
comment on: http://stackoverflow.com/q/78409475
score: 0

http://stackoverflow.com/comment/138266406
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
type: Comment
has text: @CurtisG — your comments about the output of `od -a bash-if-trouble.sh` would be best presented in the question — you'd be able to format the information for readability.
score: 3

http://stackoverflow.com/comment/138122317
score: 0
has text: @F.Hauri-GiveUpGitHub : Why not? It looks like a reasonable choice to me...
comment on: http://stackoverflow.com/q/78342422
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138094856
type: Comment
score: 1
has text: You should escape the `.` in the regexp, although in this case I don't thjink it should make any difference.
comment on: http://stackoverflow.com/q/78330348
type: QuestionComment

http://stackoverflow.com/comment/138284272
score: 0
comment on: http://stackoverflow.com/q/78437863
type: QuestionComment
type: Comment
has text: `*.{jp*,png,webp}` is expanded by both bash and zsh to `*.jp* *.png *.webp` before filename expansion. If one of those patterns doesn't match any files, the default zsh (maybe bash too?) behavior is to raise an error. Both shells have options to control exact behavior.

http://stackoverflow.com/comment/138137595
type: Comment
comment on: http://stackoverflow.com/q/78354730
has text: [BashFAQ #50](https://mywiki.wooledge.org/BashFAQ/050), *I'm trying to put a command in a variable, but the complex cases always fail!*, is directly on-point.
score: 3
type: QuestionComment

http://stackoverflow.com/comment/138257865
score: 0
comment on: http://stackoverflow.com/q/78420308
type: QuestionComment
has text: You mention that setting the variable `transformer_cmd` in a certain way does nor work as expected, but I can't see this variable anywhere in your code. Try to create a small reproducible example, which shows the core issue of your question.
type: Comment

http://stackoverflow.com/comment/138180135
has text: @CharlesDuffy I'm not that experienced with linux like you, but I like your idea about a new executable for every update, however, the golang app is restarted through a systemd service file, which has the path to the go executable, so with every update a new service file should be created ? or how can you solve that ? I'm doing this whole thing for simplifying the update process, the update would be downloaded and the app restarted automatically, without even having to login to the terminal, just a click on a web interface
comment on: http://stackoverflow.com/q/78373696
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/a/78333576
type: Answer
has comment: http://stackoverflow.com/comment/138108282
has body: How do you interact with a shared Volume created by Docker Compose in a Dockerfile? You can't. It doesn't exist yet. It's possible the image that's being built will be run multiple times, on different machines, with different mounted volumes. The setup you describe sounds like you're trying to inject the entire application source code through a bind mount. This is often used to try to make Docker emulate a local development environment. A typical Docker setup is to have immutable, self-contained images, however: all of the application code is contained in the image (and compiled if required), and you can run the image without the mount you show. If you COPY the application code into the image, then it's present, and you can RUN your build command. COPY ./apps /var/www/ COPY dockerfiles/php/setup.sh /usr/local/bin/setup.sh RUN setup.sh CMD ["php-fpm", "-F"] If you're in a different situation – maybe these files are some sort of installation-specific data – then you must run this at container startup time; you can't run it earlier. In that case, I prefer an entrypoint wrapper script as a little bit cleaner than the extended CMD you show. That script can look like #!/bin/sh # run the setup script setup.sh || exit 1 # switch to the main container command exec "$@" Check the script into source control as executable, COPY it into your image, and make that script be the image's ENTRYPOINT. You must use JSON-array syntax for ENTRYPOINT. The last line of the script runs the CMD, which may be any syntax. COPY entrypoint.sh /usr/local/bin/ ENTRYPOINT ["entrypoint.sh"] CMD ["php-fpm", "-F"] In both cases I'm using the php-fpm -F option to run the interpreter in the foreground. Avoid using tail(1) to "keep the container alive". With the ENTRYPOINT approach it's possible to override the CMD to do something else. For example, if you docker run --rm your-image \ ls -l /var/www/extra_content or similar, you can run a temporary container (--rm), running ls as the main container proce…
accepted answer of: http://stackoverflow.com/q/78332428
type: AcceptedAnswer
score: 0
answers question: http://stackoverflow.com/q/78332428

http://stackoverflow.com/a/78442980
type: Answer
has comment: http://stackoverflow.com/comment/138329506
has body: Do the assignment and the declaration at the same time. Given compound='[lv_home_oracle]=20480 [lv_home_oracle_app]=40960 [lv_home_oracle_swdepot]=40960 [lv_opt_crs]=40960' This fails, as you've discovered: $ declare -A x; x=($compound) $ declare -p x declare -A x=(["[lv_home_oracle]=20480 [lv_home_oracle_app]=40960 [lv_home_oracle_swdepot]=40960 [lv_opt_crs]=40960"]="" ) But this is OK, without eval $ declare -A "y=($compound)" $ declare -p y declare -A y=([lv_home_oracle_swdepot]="40960" [lv_home_oracle]="20480" [lv_opt_crs]="40960" [lv_home_oracle_app]="40960" ) This is bash version 5.2.26(1)-release
answers question: http://stackoverflow.com/q/78442690
score: 3
upvote count: 3
downvote count: 0

http://stackoverflow.com/comment/138288811
score: 0
comment on: http://stackoverflow.com/q/78438850
type: QuestionComment
has text: You can see whether your environment variable is set, by doing a `printenv CWPROOT`. If it is not set, first test it by setting it manually. If this works, do the changes in your shell startup file, create a new shell and test again. Make sure that the new shell is one which actually processes your respective startup file. The bash man page tells you which file is processed depending on the kind of the shell.
type: Comment

http://stackoverflow.com/a/78337048
answers question: http://stackoverflow.com/q/78336169
downvote count: 0
score: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/78336169
type: AcceptedAnswer
upvote count: 1
has body: Because the working-directory information you want to convey belongs to the PowerShell session and is lost when it starts Bash, you need to capture it via PowerShell. The $PWD PowerShell variable provides it in the form of a Windows path, and apparently, in your Bash environment, the cygpath command will convert the Windows path into a corresponding path for your Bash session. Note in particular, then, that this ... C:\msys64\usr\bin\bash -lc "cygpath -u '$PWD'" ... relies on PowerShell to expand $PWD into the content of a Bash single-quoted string serving as an argument to a cygpath command executed by Bash. I imagine you already knew that. Here's are just two of my failed attempts: C:\msys64\usr\bin\bash -lc "env --chdir=(cygpath -u '$PWD') There are at least three issues with that: It is missing a closing double quote. This is probably just a typo in the question. It does not specify a command for env to run. Possibly this was accidentally truncated along with the closing double quote The (cygpath -u '$PWD') seems intended to be a Bash command substitution (where $PWD was already expanded by PowerShell), but it has the wrong syntax. The Bash syntax for command substitution is $(command ...) -- the same as PowerShell's syntax for the same thing, I think. It looks like what you want here is probably something more like this: C:\msys64\usr\bin\bash -lc "env --chdir=`$(cygpath -u '$PWD') bash ./super_duper_script.sh" The backtick (`) escapes the following $ from PowerShell, but since the overall string is double quoted, PowerShell will still do the needed expansion of $PWD. But that's needlessly complex. There is no need to get env involved when you can instead do this: C:\msys64\usr\bin\bash -lc "cd `$(cygpath -u '$PWD') && . super_duper_script.sh" That has Bash do the directory conversion via command substitution as before, then change to the directory designated by the result, and on success, it then has Bash read and execute the contents of the script directly (t…

http://stackoverflow.com/comment/138191628
has text: What kind of answer are you looking for? `eval` should be avoided at all cost. It'll work, but when replacing `seq 3` with another data-source, it's getting scary already.
comment on: http://stackoverflow.com/q/78385809
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/138222114
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78402923
has text: This provides an alternative, but you are correct is not the most desirable approach/answer. It may be that the terminal simply can't do what's been asked of it.

http://stackoverflow.com/q/78421398
tagged with: open-policy-agent
type: Question
has comment: http://stackoverflow.com/comment/138255461
has body: I have no ideas what I am doing wrong. Just running this simple bash script on my pipeline. It also does not work when I test it locally. Same error. refresh.sh #!/bin/sh # refresh.sh # Create a kustomization.yaml and then add all kubernetes YAMLs into resources... echo -n " # built by ./refresh.sh apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: " > kustomization.yaml yamls=$(find . -type f -name "*.yaml" | grep -v kustomization.yaml) for y in ${yamls[@]}; do kustomize edit add resource $y done Error: ./refresh.sh: line 16: syntax error: bad substitution my .gitlab-ci.yml image: name: openpolicyagent/conftest:latest stages: - kustomize - policy kustomize: stage: kustomize script: - echo "Running test 1..." - chmod +x refresh.sh - ./refresh.sh policy: stage: policy script: - echo "Running test 2" - kubectl kustomize | conftest test - - rm kustomization.yaml Also I can see my script listed on my current directory on the logs when I add ls -al in the pipeline kustomize stage so not sure what the issue is: $ ls -al total 24 drwxrwxrwx 8 root root 167 May 2 18:11 . drwxrwxrwx 4 root root 44 May 2 18:11 .. drwxrwxrwx 6 root root 128 May 2 18:11 .git -rw-rw-rw- 1 root root 1020 May 2 18:11 .gitlab-ci.yml -rw-rw-rw- 1 root root 9140 May 2 18:11 README.md drwxrwxrwx 2 root root 76 May 2 18:11 policy -rwxrwxrwx 1 root root 375 May 2 18:11 refresh.sh drwxrwxrwx 4 root root 38 May 2 18:11 staging Thanks
downvote count: 0
has answer: http://stackoverflow.com/a/78421562
has title: Calling a bash script from Gitlab CI
possible better answer: http://stackoverflow.com/a/78421472
tagged with: conftest
score: 2
tagged with: gitlab-ci
has comment: http://stackoverflow.com/comment/138254768
upvote count: 2
tagged with: bash
favorite count: 0
has comment: http://stackoverflow.com/comment/138255057
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78421562
has answer: http://stackoverflow.com/a/78421472
answer count: 2
has comment: http://stackoverflow.com/comment/138257835

http://stackoverflow.com/comment/138282106
type: Comment
comment on: http://stackoverflow.com/q/78434093
has text: The code you posted will just output syntax errors, it won't do what you say it does. Please run your code through http://shellcheck.net and then post a [mcve] with code that does demonstrate the problem you're asking for help to solve.
score: 0
type: QuestionComment

http://stackoverflow.com/q/78422524
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138262767
has comment: http://stackoverflow.com/comment/138258095
has comment: http://stackoverflow.com/comment/138256816
type: UnansweredQuestion
tagged with: automation
has title: export json output to environment variable missing commas in Bash
answer count: 1
tagged with: jq
has comment: http://stackoverflow.com/comment/138256831
linked to: http://stackoverflow.com/q/78401284
has answer: http://stackoverflow.com/a/78427832
tagged with: bash
has comment: http://stackoverflow.com/comment/138256821
has body: [{ "Availab]ilityZone": "ap-east-1a" "Description": "AWS_FOO" "Groups": [ { "GroupName": "AWS_FOO" "GroupId": "sg-AWS_FOO" } { "GroupName": "AWS_FOO" "GroupId": "sg-AWS_FOO" } ] } { "Availab]ilityZone": "ap-east-1a" "Description": "AWAWS_FOOAWS_FOO" "Groups": [ { "GroupName": "AWS_FOO-eAWS_FOOAWS_FOO" "GroupId": "sAWS_FOO" } { "GroupName": "AWS_FOO" "GroupId": "AWS_FOO" } ] }] I am tring to write a automation script that required to use aws cli to find the values, NETWORK_INTERFACE=$(aws ec2 describe-network-interfaces --filters Name=vpc-id,Values="${VPC_ID}" --output json | jq -r '.NetworkInterfaces[]') However, when I echo $NETWORK_INTERFACE the output will missing all commas "," , make it not a valid json format and cannot use jq to further action I tried using IFS, sed but the result is not what I expected My expected output is valid json like [{ "Availab]ilityZone": "ap-east-1a", "Description": "AWS_FOO" , "Groups": [ { "GroupName": "AWS_FOO" , "GroupId": "sg-AWS_FOO", } , { "GroupName": "AWS_FOO" , "GroupId": "sg-AWS_FOO", } ] }, { "Availab]ilityZone": "ap-east-1a", "Description": "AWAWS_FOOAWS_FOO", "Groups": [ { "GroupName": "AWS_FOO-eAWS_FOOAWS_FOO", "GroupId": "sAWS_FOO", }, { "GroupName": "AWS_FOO", "GroupId": "AWS_FOO", } ] }]
has comment: http://stackoverflow.com/comment/138258058
tagged with: http://stackoverflow.com/tag/json

http://stackoverflow.com/comment/138173387
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78374017
has text: this is amazing. I learnt several new things about bash scripting in this example. Thanks!!!

http://stackoverflow.com/comment/138261544
type: Comment
score: 0
has text: Thanks @oguzismail for confirming, as I wanted to double check if there is any other way apart from command line passing. Thanks for confirming.
type: QuestionComment
comment on: http://stackoverflow.com/q/78424828

http://stackoverflow.com/comment/138183989
has text: BTW, the quotes around `content` are not correct. They're matching the quotes that are used to delimit the whole `jq` argument.
type: QuestionComment
comment on: http://stackoverflow.com/q/78381387
score: 1
type: Comment

http://stackoverflow.com/comment/138254588
has text: the output from the 1st script appears to show what happens if the (bash) variable `today` is not set (hence the reason you're able to show events from 2 different days - 20240505 and 20240510); invocation of the 2nd script (`awk -f format.awk input.txt`) is missing the `-v date="${today}"` clause; the `mktime()/strftime()` calls aren't really needed ... you could populate `eventBuffer` directly with the results of the various `substr()` calls
comment on: http://stackoverflow.com/a/78420842
type: Comment
type: AnswerComment
score: 2

http://stackoverflow.com/comment/138139987
type: QuestionComment
comment on: http://stackoverflow.com/q/78356050
type: Comment
has text: using addresses would help too `/[^,]*,[^,]*,[^,]*,[1-9]?[0-9],[^,]*/ s/....`
score: 0

http://stackoverflow.com/comment/138078136
score: 1
type: QuestionComment
has text: yes, agreed. So a quick test then is to use `/full/path/to/chromium...` . Good luck.
type: Comment
comment on: http://stackoverflow.com/q/78320604

http://stackoverflow.com/comment/138169602
has text: @F.Hauri-GiveUpGitHub it probably works, but it is almost impossible to modify by someone else than the author. My answer is maybe less optimal (although I haven't benchmarked it) but I believe it is significantly easier to work with by people who are not sed experts.
score: 1
comment on: http://stackoverflow.com/a/78373052
type: Comment
type: AnswerComment

compression
tags question: http://stackoverflow.com/q/78436832
type: Tag
tag name: compression
tags question: http://stackoverflow.com/q/79118101

http://stackoverflow.com/comment/138173891
has text: Thanks. I have tried -T option however it now hangs after the password prompt (both via expect and ssh direct). Hardware in question is a Calix E7 GPON OLT, which has no reference to PAGER anywhere from what I can see in any doco.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78375308
type: Comment

http://stackoverflow.com/a/78390054
score: 0
answers question: http://stackoverflow.com/q/78389511
has body: Using eval or . (aka source) is very tempting for a problem like this, but is fraught with peril. If you dynamically generate source code and evaluate it (with eval or source), you are using a very powerful foot gun. It is safer to do something like: $ grep variable1 input variable1=foo $ while IFS== read var value; do test "$var" = variable1 && variable1=$value; done < input $ echo $variable1 foo Using a while/do loop to read through a file is extremely slow, but if you want speed you probably shouldn't be writing this as a shell script. If you are setting multiple values, do it all in one loop, though.
type: Answer

http://stackoverflow.com/comment/138112696
type: Comment
comment on: http://stackoverflow.com/q/78336864
score: 0
has text: markp-fuso already explained the basic problem in your code, but in case you wondered, why in your case `[` is not treated as special charcter: Usually, `[...]` is treated as a wild card expression (glob pattern), but bash does word splitting before filename generation, and hence it "sees" only the `[yes` part in the first word (i.e. the command), and this command indeed does not exist. You can experiment a bit, by doing on the command line a `shopt -s failglob; [yes=yes]`, which will produce the more helpful error message _bash: no match: [yes=yes]_.
type: QuestionComment

http://stackoverflow.com/comment/138072461
type: QuestionComment
type: Comment
has text: `&` is like `;` excect it puts the thing in the left-hand side in the background (and stores the PID that thing was assigned in `$!`), so `sleep_pid=$!` is just another command, one that copies the PID from `$!` into a variable named `sleep_pid` so you can later run `kill "$sleep_pid"` or such. The reason to put it on the same line is robustness -- so extra commands added to the script in the future can't change `$!` between when it's set and copied to the variable that'll hold it longer-term; you _could_ put `sleep_pid=$!` on a separate line and it'd still work, but I don't recommend it.
score: 0
comment on: http://stackoverflow.com/q/78317514

http://stackoverflow.com/comment/138129954
comment on: http://stackoverflow.com/a/78350523
type: Comment
type: AnswerComment
score: 0
has text: _nod_. If it's GNU tar they can even ditch the `cd` and use `tar -C blah -xzf -`

http://stackoverflow.com/comment/138275959
has text: I opened the normal terminal and ran the command "py test.sh" as well as "py test.ps1" and threw the same error.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78433313

http://stackoverflow.com/comment/138148495
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78360964
type: Comment
has text: I don't think there is, unless you go for `eval` (which has its own share of caveats)

http://stackoverflow.com/comment/138072427
comment on: http://stackoverflow.com/q/78317514
score: 0
has text: In https://pubs.opengroup.org/onlinepubs/9699919799/utilities/jobs.html, see the UP flag -- that means the command is part of the "user portability" extensions, not the baseline spec for what a shell is guaranteed to provide.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138140310
type: QuestionComment
comment on: http://stackoverflow.com/q/78356050
type: Comment
score: 0
has text: what are addresses?

http://stackoverflow.com/comment/138190578
type: Comment
comment on: http://stackoverflow.com/a/78380299
type: AnswerComment
has text: I'll accept this, although oguz ismail posted the same info (as a comment) before your answer. How about you add his remarks regarding `PIPESTATUS` (see comments below question)?
score: 0

http://stackoverflow.com/comment/138095000
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78330653
has text: Change `*/*/*20*` to `./*/*/*20*`; the leading `./` will ensure that even a directory with a `-` starting its name isn't confused for an action.
score: 0

http://stackoverflow.com/q/78362703
type: UnansweredQuestion
has body: I need to demonstrate that the number of threads of the previously identified process can change and that not every thread of the process needs to be created at the same time. How to do that? I have this: [root@251663 ttyid:1 nie kwi 21 19:27:09 s251663]# ps -o pid,nlwp,lwp,cmd,stime -L -p 2569 PID NLWP LWP CMD STIME 2569 4 2569 /usr/bin/clipit 11:38 2569 4 2631 /usr/bin/clipit 11:38 2569 4 2632 /usr/bin/clipit 11:38 2569 4 2640 /usr/bin/clipit **11:38** and need something like that: [sysop@247648 ttyid:0 śro maj 03 16:13:02 /]$ ps -o pid,nlwp,lwp,cmd,stime -L -p 7257 PID NLWP LWP CMD STIME 7257 6 7257 /usr/bin/gigolo 16:07 7257 6 7259 /usr/bin/gigolo 16:07 7257 6 7260 /usr/bin/gigolo 16:07 7257 6 7261 /usr/bin/gigolo 16:07 7257 6 7263 /usr/bin/gigolo 16:07 7257 6 **10462** /usr/bin/gigolo **16:13** [sysop@247648 ttyid:0 śro maj 03 16:13:16 /]$ How to make a new thread?
has comment: http://stackoverflow.com/comment/138151869
score: 0
has title: non-interactive single-threaded process limited by input-output (I/O)
tagged with: linux
tagged with: bash
answer count: 1
has comment: http://stackoverflow.com/comment/138154649
tagged with: command
has answer: http://stackoverflow.com/a/78368119
type: Question

http://stackoverflow.com/q/78371491
has comment: http://stackoverflow.com/comment/138167402
duplicate of: http://stackoverflow.com/q/14230467
has comment: http://stackoverflow.com/comment/138170452
tagged with: bash
type: Question
tagged with: postgresql
type: UnansweredQuestion
answer count: 1
has comment: http://stackoverflow.com/comment/138167438
tagged with: python
has comment: http://stackoverflow.com/comment/138167457
score: 0
has answer: http://stackoverflow.com/a/78381324
has title: Trying to write to .bash_profile for postgres user from python script run as root
linked to: http://stackoverflow.com/q/14230467
has body: So I am writing a programme in python3 which will install postgreSQL on the local host. I am trying to configure some parameters in the .bash_profile file using the below code import subprocess; import os; import pwd; db_version = '15.0' db_version_short = (str(db_version)).split('.')[0] def runcmd(cmd, verbose = False, *args, **kwargs): process = subprocess.Popen( cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True ) std_out, std_err = process.communicate() if verbose: print((std_out.strip()).decode('utf-8'), std_err) pass ######### stdoutdata = subprocess.getoutput("sudo -u postgres echo ~") print("stdout: " + (stdoutdata.split()[0]) + '\n') homedir = (stdoutdata.split()[0]) print(homedir) os.chdir(homedir) #clear contents of existing bash profile runcmd('> .bash_profile', verbose= True) # Define the lines to write in the .bash_profile file bash_lines = [f"export PGDATA=/db/pgdata/{db_version_short}/data", f"export LD_LIBRARY_PATH=/db/pgbin/{db_version_short}/lib", "export PGPORT=5432", f"export PGSQL=/db/pgbin/pgsql/{db_version_short}", "PATH=$PATH:$PGSQL/bin;export PATH", "LANG=en_US.UTF-8; export LANG;"] # Join the lines with line breaks bash_command = "\n".join(bash_lines) write_command = "sudo -u postgres echo '{}' >> {}/.bash_profile".format(bash_command,homedir) runcmd(write_command, verbose= True) The problem I am having is that when I am running this script as root, it is trying to write to /root/.bash_profile instead of to /home/postgres/.bash_profile. Anyone have any ideas of how I could set homedir to the postgres user's home directory? I tried running the script but it keeps setting homedir to /root, when I want it to be /home/postgres/

http://stackoverflow.com/comment/138149052
comment on: http://stackoverflow.com/q/78361035
score: 0
type: QuestionComment
has text: I am talking about presto-data1 and actually presto-data[0-9] , I update my question since details are confused
type: Comment

http://stackoverflow.com/a/78420654
type: Answer
has body: I would harness GNU AWK for this task following way, let file.txt content be start:20240502T080000Z end:20240502T090000Z SUMMARY:Event then awk 'BEGIN{FS=OFS=":"}$1=="start"||$1=="end"{gsub(/[TZ]/,"");$0=gensub(/([0-9][0-9])/,":\\1","g");$0=gensub(/::([0-9][0-9]):/,":\\1",1)}{print}' file.txt gives output start:2024:05:02:08:00:00 end:2024:05:02:09:00:00 SUMMARY:Event Explanation: I inform GNU AWK that : is both field separator (FS) and output field separator (OFS). When encountering start or end in 1st field I remove all T and Z using gsub, then use gensub String Function to prefix every pair of digits with : and then use it again to remove : before first (superfluous) and second (inside year).
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78419985
downvote count: 0

http://stackoverflow.com/comment/138252567
type: QuestionComment
comment on: http://stackoverflow.com/q/78420131
type: Comment
has text: What do you want to happen exactly? If you try to write errors to a file you don't have permissions for they're still going to go _somewhere_. Where do you want it to go?
score: 0

http://stackoverflow.com/comment/138269226
has text: Very informational. Unfortunately, your answer is accomplishing the opposite of what I am trying to do, which is to remove the non foo/bar elements.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78428136
score: 0

http://stackoverflow.com/comment/138150056
comment on: http://stackoverflow.com/q/78361451
type: QuestionComment
score: 0
type: Comment
has text: note that `termux-fix-shebang` is just a simple shell script that calls `sed`. It **always** updates the file, even if it makes no changes.

http://stackoverflow.com/a/78378824
type: Answer
has body: Well, i found the mistake about that. I forgot add a value from pipeline parameter of the pipeline2 that I use into variable that after it be used on for statement.
score: 0
answers question: http://stackoverflow.com/q/78376379

http://stackoverflow.com/a/78340540
type: Answer
type: AcceptedAnswer
score: 2
answers question: http://stackoverflow.com/q/78339485
upvote count: 2
accepted answer of: http://stackoverflow.com/q/78339485
has body: You need to add gsub(/^"*|"*$/, "", val) to your value extraction in the block below to strip leading or trailing double quotes from the value: { tag = val = $0 sub(/:.*/,"",tag) sub(/[^:]+:[[:space:]]*/,"",val) gsub(/^"*|"*$/, "", val) tag2val[tag] = val } Here is your fixed script: cat test2csv #!/usr/bin/env -S awk -f BEGIN { OFS = "," numTags = split("insert_job job_type box_name command machine owner date_conditions condition run_calendar exclude_calendar days_of_week run_window start_times start_mins resources profile term_run_time watch_file watch_interval",tags) for ( tagNr=1; tagNr<=numTags; tagNr++ ) { tag = tags[tagNr] printf "\"%s\"%s", tag, (tagNr<numTags ? OFS : ORS) } } !NF || /^\/\*/ { next } { gsub(/^[[:space:]]+|[[:space:]]+$/,"") } match($0,/[[:space:]]job_type:/) { if ( jobNr++ ) { prt() delete tag2val } # save "insert_job" value tag = substr($1,1,length($1)-1) val = substr($0,length($1)+1,RSTART-(length($1)+2)) gsub(/^[[:space:]]+|[[:space:]]+$/,"",val) tag2val[tag] = val # update $0 to start with "job_type" to look like all other input $0 = substr($0,RSTART+1) } { tag = val = $0 sub(/:.*/,"",tag) sub(/[^:]+:[[:space:]]*/,"",val) # Delete leading or trailing double quotes gsub(/^"*|"*$/, "", val) tag2val[tag] = val } END { prt() } function prt(tagNr,tag,val) { for ( tagNr=1; tagNr<=numTags; tagNr++ ) { tag = tags[tagNr] val = tag2val[tag] printf "\"%s\"%s", val, (tagNr<numTags ? OFS : ORS) } } Usage: chmod +x test2csv ./test2csv test.txt
downvote count: 0

http://stackoverflow.com/comment/138297709
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78445411
has text: Initial issue with the title and tagging: `sh` is not bash. A sh script is not a bash script. If you want bash features, you need to use bash (`#!/usr/bin/env bash`), not sh (`#!/usr/bin/env sh`).

http://stackoverflow.com/comment/138229340
score: 2
type: Comment
has text: You're passing the directory to `cd` as input rather than as a argument, but `cd` only takes arguments, not input. See ["Command Line Arguments vs Input - What's the Difference?"](https://stackoverflow.com/questions/53571637/command-line-arguments-vs-input-whats-the-difference) and ["What's the difference between STDIN and arguments passed to command?"](https://unix.stackexchange.com/questions/46372/whats-the-difference-between-stdin-and-arguments-passed-to-command)
comment on: http://stackoverflow.com/q/78406644
type: QuestionComment

http://stackoverflow.com/comment/138256843
type: Comment
comment on: http://stackoverflow.com/a/78403450
type: AnswerComment
score: 0
has text: Since we have approx 35,000 of check commands in total, i want to use the same list that we used for the UPDATE script to extract only those check commands which i will then import into excel for better processing. my thinking is i would select the items from the columns containing the values and export it to a text file. however, this is not happening. as i am new to mysql, i am checking here if someone can explain to me what is wrong. I am thinking of completely overhauling these scripts but i can't do it until i fully understand the problem it has.

http://stackoverflow.com/comment/138102318
comment on: http://stackoverflow.com/q/78334722
score: 0
type: QuestionComment
type: Comment
has text: @Ctx: The pseudoterminal buffer capacity is part of the terminal software. Still not a limitation in “the max size of the Kernel I/O queues”.

http://stackoverflow.com/comment/138068285
type: Comment
comment on: http://stackoverflow.com/a/78308972
type: AnswerComment
has text: @MakisH: If I understand your question, yes. If you find that that’s getting in the way before you retrain your muscle memory, you make the warning more specific for `-b`/single arguments/whatever’s ingrained (`&& ("$2" = -b || $# -eq 2)`… `restore` gets more complicated). Or take out the `return 1` so the command still runs, but that might be less effective, since it doesn’t force you to correct yourself.
score: 1

http://stackoverflow.com/comment/138287212
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78438177
has text: I have corrected my answer for the quotation marks and the return values
score: 0

http://stackoverflow.com/comment/138099594
comment on: http://stackoverflow.com/a/78333360
type: Comment
has text: [Why is testing `$?` to see if a command succeeded or not, an anti-pattern?](https://stackoverflow.com/questions/36313216/why-is-testing-to-see-if-a-command-succeeded-or-not-an-anti-pattern) A better formulation might be `if commandOutput=$(command) && [[ $commandOutput = *"str"[io]"ng"* ]]`
type: AnswerComment
score: 1

http://stackoverflow.com/comment/138238419
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78410973
type: Comment
has text: Feel free to upvote [Best way to divide in bash using pipes?](https://stackoverflow.com/a/13182139/1765658) if it answer you queston! ;-)

http://stackoverflow.com/comment/138174809
type: Comment
has text: So the correct value for `argv` is `["bash\0", "-c\0", "echo hello; ls\0"]`
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78374935

http://stackoverflow.com/comment/138183023
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78378370
has text: Is your history linear or do you have some merge commits, and if you have merge commits, do they ever resolve conflicts? (I don't actually know if this matters yet, but if the history is linear, or if all merges didn't have conflicts, at least an automated rebase is one possible solution.)
type: Comment

http://stackoverflow.com/a/78425612
upvote count: 1
has body: tl;dr The most common, and quickest/easiest to consistently implement, is probably read -rsp 'Please enter the "FooThingy" application password: ' pw to let them type it in when asked. You are using bash, so I'm writing this with some bash-isms. Be advised. Is there a way to solve this by any change inside the shell script so that users can pass ./test.sh $-123 without single quotes? You're going to have to refactor your design, but that's basically what you were asking, yes? This is something of an X/Y Problem where you've asked for a solution to what you were trying to do rather than a way to get the result you wanted, which I assume is to get the correct password value into a variable for the program to use. The short answer is no, your script can't let users arbitrarily pass special characters as CLI arguments without quotes this way, because the interpreter will already have mangled your data by the time the script sees it, but you shouldn't be putting passwords on the CLI this way anyway. The longer answer is it depends, so let's look at a few options. Quote your data. First, quote your variables. What if the password is the Magic Word? What if instead of just spaces, it has a tab and a newline in it? The embedded spaces will make it three (3) separate arguments on the CLI, so the user would have to quote it anyway, and inside your program you might successfully assign their quoted $1 to var, but then if you use $var unquoted it separates it again. Just make a habit of always quoting your variables unless you have an actual, functional reason not to do so...and then you should be suspicious of your reason. To demonstrate some of the differences: #!/bin/bash echo "Number of arguments passed: $#" printf '[%s]\n' "$@" echo "Without quotes:" var=$1 echo $var echo "With quotes:" var="$1" echo "$var" Passing my password unquoted: $: ./test.sh the Magic Word Number of arguments passed: 3 [the] [Magic] [Word] Without quotes: the With quotes: the Without quoting I can'…
downvote count: 0
answers question: http://stackoverflow.com/q/78424828
score: 1
type: Answer

http://stackoverflow.com/comment/138283527
type: Comment
has text: Don't use all upper case for non-exported variable names, see [correct-bash-and-shell-script-variable-capitalization](https://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization). Also, regarding `LAUNCH_CMD="..."` - variables are for storing data, functions are for storing code, see https://mywiki.wooledge.org/BashFAQ/050. Finally, make sure to run your code through http://shellcheck.net and fix the other issues it'll tell you about. Once you've done that, if you still have a problem then [edit] your question to show the corrected script.
score: 0
comment on: http://stackoverflow.com/q/78436977
type: QuestionComment

http://stackoverflow.com/comment/138268691
score: 0
comment on: http://stackoverflow.com/q/78420308
has text: @user1934428, I've tried `cat` as `transformer_cmd` and that failed this requirement. The reason this doesn't work is because `mysql` must still open up an interactive shell for a "null object" `transformer_cmd`. This is already described in the question.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138079001
type: Comment
comment on: http://stackoverflow.com/a/78320229
has text: I believe pgrep actually uses [`task.cmd`](https://gitlab.com/procps-ng/procps/-/blob/v3.3.17/pgrep.c#L644) in this situation, rather than `cmdline`. I'm not entirely sure what it is, but it seems to be the ps comm value
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138253714
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78420308
has text: @tjm3772, "interactive" means that a `mysql` shell is opened in which one can type in SQL statements
type: QuestionComment

http://stackoverflow.com/a/78441809
answers question: http://stackoverflow.com/q/78441743
downvote count: 0
has body: Try to solve it by Gawk: $ gawk -k 'NR>=2{printf ("%s,\"%s\",%s\n", $1,$3,$4);}' csv_file3.csv A1101,"303,SCA,JDM",Ram A1102,"303,SCA,JDM",Ram cut -d, will consider the "303 and JDM" is a single one field. The GNU Awk -k option activates a CSV parser which knows how to cope with quoted fields.
upvote count: 1
type: Answer
score: 1

http://stackoverflow.com/comment/138200152
type: Comment
type: AnswerComment
score: 0
has text: Thank you. I tried that, but unfortunately it fails where the syntax rubs bash the wrong way. The script is configured with `set -e`, `set -E` and `set -o pipefail`, which is not up to me and is probably why it "works" (read: doesn't work) like that
comment on: http://stackoverflow.com/a/78389556

http://stackoverflow.com/comment/138067888
score: 0
type: QuestionComment
type: Comment
has text: Alternative answers would have been "you need to configure something in Git" or "you can install this additional package that does it for you". I don't think this is directly a duplicate.
comment on: http://stackoverflow.com/q/78308913

http://stackoverflow.com/comment/138112430
comment on: http://stackoverflow.com/a/78335433
type: Comment
score: 0
type: AnswerComment
has text: From which directory are you running both commands?

http://stackoverflow.com/a/78334326
has comment: http://stackoverflow.com/comment/138101674
answers question: http://stackoverflow.com/q/78334264
has comment: http://stackoverflow.com/comment/138102151
has comment: http://stackoverflow.com/comment/138101528
upvote count: 1
type: Answer
score: 0
downvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138101689
accepted answer of: http://stackoverflow.com/q/78334264
has body: bash doesn't do it in general. The bash builtin echo does. But if you had written it as $'a\nb', bash would have done the interpretation on the string itself. UPDATE As @yvs2014 pointed out, even this behaviour of echo can be turned configured. If you do a shopt -s xpg_echo the builtin echo expands the escape sequences. If you do a shopt -u xpg_echo it does not.

http://stackoverflow.com/comment/138235552
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78409475
type: Comment
has text: @d-b, the question posed in the title is why *your script* exits with status zero. I have taken that to mean your *Bash* script, and that's where my second comment was targeted. And I think my comment was at least clear in that that was the "script" to which it was directed. Besides, `whisper` is not *your* script, and I've anyway no idea why you would be bringing us a question about the design or implementation of a third party tool such as that.

http://stackoverflow.com/comment/138283396
comment on: http://stackoverflow.com/q/78437542
score: 4
has text: `mapped+="${c}"` should probably be `mapped+=("${c}")`.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/139252790
comment on: http://stackoverflow.com/q/78375308
has text: This is fantastic ... I've been trying to deal with --more-- for years, all kinds of acrobatics in my expect script. SSH -T works wonders. Thanks
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138109789
comment on: http://stackoverflow.com/q/78335326
type: QuestionComment
has text: I think you'd better read them ;) That's not even the *name* of the class, let alone the package
type: Comment
score: 0

http://stackoverflow.com/comment/138162283
has text: Consider making a habit of running your code through http://shellcheck.net/ before asking questions here -- some editor integrations, like [bash-lsp](https://github.com/bash-lsp/bash-language-server), can do this for you if you have shellcheck installed locally on your system.
comment on: http://stackoverflow.com/q/78368689
score: 1
type: QuestionComment
type: Comment

pip
tag name: pip
type: Tag
tags question: http://stackoverflow.com/q/78356154
tags question: http://stackoverflow.com/q/79374693

http://stackoverflow.com/comment/138078950
has text: X Windoes applications require the `DISPLAY` environment variable to be set.
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78320604
type: QuestionComment

http://stackoverflow.com/q/78361173
has comment: http://stackoverflow.com/comment/138149645
score: 0
type: Question
type: UnansweredQuestion
has body: I have been trying to write a code that would check if a file contains domain names and if it does would print out the domain names using bash script here is my code: is_valid_domain() { local domain="$1" if host "$domain" &> /dev/null; then return 0 else return 1 fi } if [ "$#" -eq 1 ]; then filename="$1" # Check if the file exists if [ ! -f "$filename" ]; then echo "Error: File '$filename' not found." exit 1 fi #if the file exists #Process each domain in the file while IFS= read -r domain_name; do if is_valid_domain "$domain_name"; then echo -e "Domain name: $domain_name\nIP Address: $(host "$domain_name" | awk '/has address/ {print $4}')" else echo "No domain names found" fi done < "$filename" When I run my script with a file that contains domain names as the first command line parameter it just pauses action and does not continue is there anything I am doing wrong?
has answer: http://stackoverflow.com/a/78361234
answer count: 1
has comment: http://stackoverflow.com/comment/138149665
tagged with: linux
tagged with: bash
linked to: http://stackoverflow.com/q/951336
has title: How to print out ip address of domain names in a file using bash script

bun
tag name: bun
type: Tag
tags question: http://stackoverflow.com/q/78388698

http://stackoverflow.com/comment/138237903
comment on: http://stackoverflow.com/a/78411741
score: 0
has text: @Rasec Just replace `.Filename` with `input_filename` (no preceding dot!) in any of the examples above to get the path of the currently processed input file. If you want to strip the filename (just retain the path to its containing folder), use string functions to delete everything starting from the last path separator character `/`, e.g. `(input_filename | sub("/[^/]+$"; ""))`.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138129980
comment on: http://stackoverflow.com/a/78350523
score: 0
has text: BSD (e.g. MacOS) tar also has that, so probably most tars in the wild. Although if the default shell isn't compatible with his original command, who knows what tar it has?
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138293251
type: Comment
has text: A good beginner question and using `for i in $(seq -f "%02g" 1 $ep_no)`? Good show! You're getting the idea about shell scripting! BUT ... (-;, Verbal descriptions of problems are often/usually ambiguous. Give us some sample data to work with, the expected output, your current code, output, and error messages formatted using the `{}` tool on the Edit Menu. You can make it really easy for readers and include "make test data steps" like `mkdir testData ; cd testData ; touch file1 'file2 - with spaces'` to show your issues. Good luck.
score: 0
comment on: http://stackoverflow.com/q/78440831
type: QuestionComment

http://stackoverflow.com/a/78336259
score: 3
type: Answer
downvote count: 0
has body: You could use a case statement with extended globbing patterns: shopt -s extglob case $hostname in ?(mngmnt)presto+([[:digit:]]) ) memory=23G;; ?(mngmnt)hadoop+([[:digit:]]) ) memory=12G;; ?(mngmnt)kafka+([[:digit:]]) ) memory=10G;; *) printf 'ERROR: Unrecognized hostname: %s\n' "$hostname" >&2;; esac See the extglob section in glob - Greg's Wiki for an explanation of shopt -s extglob and extended globbing.
answers question: http://stackoverflow.com/q/78336037
type: AcceptedAnswer
upvote count: 3
accepted answer of: http://stackoverflow.com/q/78336037

http://stackoverflow.com/comment/138202776
score: 0
has text: even assignment does the same thing `y=cat plan | sed -E 's/\"/\\"/g`
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78392023

data-manipulation
type: Tag
tag name: data-manipulation
tags question: http://stackoverflow.com/q/78359494

http://stackoverflow.com/comment/138169212
comment on: http://stackoverflow.com/q/78372639
has text: If you want *insert* `1.0.7.2` between `1.0.7.1` and `1.2.2.8`, you have to: 1 extract list, 2 add you value 3 sort list, 4 replace line.
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/138222480
type: QuestionComment
type: Comment
score: 0
has text: i am just truncating it to get the proper url. see this is the download url https://corretto.aws/downloads/latest/amazon-corretto-11-x86-linux-jdk.tar.gz even if the architecture is x86_64bit, the download url only contains x86
comment on: http://stackoverflow.com/q/78398495

http://stackoverflow.com/comment/138121719
type: QuestionComment
type: Comment
score: 0
has text: I don't know what the batch file is doing (did you try to put a `@echo on` into it?), but your 2nd `cmd` looks flakey. You haven't done a `export ESP32_REPO_PROD=....` anywhere.
comment on: http://stackoverflow.com/q/78343975

http://stackoverflow.com/comment/138263391
type: Comment
type: AnswerComment
score: 0
has text: How do you "verify each of the lines"? Also, you mentioned "this is not happening." Are you saying your sql query isn't getting you the information you are looking for? Can you provide the exact select statement you are using? As well as the output, if any?
comment on: http://stackoverflow.com/a/78403450

http://stackoverflow.com/comment/138255963
has text: Why do you check for the directory `/Applications/Microsoft Teams.app`? All the rest of the code only works for `Microsoft Teams Classic`.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78422019

http://stackoverflow.com/comment/138136800
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78353316
type: Comment
has text: @kvantour That is correct, but the OP doesn't seem to comprehend that there's an asynchronous issue to begin with. If you can re-open the issue, I believe I can provide helpful information to the OP.

http://stackoverflow.com/a/78436112
downvote count: 0
score: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78435782
has body: You can pass an error message from script to Terraform by writing the error message to the standard error (stderr) stream. In your script, you can write the error message to stderr using the ">&2" redirection operator. Ex: >&2 echo "Error: Environment variable SOME_ENV is missing" #!/bin/bash if [ -z $SOME_ENV ]; then >&2 echo "Error: Environment variable SOME_ENV is missing" exit 1 fi provider "azurerm" { features {} } data "external" src { program = ["bash", "my_script.sh"] } Terraform apply
upvote count: 1
answers question: http://stackoverflow.com/q/78435782
type: Answer

http://stackoverflow.com/comment/138103047
score: 0
type: QuestionComment
type: Comment
has text: @AnassAbidar You didn't answer my question. If you redirect the output to a file and get exactly the same content as in your original file, your program is most likely doing the right thing (except that you don't deal with `-1`). Have you also tried using the standard C functions `fread`/`fwrite` instead?
comment on: http://stackoverflow.com/q/78334722

http://stackoverflow.com/comment/138136076
comment on: http://stackoverflow.com/q/78354041
score: 1
has text: [edit] your question to provide a [mcve] including concise, testable sample input and expected output so we can help you. Dont assume that the people who can best help you write a bash script are also python experts who MAY be able to get all the information they need about what they need to do in bash by reading your python script. Also, a quote is normally a single quote (`'`) or a double quote (`"`) so it's not obvious why your script is splitting on a percent character (`%`), please explain that and tell us which type of quote you're using. Add all information in the question, not comments
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78341842
type: Answer
answers question: http://stackoverflow.com/q/78309717
score: 0
has body: Either your build process doesn't fetch tags for some reason (add git fetch --tags somewhere in your workflow), or the build does fetch tags, but you have some local tags that you have not pushed to the server (git push &amp;&amp; git push --tags, or if your push triggers a remote build, git push --atomic REMOTE BRANCH_NAME TAG)

http://stackoverflow.com/q/78436832
type: Question
tagged with: notion
downvote count: 1
tagged with: synology
type: UnansweredQuestion
has title: Recursively extract zip archive on synology nas (notion)
has body: I'm working with a Synology NAS. I have a notion backup ZIP file (a ZIP file containing another ZIP file). The file is big so I want to script unzipping so first the outer zip gets extracted and then the inner zip automatically without intervention. The usual unzip utility is not available for synology NAS. I need to automate the process of extracting these nested ZIP files using a Bash script. I realized have 7z installed on my NAS but am unsure how to handle nested archives effectively. How can I recursively extract all nested ZIP files using 7z?
tagged with: recursion
upvote count: 1
score: 0
answer count: 0
tagged with: bash
favorite count: 0
tagged with: compression

http://stackoverflow.com/q/78436977
type: UnansweredQuestion
tagged with: llamacpp
has comment: http://stackoverflow.com/comment/138283527
tagged with: llama
has title: Is there a way to automate formatting terminal input when talking to an LLM model?
tagged with: gnome-terminal
tagged with: bash
answer count: 1
has body: Currently when the user sends input to the LLM it has to be in the format of: <|im_start|>user\ User input here.<|im_end|> This is very cumbersome and makes prompt engineering very tedious. Right now i am using llama.cpp to run a llama2 model locally in the terminal - is there a way to automatically insert user input between the two tokens (im_start and im_end)? I might have approached this problem in the wrong way, but the following is what I have tried: My current (so far unsuccessful) method is to use a bash script to launch the LLM in another terminal and redirecting the output of the current terminal to the LLM-terminal. Later I was going to make a script that the first "launcher-terminal" would, which would format all user input and send it to the LLM-terminal. Sofar I haven't been able to get the communication between the terminals working. The script would be trivial for me to make. It is moreso the bash-scripting that I'm struggling with. I suspect my bash implementation is highly flawed, I'm not very experienced with it. RUN_PATH="/llama.cpp/main" MODEL_PATH="/llama.cpp/models/dolphin-2.9-llama3-8b-q4_K_M.gguf" INIT_PATH="prompt.txt" FLAGS="-n 512 --keep -1 --ctx-size 2048 --temp 0.0" LAUNCH_CMD=".${RUN_PATH} -m .${MODEL_PATH} ${FLAGS} --color --interactive-first --file .${INIT_PATH}" # gnome-terminal -- "${LAUNCH_CMD}" # Here im launching an impostor python program which just prints the input it receives. gnome-terminal -- python3 impostor.py LAUNCHER_PID="${$}" LLM_PID="$PPID" # It seems I don't get the PIDs i expect to get. echo "Launcher PID: ${LAUNCHER_PID}" echo "LLM PID: ${LLM_PID}" # Set STD-output of the launcher to LLM ps -p $LLM_PID << ps -p $LAUNCHER_PID /bin/bash When typing echo hello world in the launcher terminal, it does not show up in the LLM-terminal, which is the desired effect.
linked to: http://stackoverflow.com/q/673055
score: 0
has answer: http://stackoverflow.com/a/78438933
type: Question

http://stackoverflow.com/comment/138191531
comment on: http://stackoverflow.com/q/78385603
type: Comment
score: 0
has text: Is the "Just Text" section always in red? You said it was always in the same place? Is that really correct? What did you mean by that? Is the size and placement of the red box always the same? Please clarify. If the top of the red box is always in the same location, then you can just crop off the white text above it.
type: QuestionComment

http://stackoverflow.com/comment/138221839
has text: Won't it be easier to find your command using 'bck-i-search' ?
type: Comment
comment on: http://stackoverflow.com/q/78402822
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138111010
has text: I Think you should remove [tag:ksh] and add [tag:awk]...
comment on: http://stackoverflow.com/q/78339485
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/a/78423240
answers question: http://stackoverflow.com/q/78423090
has comment: http://stackoverflow.com/comment/138274530
has body: You could also use awk as a solution awk 'NR > 1 && !/^#/ {$0 = "E_" $0} "true"' input.csv Explanation: NR > 1 means execute from the second line onwards And "true" means display all lines. !/^#/: This checks if the line does not start with a #. If the line starts with a hash, this condition will be false, and the prefix will not be added.
has comment: http://stackoverflow.com/comment/138258286
score: 2
downvote count: 0
type: Answer
upvote count: 2

http://stackoverflow.com/comment/138296896
score: 3
type: QuestionComment
type: Comment
has text: If there's a problem with `$qtr`, it might give the wrong filename, but it shouldn't result in an unreadable file. Are you sure that's the only thing that changed between when it works and when it doesn't? You can put `set -x` to get an execution trace (which'll show the commands a bit differently -- mostly using single-quotes instead of double-quotes) and see how that differs with vs without the quarter name. Also, exactly what's wrong with the file that makes it unreadable? Examine the contents to see what's wrong with the unreadable file.
comment on: http://stackoverflow.com/q/78444871

http://stackoverflow.com/comment/138272178
has text: Can you give an example of a `URL` that causes the error relating to control characters. You can obfuscate it appropriately so that you don't leak any sensitive information.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78429844
type: Comment

http://stackoverflow.com/comment/138203501
type: QuestionComment
has text: @pmf I could use an associative array, but I thought, gathering from the last link in the question, there should be a syntax to handle this issue in indirect references? Or maybe the developers really didn't consider this use case?
score: 0
comment on: http://stackoverflow.com/q/78392419
type: Comment

http://stackoverflow.com/comment/138282936
type: Comment
score: 3
comment on: http://stackoverflow.com/q/78437288
type: QuestionComment
has text: `return` in bash is not like in other languages where you can return any data you like, it only sets the numerical exit status of the function so that the caller can know if it succeeded or not.

http://stackoverflow.com/q/78324472
has comment: http://stackoverflow.com/comment/138103360
tagged with: macos
has title: Enumerating the files on a directory in localized case insensitive alphabetical order
tagged with: terminal
score: 0
type: Question
answer count: 0
type: UnansweredQuestion
tagged with: bash
has comment: http://stackoverflow.com/comment/138089157
has comment: http://stackoverflow.com/comment/138083938
has body: I am trying to enumerate the files on directory, all mp4 videos, and get their dimensions using FFMEG's ffprobe. This Bash script is working fine for filename in *.mp4; do printf &quot;$filename;&quot; ffprobe -v error -select_streams v -show_entries stream=width,height -of csv=p=0:s=&quot;;&quot; ${filename} done The result is a CSV like this: video7.mp4;320;200 video1.mp4;800;600 videoAlpha.mp4;1024;1024 But now I want to do it in localized, case-insensitive, alphabetical order. How can I do that?

http://stackoverflow.com/comment/138137136
type: QuestionComment
type: Comment
has text: @Barmar above is a dumbed-down version: in the actual script I'm reading values as variables from a .json config file (e.g. "/some-path/" is a variable with the server's root directory in it).
comment on: http://stackoverflow.com/q/78350497
score: 0

http://stackoverflow.com/a/78423429
has comment: http://stackoverflow.com/comment/138258770
downvote count: 0
has body: You might use awk to print the whole line if it is not the first row or if it starts with #. Else you print the whole line prepended by E_ awk 'NR==1 || /^#/ {print; next} {print "E_" $0}' input.csv Output E_EMP_ID,EMP_NAME,JOINING_DATE,SALARY E_1,T Natarajan,22-APR-2024,6000000 E_2,Velmurugan,22-JUL-2024,2000000 E_3,Rowin,21-OCT-2024,5000000 #END_OF_FILE
type: Answer
has comment: http://stackoverflow.com/comment/138258875
score: 2
has comment: http://stackoverflow.com/comment/138258816
has comment: http://stackoverflow.com/comment/138258821
upvote count: 2
answers question: http://stackoverflow.com/q/78423090

http://stackoverflow.com/comment/138283463
comment on: http://stackoverflow.com/q/78437542
type: QuestionComment
type: Comment
score: 2
has text: @TobySpeight, ...ideally they shouldn't want `allCollections=($(...))` -- it runs afoul of [BashPitfalls #50](https://mywiki.wooledge.org/BashPitfalls#hosts.3D.28_.24.28aws_.2BICY.29_.29).

http://stackoverflow.com/comment/138071488
comment on: http://stackoverflow.com/q/78313378
score: 0
has text: Is the call to the `import example` in your notebook? You need to put the example files with the notebook or add it to your path, it would seem.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138204337
type: QuestionComment
has text: you code snippets mention `x='foo bar'` while the description mentions processing colors; recommend you rewrite the question to focus on your actual (color) issue: *a)* show the setup of a couple colors, *b)* show your code working for a valid color and *c)* show your code's result with an invalid color (ie, show *all* stdout/stderr output); net result: provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)
type: Comment
comment on: http://stackoverflow.com/q/78392419
score: 2

http://stackoverflow.com/q/78435782
accepted answer: http://stackoverflow.com/a/78436112
has title: How to correctly fail bash script in terraform external datasource
has comment: http://stackoverflow.com/comment/138280556
tagged with: bash
has comment: http://stackoverflow.com/comment/138280532
answer count: 1
has body: I have a terraform datasource: data "external" src { program = ["bash", "my_script.sh"] } In the my_script.sh I assert that environment variable SOME_ENV is set and if so, the script does some logic: #!/bin/bash if [ -z $SOME_ENV ]; then echo "Env SOME_ENV is missed" exit 1 fi # do some work... Otherwise, I want to highlight during the terraform apply that env is missed. Current behaviour: The following message is printed to the console: ... │ The data source received an unexpected error while attempting to execute the program. │ │ The program was executed, however it returned no additional error messaging. │ │ Program: /bin/bash │ State: exit status 1 Is there any options to pass error message while applying? Thanks
type: AnsweredQuestion
tagged with: azure
score: 0
type: Question
has answer: http://stackoverflow.com/a/78436112
tagged with: terraform

http://stackoverflow.com/comment/138105981
comment on: http://stackoverflow.com/q/78336169
score: 1
type: Comment
has text: @JohnBollinger THANK YOU for encouraging me to take a closer look at the arguments. This works `C:\msys64\usr\bin\bash -c "pushd .; source /etc/profile; popd; ./super_duper_script.sh"`, although I'm not sure its the best way to get the `$PATH` set.
type: QuestionComment

http://stackoverflow.com/comment/138298146
score: 1
type: QuestionComment
has text: Not your problem but regarding `tr "\\t" ","` - you're having to double the escapes because by using double quotes instead of single (which you should always use until if/when you need to not use them) you're asking the shell to come in and interpret what's between the quotes but you don't actually want the shell to consume the backslash before the `t` so you're having to add an extra backslash to protect the existing backslash from the shell that you invited in to interpret it. Just don't do that, use `tr '\t' ','`.
comment on: http://stackoverflow.com/q/78444871
type: Comment

http://stackoverflow.com/comment/138285610
score: 0
has text: U could try this: `while IFS=' :\t\r\n' read -r _ locip locport remip remport act _;do case $act$locip in 0A845DA8C0 ) printf '%d\n' 0x$locport;;esac ;done </proc/net/tcp` ...
comment on: http://stackoverflow.com/q/78438262
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78334609
has comment: http://stackoverflow.com/comment/138101767
tagged with: sed
has comment: http://stackoverflow.com/comment/138101918
has title: How to replace string in small part of the text after occurence of certain keyword
answer count: 2
has comment: http://stackoverflow.com/comment/138102062
has answer: http://stackoverflow.com/a/78334765
tagged with: bash
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78334765
has comment: http://stackoverflow.com/comment/138101816
has answer: http://stackoverflow.com/a/78335552
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138101955
has body: I have multiple Azure DevOps pipeline files with many stages like this: ... - stage: 'qa' dependsOn: - dev condition: | and ( condition1, condition2, ..., startswith(variables['Build.SourceBranch'], 'refs/heads/development') ) # This needs to stay the same - stage: 'uat' dependsOn: - dev condition: | and ( condition1, condition2, ..., startswith(variables['Build.SourceBranch'], 'refs/heads/development') ) ... Now we are updating all these files to new deployment strategy and I need to change two things - the dependsOn clause and the source branch refs/heads/development in the condition - but only for the qa stage. The result should look like this ... - stage: 'qa' dependsOn: - build condition: | and ( condition1, condition2, ..., startswith(variables['Build.SourceBranch'], 'refs/heads/main') ) # This needs to stay the same - stage: 'uat' dependsOn: - dev condition: | and ( condition1, condition2, ..., startswith(variables['Build.SourceBranch'], 'refs/heads/development') ) ... I am able to do the first part quite easily - I know there is always just one item in that array. So this will work sed &quot;/stage: 'qa'/{ n; n; s/dev/build/g }&quot; pipeline.yaml But the second part is harder, there can be multiple conditions and I don't exactly know how many lines to skip. Is there any way how to tell sed to replace a string only in part of the file, lets say from 4 to 10 lines below occurrence of the stage: 'qa' string?
possible better answer: http://stackoverflow.com/a/78335552

http://stackoverflow.com/comment/138581754
type: Comment
type: AnswerComment
score: 0
has text: In second snippet, OP is running the script and printing $? after execution. and echo is the last command as shown in 3rd snippet. If I missed something, please tell, I prefer being taught than laughed at ;)
comment on: http://stackoverflow.com/a/78603441

http://stackoverflow.com/a/78390423
answers question: http://stackoverflow.com/q/78388939
score: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/78388939
downvote count: 0
has body: Thanks Barmar and Mou Sam Dahal for your useful tips! I've decided to go with the inotifywait -e close_write solution, as it immediately notifies me when a file is closed for writing (= finishes being uploaded). I also didn't want to force uploaders to create additional .lock files or mark incomplete uploads with .temp suffix. However, the inotifywait solution is still not ideal, as the script can easily miss new events while executing lines handling the first event. Also, unfortunately, it is not possible to combine the -m flag (= monitor events continously instead of exiting immediately after receving the first one) with -t (timeout seconds). The reason I need a timeout is that I want to wait until a batch of files is uploaded, move them to a separate directory processingDir, and only then launch jpeg2txt on all of them. This comes at the cost of 1 minute delay before starting processing, but is completely acceptable for me. So, here's my final(?) script. I've also added some logging. PS. Still have no slightest idea why do I need to put filename wildcards OUTSIDE of quotes, like "$uploadDir"/* ??? #!/bin/sh uploadDir=/home/me/upload outputDir=/home/me/output processingDir=/home/me/input mkdir -p "$processingDir" # infinite loop while true; do # keep on moving completed uploads from $uploadDir to $processingDir # time out after 1 idle minute while true; do uploadedFile=$(inotifywait -rq -e close_write -t 60 "$uploadDir" --format "%w%f") if [ -z "$uploadedFile" ]; then break; fi mv -f "$uploadedFile" "$processingDir" done # move any remaining leftover files from $uploadDir to $processingDir # there's a race condition here, but gee, oh well mv -f "$uploadDir"/* "$processingDir" &>/dev/null processingDirNotEmpty=$(find "$processingDir" -type f -print -quit) if [ -n "$processingDirNotEmpty" ]; then now=$(date +%Y-%m-%d_%H-%M-%S) mkdir -p "$outputDir/logs" jpeg2txt "$processingDir" "$outputDir" &>"$outputDir/logs/$now.log" rm -rfd "$processingDir"/* fi done
type: AcceptedAnswer
upvote count: 1

http://stackoverflow.com/comment/138173612
type: QuestionComment
has text: (...mind, I'd also argue that you should never give a service enough permissions to update its own executable -- that means that a user who subverts that service is necessarily capable of persisting the damage they've done to run code of their choice on reboot/restart/similar; better to keep updaters out-of-band, run under a separate account with more permissions than the service itself; even better _than that_ to go with a Nix-esque mechanism where "updates" consist of adding new executables, not overwriting old ones in place, with signatures and hashes available to verify integrity).
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78373696

http://stackoverflow.com/comment/138233131
type: Comment
has text: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/78409095

http://stackoverflow.com/comment/138116159
comment on: http://stackoverflow.com/q/78342422
type: QuestionComment
type: Comment
has text: Using `expect` for this seem to be a *not so good* idea!
score: 0

http://stackoverflow.com/comment/138101955
type: QuestionComment
has text: are you looking to replace all lines (within `- stage: 'qa'` block) that includes the string `SourceBranch` or is there an additional filter that needs to be considered? or will there only be a single line containing the string `SourceBranch`?
comment on: http://stackoverflow.com/q/78334609
type: Comment
score: 0

http://stackoverflow.com/comment/138152728
has text: Why use ``echo `1` `` instead of just `1`?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78363374

http://stackoverflow.com/comment/138224439
score: 0
has text: @CharlesDuffy ```when read starts failing, you can just reopen the FIFO and get back into the state where reads block until there's a writer.``` that sounds like a better approach :o
comment on: http://stackoverflow.com/a/78403776
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78319702
type: Answer
score: 0
has body: We can consider your problem as counting in base 26 using only A-Z digits. We count 1 digit numbers first (0 to 25), then 2 digits (0 to 26^2 - 1), etc. The to_string n m function converts n (the number passed as its first argument) to base 26 with digits A-Z on m digits. If you can wait a few centuries (approximately 5 according my experiments on a quad core Intel Core i7 at 3.6 GHz): declare -a a=( {A..Z} ) to_string() { local -i n=$1 m=$2 local s for (( m; m &gt; 0; m-- )); do s=${a[n % 26]}$s (( n /= 26 )) done printf '%s\n' $s } for (( i = 1; i &lt;= 10; i++ )); do for (( n = 0; n &lt; 26**i; n++ )); do to_string $n $i done done
answers question: http://stackoverflow.com/q/78317617

http://stackoverflow.com/comment/138271175
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78429844
score: 1
has text: Why you need `echo`? It may be much easier without it.

http://stackoverflow.com/comment/138298084
score: 1
has text: [edit] your question to show us the contents of the file (or pipe or whatever) you're reading the file names from and the undesirable output you're seeing given that input.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78445380

http://stackoverflow.com/comment/138240508
has text: You can form ternary expressions like this `${{ condition && true || false }}`. See https://docs.github.com/en/actions/learn-github-actions/expressions#example.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78412927
score: 0

http://stackoverflow.com/comment/138232250
comment on: http://stackoverflow.com/q/78405506
type: Comment
score: 0
has text: That said, the question is much too hand-wavey and high-level to be concretely answerable here -- I'd want to see a concrete implementation, not just hear it described, to be able to review its actual (as opposed to intended) behavior.
type: QuestionComment

http://stackoverflow.com/comment/138265401
has text: @Barmar I wanted to check if teams is in the directory. I guess u can eliminate the other portion.
type: Comment
comment on: http://stackoverflow.com/q/78422019
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138150381
score: 0
type: Comment
has text: The command suggested results in another batch script that causes the same error, with what appears to be an incomplete character at the start: `test2.sh: line 1: �#!/data/data/com.termux/files/usr/bin/env: No such file or directory` But I was able to remove the BOM and the version without it runs fine. Thank you for your help, @oguz-ismail !
type: QuestionComment
comment on: http://stackoverflow.com/q/78361451

http://stackoverflow.com/a/78405627
has body: Using any awk, this is probably what you want to cover not just the sunny day case where the input file has 10 or more input lines but also the rainy day cases of an input file with less than 10 lines or even empty (given my assumption that you'd want to output a valid POSIX text file, one that ends in a newline, without adding a trailing blank char in those cases): $ awk '{printf "%s%s", (NR == 10 ? OFS : ors), $0; ors=ORS} END{printf ors}' file a b c d e f g h this is line nine and this is line ten i j
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78404233

http://stackoverflow.com/comment/138097910
type: QuestionComment
comment on: http://stackoverflow.com/q/78330348
type: Comment
score: 0
has text: @jhnc Oh, I see, and I also just realized that they are also in the OP's input. Sorry, you're right, please ignore my comment.

http://stackoverflow.com/comment/138204459
type: Comment
has text: In the first form, the command substitution -- the `$( )` operation -- is invoked _in your outer shell_ before bsub is ever started, it's not distributed as a job for remote nodes to run. Similarly, the `echo` runs after `bsub` completes, on your local client system, not on the worker nodes.
score: 0
comment on: http://stackoverflow.com/q/78392914
type: QuestionComment

http://stackoverflow.com/comment/138159503
comment on: http://stackoverflow.com/q/78366286
score: 0
has text: Turns out that it was where the flag.txt file was being placed. From what I'm seeing it looks like /run and /var/run are not present when the startup script runs so it does not see the flag.txt file. By the time the python file ran to write the flag file the directories were there. This was driving me nuts. :-(
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138223408
comment on: http://stackoverflow.com/q/78403621
score: 4
type: QuestionComment
type: Comment
has text: Please show how you feed your input into your `while` loop.

data-filtering
tag name: data-filtering
tags question: http://stackoverflow.com/q/78378844
type: Tag

http://stackoverflow.com/a/78444349
answers question: http://stackoverflow.com/q/78442690
has comment: http://stackoverflow.com/comment/138330017
has body: If I were you I would avoid eval for this, you're trying to solve a problem that you don't need to have as you don't need to pipe the output of a command to awk to create what looks like associate array instructions and then save that string in a scalar variable and then try to extract those instructions from the scalar variable again to populate an associative array. Its that saving in a scalar and then trying to extract again from the scalar that's causing your problem so just don't do that. For example, if we assume the output of lvs --noheadings --units m --nosuffix -o name,size vg_oracle|cut -d. -f1 looks like this: $ cat file lv_home_oracle 20480 lv_home_oracle_app 40960 lv_home_oracle_swdepot 40960 lv_opt_crs 40960 then the natural approach would be to populate an associative array from that (obviously I'm using cat file here instead of lvs... just for demo purposes): $ declare -A compound $ while read -r name size; do compound[$name]=$size; done < <(cat file) which gives us: $ declare -p compound declare -A compound=([lv_home_oracle_swdepot]="40960" [lv_home_oracle]="20480" [lv_opt_crs]="40960" [lv_home_oracle_app]="40960" ) and from there you can safely copy it into oralvs[] or do whatever you like with it.
downvote count: 0
score: 1
upvote count: 1
type: Answer

groovy
tags question: http://stackoverflow.com/q/78429844
type: Tag
tag name: groovy
tags question: http://stackoverflow.com/q/78956880
tags question: http://stackoverflow.com/q/79312384

http://stackoverflow.com/comment/138258816
score: 1
type: Comment
has text: @tripleee Yes you are right, that should be `!NR` but I changed it to `NR==0` to make it clearer.
comment on: http://stackoverflow.com/a/78423429
type: AnswerComment

http://stackoverflow.com/comment/138295716
comment on: http://stackoverflow.com/q/78444401
type: QuestionComment
score: 0
type: Comment
has text: Happen to know what that path would be, @choroba?

http://stackoverflow.com/a/78441170
type: Answer
has comment: http://stackoverflow.com/comment/138290543
has comment: http://stackoverflow.com/comment/138292447
accepted answer of: http://stackoverflow.com/q/78440219
has comment: http://stackoverflow.com/comment/138290721
type: AcceptedAnswer
has body: Your bash script lacks the comparison between the two inputs and the sum when rows match. If you absolutely want to do this with just bash, if your CSV files are as simple as what you show (no quoted fields, no newlines in fields...), if you want to also print lines that are found in only one of the two input files, and if you don't care about the final order, then you can try: #!/bin/bash declare -iA a=() declare -i Data declare Account Entity FILE1="csv_file1.csv" FILE2="csv_file2.csv" head -n1 "$FILE1" while IFS=, read -r Account Entity Data; do a["$Account,$Entity"]+=Data done < <(tail -n +2 "$FILE1"; tail -n +2 "$FILE2") for k in "${!a[@]}"; do printf '%s,%d\n' "$k" ${a[$k]} done For performance reasons awk would be a better choice than bash. With the same assumtions as for the bash version, you can try the following with any awk: awk ' BEGIN { FS = OFS = "," } NR == 1 { print; next } FNR == 1 { next } { a[$1 OFS $2] += $3 } END { for(k in a) print k, a[k] } ' csv_file1.csv csv_file2.csv We declare the comma as input (FS) and output (OFS) field separators. We print the header line of the first file and skip the header line of the second file. While parsing the files we store the content in array a with 2 first fields as key and last field as value (e.g., a[A1101,E101] = 1000), adding the third field to the value if the key exists already. At the end (END) we print the content of array a. If your CSV format is more complex, with double-quoted fields, possibly containing escaped double-quotes ("") or even newline characters, you could try the --csv option of recent versions of GNU awk: awk --csv ' function quote(s) { if(s ~ /[",\n]/) { gsub(/"/, "\"\"", s) s = "\"" s "\"" } return s } BEGIN { OFS = "," } NR == 1 { print; next } FNR == 1 { next } { a[$1][$2] += $3 } END { for(k1 in a) for(k2 in a[k1]) print quote(k1), quote(k2), a[k1][k2] } ' csv_file1.csv csv_file2.csv Demo: $ cat csv_file1.csv Account,Entity,Data A1101,E101,1000 A1101,"E101,E102",3000 A1101,"hel…
score: 0
answers question: http://stackoverflow.com/q/78440219

http://stackoverflow.com/comment/138148549
comment on: http://stackoverflow.com/q/78360964
type: QuestionComment
has text: See ["Brace expansion with variable?"](https://stackoverflow.com/questions/19432753/brace-expansion-with-variable) and ["How do I iterate over a range of numbers defined by variables in Bash?"](https://stackoverflow.com/questions/169511/how-do-i-iterate-over-a-range-of-numbers-defined-by-variables-in-bash)
type: Comment
score: 1

http://stackoverflow.com/comment/138137356
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78343881
score: 0
has text: This solved my issue for some purposes, but not others, like the issue I'm now having [piping a file to the server](https://stackoverflow.com/questions/78350497/is-it-possible-to-pipe-a-file-into-heredoc-in-bash). If I could get both servers to treat strings the same, I wouldn't be running into the pipe+heredoc stdin issues mentioned in that thread and my problem would be solved.

http://stackoverflow.com/q/78441743
has comment: http://stackoverflow.com/comment/138290885
has comment: http://stackoverflow.com/comment/138290945
tagged with: bash
has comment: http://stackoverflow.com/comment/138290901
type: Question
has answer: http://stackoverflow.com/a/78441809
duplicate of: http://stackoverflow.com/q/45420535
linked to: http://stackoverflow.com/q/1392990
has body: I am trying to print the columns in a CSV file. The CSV file is as below: Account,Data,Address,Name A1101,100,"303,SCA,JDM",Ram A1102,100,"303,SCA,JDM",Ram And I have used the below Bash code to print the pattern. patterns="$(cat csv_file3.csv | tail -n +2 | sort -k 2 | cut -d , -f 1,3,4 | uniq | tr -d ' ')" echo "$patterns" While I was executing in Git-Bash, the pattern is being printed as below: As you can see, only a part of the 3rd column is being printed. Is it possible to print the format correctly? Below is the expected output. Account,Address,Name A1101,"303,SCA,JDM",Ram A1102,"303,SCA,JDM",Ram
type: UnansweredQuestion
has title: Unable to echo data under column which is enclosed in double quotes
answer count: 1
tagged with: unix
tagged with: http://stackoverflow.com/tag/csv
duplicate of: http://stackoverflow.com/q/1392990
has comment: http://stackoverflow.com/comment/138290929
score: 0
tagged with: git-bash

http://stackoverflow.com/comment/138091376
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78327616
type: QuestionComment
has text: @user1934428 it was just a school assignment, which finally had to be handed in with the file extension sh, that's why i was looking for solutions, but it's cleared up, thanks

http://stackoverflow.com/comment/138089889
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78325081
has text: Yes, that's what `exec` does: it looks for an executable file, and executes it. Functions and built-ins are excluded (though not in `zsh`), rather than taking precedence over path lookup.
score: 0

http://stackoverflow.com/comment/138266106
score: 3
type: QuestionComment
has text: The function is run with its exit status tested (with `&&`), so errors aren't treated as exit-worthy. `set -e` is *full* of weird exceptions like this, and isn't even consistent between different versions of bash. See [BashFAQ #105: "Why doesn't `set -e` (or `set -o errexit`, or `trap ERR`) do what I expected?"](http://mywiki.wooledge.org/BashFAQ/105)
comment on: http://stackoverflow.com/q/78427625
type: Comment

http://stackoverflow.com/a/78340243
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78339485
has body: What changes do I need to make to the script so it compensates the extra "" in the input data You are doing printf "\"%s\"%s", val, (tagNr<numTags ? OFS : ORS) if val already has leading and trailing " you are slapping additional " and thus get ""06:00,08:00,10:00,12:00,14:00,16:00"" to avoid that you might substring val if it starts with " and ends with ". Let file.txt content be something_without_quotes "something_in_quotes" doubled""quote then awk '{val=$1;if(val~/^".*"$/){val=substr(val,2,length(val)-2)};printf "\"%s\"\n",val}' file.txt gives output "something_without_quotes" "something_in_quotes" "doubled""quote" Explanation: If value in val is starting with " and ending with " I use substr string function to remove 1st and last character by starting at 2nd character and getting substring of length equal to length of original string less 2. For each line I printf value enclosed in ". (tested in GNU Awk 5.1.0)

http://stackoverflow.com/a/78361839
has body: Use * to ignore last characters #!/usr/bin/env bash hostname=$(hostname -s) shopt -s extglob case $hostname in presto+([[:digit:]])*) bash /home/presto.sh;; presto-data+([[:digit:]])*) bash /home/presto-data.sh;; *) echo "Unrecognized hostname $hostname" ;; esac
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78361035
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78361035
type: Answer
score: 2

http://stackoverflow.com/comment/138272624
comment on: http://stackoverflow.com/q/78431133
type: QuestionComment
type: Comment
has text: What directory are those commands in? By default, cron jobs run with a `PATH` containing only /bin and /usr/bin, so if they're anywhere else (and you don't add the relevant directory to `PATH`), they won't be found. See ["crontab and binaries in /usr/local/bin"](https://superuser.com/questions/784252/crontab-and-binaries-in-usr-local-bin/785102#785102) and if that doesn't solve it, ["CronJob not running"](https://stackoverflow.com/questions/22743548/cronjob-not-running/22744360#22744360) has more troubleshooting recommendations.
score: 1

http://stackoverflow.com/comment/138204541
type: QuestionComment
type: Comment
has text: I'd need to know more about bsub's usage, but _if_ it just runs arbitrary commands exactly as it receives them, consider embedding the code you want to distribute in a function. If you define a function with `yourfunc() { ...; }`, for example -- putting your actual code in place of `...` -- then you can run `bsub ... bash -c "$(declare -f yourfunc); yourfunc"`, with all your other arguments in place of the second `...`.
comment on: http://stackoverflow.com/q/78392914
score: 0

http://stackoverflow.com/comment/138252532
comment on: http://stackoverflow.com/a/78419717
score: 1
type: Comment
has text: `!` inverts one *pipeline*, e.g. `! foo | bar` negates the exit status of `foo | bar`, not just `foo`.
type: AnswerComment

key
tag name: key
tags question: http://stackoverflow.com/q/78381387
type: Tag

http://stackoverflow.com/comment/138121814
type: QuestionComment
type: Comment
has text: So what do you recommend?
comment on: http://stackoverflow.com/q/78342422
score: 0

http://stackoverflow.com/comment/138221926
comment on: http://stackoverflow.com/q/78402822
score: 0
has text: Just to be clear, are you really using `bash`, or are you using `zsh` (which is the default shell on macOS)?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138073657
score: 0
type: QuestionComment
type: Comment
has text: Another way to get at this, given what you say about `pip list`. ... If you put `%pip list` inside a new notebook and run that the way you are trying to run `file1.ipynb` with your `.sh` file, what happens? Does what is listed in the result of `%pip list` run in side the notebook match what you think?
comment on: http://stackoverflow.com/q/78313378

http://stackoverflow.com/comment/138299424
type: QuestionComment
comment on: http://stackoverflow.com/q/78444623
type: Comment
score: 0
has text: Also see: [Bash array with spaces in elements](https://stackoverflow.com/questions/9084257/bash-array-with-spaces-in-elements) in case that's your issue.

http://stackoverflow.com/comment/138089060
comment on: http://stackoverflow.com/q/78325081
has text: But there is in addition a `/bin/echo`, while there can't be a `/bin/declare`. I guess bash and zsh both run the /bin/echo, when they exec.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/a/78351090
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/138137926
has body: To exclude specific sub-directories from your select loop, you can modify your code to filter out the directories you want to exclude. I’ll provide you with an example of how to achieve this. First, let’s create an array containing the static directories you want to exclude. You mentioned that there are seven sub-directories with the same prefix (e.g., thing-*) and three other sub-directories that do not share that prefix. We’ll use this information to construct our exclusion list. #!/bin/bash # Define the static directories to exclude declare -a directoriesToExclude=("sub_dir2" "sub_dir4" "thing-1" "thing-2" "thing-3" "thing-4" "thing-5" "thing-6" "thing-7") # Dynamically list all sub-directories under classes/ select d in */; do # Check if the selected directory is non-empty and not in the exclusion list if [[ -n "$d" && ! " ${directoriesToExclude[@]} " =~ " $d " ]]; then break else echo ">>> Invalid Selection" fi done # Now you can use the selected directory ($d) for further processing echo "Selected directory: $d"
answers question: http://stackoverflow.com/q/78351058
has comment: http://stackoverflow.com/comment/138131047

digital-ocean
tag name: digital-ocean
tags question: http://stackoverflow.com/q/78412927
type: Tag

http://stackoverflow.com/comment/138240530
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78412927
score: 0
has text: tl;dr You should give `jq` a try. It's a much better tool to manipulate JSON. See https://jqlang.github.io/jq/.

http://stackoverflow.com/comment/138116152
type: Comment
has text: I tried to do `xsltproc sheet.xslt file.xml` but I get a parsing error for the sheet file on line 5 ... What should I do ??
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78342527

http://stackoverflow.com/comment/138172821
type: QuestionComment
comment on: http://stackoverflow.com/q/78373696
type: Comment
has text: @CharlesDuffy Running the bash file from the terminal does everything fine, the service is stopped, update file extracted and the service file is overwritten, then it's started again the problem is doing this from the go app itself, I want the go app to trigger the bash script so that the user can click "update & restart", is this possible ? ChatGPT is hallucinating. I prefer not to use systemd and keep the whole setup limited to the go app and a bash script "if possible"
score: 0

http://stackoverflow.com/q/78390075
score: 0
type: Question
answer count: 0
type: UnansweredQuestion
has body: I am trying to retrieve the output of zypper search in a particular format. When I run zypper search on my repo with the following command: zypper search --details --repo my_repo_alias, I get an output that looks like this: | Mesa | package | 22.3.5-150500.75.2 | x86_64 | my_repo_alias | Mesa | srcpackage | 22.3.5-150500.75.2 | noarch | my_repo_alias | Mesa-dri | package | 22.3.5-150500.75.2 | x86_64 | my_repo_alias | Mesa-drivers | srcpackage | 22.3.5-150500.75.2 | noarch | my_repo_alias | Mesa-gallium | package | 22.3.5-150500.75.2 | x86_64 | my_repo_alias | Mesa-libEGL1 | package | 22.3.5-150500.75.2 | x86_64 | my_repo_alias | Mesa-libGL1 | package | 22.3.5-150500.75.2 | x86_64 | my_repo_alias | Mesa-libglapi0 | package | 22.3.5-150500.75.2 | x86_64 | my_repo_alias However, I need to get the above info in this format: Mesa-22.3.5-150500.75.2.x86_64.rpm Mesa-22.3.5-150500.75.2.noarch.rpm Mesa-dri-22.3.5-150500.75.2.x86_64.rpm Mesa-drivers-22.3.5-150500.75.2.noarch.rpm Mesa-gallium-22.3.5-150500.75.2.x86_64.rpm Mesa-libEGL1-22.3.5-150500.75.2.x86_64.rpm Mesa-libGL1-22.3.5-150500.75.2.x86_64.rpm Mesa-libglapi0-22.3.5-150500.75.2.x86_64.rpm Currently, to do this I'm using this code: while IFS= read -r line; do package_name=$(echo "$line" | awk '{print $2}') package_version=$(echo "$line" | awk '{print $6}') package_arch=$(echo "$line" | awk '{print $8}') concatenated_info="$package_name-$package_version.$package_arch.rpm" done < <(zypper search --details --repo sles_base_os_repo) I think this is not ideal as this is using the position of certain fields (name, version, arch) to retrieve the necessary info to make the concatenated string. While unlikely, the position of these fields might be subject to change which would break the code. I have been looking the zypper command to see if there is a way I can control how the above info is outputted but haven't found anything yet. Is anyone aware of something that might be available with zypper that would allow me to output…
tagged with: zypper
tagged with: bash
has title: Control output of zypper search, packages, etc

http://stackoverflow.com/comment/138174064
type: QuestionComment
type: Comment
has text: I need to clarify that I do not want a person to write a script, **I need a scripting language, I do not know what commands to use**.. it would be like writing Python commands in a shell script without links. Also I can not just place random "commands" here, it may erase my environment and I would have to recreate everything from scratch.
score: 0
comment on: http://stackoverflow.com/q/78344853

forticlient
tags question: http://stackoverflow.com/q/78342422
tag name: forticlient
type: Tag

http://stackoverflow.com/comment/138258048
type: QuestionComment
comment on: http://stackoverflow.com/q/78423157
has text: Try: `while read -r token email; do ... ;done < <(jq -r 'to_entries[] | "\(.value) \(.key)"' <output.json)`
type: Comment
score: 0

http://stackoverflow.com/comment/138150013
score: 0
has text: Interesting. Would you mind showing us the output of this command `od -t x1 <test.sh`?
comment on: http://stackoverflow.com/q/78361451
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138126335
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78348089
has text: You did not show, how you are calling your Python program, but did you ensure that you have set the environment variable in that process as well? Show your "server launch script".
type: QuestionComment

http://stackoverflow.com/comment/138224676
has text: Just once: I only need that modification once at line 9
comment on: http://stackoverflow.com/q/78404233
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138289250
type: Comment
type: AnswerComment
score: 0
has text: @user1934428 Thanks, good to know. Sorry for tagging my question with both `bash` and `zsh` tags. I agree, it can be confusing at times.
comment on: http://stackoverflow.com/a/78438177

http://stackoverflow.com/comment/138302137
comment on: http://stackoverflow.com/q/78441613
score: 0
type: QuestionComment
type: Comment
has text: sed is not the best choice of tool for anything spanning multiple lines. Why does it have to be sed? Also, you didn't answer @KamilCuk's other question - does it have to be posix (since you tagged the question with [tag:posix])?

http://stackoverflow.com/comment/138203085
comment on: http://stackoverflow.com/a/78391686
score: 0
type: Comment
type: AnswerComment
has text: @F.Hauri-GiveUpGitHub, your `coproc` solution is definitely a better way to do it. I'm sorry that I didn't think of it.

http://stackoverflow.com/comment/138111779
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78339485
has text: Probably avoid the [useless use of `cat`](https://stackoverflow.com/questions/11710552/useless-use-of-cat)
type: QuestionComment

http://stackoverflow.com/a/78438419
type: Answer
answers question: http://stackoverflow.com/q/78438262
upvote count: 5
has body: If we ignore that part about requiring a oneliner, then using any POSIX awk you could do this: $ cat tst.sh #!/usr/bin/env bash ip="$1" shift awk -v ip="$ip" ' BEGIN { FS="[[:space:]:]+" } !/local_address/ && ( ($3 == ip) || ($3+0 == 0) ) { port = $4 $7 if ( !seen[port]++ ) { print port } } ' "${@:--}" $ ./tst.sh 845DA8C0 "/proc/net/tcp" "/proc/net/tcp6" 00160A 1F910A 1F900A 1F920A No need to call grep first, just run that on the tcp input files you currently run grep on. If you wanted to pass it a dot-separated decimals IP address then just change the awk command to: awk -v ip="$ip" ' BEGIN { FS = "[[:space:]:]+" ip = dec2hex(ip) } !/local_address/ && ( ($3 == ip) || ($3+0 == 0) ) { port = $4 $7 if ( !seen[port]++ ) { print port } } function dec2hex(dec, a) { split(dec,a,".") return sprintf("%02X%02X%02X%02X", a[4], a[3], a[2], a[1]) } ' "${@:--}" You can even automate it to do the conversion only if/when necessary if you like: ip = (ip ~ /\./ ? dec2hex(ip) : ip) Replace all newlines with ; if you really want to cram it into 1 line for some reason.
has comment: http://stackoverflow.com/comment/138286132
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/138285598

http://stackoverflow.com/a/78347012
answers question: http://stackoverflow.com/q/78346345
has body: You cannot do this job robustly without writing a parser for PHP but if you're happy with a simple, best-effort tool that'll work for the format you show where if only appears as the first "word" on a line if it's the start of an if-condition and the matching } is always indented the same way as the if, an else is always on the same line as the ending }, etc. then just using mandatory POSIX tools you could do the following: find . -name '*.php' -exec \ awk -v numLines=100 ' /^[[:space:]]*if[[:space:]]*\(.*\{/ { begNr[++depth] = FNR sub(/[^[:space:]].*/,"") endRe[depth] = "^" $0 "}" } depth && match($0,endRe[depth]) { if ( (FNR - begNr[depth]) >= (numLines + 2) ) { print FILENAME, "match started at line", begNr[depth] } if ( substr($0,RLENGTH+1) ~ "[[:space:]]*else[[:space:]]*\{" ) { begNr[depth] = FNR } else { depth-- } } ' {} + In the case of nested ifs, if one contains >= 100 lines then any it is nested within also contain >= 100 lines and so will also be reported as such. The above is, obviously, untested since you didn't provide sample input and expected output we could test with.
downvote count: 0
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/a/78354848
type: AcceptedAnswer
has body: If you enable debug mode (set -xv) you'll see what bash sees: $ touch some_file $ criteria_col="-f 1-8,20,22" $ set -xv $ cut -d';' "$criteria_col" some_file + cut '-d;' '-f 1-8,20,22' some_file ^^^^^^^^^^^^^^ cut: fields are numbered from 1 Try 'cut --help' for more information. Notice that -f 1-8,20,22 is being treated as a single string '-f 1-8,20,22' which in turn causes the error. One simple fix would be to move the -f from the variable to the command line, eg: $ criteria_col="1-8,20,22" $ cut -d';' -f "$criteria_col" some_file ^^ + cut '-d;' -f 1-8,20,22 some_file $ # no error; no output since my file is empty If you need the -f to be part of the criteria then I'd recommend F.Hauri's comment/suggestion of using an array.
downvote count: 0
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78354730
score: 1
accepted answer of: http://stackoverflow.com/q/78354730

select
tags question: http://stackoverflow.com/q/78338291
type: Tag
tag name: select

http://stackoverflow.com/a/78420632
type: Answer
has comment: http://stackoverflow.com/comment/138258430
answers question: http://stackoverflow.com/q/78419971
score: 3
upvote count: 3
downvote count: 0
has body: As you probably know: git rebase resorts to an algorithm on the diff for each individual commit to detect if a commit is "already présent" on the other side. There actually is a way to view this detection beforehand: look at the --cherry-* options in git help log : # will draw a = in front of each commit which # is also "on the other side" git log --oneline --graph --boundary --cherry-mark E1...F2 # --cherry-pick will hide these commits altogether: git log --oneline --graph --boundary --cherry-pick E1...F2 This may help you re-stitch more easily the histories of the two branches (technically you didn't ask a question, but it looks like you are trying to do this, am I correct?)

slurm
type: Tag
tag name: slurm
tags question: http://stackoverflow.com/q/78316544
tags question: http://stackoverflow.com/q/78475004
tags question: http://stackoverflow.com/q/78609174
tags question: http://stackoverflow.com/q/78598748
tags question: http://stackoverflow.com/q/78686318
tags question: http://stackoverflow.com/q/78678279
tags question: http://stackoverflow.com/q/78836173
tags question: http://stackoverflow.com/q/78750797
tags question: http://stackoverflow.com/q/79048675
tags question: http://stackoverflow.com/q/78918638
tags question: http://stackoverflow.com/q/79025201
tags question: http://stackoverflow.com/q/79216406
tags question: http://stackoverflow.com/q/79147567
tags question: http://stackoverflow.com/q/79126444
tags question: http://stackoverflow.com/q/79248883
tags question: http://stackoverflow.com/q/79347783
tags question: http://stackoverflow.com/q/79409298
tags question: http://stackoverflow.com/q/79526480

http://stackoverflow.com/comment/138115204
has text: BTW, `"export \(.key)=\(.value)"` has serious security problems. **Always** use the `@sh` filter in jq to shell-quote strings before dumping them into a context where they'll be evaluated as code.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78342087

http://stackoverflow.com/comment/138190284
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78383368
has text: @GordonDavisson can you give me the code snippet that will make it work without eval and also return the json that the curl returns please?

http://stackoverflow.com/comment/138222168
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78402822
has text: Relocated to https://unix.stackexchange.com/questions/775468/maintain-position-in-terminal-command-history-on-macos.

http://stackoverflow.com/comment/138072389
type: Comment
score: 0
has text: @CharlesDuffy What do you mean by store the PID directly? This is not something we went over in the class. You say not to use jobs -l but my assignment instructions are "The script will use the jobs -l command AND the cut command to obtain the PID of the background job." It seems every time I post my scripts asking for help I'm told I'm doing it the wrong way and whatever the right way is not something that will get me any points. Starting to think I'll get this degree and not know how to do anything I'm asked to do.
comment on: http://stackoverflow.com/q/78317514
type: QuestionComment

http://stackoverflow.com/a/78412598
has comment: http://stackoverflow.com/comment/138240755
score: 0
has body: Sure it's better to use jq if you work with json but in case when jq is not available printf can be used, like this: declare -A arr=([key1]=val1 [key2]=val2) items=$( for key in "${!arr[@]}"; { val=${arr[$key]} printf '{"%s": "%s"},\n' "$key" "$val" } ) echo "[${items%,*}]" [{"key2": "val2"}, {"key1": "val1"}] Here is I'm using jq to validate the result: $ echo "[${items%,*}]" | jq [ { "key2": "val2" }, { "key1": "val1" } ] Note this syntax ${items%,*} it will print $items without last comma which is crucial for json. But yes, some tricky values like the one from comments may ruin everything and must be worked around: declare -A arr=([key1]=val1 [key2]=val2 [key3]='foo "bar \ bar"') items=$( for key in ${!arr[@]}; { printf -vval -- '%q' "${arr[$key]}" printf -vkey -- '%q' "$key" printf '{"%s": "%s"},\n' "${key//'\ '/ }" "${val//'\ '/ }" } ) echo "[${items%,*}]" | jq [ { "key2": "val2" }, { "key3": "foo \"bar \\ bar\"" }, { "key1": "val1" } ]
answers question: http://stackoverflow.com/q/78411838
type: Answer

http://stackoverflow.com/comment/138329506
comment on: http://stackoverflow.com/a/78442980
type: Comment
type: AnswerComment
score: 0
has text: Care! [Using `declare -A "varname=($compound)"` is a kind of `eval`!!](https://stackoverflow.com/a/78464354/1765658)

http://stackoverflow.com/comment/138312257
score: 0
comment on: http://stackoverflow.com/q/78441613
type: QuestionComment
type: Comment
has text: @EdMorton yeah you are right. I just need the best solution. If better posix -> OK

http://stackoverflow.com/comment/138067533
type: Comment
comment on: http://stackoverflow.com/q/78314716
score: 0
has text: `\r` is part of Window's newline "character". Windows uses `\r\n` while Linux uses just `\n`. Therefore bash (originally a Linux program) interprets the `\r` as a regular (but invisible) character. To solve the issue, convert your files (script and the csv) to Linux line endings using `dos2unix`.
type: QuestionComment

win-bash
type: Tag
tags question: http://stackoverflow.com/q/78416162
tag name: win-bash

http://stackoverflow.com/comment/138238936
has text: This will work with grep using the `-P` flag for using Perl-compatible regular expressions
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78411195
score: 3

http://stackoverflow.com/a/78444399
has body: I managed to find the culprit, it appears that the device has some obfuscation protection for these commands, some wrapper of sorts, i eventually found it via the forums. Here is the final version of the script with a loop that reconnects until it gets a matching IP address. #!/bin/bash int_ip_addr=`/sbin/ifconfig pppoe0 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f1` pb_ip_addr=`curl ipinfo.io/ip` echo "Internal IP Address is $int_ip_addr" echo "External IP Address is $pb_ip_addr" while [ "$int_ip_addr" != "$pb_ip_addr" ]; do echo "PPPoE IP is not Public - $int_ip_addr"; /opt/vyatta/bin/vyatta-op-cmd-wrapper disconnect interface pppoe0; /opt/vyatta/bin/vyatta-op-cmd-wrapper connect interface pppoe0; echo "Sleeping for 30 seconds" sleep 30s int_ip_addr=`/sbin/ifconfig pppoe0 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f1` pb_ip_addr=`curl ipinfo.io/ip` echo "Internal IP Address is $int_ip_addr" done echo "PPPoE IP is Public - $int_ip_addr";
type: AcceptedAnswer
score: 0
answers question: http://stackoverflow.com/q/78444070
type: Answer
accepted answer of: http://stackoverflow.com/q/78444070

http://stackoverflow.com/comment/138203882
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78392419
has text: It certainly was considered -- these names are _explicitly_ illegal by specification. An associative array would avoid the issue -- key names are allowed to have spaces.
type: QuestionComment

zypper
tag name: zypper
type: Tag
tags question: http://stackoverflow.com/q/78390075

http://stackoverflow.com/comment/138210760
comment on: http://stackoverflow.com/a/78396452
type: Comment
score: 0
type: AnswerComment
has text: Thank you! It works with 33 lines of Downstream channels. However it also outputs one empty line before the first line which starts with ` `

http://stackoverflow.com/comment/138146588
comment on: http://stackoverflow.com/q/78359720
type: Comment
score: 0
has text: There's no easy way to do this. If the terminal is a pty, as it usually is in a window or SSH server, you would have to write the data to the master end of the pty. The `complete` built-in doesn't send the input to stdin, it puts it in the shell's editing buffer (it can do this because it's built into the shell).
type: QuestionComment

google-alloydb
tags question: http://stackoverflow.com/q/78338056
tag name: google-alloydb
type: Tag
tags question: http://stackoverflow.com/q/78513768

http://stackoverflow.com/comment/138109606
type: Comment
has text: If you dislike the answers on the other question, feel free to post your answer there instead. Creating a new duplicate is generally not the way to go.
comment on: http://stackoverflow.com/q/78331935
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138251747
has text: Just learned about the command group, it looks nicer, thanks for the answer!
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78419699

gsutil
type: Tag
tag name: gsutil
tags question: http://stackoverflow.com/q/78431133

error-handling
tag name: error-handling
tags question: http://stackoverflow.com/q/78415633
tags question: http://stackoverflow.com/q/78420131
type: Tag
tags question: http://stackoverflow.com/q/78842889
tags question: http://stackoverflow.com/q/79027290
tags question: http://stackoverflow.com/q/79128348
tags question: http://stackoverflow.com/q/79246769

http://stackoverflow.com/comment/138168145
has text: So, the `sh` step is executing. I believe you can close the original question.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment

http://stackoverflow.com/comment/138192194
type: Comment
comment on: http://stackoverflow.com/q/78385809
has text: If you're reading the BashFAQ, [see #48](https://mywiki.wooledge.org/BashFAQ/048), which is _directly on point_ for why `eval` is discouraged.
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138295927
comment on: http://stackoverflow.com/q/78444497
has text: ...so in general, the Right Way to prioritize `/usr/local/bin` over `/usr/bin` is just to modify PATH to put `/usr/local/bin` first. Don't use aliases -- forget they ever existed; there are almost no cases where an alias is a better choice than a shell function.
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/138122545
type: Comment
score: 1
has text: _There could be nested if conditions as well_ : What is the expected outcome, if a text looking like an if condition happens to be part of a multi-line comment or a multiline string?
comment on: http://stackoverflow.com/q/78346345
type: QuestionComment

http://stackoverflow.com/q/78392914
tagged with: lsf
has body: Please help me as I am relatively new to using the bash shell. I have a simple script that I want to submit as a job on the LSF my institution's computing cluster uses using the bsub command like this: bsub \ -R rusage[mem=8G] \ -R span[hosts=1] \ -n 1 \ -q short \ -W 2:00 \ -o log.N1.kallisto_calc.out \ -e log.N1.kallisto_calc.err \ -J kallisto_calc_test \ kallisto_stats=$(zcat N1_pear_merged.fastq.gz | \ awk ' BEGIN {t=0.0; sq=0.0; n=0;}; NR%4==2 {n++; L=length($0); t+=L; sq+=L*L;} END {m=t/n; printf("total %d avg_length %f std_dev %f\n",n,m,sqrt(sq/n-m*m));} ' ) && echo -e N10'\t'$kallisto_stats >> kallisto_stats2.txt However, when I do this, the script does not run. When I check the status using bjobs, it says "RUN" under the status but it doesn't finish and doesn't even make log files. When I run it in this format it runs with no problems: #BSUB -R rusage[mem=8G] #BSUB -R span[hosts=1] #BSUB -n 1 #BSUB -q short #BSUB -W 2:00 #BSUB -o log.N1.kallisto_calc.out #BSUB -e log.N1.kallisto_calc.err #BSUB -J kallisto_calc_test kallisto_stats=$(zcat N1_pear_merged.fastq.gz | awk 'BEGIN {t=0.0; sq=0.0; n=0;}; NR%4==2 {n++; L=length($0); t+=L; sq+=L*L;} END {m=t/n; printf("total %d avg_length %f std_dev %f\n",n,m,sqrt(sq/n-m*m));}') && echo -e N10'\t'$kallisto_stats >> kallisto_stats2.txt This has never happened to me before, can anyone tell me what is going wrong here? If it helps, the cluster runs Linux Red Hat 8. I tried putting the command in quotes and it did not help. The script should read the "N1_pear_merged.fastq.gz " file and make a new file called "kallisto_stats.txt" with a line of text like this: total 100 avg_length 223.410000 std_dev 47.398121
score: 0
has comment: http://stackoverflow.com/comment/138204557
type: Question
answer count: 0
tagged with: linux
has title: Having issues with formatting a script for job submission on LSF
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138204507
has comment: http://stackoverflow.com/comment/138204459
tagged with: bash
has comment: http://stackoverflow.com/comment/138204541

http://stackoverflow.com/comment/138067010
has text: Can you try `echo "-$status_column3-"` instead of your plain `echo $status_column3` to see if `$status_column3` does not contain trailing spaces?
type: QuestionComment
comment on: http://stackoverflow.com/q/78314716
type: Comment
score: 2

http://stackoverflow.com/a/78316783
has body: I've found an issue on GitHub like your issue : https://github.com/gauravsacc/MMM-GoogleAssistant/issues/72 I found the reason, because when I run MMM, assistant.py already run. And I run assistant.py again, mic was used by the first time, so nothing error. And finally MMM run(at the same time I run assistant.py???The first time assistant.py was run by MMM, and after I killed python, it cannot run automatically). The experience is bad. Most of time it cannot get what I said. Try it and say us the result :)
answers question: http://stackoverflow.com/q/78316769
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/138070973

http://stackoverflow.com/comment/138295640
has text: Try using the full path to the `system_profiler` and the shell script instead of just their names.
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78444401

http://stackoverflow.com/comment/138366890
type: Comment
score: 0
comment on: http://stackoverflow.com/a/78403450
type: AnswerComment
has text: So, I'm willing to help, but I need to understand what the end goal here is.

http://stackoverflow.com/comment/138103565
type: QuestionComment
has text: If there is just one package, then you should be able to do (from the project directory) `javac -d build/classes src/com/estudio/ejerciciosclase/*.java;java com.estudio.ejerciciosclase.sumScanner` If not, you should provide the path to each package to `javac`. This is why build tools are necessary normally ;) btw, class names should begin [upper case](https://technojeeves.com/index.php/aliasjava1/106-java-style-conventions) in Java
comment on: http://stackoverflow.com/q/78335326
type: Comment
score: 0

http://stackoverflow.com/a/78424119
score: 2
upvote count: 2
has body: I would harness GNU AWK for this task following way, let file.txt content be &gt;Cluster 94 0 416aa, &gt;crgi_XP_019918436.1... * &gt;Cluster 95 0 415aa, &gt;TRINITY_DN19027_c1_g1_i3_77... * &gt;Cluster 96 0 415aa, &gt;TRINITY_DN31043_c0_g1_i1_68... * &gt;Cluster 97 0 414aa, &gt;TRINITY_DN4649_c0_g1_i1_24... * 1 414aa, &gt;TRINITY_DN4649_c0_g1_i2_29... at 100.00% 2 414aa, &gt;TRINITY_DN4649_c0_g1_i3_23... at 100.00% 3 414aa, &gt;TRINITY_DN4649_c0_g1_i4_23... at 100.00% 4 414aa, &gt;TRINITY_DN4649_c0_g1_i5_27... at 100.00% &gt;Cluster 98 0 414aa, &gt;TRINITY_DN11838_c0_g1_i1_77... * &gt;Cluster 99 0 414aa, &gt;TRINITY_DN13974_c0_g1_i1_33... * 1 414aa, &gt;TRINITY_DN13974_c0_g1_i3_29... at 100.00% 2 414aa, &gt;TRINITY_DN13974_c0_g1_i4_34... at 100.00% &gt;Cluster 100 0 414aa, &gt;TRINITY_DN15453_c0_g1_i1_84... * &gt;Cluster 101 0 414aa, &gt;TRINITY_DN23802_c0_g1_i1_50... * &gt;Cluster 102 0 414aa, &gt;TRINITY_DN24921_c0_g1_i1_102... * &gt;Cluster 103 0 414aa, &gt;TRINITY_DN26456_c0_g1_i1_61... * &gt;Cluster 104 0 414aa, &gt;TRINITY_DN49299_c0_g1_i1_30... * &gt;Cluster 105 0 412aa, &gt;TRINITY_DN13974_c0_g1_i2_27... * &gt;Cluster 106 0 411aa, &gt;TRINITY_DN5517_c0_g1_i1_28... * 1 411aa, &gt;TRINITY_DN5517_c0_g1_i2_35... at 100.00% &gt;Cluster 107 0 410aa, &gt;TRINITY_DN9528_c0_g1_i1_30... * 1 410aa, &gt;TRINITY_DN9528_c0_g1_i2_36... at 100.00% 2 404aa, &gt;crgi_XP_011414097.1... at 100.00% &gt;Cluster 108 0 410aa, &gt;TRINITY_DN11082_c0_g1_i1_69... * 1 410aa, &gt;TRINITY_DN11082_c0_g1_i2_69... at 100.00% &gt;Cluster 109 0 410aa, &gt;crgi_XP_011450995.2... * &gt;Cluster 110 0 407aa, &gt;TRINITY_DN4674_c0_g1_i3_24... * &gt;Cluster 111 0 407aa, &gt;TRINITY_DN11077_c0_g2_i1_64... * &gt;Cluster 112 0 407aa, &gt;TRINITY_DN11838_c0_g1_i2_78... * &gt;Cluster 113 0 407aa, &gt;TRINITY_DN11978_c0_g1_i1_33... * &gt;Cluster 114 0 406aa, &gt;TRINITY_DN26600_c0_g1_i1_86... * &gt;Cluster 115 0 406aa, &gt;TRINITY_DN50774_c0_g1_i1_65... * &gt;Cluster 116 0 406aa, &gt;crgi_XP_034333283.1…
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/78423821

http://stackoverflow.com/comment/138073693
has text: Idea based on [here](https://github.com/jupyter/nbconvert/issues/1756#issue-1197066507): convert your `jupyter nbconvert` command to `python -m jupyter nbconvert --execute --ExecutePreprocessor.kernel_name=repo_venv --to notebook file1.ipynb`
type: QuestionComment
comment on: http://stackoverflow.com/q/78313378
type: Comment
score: 0

http://stackoverflow.com/comment/138072194
score: 0
comment on: http://stackoverflow.com/q/78317617
type: QuestionComment
type: Comment
has text: When I look at this, the solution that looks obvious to me (other than _not using bash_ for something as intrinsically slow as this is -- when you're doing expensive things you don't want a language runtime that's going to slow you down) is to write a recursive function that, given a line of input, writes first that exact line to output, then that line with each of `{A..Z}` appended. That way you're only ever evaluating _one_ brace expansion at a time. Pipe `printf '%s\n' {A..Z}` into nine copies of that function, and there you are.

http://stackoverflow.com/comment/138129313
type: QuestionComment
has text: [so] is for programming questions, not questions about using or configuring Unix and its utilities. [unix.se] or [su] would be better places for questions like this.
comment on: http://stackoverflow.com/q/78349529
type: Comment
score: 0

http://stackoverflow.com/comment/138192934
score: 0
comment on: http://stackoverflow.com/q/78383368
type: QuestionComment
type: Comment
has text: I get a Search Response {"code":"401", "message":"String index out of range: -1"}

http://stackoverflow.com/comment/138073676
type: QuestionComment
type: Comment
has text: That looks like what I'd expect your output to be on zsh. With the exact code you ran I'd expect on bash the output to be only the word `Software`. (zsh _is_ default on MacOS, since Apple is unwilling to agree to GPLv3 license terms to be able to distribute modern releases of bash, so it seems likely you're actually using zsh and tagged the question with the wrong shell).
comment on: http://stackoverflow.com/q/78316829
score: 0

http://stackoverflow.com/comment/138119249
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78344420
has text: Uh, THANKS, but can you please explain why the dollar sign helps?

http://stackoverflow.com/comment/138187703
score: 0
has text: You run a subshell to populate each variable. In some subshells, you run several commands in a pipe. Using *parameter expansion* might be much faster as it stays in the same shell (but doesn't have all the capabilities of `awk` or `sed`).
comment on: http://stackoverflow.com/q/78383503
type: QuestionComment
type: Comment

perl
tag name: perl
tags question: http://stackoverflow.com/q/78418827
type: Tag
tags question: http://stackoverflow.com/q/78878978
tags question: http://stackoverflow.com/q/78761618
tags question: http://stackoverflow.com/q/78954892
tags question: http://stackoverflow.com/q/79268904
tags question: http://stackoverflow.com/q/79269485

http://stackoverflow.com/comment/138078756
type: Comment
type: AnswerComment
score: 0
has text: @CharlesDuffy it's not a `pgrep` issue, per se
comment on: http://stackoverflow.com/a/78320229

http://stackoverflow.com/comment/138129206
type: QuestionComment
type: Comment
has text: watch 3.3.17 seems to skip lines if the output is <= $COLUMNS and `--no-wrap` is specified.
comment on: http://stackoverflow.com/q/78349529
score: 0

http://stackoverflow.com/comment/138105895
has text: you need a space after `[` and before `]`; fwiw, cut-n-paste your entire script (including shebang) into [shellcheck.net](https://www.shellcheck.net/) to get help with addressing these types of syntax issues
type: Comment
comment on: http://stackoverflow.com/q/78336864
type: QuestionComment
score: 5

http://stackoverflow.com/comment/138265770
score: 0
has text: Why? is there any difference with or without the ending `;`?
comment on: http://stackoverflow.com/a/78419699
type: Comment
type: AnswerComment

scp
tag name: scp
tags question: http://stackoverflow.com/q/78384843
type: Tag
tags question: http://stackoverflow.com/q/79031905
tags question: http://stackoverflow.com/q/78993407

http://stackoverflow.com/comment/138265405
type: Comment
has text: The part with `grep` shouldn't be inside `[]`
score: 0
comment on: http://stackoverflow.com/q/78422019
type: QuestionComment

http://stackoverflow.com/comment/138159865
score: 1
type: QuestionComment
has text: @Ed Morton thanks for the tip! I'll read up on it.
type: Comment
comment on: http://stackoverflow.com/q/78364618

http://stackoverflow.com/comment/138166773
comment on: http://stackoverflow.com/q/78353316
type: QuestionComment
type: Comment
has text: @dbergloev Since I can't write a full-fledged answer, I'll sum up real quick (too quick, maybe). What you are asking cannot be done as long as 1. your messages are output in separate processes, and 2. those processes are running asynchronously. To make sure they are written in a controlled order, you either need to 1. remove asynchronous output, or 2. synchronize background processes. The latter is quite complex and kind of breaks the benefits of having background processes in the first place, so I would recommend to avoid that.
score: 0

http://stackoverflow.com/q/78385809
score: 0
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138192233
has title: Why does BashFAQ #50 not recommend using eval?
answer count: 1
has comment: http://stackoverflow.com/comment/138192194
linked to: http://stackoverflow.com/q/17529220
has comment: http://stackoverflow.com/comment/138192177
tagged with: bash
has comment: http://stackoverflow.com/comment/138192221
has comment: http://stackoverflow.com/comment/138191628
has comment: http://stackoverflow.com/comment/138192052
has answer: http://stackoverflow.com/a/78385881
has body: According to https://mywiki.wooledge.org/BashFAQ/050 ...putting bash commands in shell variables for subsequent execution is a Very Bad Idea. But what's bad about the following? #!/bin/bash cmd="for i in \$(seq 3); do echo 'a' 'b c' 'd' \$i | tr '[a-z]' '[A-Z]'; done" eval "$cmd" It seems to work pretty well, even preserving whitespace, allowing a for loop and allowing a pipe. Granted it's not that fast, but is bash really about speed?
duplicate of: http://stackoverflow.com/q/17529220

http://stackoverflow.com/comment/138170645
score: 1
type: QuestionComment
has text: There _are_ other options -- you can change how systemd is configured to manage shutdown to tell it to shut down only the MainPID and not the whole process group, for example -- but those other options tend to have undesirable side effects and I can't recommend them without a lot more details explaining why anything that's more in line with good practices is outside consideration.
type: Comment
comment on: http://stackoverflow.com/q/78373696

http://stackoverflow.com/comment/138170934
score: 0
type: QuestionComment
has text: Thank you! That was a leftover from trying out. I'll remove it for clarity
comment on: http://stackoverflow.com/q/78373828
type: Comment

http://stackoverflow.com/comment/138101918
type: QuestionComment
has text: please update the question with all replacement details as well as the expected result
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78334609

http://stackoverflow.com/comment/138300010
type: QuestionComment
comment on: http://stackoverflow.com/q/78444561
type: Comment
has text: @iRon Shouldn't be the case with a simple `rm` command.
score: 0

http://stackoverflow.com/comment/138284762
type: QuestionComment
type: Comment
has text: `awk '!/local_address/ {...}' filenames`
comment on: http://stackoverflow.com/q/78438262
score: 0

http://stackoverflow.com/comment/138238192
score: 2
type: Comment
has text: Newer versions of bash support `"${mymap[@]@k}"`, which eliminates the need to transpose.
type: AnswerComment
comment on: http://stackoverflow.com/a/78411906

http://stackoverflow.com/comment/138252978
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78420308
score: 1
has text: `>/dev/stdout` makes little sense. `/dev/stdout` is just a synonym for stdout, which is where output goes by default.

http://stackoverflow.com/comment/138069552
comment on: http://stackoverflow.com/q/78315911
type: QuestionComment
type: Comment
has text: Have you tried with a different file browser?
score: 0

http://stackoverflow.com/a/78610457
has body: NOTE VMWare was purchased by Broadcom, so if the links do not work is because they have moved the documentation across. NOTE the links to download vCenter 7 have changed because of this too. ----------------------------------------Information HERE---------------------------------------- there are several aspects to solve this problem, but first, the scripting language. PHOTON OS as defined in the link from my question has a limited set of commands that can be used. Upon using SSH to enter vCenter 7.x VM there are 3 lists of commands. API commands like "com.vmware.appliance.version1.services.list" as defined in this VMWare Link generally used to see the health or config of the vCenter environment, Also in 2. vCenter PDF link Plug-Ins Commands like "com.vmware.ping" as defined in this vCenter PDF generally used as administrative tools. list of 22 options limited shell commands like "pwd [-LP]" mostly as defined in this GNU link, PHOTON list is limited to 84 options in detail job_spec [&] (( expression )) . filename [arguments] : [ arg... ] expression alias [-p] [name[=value] ... ] bg [job_spec ...] bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r key> break [n] builtin [shell-builtin [arg ...]] caller [expr] case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac cd [-L|[-P [-e]] [-@]] [dir] command [-pVv] command [arg ...] compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordl> complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globp> compopt [-o|+o option] [-DE] [name ...] continue [n] coproc [NAME] command [redirections] declare [-aAfFgilnrtux] [-p] [name[=value] ...] dirs [-clpv] [+N] [-N] disown [-h] [-ar] [jobspec ... | pid ...] echo [-neE] [arg ...] enable [-a] [-dnps] [-f filename] [name ...] eval [arg ...] exec [-cl] [-a name] [command [arguments ...]] [redirection ...] exit [n] export [-fn] [name[=value] ...] export -p false fc [-e ename] [-lnr] [first] [last] fc -s [pat=rep] [command] fg [job_spec] fo…
type: Answer
answers question: http://stackoverflow.com/q/78344853
score: 0

http://stackoverflow.com/comment/138251473
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78416162
has text: Hint: If you get weird output, have a look what is actually stored in your variable. To peek into a variable, do i.e. `xxd <<<$folder`.

http://stackoverflow.com/comment/138199416
type: Comment
type: AnswerComment
has text: @LouisNichols: that's the whole idea: the `source` command treat a regular file and launch it as a script, which causes lines, like `var1=value1` to cause the variable `var1` to get the value `value1`, which can be used with the dollar-sign in front of the variable's name: `$var1`.
score: 0
comment on: http://stackoverflow.com/a/78389556

http://stackoverflow.com/a/78313113
answers question: http://stackoverflow.com/q/78309717
score: 0
has comment: http://stackoverflow.com/comment/138065990
type: Answer
has body: you can use the command git tag --contains "your commit SHA". If you don't know what a code SHA is, it's basically a code of 40 characters that is created when you do a commit, it make so every commit is unique. If you don't know your code SHA, you can use git log to try and find it.

http://stackoverflow.com/comment/138087531
type: QuestionComment
has text: I can't reproduce it. With my bash (5.2), `exec echo '$a'`, prints a literal _$a_ and then brings me back to the parent shell. Same with zsh (5.8.1).
type: Comment
comment on: http://stackoverflow.com/q/78325081
score: 0

http://stackoverflow.com/a/78382071
upvote count: 2
downvote count: 0
type: Answer
score: 2
has body: The use of " around $md is causing JQ to interpret your input as a string literal instead of expanding the variables Access the variable directly without quotes jq --arg md "blablabla" '. + {"content": $md}' blog.json output { "foo": "bar", "content": "blablabla" }
accepted answer of: http://stackoverflow.com/q/78381387
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78381387

http://stackoverflow.com/comment/138255017
comment on: http://stackoverflow.com/a/78420842
score: 0
type: Comment
type: AnswerComment
has text: True. True. True. I didn't use the `${today}` in my test. I used `mktime` to exemplify in case the formatting is required to be extended something else.

http://stackoverflow.com/comment/138150274
type: Comment
has text: I've added the outputs for `od -t x1 <test.sh` and `type env` to the question, as I tried to put them here and the block code formatting didn't work correctly.
type: QuestionComment
comment on: http://stackoverflow.com/q/78361451
score: 0

terraform
tags question: http://stackoverflow.com/q/78435782
type: Tag
tags question: http://stackoverflow.com/q/78366286
tag name: terraform
tags question: http://stackoverflow.com/q/78573908
tags question: http://stackoverflow.com/q/78490432
tags question: http://stackoverflow.com/q/79302612
tags question: http://stackoverflow.com/q/79450971

http://stackoverflow.com/comment/138297735
comment on: http://stackoverflow.com/q/78445411
has text: Anyhow -- a good place to start would be to demonstrate with a transcript `source` not working; since two of your three usage attempts are things that aren't expected to work in the first place, a transcript showing how you tested the one that _is_ expected to work would be a good place to start. Consider using `set -x` to enable trace logging, and possibly setting a PS4 that logs the PID of the current process so it can be determined when process boundaries are crossed.
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/138215756
score: 0
type: QuestionComment
type: Comment
has text: I didn't downvote but I'd guess it's mostly because you didn't provide your code attempt to solve the problem yourself and this forum exists to help people with their code, not as a free code writing service. Usually questions without code just get downovoted and closed without answers.
comment on: http://stackoverflow.com/q/78396373

http://stackoverflow.com/comment/138284019
score: 0
type: QuestionComment
has text: Does this answer your question? [How to return a string value from a Bash function](https://stackoverflow.com/questions/3236871/how-to-return-a-string-value-from-a-bash-function)
type: Comment
comment on: http://stackoverflow.com/q/78437288

http://stackoverflow.com/comment/138123410
comment on: http://stackoverflow.com/a/78343881
has text: Unfortunately, that last example will break unexpectedly off your script includes variable references. Using single quotes would help, but it is still problematic if your script itself requires multiple levels of quoting. Using a heredoc as shown in the answer avoids these problems.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/a/78445474
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78440831
type: Answer
answers question: http://stackoverflow.com/q/78440831
has body: Why are you bothering asking for the season number and number of episodes? Do you typically only want to compress some of the shows before deleting all of them? Why not just process all the files in the "input" directory to the "output" directory: #!/bin/bash echo "Warning! Please ensure before running this script that the files you'd like to convert are in the following format: 'series_name - SXXEYY' and mind that by running this script you're aware that the uncompressed files are going to be automatically deleted. If you change your mind press 'Ctrl + C' to cancel or press [ENTER] to continue:" read read -p "Enter destination of the input folder: " input read -p "Enter destination of the output folder: " output if [ ! -d "$input" ]; then echo "Error: $input is not a directory." exit 1 fi if [ ! -d "$output" ]; then echo "Error: $output is not a directory." exit 1 fi set -e # force the shell to exit if commands fail. for input_file in "${input}"/*; do output_file="$output"/$(basename "$input_file") ffmpeg -i "$input_file" -c:v libx264 -crf 22 -c:a copy -c:s copy -map 0 "$output_file" done rm -rf "$input" # clear # why do this? echo "Done :)" Notice that I put in some error checking, pretty important to do, since you are deleting data.

http://stackoverflow.com/comment/138257440
comment on: http://stackoverflow.com/a/78422867
score: 0
has text: Still the same error. Tried both `SHELL = /usr/local/bin/bash` and `SHELL= /usr/local/bin/bash`.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138172286
type: QuestionComment
has text: @Cloudlady Here is the thing: The process calling the bash instance which is supposed to interpret the. `&& ...` will be terminated - and so will be ALL it's child processes, including said bash instance.
comment on: http://stackoverflow.com/q/78373696
type: Comment
score: 0

http://stackoverflow.com/comment/138255184
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78421472
has text: The author of the question edited it. The initial error was `file not found`.

http://stackoverflow.com/comment/138201951
comment on: http://stackoverflow.com/a/78390677
type: Comment
has text: Try it. `cat < fifo &` and then `echo a >fifo` and `echo b>fifo` versus the `tail -f` version.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138253135
type: QuestionComment
has text: You could use the `pager` command within the MySQL client. You don't have to set it to `more` or `less` as pagers, you could use any filtering command. I often use it for `grep`.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78420308

http://stackoverflow.com/q/78336864
type: Question
has title: Bash: Comparing User Input To A String Isn't Working
score: 0
tagged with: shell
answer count: 0
tagged with: linux
has body: Here's the entire script: #!/bin/bash echo "enter name please:" read name echo "your name is $name." read randominput echo "Are you ok?" read feeling if ["$feeling" = "yes"] then echo "Nice!" fi When I run the script, everything works fine, until after the read feeling line. I then get this error: ./practice.sh: Zeile 9: [yes: Befehl nicht gefunden Which is german and means in eglisch something like: ./practice.sh: line 9: [yes: command not found If give it a different input, I get the same error, except [yes: is now [somethingelse: How do I fix this error? I was trying to write a script, where the user would have to answer a question, and an if statement would then decide the output depending on the answer. Thank you for the help in advance!
tagged with: bash
duplicate of: http://stackoverflow.com/q/9581064
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/9581064
has comment: http://stackoverflow.com/comment/138105895
has comment: http://stackoverflow.com/comment/138112696

http://stackoverflow.com/q/78376334
tagged with: shell
tagged with: linux
has body: I have terminal linux server (xrdp) and I need a script that will terminate the session and send the user to the login screen after completing the rdp connection OS: CentOS 8 I wrote this, but i sense i need something more #!/bin/bash if xfreerdp /v:"my-IP" /u:"my-user" /p:"pass" -f else gnome-session-quit fi The idea is this: The user starts his computer, logs into his account, the script runs automatically and connects it to the rdp session on the server. After the user finishes working, he completes the connection and the script sends it to the login screen. In fact, the user has little interaction with the installed OS on the computer
score: 1
upvote count: 1
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78376416
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78376416
downvote count: 0
tagged with: bash
has title: Bash script to close user session after a remote work
type: Question

http://stackoverflow.com/comment/138115340
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78342087
has text: @CharlesDuffy Thanks for the reply. As I said I am new to script and jq both. It's just a start. After getting the values I will create a `systemd` service with these values. Here I am just making sure that I am getting the correct values so in the service all work well. I am not getting the `@sh` thing. can you provide some link so I can take a look at it. Thanks
type: QuestionComment

unset
tag name: unset
tags question: http://stackoverflow.com/q/78445411
type: Tag
tags question: http://stackoverflow.com/q/79088930

http://stackoverflow.com/q/78348089
tagged with: django
has comment: http://stackoverflow.com/comment/138133847
score: 0
type: Question
has body: I set an environment variable here ~/.bashrc by adding export DJANGO_DEVELOPMENT=true the committing the changes with source ~/.bashrc Then I checked if the value was correctly wrote with echo $DJANGO_DEVELOPMENT --&gt;RESULT: true Now I'm simply triyng to accede this variabile during the server launch, so Django can figure out I'm in development and override the settings.py file with a settings_dev.py file. The code doing this in setting.py is: import os if os.getenv('DJANGO_DEVELOPMENT') == 'true': from .settings_dev import * The problem is that the server is always executed with DEBUG = False so I know as a fact that python is not reading properly the env. variable. I also double checked by putting a print(os.getenv('DJANGO_DEVELOPMENT')) but it's always None. Someone have any idea where my error is?
has comment: http://stackoverflow.com/comment/138127771
type: UnansweredQuestion
tagged with: python
answer count: 0
has comment: http://stackoverflow.com/comment/138126335
has comment: http://stackoverflow.com/comment/138126528
tagged with: bash
has title: Why does evaluating enviroment variable in setting.py does not work?

cpu-registers
tag name: cpu-registers
type: Tag
tags question: http://stackoverflow.com/q/78374908

http://stackoverflow.com/a/78319265
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78319248
upvote count: 1
has comment: http://stackoverflow.com/comment/138076756
type: Answer
has body: Thanks to @Cyrus and help from https://shellcheck.net, the answer turned out to be my own silliness... commas are not used as separators in bash arrays, so the following line: required_commands=('git', 'curl', 'sdfsdf', 'jq') results in four items, each ending in a , character. Oops.

http://stackoverflow.com/comment/138103246
comment on: http://stackoverflow.com/a/78335433
score: 0
type: Comment
type: AnswerComment
has text: I'm getting this error "java com.estudio.ejerciciosclase.sumScanner Error: Could not find or load main class com.estudio.ejerciciosclase.sumScanner Caused by: java.lang.ClassNotFoundException: com.estudio.ejerciciosclase.sumScanner "

http://stackoverflow.com/comment/138202759
has text: it works perfectly. However when I am trying append this to variable. it doesn't work something like this x+=`cat plan | sed -E 's/\"/\\"/g'`
type: Comment
comment on: http://stackoverflow.com/a/78392023
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138107661
has text: Are you sure it is in the package directory and already compiled it? Yes. I have tried the following: javac SumScanner.java Then to run it: java com.estudio.ejerciciosclase.SumScanner Error: Could not find or load main class com.estudio.ejerciciosclase.SumScanner Caused by: java.lang.ClassNotFoundException: com.estudio.ejerciciosclase.SumScanner
comment on: http://stackoverflow.com/a/78335433
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138290885
comment on: http://stackoverflow.com/q/78441743
score: 0
has text: `cut` doesn’t care about quotes. Use a proper CSV parser.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138297450
type: QuestionComment
comment on: http://stackoverflow.com/q/78444561
score: 2
type: Comment
has text: I'm guessing that if the command hangs, it is because it is waiting for the "server". Can you try 'ping'ing the server? If that doesn't work and you have access to PowerShell, try the following: `Test-NetConnection server -port 22` If the last line of output from that command is: `TcpTestSuccesseded: False` then you have a network issue.

http://stackoverflow.com/comment/138159311
has text: Check whether there's a slash or backslash in the string.
comment on: http://stackoverflow.com/q/78366773
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/138224429
comment on: http://stackoverflow.com/a/78403776
score: 0
type: Comment
has text: @CharlesDuffy well the test managed to reproduce OP's CPU issue, remove the sleep and the script will start using 100% cpu-of-1-core after the first successful read for some reason
type: AnswerComment

http://stackoverflow.com/comment/138088868
type: AnswerComment
type: Comment
score: 0
has text: Hey, echo is also a builtin. So did it also execute in the current shell? Also, could you provide any reference for what you said regarding `declare` being executed in the current shell?
comment on: http://stackoverflow.com/a/78325122

http://stackoverflow.com/comment/138159843
comment on: http://stackoverflow.com/q/78364618
score: 0
type: QuestionComment
type: Comment
has text: @kvantour OMG you're probably right! I didn't even think to try adding \r. :facepalm:

http://stackoverflow.com/comment/138270574
comment on: http://stackoverflow.com/a/78428136
has text: @kmt Sorry, answer edited:added reverse job in all 3 ways.
type: Comment
type: AnswerComment
score: 0

x86-64
tag name: x86-64
type: Tag
tags question: http://stackoverflow.com/q/78374908
tags question: http://stackoverflow.com/q/78830848

http://stackoverflow.com/comment/138101044
score: 0
has text: Are you using Gnu `find`? Then read in the man-page for _find_ the second (a bit lengthy) paragraph of the _OPTIONS_ section. `find` is, by its nature, a bit different from the usual Unix/Linux utilities, when it comes to filenames starting with a dash.
type: Comment
comment on: http://stackoverflow.com/q/78330653
type: QuestionComment

http://stackoverflow.com/a/78444615
type: Answer
answers question: http://stackoverflow.com/q/78444497
score: -1
has comment: http://stackoverflow.com/comment/138315462
has body: Troubleshoot Check for alias type python :it maybe an alias pointing to another version. Check your shell config file ~/.bashrc. Try pyenv versions if you have it installed. If not, try it for it is a great way to manage multiple versions. Set defaults and have project specific environments with different versions. Solution If none of the above work, ensure you have python 3.10 installed and do this: echo 'alias python3=python3.10' &gt;&gt; ~jenkins/.bashrc source ~jenkins/.bashrc Check with su jenkins python3 --version
downvote count: 1
upvote count: 0

http://stackoverflow.com/a/78351159
answers question: http://stackoverflow.com/q/78351058
downvote count: 0
score: 1
type: Answer
has body: Use an extglob: shopt -s extglob select d in !(sub_dir2|sub_dir4)/; do ...
upvote count: 1
has comment: http://stackoverflow.com/comment/138137161

http://stackoverflow.com/comment/138299179
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78444623
type: Comment
has text: have you actually *__tried__* the solution suggested in the linked duplicate? Something like `echo "$subject"` instead of `echo $subject`?

http://stackoverflow.com/q/78390318
tagged with: linux
downvote count: 0
tagged with: bash
type: Question
linked to: http://stackoverflow.com/q/28693737
accepted answer: http://stackoverflow.com/a/78392246
has answer: http://stackoverflow.com/a/78390677
has body: I have two programs (p1 and p2), and I need to connect the p1 output to p2 input, and the p2 output to p1 input. Is there a way to do this? The 'why' is because I have two programs that will play a game, so the first program will do a move and wait to receive a move from the other program and so on. The end of execution will be when the first program exit with signal 0 or 1. The program p1 will always be the same, but the p2 will change over every iteration. I need to do this in linux terminal, because the programs p1 and p2 can be (and probably will be) executed in different languages, like p1 will be c++ executable and p2 will be a python script.
has title: Is there a way to connect two programs output/input in linux?
has comment: http://stackoverflow.com/comment/138199666
has answer: http://stackoverflow.com/a/78391874
answer count: 4
has comment: http://stackoverflow.com/comment/138200216
has answer: http://stackoverflow.com/a/78392246
possible better answer: http://stackoverflow.com/a/78391874
score: 1
has answer: http://stackoverflow.com/a/78391686
upvote count: 1
favorite count: 0
type: AnsweredQuestion
tagged with: console

http://stackoverflow.com/comment/138237507
comment on: http://stackoverflow.com/q/78411166
has text: it sure is - always in programming
score: 0
type: QuestionComment
type: Comment

case
type: Tag
tags question: http://stackoverflow.com/q/78336037
tag name: case
tags question: http://stackoverflow.com/q/78454806
tags question: http://stackoverflow.com/q/78556921

http://stackoverflow.com/comment/138126152
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78346345
has text: I suspect what you're actually looking for is some measure of cyclomatic complexity, which you could accomplish pretty easily with [PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#genericmetricscyclomaticcomplexity). I'm not sure what use an actual physical line count is, but if you insist on that, PHPCS gives you the parsing framework to do so, you could write a fairly simple sniff to detect violations of your limit.
score: 0

http://stackoverflow.com/comment/138252757
type: Comment
type: AnswerComment
score: 0
has text: @MikhailT. you'd have to ask whoever provides `declare` why they made that choice. Looks like they decided to map any non-numeric string to zero and consider it a success - other tools such as awk do the same so it's not a crazy decision.
comment on: http://stackoverflow.com/a/78419189

system
tag name: system
type: Tag
tags question: http://stackoverflow.com/q/78388693

http://stackoverflow.com/a/78390580
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/78390223
has body: If your find has -quit, instead of piping into xargs and bash: ... find v2/services -type f -regex ".*$${filter}.*.jsonnet" -print0 | \ xargs -r -0 -I {} bash -c 'echo -e "\033[1;32mjsonnet {} \033[0m"; jsonnet {} || exit $$?' ... just use find's -exec option and then you can test its return directly: ... find v2/services -type f -regex ".*$${filter}.*.jsonnet" \ -printf '\033[1;32mjsonnet %p \033[0m\n" \ \( -exec jsonnet {} \; -o -quit \) ... Note that the return value will follow find's specification. For the GNU version, this is: find exits with status 0 if all files are processed successfully, greater than 0 if errors occur. This is deliberately a very broad description, but if the return value is non-zero, you should not rely on the correctness of the results of find. The value will be non-zero if -quit is invoked but can be non-zero even if all jsonnet processes succeeded. (e.g. unreadable directory that find could not enter)
score: 3
type: AcceptedAnswer
upvote count: 3
has comment: http://stackoverflow.com/comment/138208902
accepted answer of: http://stackoverflow.com/q/78390223

http://stackoverflow.com/comment/138268467
has text: Please add `echo "$BASH_VERSION"` to your script and then add that output to your question so we can see which bash version you're running when you source the script. The shebang at the top, `#!/bin/bash` will be ignored when sourcing it btw, the code will run under whichever shell you're running when you source the file. Also, `echo "$SHELL"` just tells us your default shell, it doesn't tell us which shell is currently running.
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
score: 2
type: Comment

http://stackoverflow.com/comment/138084588
comment on: http://stackoverflow.com/q/78324242
score: 0
type: QuestionComment
has text: You need to share more details, I have never saw that error, but I also have no idea what you are talking about, share the full error (as text), share what you are running literally, inside what, etc.
type: Comment

http://stackoverflow.com/comment/138296089
has text: `type system_profiler` should tell you.
score: 0
comment on: http://stackoverflow.com/q/78444401
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138178847
has text: Most likely it's the spawned program that does it. It may have different behaviours if it detects it's not connected to a "real" terminal.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78373722
type: Comment

http://stackoverflow.com/comment/138190590
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78385269
type: Comment
has text: link to `env-setup.sh`: [https://file.io/RmH5HduHxh9M](https://file.io/RmH5HduHxh9M) link to `en-setup-ioannnis.sh`: [https://file.io/qPd2LgHbXCPX](https://file.io/qPd2LgHbXCPX)

http://stackoverflow.com/comment/138139393
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78351708
has text: +1 Your _forked_ vs. _script_ differentiation does seem to explain this 100%. However, I still am unable to find any documentation that states this differentiation. In the `man bash` snippets you quoted, both use the same phrase "most-recently-executed foreground pipeline".
score: 1

http://stackoverflow.com/comment/138207367
score: 0
has text: The fact that you got an error message from curl actually demonstrates that it does work, but you have an error with your `${requestURL}`.
type: Comment
comment on: http://stackoverflow.com/a/78384589
type: AnswerComment

http://stackoverflow.com/a/78373052
upvote count: 1
answers question: http://stackoverflow.com/q/78372639
has comment: http://stackoverflow.com/comment/138169602
downvote count: 0
has comment: http://stackoverflow.com/comment/138169477
type: Answer
has body: sed alone is not very good for this kind of operations. Assuming that all your versions are in a single line, and that line is always the exact line below the [version] tag, this script should fix it: #!/bin/bash # Define the value to append value_to_append="$1" # Path to the configuration file config_file="app.config" # Find list of versions, which is the line below the [version] tag line_number=$(($(grep -n "\[version\]" "$config_file" | cut -d':' -f1) + 1)) version_list=$(sed -n "${line_number}p" "$config_file") # Deconstruct the list from single line to multi-line, add the new version, sort the list, and reconstruct the list as single line new_version_list=$(printf -- %s "$version_list" | sed -E -e 's/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/\n&/g' -e "1i ${value_to_append}, " | sort -V | tr -d '\n') # Replace the value at line_number sed -i -e "${line_number}i ${new_version_list}" -e "${line_number}d" "$config_file" Side notes The script will sort version numbers which were not sorted beforehand. In your app.config example, the version list ended with 1.2.3.0, 1.3.0.0, 1.2.3.1, which is not sorted beforehand, and will be sorted afterwards. The script does not support multi-line lists if e.g., the version list line ends with \. This is the case in your example, so I assume you may need to deal with it. If you run the script multiple times in a row, the new version number will be written multiple times. This can be fixed easily by replacing sort -V with sort -V | uniq but doing so will also remove existing duplicates of versions already there.
has comment: http://stackoverflow.com/comment/138169969
score: 1

http://stackoverflow.com/comment/138183883
type: QuestionComment
comment on: http://stackoverflow.com/q/78381387
type: Comment
has text: Try this `jq --arg md "blablabla" '. + {content: $md}'`
score: 1

http://stackoverflow.com/comment/138204807
comment on: http://stackoverflow.com/q/78393091
has text: This is like asking "What's the difference between painting and painting with oil?"
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138239365
score: 2
has text: @peak According to this [Bash changelog](https://tiswww.case.edu/php/chet/bash/NEWS), `@K` (all pairs quoted in one word) was added in 5.1 (see 5.1.hh), but `@k` (each item as separate words, which is used here) was added in 5.2 (see 5.2.t)
type: Comment
comment on: http://stackoverflow.com/a/78411906
type: AnswerComment

http://stackoverflow.com/a/78320229
has comment: http://stackoverflow.com/comment/138078732
type: Answer
has comment: http://stackoverflow.com/comment/138079114
upvote count: 2
has comment: http://stackoverflow.com/comment/138078729
has comment: http://stackoverflow.com/comment/138076799
has comment: http://stackoverflow.com/comment/138078724
has body: As a wise man commented below it says in the pgrep manpage: The pattern is normally only matched against the process name. When -f is set, the full command line is used. This made you assume (quite understandably) that the process running is /bin/bash, however, if you run a short test you can see that this is not the case. If we create a test script called test.sh that looks like this: #!/bin/bash -x ps echo "Current PID is $$" ps -p $$ pgrep "test" And if we then run chmod +x test.sh we can run the script twice, once with bash, and once without, and see the result: user@machine:/tmp$ /tmp/test.sh + ps PID TTY TIME CMD 685214 pts/6 00:00:00 bash 737744 pts/6 00:00:00 test.sh 737745 pts/6 00:00:00 ps + echo 'Current PID is 737744' Current PID is 737744 + ps -p 737744 PID TTY TIME CMD 737744 pts/6 00:00:00 test.sh + pgrep 737744 + pgrep test 737744 user@machine:/tmp$ bash /tmp/test.sh PID TTY TIME CMD 685214 pts/6 00:00:00 bash 737749 pts/6 00:00:00 bash 737750 pts/6 00:00:00 ps Current PID is 737749 PID TTY TIME CMD 737749 pts/6 00:00:00 bash If we want to go a bit deeper we can look in the source code for pgrep here where we can see in library/include/readproc.h that they use /proc/#/cmdline so we can now test that. We'll create a test2.sh file: #!/bin/bash -x echo "Current PID is $$" pgrep -a "test" echo "/proc/$$/cmdline is $(cat /proc/$$/cmdline)" And after running chmod +x test2.sh we do both test2.sh and bash test2.sh and see: user@machine:/tmp/procps$ /tmp/test2.sh + echo 'Current PID is 10085' Current PID is 10085 + pgrep -a test 10085 /bin/bash -x /tmp/test2.sh ++ cat /proc/10085/cmdline /tmp/test2.sh: line 5: warning: command substitution: ignored null byte in input + echo '/proc/10085/cmdline is /bin/bash-x/tmp/test2.sh' /proc/10085/cmdline is /bin/bash-x/tmp/test2.sh user@machine:/tmp/procps$ bash /tmp/test2.sh Current PID is 10089 /tmp/test2.sh: line 5: warning: command substitution: ignored null byte in input /proc/10089/cmdline is bash/tmp/test2.sh So …
has comment: http://stackoverflow.com/comment/138079118
has comment: http://stackoverflow.com/comment/138079001
has comment: http://stackoverflow.com/comment/138078574
answers question: http://stackoverflow.com/q/78319238
has comment: http://stackoverflow.com/comment/138078963
has comment: http://stackoverflow.com/comment/138078756
downvote count: 2
score: 0

http://stackoverflow.com/comment/138148944
type: QuestionComment
type: Comment
has text: we want a partial match in for presto-data1 , so even machine name is presto-data1-01 or presto-data1-02 , etc then the regex will be match satisfied with presto-data1
comment on: http://stackoverflow.com/q/78361035
score: 0

http://stackoverflow.com/comment/138680127
has text: @anatolyg I don't think I understand your comment. Do you think you elaborate? Thank you.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78409475

http://stackoverflow.com/comment/138221477
score: 0
comment on: http://stackoverflow.com/a/78396833
has text: I'm having a hard time believing that `printf` on it's own works in any context in any awk but if you have a version of awk that doesn't fail with a syntax error given `printf` on it's own then you need to get a different awk because if your current one has that bug then it probably has other bugs too.
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78432319
type: Answer
score: 0
has body: I tried to make this work with filter-branch, but totally failed due to the current commit not being available in the filters. It might be possible with git filter-repo --commit-callback. So my next attempt was to git rebase. It should be possible to come up with a custom GIT_SEQUENCE_EDITOR which modifies the todo list accordingly, but I went for a solution that's a bit more hacky: git rebase -x. It's inefficient, but it gets the task done. $ cat >edit.sh <<'EOF' #!/bin/sh head="$(git rev-parse HEAD)" if ! git rev-parse -q --verify HEAD^ >/dev/null; then echo "Ignoring root commit $head" >&2 exit 0 fi if ! git diff --exit-code HEAD^ HEAD -- ':!github-metrics.svg' >/dev/null; then # changes in other files, keep commit echo "Other files changed, keeping commit $head" >&2 exit 0 fi if git diff -U0 HEAD^ HEAD -- 'github-metrics.svg' | tail +6 | grep -qv 'Last updated .* with lowlighter/metrics@.*'; then # other lines changed in metrics svg, keep commit echo "Other lines in metrics file changed, keeping commit $head" >&2 exit 0 fi # only timestamp was updated, drop commit echo "Only timestamp changed, dropping commit" >&2 git reset --soft HEAD^ git commit --amend --no-edit exit 0 EOF $ chmod +x edit.sh $ git rebase -x ./edit.sh This creates a todo list similar to the following: pick 7d03915c Commit message one exec ./edit.sh pick 9de881c4 Commit message two exec ./edit.sh pick 0b0e07b8 Commit message three exec ./edit.sh pick 038655e9 Commit message four exec ./edit.sh pick ade63693 Commit message five exec ./edit.sh pick 43f578d2 Commit message six exec ./edit.sh After each commit, the script is executed. It performs the following steps in order: Is it a root commit (i.e. doesn't have a parent)? → Don't do anything, keep commit Does the commit change files other than github-metrics.svg? → Don't do anything, keep commit Does the commit change other lines than the "Last updated" line in the svg? → Don't do anything, keep commit All prior checks failed. This means that on…
answers question: http://stackoverflow.com/q/78378370

http://stackoverflow.com/comment/138265959
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78422398
has text: fyi for future questions: [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551)

syntax-error
type: Tag
tags question: http://stackoverflow.com/q/78427118
tag name: syntax-error

http://stackoverflow.com/comment/138270239
has text: @CharlesDuffy, the script produces the expected output using bash on ideone.com. That output indicates `GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)`. I don't see any way to control the version of bash used there.
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
type: Comment
score: 0

exit-code
type: Tag
tags question: http://stackoverflow.com/q/78351657
tag name: exit-code
tags question: http://stackoverflow.com/q/78823127
tags question: http://stackoverflow.com/q/78790696
tags question: http://stackoverflow.com/q/79027290
tags question: http://stackoverflow.com/q/79182624

http://stackoverflow.com/comment/138119414
type: QuestionComment
has text: Re `^M`, see [my comment on these](https://stackoverflow.com/questions/78294275/awk-as-seen-by-emacs-m-at-the-end-of-some-fields-and-i-am-struggling-to-remove#comment138030818_78294275) . I think the `$'\n'` below is the right answer, but if you want `^M` processing, I recommend you set up the smallest test possible in a separate test script to get it working. Good luck.
comment on: http://stackoverflow.com/q/78344372
score: 0
type: Comment

http://stackoverflow.com/comment/138073622
comment on: http://stackoverflow.com/a/78318299
type: Comment
type: AnswerComment
score: 2
has text: Not just that, but (while it's not my downvote either) this is simply nonresponsive; question asked for an answer "in bash". What are we going to do next, start answering Java questions with C answers because it's possible to run C programs from Java? _At least_ show how to embed the Python script inside a shell script -- `python3 -c '` at the top and a closing single quote at the bottom would be making at least a gesture towards trying to follow the bounds of the question as asked.

http://stackoverflow.com/a/78420840
answers question: http://stackoverflow.com/q/78420131
type: Answer
has comment: http://stackoverflow.com/comment/138254705
has body: Does the echo command in Bash shell ever write anything to stderr without an explicit redirect of the output? Yes. Proof by example: #!/bin/bash exec &gt;&amp;- echo hello /bin/echo world Result showing both Bash builtin echo and GNU external echo writing to stderr: foo: line 3: echo: write error: Bad file descriptor /bin/echo: write error: Bad file descriptor Similar effects and situations can be achieved through broken pipes, full disks, and disconnected terminals. But really, adding &gt;&gt; log 2&gt;&amp;1 to every command is an antipattern. Whatever invokes the script should be responsible for redirecting any output to a log file.
score: 4
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/138254261
has comment: http://stackoverflow.com/comment/138255571
has comment: http://stackoverflow.com/comment/138254158

http://stackoverflow.com/comment/138170895
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78373828
type: Comment
has text: You don't have any pipelines, why is `pipefail` in the snippet?

http://stackoverflow.com/comment/138170724
has text: `echo task.sh | at now` can be used to execute commands in an external way, but there's something wrong with the initial approach, so as it said above better to consider other options
comment on: http://stackoverflow.com/q/78373696
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138057614
type: Comment
type: AnswerComment
has text: @Guildenstern: It works well enough in practice.
score: 0
comment on: http://stackoverflow.com/a/78308972

http://stackoverflow.com/comment/138223895
score: 0
comment on: http://stackoverflow.com/a/78400214
has text: Thanks for this, it is a very rapid and detailed response! I'll save this away for future reference.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138238226
has text: I've changed to `jq -r 'input_filename + (.Blocks | map(", " + select(.Dmo == "Path").Value)[] // "")' file` to process one file and in the output shows the filename without full path like this `filename, /Files/2024/abd`. Then, If I run that command inside a for loop, instead of the filename with path I get `<stdin>, /Files/2024/abd`
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78411741
score: 0

http://stackoverflow.com/comment/138116913
type: Comment
type: AnswerComment
has text: @CharlesDuffy it trades performance for peace of mind. Given the shell context it is a good deal.
comment on: http://stackoverflow.com/a/78341268
score: 0

http://stackoverflow.com/a/78411195
downvote count: 0
answers question: http://stackoverflow.com/q/78411166
has body: How about this? Positive lookahead for u, then match 4+ characters? grep -P '^(?=.*u)[bluntam]{4,}$' /usr/share/dict/words https://regex101.com/r/7UM5Yr/2
score: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138238936
has comment: http://stackoverflow.com/comment/138242627
upvote count: 3
has comment: http://stackoverflow.com/comment/138242614
type: Answer
accepted answer of: http://stackoverflow.com/q/78411166

http://stackoverflow.com/a/78422089
has body: Whenever you have tag-value pairs in your input, as in this case, I find it best to first create an array mapping tags (e.g. "DTSTART") to their associated values (v[] below) and then you can compare, print, modify whatever values you like just by indexing the array by the appropriate tag. Using any POSIX awk: $ cat tst.sh #!/usr/bin/env bash today=$(date +%Y%m%d) # replace this `cat` with your `curl` command cat input.txt | awk -v date="$today" ' { if ( match($0,/^[[:upper:]]+:/) ) { tag = substr($0,RSTART,RLENGTH-1) v[tag] = substr($0,RSTART+RLENGTH) } else { v[tag] = v[tag] ORS $0 } } /^END:VEVENT/ { if ( v["DTSTART"]+0 == date ) { print "start:" dfmt(v["DTSTART"]) print "end:" dfmt(v["DTEND"]) print "SUMMARY:" v["SUMMARY"] ORS v["DESCRIPTION"] ORS } delete v } function dfmt(date) { return \ substr(date,10,2) ":" \ substr(date,12,2) } ' The above would work even if your input contained multi-line DESCRIPTION or any other field (assuming it conforms to RFC 5545), e.g. given this modified version of the input provided by @azbarcea: $ cat input.txt BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Example Corp.//iCal4j 1.0//EN CALSCALE:GREGORIAN BEGIN:VEVENT DTSTAMP:20240502T120000Z DTSTART:20240503T090000Z DTEND:20240505T100000Z SUMMARY:Team Meeting DESCRIPTION:Weekly team meeting to discuss progress and upcoming tasks. LOCATION:Conference Room UID:1234567890 SEQUENCE:0 END:VEVENT BEGIN:VEVENT DTSTAMP:20240502T120000Z DTSTART:20240510T140000Z DTEND:20240510T160000Z SUMMARY:Client Presentation DESCRIPTION: Present our latest project updates to the client. LOCATION:Client's Office UID:0987654321 SEQUENCE:0 END:VEVENT END:VCALENDAR We would get this output: $ ./tst.sh start:09:00 end:10:00 SUMMARY:Team Meeting Weekly team meeting to discuss progress and upcoming tasks. Obviously you can tweak it to adjust the white space and/or output date format however you like and I'm combining the SUMMARY and DESCRIPTION parts in one output block since that's what the code in the question doe…
upvote count: 2
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/78419985
score: 2

http://stackoverflow.com/comment/138235456
type: QuestionComment
type: Comment
has text: @JohnBollinger I am not sure I follow your second comment. The if-line executes whisper on a file, similar to `cat my.txt`would do. If whisper fails, shouldn't it return a non-zero value, a value which could be branched upon (using if)?
comment on: http://stackoverflow.com/q/78409475
score: 0

http://stackoverflow.com/comment/138127903
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78344372
score: 0
has text: @user1934428 Thanks for being so attentive; I didn't really care about that particular while loop other than to just keep looping. And yeah, left out that pesky dollar sign! I was focused on the case statement. ... I would NEVER have thought to look to ANSI C quoting for this. I guess we're just supposed to know BASH follows that standard, probably because it's well known to programmers. ...I wish I'd have taken BASH more seriously as a programming language back some 30+ years ago when I started using it daily!

http://stackoverflow.com/q/78404233
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138226999
type: UnansweredQuestion
has body: I'm trying to modify a file in such a way that line number 10 is merged to line number 9. For instance my file looks like: a b c d e f g h this is line nine and this is line ten i j And I would like a new file like this: a b c d e f g h this is line nine and this is line ten i j How can I merge two specific lines of a file? Also, since the file has a huge number of lines, would it be possible to avoid reading the whole file? I tried to use echo $(cat filename) but it doesn't seem to work and it would also modify the whole file, not only lines 9 and 10.
has comment: http://stackoverflow.com/comment/138224676
has comment: http://stackoverflow.com/comment/138224602
linked to: http://stackoverflow.com/q/47347269
has comment: http://stackoverflow.com/comment/138224584
answer count: 2
has comment: http://stackoverflow.com/comment/138224632
has answer: http://stackoverflow.com/a/78404326
tagged with: bash
has title: Merge two lines of a file
has answer: http://stackoverflow.com/a/78405627

http://stackoverflow.com/comment/138258095
has text: Your first code block cannot be generated by jq. Either you get square brackets with commas or no brackets and no commas.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78422524
score: 0

http://stackoverflow.com/q/78385555
answer count: 1
tagged with: bash
type: Question
has body: I have an internal SLES repo that contains numerous packages/dependencies - they are stored under various sub directories like src, noarch, x86_64, etc. I also have a list of packages/dependencies that are needed - I am trying to check if the packages/dependencies I have in my file are stored/can be found in my internal SLES repo. If it does exist, then skip that line in the file, if it doesn't exist then save this line to a new file so that I can any and all missing packages/dependencies. I have tried a few things now, such as: SLES_ALIAS=<repo-alias> MY_REPO=<some/url/internal-sles-repo> repo_pkg_list="../repo/required_pkgs.list" missing_pkg_list="../repo/missing_cbo_pkg.list" while IFS= read -r rpm; do found=false for subdir in noarch src x86_64; do if curl --output /dev/null --silent --head --fail "$MY_REPO/$subdir/$rpm"; then found=true break fi done if ! $found; then echo "RPM not found: $rpm" fi done < "$repo_pkg_list" So I'm trying to go through each subdir in MY_REPO and check for the .rpm listed in my file. My file and the the rpms in MY_REPO appear as so: expat-2.4.4-150400.3.17.1.x86_64.rpm filesystem-15.0-11.8.1.x86_64.rpm fillup-1.42-2.18.x86_64.rpm findutils-4.8.0-1.20.x86_64.rpm fontconfig-2.13.1-150400.1.4.x86_64.rpm fonts-config-20200609+git0.42e2b1b-150000.4.10.1.noarch.rpm gawk-4.2.1-150000.3.3.1.x86_64.rpm I have also tried: while IFS= read -r line; do package_found=false for subdir in x86_64 src noarch; do if zypper --non-interactive-download "$MY_REPO$line"; then echo "Downloaded: $line" else echo "$line" >> "$missing_pkg_list" echo "Failed to download: $line, adding to $missing_pkg_list" fi done done < "$repo_pkg_list"
type: UnansweredQuestion
has title: Check if an .rpm file exists in a repo/location based on contents of a file
has answer: http://stackoverflow.com/a/78403471
has comment: http://stackoverflow.com/comment/138214096
score: 0

unify
tag name: unify
tags question: http://stackoverflow.com/q/78444070
type: Tag

http://stackoverflow.com/comment/138149885
type: QuestionComment
type: Comment
has text: It does it on two separate installs of Termux on two different versions of Android, installed today.
comment on: http://stackoverflow.com/q/78361451
score: 0

http://stackoverflow.com/comment/138119455
comment on: http://stackoverflow.com/q/78344372
has text: @shellter I WOULD like to write in a way that takes into consideration "portability," and VERY much appreciate the link. But I'd be a LOT happier if someone would explain why the $ in front of the tick-quoted \n works when the double-quoted, NOT dollar-sign prefaced version does not!
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138251345
has text: Also, although `elif` could help you simplify your function, I would probably use a `case` statement, myself, instead of an `if` / `elif` / `else` statement.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78419450
type: QuestionComment

http://stackoverflow.com/comment/138529187
score: 0
comment on: http://stackoverflow.com/a/78368630
has text: I ran into a problem with devices that have long enginID's using this method. ```SNMP-FRAMEWORK-MIB::snmpEngineID.0 = Hex-STRING: 80 00 92 C4 04 53 4E 2D 35 33 32 30 36 30 37 33 31``` is the string, which wraps. So $hex drops the last two characters ```hex for Device_FQDN is 80 00 92 C4 04 53 4E 2D 35 33 32 30 36 30 37 33``` how can I capture the last 31? Apologies for the crappy formatting, I haven't figured out comments yet.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138137470
has text: @GoinOff It seems that `watch` is doing the `\n` conversion, not `echo`. When I run that command outside `watch` they show up literally.
comment on: http://stackoverflow.com/q/78349529
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/q/78427625
has body: Please, observe: mark@L-R910LPKW:~$ f(){ set -euo pipefail ; git statu; echo $?; } &amp;&amp; f &amp;&amp; echo OK ; set +euo pipefail git: 'statu' is not a git command. See 'git --help'. The most similar commands are status stage stash 1 OK mark@L-R910LPKW:~$ The command is f(){ set -euo pipefail ; git statu; echo $?; } &amp;&amp; f &amp;&amp; echo OK ; set +euo pipefail My question is - why does the function f NOT abort right after failing to run git statu? Running the command clearly shows that git statu failed with exit code 1, but still proceeds further to echo $? instead of aborting as requested by set -e.
has answer: http://stackoverflow.com/a/78427821
type: Question
has title: Does bash abort on error work inside a function?
has comment: http://stackoverflow.com/comment/138269682
score: 1
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138266106
downvote count: 0
tagged with: bash
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78427821

http://stackoverflow.com/a/78362961
has body: Try to replace your code with this one : sed -i -e 's/^\(#*\)PermitRootLogin *(yes|no)/PermitRootLogin no/g' /etc/ssh/sshd_config Sincerely.
answers question: http://stackoverflow.com/q/78362867
has comment: http://stackoverflow.com/comment/138151926
type: Answer
score: 0

unzip
type: Tag
tags question: http://stackoverflow.com/q/78372933
tag name: unzip
tags question: http://stackoverflow.com/q/78578346
tags question: http://stackoverflow.com/q/78834215
tags question: http://stackoverflow.com/q/79325829

http://stackoverflow.com/comment/138269972
comment on: http://stackoverflow.com/a/78429634
score: 1
type: Comment
has text: When you `unset` an array element you reduce the number of elements (`${#array[@]}` in this case) by one, so the loop terminates before it gets to the maximum array index. One way to fix the problem is to iterate on the list of array indexes (`for i in "${!array[@]}"; do ...`).
type: AnswerComment

http://stackoverflow.com/a/78438921
has comment: http://stackoverflow.com/comment/138286490
answers question: http://stackoverflow.com/q/78434093
score: 0
has body: Besides the problem with count increment as was told in the comments and the previous answer, the are more bug in your code. You read username and password outside the loop, so there are no three attempts. You do not exit the loop when correct username/password are entered. Erratic spaces in equality checks. Overcomplicated logic. The script that checks for username/password no more than 3 times may be like: myusername="cloud_user" mypassword="userisawesome" for count in {1..3} do read -p "Username: " username read -p "Password: " password #you can use -s to have invisible input if "$username" = "$myusername" && "$password" = "$mypassword" then echo "$HOME $TERM" exit 0 fi done exit 1 #you can add error message before this line.
has comment: http://stackoverflow.com/comment/138286640
type: Answer

http://stackoverflow.com/comment/138112381
type: Comment
comment on: http://stackoverflow.com/q/78336169
score: 0
has text: I haven't tried it, but I guess that `-l` sets the working directory to your $HOME, even if there is no explicit `cd` in `/etc/profile` or `~/.bash_profile`.
type: QuestionComment

http://stackoverflow.com/a/78396041
has body: The issue seems to be with installing gnupg. This is most likely because the repositories which the APT package sources burned in to image point to don't have gnupg1. You should try: In your script line sudo apt install -y apt-transport-https ca-certificates curl gnupg software-properties-common, change gnupg to gnupg2. Add the bullseye main repository to APT sources. Add the following lines to the top of your script: # Add Debian APT package source sudo sh -c 'echo "deb https://deb.debian.org/debian/ bullseye main" >> /etc/apt/sources.list' sudo sh -c 'echo "deb-src https://deb.debian.org/debian/ bullseye main" >> /etc/apt/sources.list' # Update sources sudo apt update Step 2 should only be requires if step 1 doesn't work on its own.
has comment: http://stackoverflow.com/comment/138215569
score: 0
answers question: http://stackoverflow.com/q/78393852
type: Answer

http://stackoverflow.com/comment/138254672
has text: you set and clear `inEvent` but never reference it; can `DTSTART` and `DTEND` occur outside of a `BEGIN:VEVENT / END:VEVENT` pair?
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78419985

http://stackoverflow.com/comment/138275235
type: QuestionComment
comment on: http://stackoverflow.com/q/78432948
type: Comment
has text: script waits for `sleep`, no?
score: 0

http://stackoverflow.com/comment/138191220
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78385537
has text: How do you run the script? Have you checked what causes the node.js process to terminate (perhaps using a tool like strace)?
score: 0

http://stackoverflow.com/comment/138292447
has text: In case your CSV is more complex than what you show in your question, I edited my answer to show how to use the `--csv` option of recent versions of GNU `awk`.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78441170

http://stackoverflow.com/a/78398734
answers question: http://stackoverflow.com/q/78396373
has body: TXR job: $ txr extract.txr data.html Channel Index Channel ID 1 10 2 1 3 2 4 3 Code in extract.txr: @(skip) @nilDownstream Channel Status@nil @(repeat) <tr@nil <td@td1 <td@td2 @ (do (put-line `<td@td1<td@td2`)) @(until) @nil @(end) We could put the curl command right into the program.
type: Answer
score: 0

http://stackoverflow.com/comment/138122626
comment on: http://stackoverflow.com/q/78346345
type: QuestionComment
type: Comment
score: 0
has text: depending on the variability of the code, it might not be achievable with line oriented processing tool like awk or sed. It may require to use a proper parser. Maybe something like semgrep.

http://stackoverflow.com/comment/138228526
comment on: http://stackoverflow.com/q/78403621
score: 0
has text: Please edit your question and explain how you pass the input data to your **while loop**, not to the "FIFO file".
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138233347
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78390328
has text: I don't understand what you mean with the "daemon while true". If you mean the second version, then, yes all traps should be processed.

http://stackoverflow.com/comment/138102062
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78334609
has text: Updated. Replacing all lines containing particular source branch should be ok.
type: Comment

http://stackoverflow.com/comment/138126528
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78348089
has text: Sure, when I launch the server my script is just "./manage.py runserver".
score: 0

http://stackoverflow.com/comment/138224351
has text: @CharlesDuffy tested like this https://paste.debian.net/plain/1315542
comment on: http://stackoverflow.com/a/78403776
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138260936
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78424828
score: 0
has text: @oguzismail this password is encrypted password which we will be passing. and also its 38 character length so will be difficult to pass, user, will pass it in script and run that script on 100 of server for automation, we can not pass as tty

http://stackoverflow.com/a/78335552
type: Answer
score: 0
has body: This might work for you (GNU sed): sed -E "/^- stage: 'qa'/{:a;N;/^\s*\)$/M"\!"ba s/(dependsOn:[^-]*- )\S+/\1build/ s#(SourceBranch'], )'[^']*'#\1'refs/head/main'#}" file Make a collection of the qa stage and then use substitution and back references to achieve the desired result. N.B. The use of double quotes to enclose the sed commands. This makes it easier to include single quotes for matching and substitution. However it also causes the shell to do unexpected things, so the negation (!) needs to be escaped (see /.../M"\!"ba ) otherwise shell history is invoked. Also note the use of M flag when matching the end of stage collection.
answers question: http://stackoverflow.com/q/78334609

http://stackoverflow.com/comment/138148487
has text: @knittl That indead is a solution. But isn't there a solution directly with printf to avoid the loop ?
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78360964

http://stackoverflow.com/comment/138104543
type: QuestionComment
type: Comment
has text: @user85421: good catch. `-cp`or `-classpath` *must* be set to the value `build/classes` with what I recommended or it will fail.
comment on: http://stackoverflow.com/q/78335326
score: 0

http://stackoverflow.com/comment/138202669
comment on: http://stackoverflow.com/q/78392006
type: QuestionComment
has text: `tr` only does 1-to-1 replacements, it can't replace 1 character with multiple characters.
score: 2
type: Comment

http://stackoverflow.com/a/78429959
has body: Attempting to parse JSON with grep+cut or anything that wasn't built to handle JSON is futile. Running the following line through your pipeline grep sessionId | cut -d ":" -f2 | tr -d "\r\n\",": "sessionId": "b67e09ac-ef3f-4b01-8aba-353436770fc9", will print b67e09ac-ef3f-4b01-8aba-353436770fc9 with a leading space character. Your next mistake was to expand unquoted parameters. curl -X DELETE http://127.0.0.1:4444/session/$SESSION will expand to: curl -X DELETE http://127.0.0.1:4444/session/ b67e09ac-ef3f-4b01-8aba-353436770fc9 can you see the space? However, running curl -X DELETE http://127.0.0.1:4444/session/$(echo $SESSION) will expand to curl -X DELETE http://127.0.0.1:4444/session/$(echo b67e09ac-ef3f-4b01-8aba-353436770fc9) can you still see the space? Which will then expand to: curl -X DELETE http://127.0.0.1:4444/session/b67e09ac-ef3f-4b01-8aba-353436770fc9 It is crucial to quote parameters when expanding to avoid all sorts of surprises (field splitting, pathname expansion). But for your concrete problem, the best action to take is not to parse JSON with tools that were never meant to parse JSON. Use tools built specifically for parsing JSON, such as jq: session="$(… | jq -r '.sessionId')" (yes, those quotes are redundant, but it's a good habit to always quote expansions) The rules which expansions occur in which order are specified in section 2.6 Word Expansions of the POSIX standard.
type: Answer
downvote count: 0
score: 3
answers question: http://stackoverflow.com/q/78428595
type: AcceptedAnswer
upvote count: 3
accepted answer of: http://stackoverflow.com/q/78428595

http://stackoverflow.com/a/78375055
downvote count: 0
type: Answer
score: 7
upvote count: 7
has body: A "file-handle" is just a number of the file descriptor. In the case of stdin it is 0. In the case of filename, you can open the filename to receive a handle to it. stdin=0 if some-condition; then exec {stdin}<some-filename fi run-command <&"${stdin}" Using eval is evil. Do not use it. Prefer lower case variables for script-local variables. You can read about exec {var}>file in bash documentation second paragraph of https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Redirections . Check your scripts with shellcheck. You can read about file descriptors even on wiki https://en.wikipedia.org/wiki/File_descriptor . You could also, if you do not care about origin stdin, just replace it depending on condition, which would simplify to just: if some-condition; then exec 0<some-filename fi run-command exec 0<&- # close it if you want
answers question: http://stackoverflow.com/q/78375007

vmware
tag name: vmware
type: Tag
tags question: http://stackoverflow.com/q/78344853

http://stackoverflow.com/comment/138170875
type: QuestionComment
has text: `set -e` doesn't have an effect when you're testing a command using `if` or the logical operators `&&` and `||`. It's in the documentation.
type: Comment
score: 3
comment on: http://stackoverflow.com/q/78373828

http://stackoverflow.com/comment/138095104
comment on: http://stackoverflow.com/q/78330348
has text: `LC_ALL=C find . -type f -name '*.jenkinsfile' -exec sed -i '.orig' "s/'\(product-ui-test-creds\.json'\)/'vaulted-\1/g" {} +`
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138134885
type: QuestionComment
type: Comment
score: 1
has text: `files` is a bash array. You can't pass bash arrays as parameters to a child process. How should this work?
comment on: http://stackoverflow.com/q/78353017

http://stackoverflow.com/comment/138234725
score: 0
type: QuestionComment
type: Comment
has text: BTW, if the child daemonizes the loop _will_ end, because self-daemonization (which is, as an aside, bad practice in the modern world) involves doing a fork and having the initially-created process exit -- you get a grandchild in the background, but the direct child is exited.
comment on: http://stackoverflow.com/q/78409749

http://stackoverflow.com/comment/138151926
comment on: http://stackoverflow.com/a/78362961
score: 0
has text: That did not work for me. It still leaves `#PermitRootLogin no`
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138119698
type: Comment
type: AnswerComment
has text: @RichardT look up the bash manual on "ANSI-C Quoting" ... https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
comment on: http://stackoverflow.com/a/78344420
score: 1

http://stackoverflow.com/a/78331936
answers question: http://stackoverflow.com/q/78331935
has body: TL;DR: (set -o pipefail &amp;&amp; &lt;your command&gt;) The answer I've been looking around SO and I found a few answers to this question. I will start with the shortest one, replace your turbo run lint | sed 's/\/out//g' with: (set -o pipefail &amp;&amp; turbo run lint | sed 's/\/out//g') This will switch your shell into the mode where exit codes are no longer swallowed by pipe operator (just for this one command). If you do not mind switching your whole script into this mode you can skip using sub-shell and just do: set -o pipefail turbo run lint | sed 's/\/out//g' Now just for completeness you might also use something like this: turbo run lint | sed 's/\/out//g' exit ${PIPESTATUS[0] And if you for some reason don't want to use sub shell but want to restore default handling of exit codes in pipes you can use this solution: set -o pipefail turbo run lint | sed 's/\/out//g' set +o pipefail There are even more exotic solutions to this question, but to be honest, I don't see the appeal.
has comment: http://stackoverflow.com/comment/138104913
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/138109536

http://stackoverflow.com/comment/138134294
type: Comment
type: AnswerComment
has text: Updated my answer, let me know if it is good for you :)
comment on: http://stackoverflow.com/a/78346403
score: 0

http://stackoverflow.com/comment/138174890
score: 1
comment on: http://stackoverflow.com/q/78375308
type: Comment
has text: Have you tried `command 1 | cat\r` etc.?
type: QuestionComment

http://stackoverflow.com/comment/138428520
comment on: http://stackoverflow.com/a/78372746
score: 0
type: Comment
type: AnswerComment
has text: This is great! This cleans up my everything completely!

http://stackoverflow.com/a/78383746
answers question: http://stackoverflow.com/q/78383503
has body: Instead of running several commands in a subshell to populate each variable, use Parameter Expansion. It happens in the same shell, which means it's much faster. It's not as powerful as sed or awk, but fortunately, you don't need it here: #! /bin/bash while read line ; do set -- $line jo=$6:$9 dc=$6 aid=${line#* al: }; aid=${aid% dc:*} or=${line#* or: }; or=${or% sv:*} jb=${line#* jb: }; jb=${jb% ho:*} ms=${line#* ms: }; ms=${ms% run_as*} callType=${line#ct: }; callType=${callType%% al:*} sv=${line#* sv: }; sv=${sv% st:*} st=${line#* st: }; st=${st% stt:*} sendTime=${line#* stt: }; sendTime=${sendTime% lu:*} ru=${line#* run_as: }; ru=${ru% sb:*} sb=${line#* sb: }; sb=${sb% ap:*} ap=${line#* ap: }; ap=${ap% jb:*} ho=${line#* ho: }; ho=${ho% al:*} al=${line##* al: }; al=${al% closed_from*} echo "JO: $jo." echo "DC: $dc." echo "AID: $aid." echo "OR: $or." echo "JB :$jb." echo "MS: $ms." echo "CALLTYPE: $callType." echo "SV: $sv." echo "ST: $st." echo "SENDTIME: $sendTime." echo "RU: $ru." echo "SB: $sb." echo "AP: $ap." echo "HO: $ho." echo "AL: $al." done
type: Answer
accepted answer of: http://stackoverflow.com/q/78383503
score: 2
upvote count: 2
downvote count: 0
type: AcceptedAnswer

http://stackoverflow.com/q/78401442
score: 0
type: Question
has body: I am trying to create a file using bash script. Here is the function that I am using. function create_service_file() { # create service file echo "Creating service file /etc/systemd/system/${SERVICE_NAME}" cat <<- EOF | sudo tee /etc/systemd/system/${SERVICE_NAME} [Unit] Description=$DESCRIPTION After=syslog.target network.target [Service] User=$USER WorkingDirectory=${WORKING_DIRECTORY} ExecStart=${JAVA_HOME}/bin/java -jar ${JAR_FILE} ExecStop=/bin/kill -15 $MAINPID SuccessExitStatus=143 Restart=always RestartSec=30s [Install] WantedBy=multi-user.target EOF echo "/etc/systemd/system/${SERVICE_NAME} file has been written successfully" } When I run the script. It asks me for password at line cat <<- EOF | sudo tee /etc/systemd/system/${SERVICE_NAME} After entering the password, it writes the file. If I check in the directory there is a file Now instead of giving password from the command I want to run this command directly. In other parts of the script. I am using the following syntax to achieve this thing local is_service_failed=$(sudo -S <<< "${PASSWORD}" systemctl is-active $service) or sudo -S <<< "${PASSWORD}" systemctl start $service These commands works fine. But now when I am trying to use the same thing it is not working. cat <<- EOF | sudo -S <<< ${PASSWORD} tee /etc/systemd/system/${SERVICE_NAME} File is creating but nothing is written inside the file. What am I doing wrong? How can I make it work.
tagged with: shell
linked to: http://stackoverflow.com/q/11710552
tagged with: io-redirection
has comment: http://stackoverflow.com/comment/138219652
has comment: http://stackoverflow.com/comment/138219677
has answer: http://stackoverflow.com/a/78401558
tagged with: bash
accepted answer: http://stackoverflow.com/a/78401558
answer count: 1
tagged with: sudo
type: AnsweredQuestion
has title: How to use -S option with sudo tee in bash script (use inline password with sudo tee)

http://stackoverflow.com/comment/138270071
type: QuestionComment
type: Comment
score: 1
has text: `bash --version` has no reason to be included, and likewise `$SHELL` (which tells you which shell is configured as default for your user account, but has nothing to do with which one is actively running). `$BASH_VERSION` is the _only_ authoritative way (other than its array equivalent) to tell which version of bash is currently running; `bash --version` just tells you which version is first in the PATH, which is a separate and unrelated thing.
comment on: http://stackoverflow.com/q/78427118

http://stackoverflow.com/comment/138102706
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78334722
has text: @AnassAbidar FWIW, I think your question is perfectly valid and you provided a good MCVE. Hence, closing the question with the provided reason above is unjustified in my opinion. However, you have received a good answer below, I don't think there is much more you can do here. If you cannot switch the terminal mode, you are out of luck, unless I miss something here.
type: Comment

http://stackoverflow.com/comment/138074303
has text: I guess it depends on how you read `A to ZZZZZZZZZZ` - all 1-char strings(sorted), followed by all 2-char strings(sorted), followed by all 3-char strings(sorted), etc? using `2 / {A..C}` it *looks* like it's 'ordered' but that appears to be an issue of the series being too small for the race condition to occur
type: Comment
comment on: http://stackoverflow.com/a/78317659
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138115095
has text: Strace shows the programm receives the signal: `[pid 335] --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=172, si_uid=1000} ---[pid 335] rt_sigreturn({mask=[CHLD]}) = -1 EINTR (Interrupted system call)`
comment on: http://stackoverflow.com/q/78341760
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138189610
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78383503
type: QuestionComment
has text: Also state whether or not your input always contains all of those fields and, if so, if they're always in that order.

http://stackoverflow.com/a/78411665
score: 0
has comment: http://stackoverflow.com/comment/138237900
answers question: http://stackoverflow.com/q/78411488
type: Answer
has body: jq is better to process JSON files than awk. for j in *.json ; do jq -r '[.Filename, [.Blocks[] | select(.Dmo=="Path")]] as [$f, $p] | if $p[0] then ($p[].Value | [$f, .]) else [$f] end | @csv' < "$j" ; done Output: "File_213","/Files/2024/abd" "File_213","/Files/2024/Ndew" "File_4" "File_43","/Files/2023/Roi2"

http://stackoverflow.com/comment/138214477
type: Comment
comment on: http://stackoverflow.com/q/78398495
score: 0
has text: (Does Oracle not provide a properly packaged JVM for their own Linux distro, btw? That's some pretty serious WTF; when you install from your distro's package management tools rather than through a tarball, those package management tools become responsible for making sure all dependencies are present, avoiding the class of problem you're encountering here).
type: QuestionComment

http://stackoverflow.com/comment/138202591
has text: Put `history -r` in your `PROMPT_COMMAND` environment variable, so it will reread the file before each command. See https://superuser.com/questions/1158739/prompt-command-to-reload-from-bash-history
comment on: http://stackoverflow.com/q/78391938
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138155179
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78364736
has text: Good point, I've edited the answer to check for the shebang too.

http://stackoverflow.com/comment/138123002
type: QuestionComment
type: Comment
has text: @user1934428 Never gets to that line anyway. ESP32_REPO_PROD is just a standard environment variabel for the machine. I can echo that no problem from anywhere.
comment on: http://stackoverflow.com/q/78343975
score: 0

http://stackoverflow.com/comment/138228162
has text: Thanks to all. I feed the fifo file with external snmp traps. I’m thinking maybe I shouldn’t use FIFO file and I should use regular file?
comment on: http://stackoverflow.com/a/78403776
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138196023
has text: I posted my result. It seems fine, if I understand what you want. Please clarify what is wrong with that output. I also added +repage to the commands in case the PNG inputs have a virtual canvas offset.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78387161

openvpn
tag name: openvpn
type: Tag
tags question: http://stackoverflow.com/q/78321765
tags question: http://stackoverflow.com/q/78492471

http://stackoverflow.com/comment/138122427
has text: Did your `trap` succeed? Do a `trap '_term' SIGINT SIGTERM || echo "trap handler can not be set up" 1>&2`
type: Comment
comment on: http://stackoverflow.com/q/78341760
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138113498
comment on: http://stackoverflow.com/a/78341268
has text: Spawning a subprocess is a lot of performance hit to avoid a portability issue.
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/comment/138226247
has text: Maybe some issue with `CRLF`used by HTTP protocol, which are not parsed by `read`. You may have to *sanitize* `$value` by using `${value%$'\r'}` for sample.
comment on: http://stackoverflow.com/q/78405034
type: QuestionComment
score: 1
type: Comment

http://stackoverflow.com/comment/138115074
has text: Yes that works. But why :D ?
comment on: http://stackoverflow.com/q/78341760
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78346403
has comment: http://stackoverflow.com/comment/138143137
has comment: http://stackoverflow.com/comment/138127807
answers question: http://stackoverflow.com/q/78337303
type: Answer
accepted answer of: http://stackoverflow.com/q/78337303
score: 0
has comment: http://stackoverflow.com/comment/138140132
has comment: http://stackoverflow.com/comment/138134294
has body: As noted by Charles Duffy, it may be a bad idea to mix automatic editing and human-maintained code. Also, note that grep is only a parsing program, it can not edit files on its own. You can still use grep for parsing MAJOR and MINOR versions, but since we'll use sed for editing the BUILD version, let's use it for everything (one dependency less!). A solution for your problem could be to use these commands (if you have GNU sed installed): # fetch the 3 versions VER_MAJOR=$(sed -nE 's/^#define VER_MAJOR[[:space:]]+([0-9]+)$/\1/p' main.cpp) VER_MINOR=$(sed -nE 's/^#define VER_MINOR[[:space:]]+([0-9]+)$/\1/p' main.cpp) VER_BUILD=$(sed -nE 's/^#define VER_BUILD[[:space:]]+([0-9]+)$/\1/p' main.cpp) # now increment the BUILD version and write it back to file ((VER_BUILD++)) sed -Ei 's/^(#define VER_BUILD[[:space:]]+)[0-9]+$/\1'$VER_BUILD/ main.cpp Explanations: -E for extended regular expressions -i tells sed to edit the file in place -n and /p are used to only print what was substituted (no other lines) The match string is pretty straightforward, but note the parentheses around the numbers. This defines a group: we replace the whole matched pattern (which is the whole line, since we used ^ and $ anchors) with \1 which is the first group (= the version number) And voilà, your VER_BUILD number is increased! For safety issues, you could prefer not editing in place (remove the -i from the last command and store stdout to another file &gt;main_edited.cpp)
type: AcceptedAnswer

http://stackoverflow.com/comment/138236553
type: QuestionComment
has text: @f-hauri-give-up-github: I don’t think it answers my question :( I’ll try the “shell connector” part and see if it permits to value a variable, thank for the link…
comment on: http://stackoverflow.com/q/78410973
score: 0
type: Comment

http://stackoverflow.com/a/78404605
answers question: http://stackoverflow.com/q/78404577
score: 1
has body: With sed: sed -E 's/.{5}$/,&amp;/' file
type: Answer
accepted answer of: http://stackoverflow.com/q/78404577
upvote count: 2
downvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/138277877
type: Comment
has text: "they're something you remove when you need to." -- so much this. :)
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78429282

http://stackoverflow.com/a/78386716
answers question: http://stackoverflow.com/q/78386230
downvote count: 0
has body: If you've got Bash 4.0 (released in 2009) or later, try this Shellcheck-clean Bash program: #! /bin/bash -p readarray -t list1 <L001 readarray -t list2 <L002 readarray -t list3 <L003 readarray -t list4 <L004 for ((i=0; i<48; i++)); do cat -- "${list1[i]}" "${list2[i]}" "${list3[i]}" "${list4[i]}" \ > "ALL_file$((i+1)).file" done readarray ((weirdly) aka mapfile) copies each line of its input into a Bash array. readarray/mapfile was introduced in Bash 4.0. $((i+1)) expands to the value of the arithmetic expression $i+1. See ArithmeticExpression - Greg's Wiki.
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/comment/138131091
comment on: http://stackoverflow.com/q/78351058
has text: Adapting the glob pattern from https://stackoverflow.com/a/48632533/9952196 should get you most of the way there.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138134976
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78348524
has text: update question again with i think that is a reproduction output. And How can i to do for sh step allow execution outside? ty @Iterokun
score: 0

http://stackoverflow.com/comment/138174674
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78375051
has text: Fair enough, @pjs, but they are still file *names* not file *handles*. This makes a difference, as the two are not used the same way.

http://stackoverflow.com/comment/138295157
score: 1
type: QuestionComment
has text: My guess is it's an alias or shell function. These aren't normally available in scripts.
type: Comment
comment on: http://stackoverflow.com/q/78444070

http://stackoverflow.com/comment/138089157
type: QuestionComment
has text: There are two problems: (1) case-insenstitivity (i.e. `ä` and `Ä` being treated equal), and (2) locality (i.e. how should `ä` be sorted relative to `a`?). For the former, `gnu sort` has the option `--ignore-case `; you may have to install it on your Mac. For the latter, I think this is controlled by LC_COLLATE, but I believe that this deserves its own question. Perhaps you could describe there what exactly you expect from "localized" sort order..
comment on: http://stackoverflow.com/q/78324472
type: Comment
score: 0

http://stackoverflow.com/a/78416883
score: 0
answers question: http://stackoverflow.com/q/78416125
type: Answer
has body: In your entrypoint.sh you reference /opt/ors/foxy/setup.bash but I could only find /opt/ros/foxy/setup.bash on the image (they differ in the second part of the path). I'm assuming that this is a typo and you meant the latter file. It's also the path that you mention in your text. So I suggest changing your entrypoint.sh as follows: #!/bin/bash source /opt/ros/foxy/setup.bash source install/local_setup.bash exec "$@" I've fiddled with the Dockerfile a bit too. You don't need to change SHELL if you source /opt/ros/foxy/setup.sh rather than /opt/ros/foxy/setup.bash. Also moved the WORKDIR earlier which means you don't need to cd sim_ws/. You don't need to make these changes though and the updated entrypoint.sh should be sufficient for the image to build and run successfully. FROM ros:foxy RUN apt-get update --fix-missing && \ apt-get install -y git \ nano \ vim \ python3-pip \ libeigen3-dev \ tmux \ ros-foxy-rviz2 && \ apt-get -y dist-upgrade && \ pip3 install transforms3d RUN git clone https://github.com/f1tenth/f1tenth_gym RUN cd f1tenth_gym && \ pip3 install -e . RUN mkdir -p sim_ws/src/f1tenth_gym_ros COPY . /sim_ws/src/f1tenth_gym_ros WORKDIR /sim_ws RUN . /opt/ros/foxy/setup.sh && \ apt-get update --fix-missing && \ rosdep install -i --from-path src --rosdistro foxy -y && \ colcon build COPY entrypoint.sh . RUN chmod +x entrypoint.sh ENTRYPOINT ["./entrypoint.sh"] CMD ["/bin/bash"] I also note that you were sourcing the /opt/ros/foxy/setup.bash script twice, once in the Dockerfile itself and then again via the entrypoint.sh script. Is this intentional? Is it really necessary?

http://stackoverflow.com/comment/138244610
score: 0
comment on: http://stackoverflow.com/q/78415633
type: QuestionComment
type: Comment
has text: You can use a regular expression to test if the first argument is a number.

http://stackoverflow.com/comment/138076322
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78319238
has text: note value of `cat /proc/$(pgrep tmux.sh)/comm`

http://stackoverflow.com/comment/138235460
type: QuestionComment
type: Comment
has text: @Barmar https://github.com/openai/whisper/
comment on: http://stackoverflow.com/q/78409475
score: 0

http://stackoverflow.com/comment/138258653
has text: Consider changing `jq -r 'to_entries[] | "\(.value) \(.key)"'` to `jq -c 'to_entries[] | {email: .key, token: .value}'`, and then just read by line. Each will be a JSON-encoded string that you can directly pass into `curl -d` (without having to manually recompose the JSON encoding).
type: QuestionComment
comment on: http://stackoverflow.com/q/78423157
type: Comment
score: 0

http://stackoverflow.com/comment/138238392
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78411741
score: 0
has text: Thanks so much. It works using `jq '...' file` instead of `jq '...' < file`

http://stackoverflow.com/comment/138130693
comment on: http://stackoverflow.com/a/78350523
has text: The OP's earlier question had nested quotes that a subset of the OP's remote systems parsed incorrectly. Those aren't present here, so we shouldn't need the workaround for noncompliant quote handling. I think they took a solution and tried to apply it outside the problem domain it was intended for.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138256804
comment on: http://stackoverflow.com/a/78403450
type: Comment
has text: I tried using just the var sqlquery by combining what was in the vars part1 and part2 but it ended up with the commands before "WHERE" getting concatenated instead. That's how that sqlquery = echo $part1 $part2 came about.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138129534
has text: @user1934428 I've added detail. Could you remove the close request. I want to figure this out.
type: QuestionComment
comment on: http://stackoverflow.com/q/78343975
score: 0
type: Comment

http://stackoverflow.com/comment/138284613
type: Comment
comment on: http://stackoverflow.com/a/78431101
type: AnswerComment
score: 1
has text: Thanks datawookie, duly accepted. Still learning the ropes, didn't realise I had to do that.

http://stackoverflow.com/a/78344012
type: Answer
has comment: http://stackoverflow.com/comment/138129844
score: 0
has body: Try this : #!/bin/bash esp_idf_v5_1_init='call C:\Users\thebi\.espressif\idf_cmd_init.bat esp-idf-f4096c5fb8232f5ffa980cf1b514d882' cmd.exe &lt;&lt; EOF $esp_idf_v5_1_init cd %ESP32_REPO_PROD% python esp-idf.py build EOF
has comment: http://stackoverflow.com/comment/138131476
has comment: http://stackoverflow.com/comment/138129478
answers question: http://stackoverflow.com/q/78343975

http://stackoverflow.com/a/78321913
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78321765
downvote count: 0
has comment: http://stackoverflow.com/comment/138079887
has body: sudo by default closes all file descriptors other than stdin, stdout and stderr -- so it deliberately invalidates /dev/fd references. You can avoid this problem by using a named FIFO -- just like bash does for >(...) and <(...) when running on operating systems that don't support /dev/fd. #!/usr/bin/env bash tempdir=$(mktemp -t -d authsock.d.XXXXXX) || exit trap 'rm -rf "$tempdir"; $write_pid && kill "$write_pid"' EXIT mkfifo "$tempdir/sock" || exit printf '%s\n' "$VPN_USER" "$VPN_PASS" >"$tempdir/sock" & write_pid=$! sudo openvpn \ --config /home/leander/Documents/Informatics-EdLAN-Forum.ovpn \ --auth-user-pass "$tempdir/sock"
score: 1
accepted answer of: http://stackoverflow.com/q/78321765
type: AcceptedAnswer

http://stackoverflow.com/comment/138140515
has text: https://stackoverflow.com/a/52844867/7976758 Found in https://stackoverflow.com/search?q=%5Bpip%5D+xcrun%3A+error%3A+invalid+active+developer+path+missing+xcrun
comment on: http://stackoverflow.com/q/78356154
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138102329
type: QuestionComment
has text: @EricPostpischil If the linux pty driver is part of the terminal software, then yes.
type: Comment
comment on: http://stackoverflow.com/q/78334722
score: 0

http://stackoverflow.com/comment/138111775
score: 1
has text: The [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) needs to start with literally the two bytes `#` and `!` to be valid.
type: QuestionComment
comment on: http://stackoverflow.com/q/78339485
type: Comment

http://stackoverflow.com/comment/138203683
score: 1
has text: what is output when you remove `2>/dev/null` ?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78392466

http://stackoverflow.com/comment/138261037
type: QuestionComment
type: Comment
score: 3
comment on: http://stackoverflow.com/q/78424828
has text: Don't put characters that need to be quoted in the password then. What you want is not possible in bash.

http://stackoverflow.com/comment/138173708
has text: If this _weren't_ how bash behaved, any script using `set -e` could never make any use of `if` (since what good's a conditional that can never be false without causing your code to exit?). `&&` and `||` are likewise flow-control operators; there wouldn't be any point to supporting them if only one exit status were possible without forcing an immediate exit.
type: QuestionComment
comment on: http://stackoverflow.com/q/78373828
score: 2
type: Comment

http://stackoverflow.com/comment/138130181
type: QuestionComment
score: 2
has text: maybe `a='b[$(echo 123 >&2)]'; b='val'; echo ${!a}` is meant by further expensions
comment on: http://stackoverflow.com/q/78350564
type: Comment

http://stackoverflow.com/comment/138116701
comment on: http://stackoverflow.com/q/78342895
has text: Not related to your problem, but always prefer `grep -E 'pattern' file` or `grep -E 'pattern' <file` to `cat file | grep -E pattern`. It's not as important for grep as other common commands, but a FIFO can only be read once, front-to-back, whereas a real file handle can be read out-of-order, can have its size checked _without_ needing to consume all its content, and otherwise allows a lot of optimizations that let other common tools (`tail`, `sort`, `wc -c`, and others) operate much more efficiently when they have a real handle and not a pipe.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138252627
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78420131
has text: The permission error happens in `bash` when it tries to open the output file, it never executes `echo` itself. You *could* get an error from `echo` if the disk is full when it tries to write.
score: 0

http://stackoverflow.com/q/78376379
has answer: http://stackoverflow.com/a/78378824
has body: i have a pipeline1 that execute a bash script block success and run ok,BUT when i invoke this pipeline1 from pipeline2 the bash script block didn't executed. Other sh individual line commands yes run ok and it showed output but all commands in for statement into block script not be are executing Any idea? I am referencing to this: pipeline1 steps { script{ <commands> echo "Hello world" sh '''#!/bin/bash sh "echo Hello1 world" for i in $var do <commands1> sh "echo Hello2 world" if ... ;then sh "echo Hello3 world" <commands2> else sh "echo Hello4 world" <commands3> fi sh "echo Hello5 world" <commands4> done sh "echo Hello6 world" <commands5> ''' sh "echo Hello7 world" } } pipeline2 steps { build (job: '../../folfer1/pipeline1', parameters: [ ... ], wait: true) } Then, the output on pipeline2 showed echo "Hello world" echo 'Hello1 World' echo 'Hello6 World' echo 'Hello7 World' but *not executing code locate into for statement in sh block bash and not showed any error, only showed Hello world, Hello1 world, Hello6 world and Hello7 world reproduction [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/lib/jenkins/workspace/folder/pipeline2 [Pipeline] { [Pipeline] ansiColor [Pipeline] { [Pipeline] stage [Pipeline] { (Executing playbook pipeline2) [Pipeline] withEnv [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] sh <commands> [Pipeline] echo Hello world [Pipeline] sh + echo 'Hello1 world' Hello1 world + echo 'Hello6 world' Hello6 world + <commands5> [Pipeline] echo Hello7 world [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // ansiColor [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS Resume: if i invoke this pipeline1 from pipeline2 all commands in for statement into block script not be are executing but, if I running pipeline1 alone the result and all executions are ok!) Update I change defined sh bash block code sh '''#!/bin/bash <comman…
tagged with: jenkins-groovy
type: Question
has title: skipped code when it be invoke from other pipeline
tagged with: jenkins
type: UnansweredQuestion
answer count: 1
score: 0
tagged with: jenkins-pipeline
tagged with: bash

http://stackoverflow.com/comment/138247785
has text: The advantages of a fifo versus a regular file are that a fifo does not use disk and is therefore faster and you don't need to clean up. When you use a regular file, the file just fills up.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78390328

http://stackoverflow.com/comment/138257473
type: Comment
score: 0
has text: OK; then your `make` command doesn't seem to be GNU; try with `gmake`
type: AnswerComment
comment on: http://stackoverflow.com/a/78422867

http://stackoverflow.com/comment/138252974
type: QuestionComment
has text: What does "interactive" mean here, like user-interactive? Most programs that read standard input don't run interactively if you provide anything on standard input.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78420308

http://stackoverflow.com/a/78372377
type: Answer
has body: You need to store the actual ANSI code in $C_CYAN, not its escaped version: C_CYAN=$'\033[36m' ~ Or, if you can't change $C_CYAN: eval echo -e "\\\\\\\\\\${C_CYAN}hello" But I'd strongly advocate for the former.
score: 0
answers question: http://stackoverflow.com/q/78372273

http://stackoverflow.com/comment/138256779
has text: Hi Cloudlady, thanks for the reply.
type: Comment
comment on: http://stackoverflow.com/a/78403450
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138242614
score: 1
has text: The regex you linked didn't have `^` so matched "stuna". But I think with `^` and `$` it's correct
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78411195

http://stackoverflow.com/a/78441790
has comment: http://stackoverflow.com/comment/138293035
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/138290991
type: Answer
has body: It worked for me. I just had to explicitly state that Easy.sh file is in the current folder. shar -M -D -Q -q RA_Test/ | sed '/^exit 0/d' > Easy.sh && echo "RA_Test/Start.sh" >> Easy.sh ; sh ./Easy.sh Also, make sure that the Start.sh in the RA_Test folder is executable (chmod +x Start.sh)
answers question: http://stackoverflow.com/q/78441672

http://stackoverflow.com/comment/138250290
score: 2
comment on: http://stackoverflow.com/q/78418827
type: QuestionComment
type: Comment
has text: That is a compiler error (fatal) that comes from using the `s///` operator with one delimiter missing. E.g. if using `s//` or `s{}`. Since you have none of those in that line, it seems likely the problem comes from somewhere else.

http://stackoverflow.com/comment/138219677
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78401442
type: Comment
has text: Do not store passwords. Instead add your user as NOPASSWD to sudoers. `User=$USER` Consider using user systemctl service files, instead of system ones.

http://stackoverflow.com/comment/138133847
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78348089
has text: @HackZero: Great, but what kind of shell is your processing your script? If it is an **interactive non-login bash shell**, it sources .bashrc automatically. Otherwise, you are responsible for explicitly setting hup the environment.
type: Comment

http://stackoverflow.com/comment/138283489
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78437542
has text: Indeed; `readarray -t allCollections < <(...)` is the general Right Thing.

http://stackoverflow.com/a/78424103
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78423821
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78423821
type: Answer
has body: Here's a shell script that processes the input line by line: #!/bin/bash search=$1 lines=() process_lines() { if [[ ${#lines[@]} -le 2 ]] ; then return fi found="" local line for line in "${lines[@]:1}" ; do if $line = *"$search"* ; then found=1 fi done if $found ; then echo "${lines[0]#>Cluster }" fi } printf "Clusters containing '%s':\n" "$search" while read line ; do if [[ $line = '>'Cluster* ]]; then process_lines lines=() fi lines+=("$line") done process_lines
downvote count: 0
score: 1

http://stackoverflow.com/comment/138139666
type: Comment
comment on: http://stackoverflow.com/q/78353316
type: QuestionComment
score: 0
has text: Let me first say, I am not new to asynchronous tasks. I use this all the time in real programming languages. But Bash is not that familiar to be and to be honest, uses some strange syntax where it reused characters a lot for different meanings. I found this example ones that I added to a larger script without worrying about how it worked. The test script was the beginning of me trying to actually learn how this trick worked and it does work in my real script.

flac
tags question: http://stackoverflow.com/q/78358550
type: Tag
tag name: flac

http://stackoverflow.com/a/78419867
downvote count: 0
upvote count: 1
has body: ssh running from your script misses destination (user@host). Git passes a destination as an argument to the script but you've forgotten to pass it to ssh. My advice is to pass all arguments from the script to ssh: ssh -i key "$@" "$@" means "pass all arguments". See section Special Parameters in man bash.
type: Answer
has comment: http://stackoverflow.com/comment/138252112
answers question: http://stackoverflow.com/q/78419810
accepted answer of: http://stackoverflow.com/q/78419810
score: 1
type: AcceptedAnswer

http://stackoverflow.com/a/78378936
downvote count: 0
has body: And I don't understand why? Because newlines in awk scripts are significant. This follows in part from the fact that awk allows either the pattern or the action of any rule to be omitted. It relies on the end of a pattern appearing on the same line as the beginning of an action to associate the pattern with the action, instead of treating them as an actionless pattern followed by a patternless action. There are considerable additional rules about where newlines may appear (unescaped) and where not, too. The default pattern matches every line, and the default action is { print }, so this ... $0 ~ "User " user ".* blocked" { print } ... says "print every line that matches pattern $0 ~ "User " user ".* blocked", and, additionally, print every line". On the other hand, this ... $0 ~ "User " user ".* blocked" { print } ... says "print every line line that matches pattern $0 ~ "User " user ".* blocked"". Of course, that could also be written as simply $0 ~ "User " user ".* blocked"
type: Answer
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/78378844

http://stackoverflow.com/comment/138253201
has text: `^SUMMARY|DESCRIPTION` may not match what you intend
type: QuestionComment
comment on: http://stackoverflow.com/q/78419985
type: Comment
score: 0

http://stackoverflow.com/q/78416162
tagged with: bash
tagged with: windows
has title: bash concatenate variables and strings
has comment: http://stackoverflow.com/comment/138245480
has comment: http://stackoverflow.com/comment/138245472
has comment: http://stackoverflow.com/comment/138250386
score: 0
type: Question
tagged with: win-bash
has body: I have a config file that contains filenames without an extensions: aa bb In a bash script, I read them to an array and use the filenames to build a full path: configFile="C:/xxxx/load.config" myarray=() while read -r line || [ -n "$line" ]; do myarray+=("$line") echo "$line" done < "$configFile" folder="C:/project/test/" for((i = 0; i < ${#myarray[@]}; ++i)) do file=${myarray[$i]} echo "folder="$folder echo "file="$file file_path=$folder$file".xml" echo "$file_path" echo "next..." done Here is the result that I get: aa bb folder=C:/project/test/ file=aa .xmlroject/test/aa next... folder=C:/project/test/ file=bb C:/project/test/bb.xml next... The .xmlroject/test/aa is unexpected. Why does it output that?
tagged with: shell
answer count: 0
has comment: http://stackoverflow.com/comment/138245487
duplicate of: http://stackoverflow.com/q/39527571
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/39527571
has comment: http://stackoverflow.com/comment/138251473

http://stackoverflow.com/comment/138102092
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78334722
has text: According to the man page for the `read` function: _On Linux, read() (and similar system calls) will transfer at most 0x7ffff000 (2,147,479,552) bytes, returning the number of bytes actually transferred. (This is true on both 32-bit and 64-bit systems.)_. You need to provide more details about your tests when you try to read 4096 bytes.
type: Comment

stdin
tags question: http://stackoverflow.com/q/78334722
tags question: http://stackoverflow.com/q/78445450
tags question: http://stackoverflow.com/q/78363374
tag name: stdin
type: Tag
tags question: http://stackoverflow.com/q/78968938
tags question: http://stackoverflow.com/q/78968615

http://stackoverflow.com/comment/138224380
score: 2
has text: So, there you're closing the FIFO after each read. If you want to emulate a case where you have a single long-lived program doing the writes (which is how FIFOs are more properly used), it wouldn't look like that -- instead, `exec 3>testfifo` to open the FIFO for write, then do each echo into it with `>&3` appended. Used that way, you'll see the `read` loop block instead of fail between them; whereas `exec 3>&-` will close the FIFO, after which `read`s will fail. But when `read` starts failing, you can just reopen the FIFO and get back into the state where reads block until there's a writer.
comment on: http://stackoverflow.com/a/78403776
type: Comment
type: AnswerComment

hive
tags question: http://stackoverflow.com/q/78444871
type: Tag
tag name: hive

mysql
tag name: mysql
type: Tag
tags question: http://stackoverflow.com/q/78420308
tags question: http://stackoverflow.com/q/78363909
tags question: http://stackoverflow.com/q/78462744
tags question: http://stackoverflow.com/q/78455854
tags question: http://stackoverflow.com/q/78551562
tags question: http://stackoverflow.com/q/78507226
tags question: http://stackoverflow.com/q/78588025
tags question: http://stackoverflow.com/q/79022674
tags question: http://stackoverflow.com/q/78994422
tags question: http://stackoverflow.com/q/79501141
tags question: http://stackoverflow.com/q/79441406
tags question: http://stackoverflow.com/q/79521747

http://stackoverflow.com/comment/138188079
comment on: http://stackoverflow.com/q/78383368
type: Comment
has text: @GordonDavisson this is very good advice.. reading thru
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138241082
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78406644
has text: `cd` is a shell built-in. It would be pointless for it to be a standalone program; the directory change would immediately be lost when the program exited. `xargs` is telling you the truth - there is no such file or directory

http://stackoverflow.com/comment/138236487
has text: @Barmar, the scripts are many (hundreds). The scripts are spread across a dozen+ different git-repositories. Many of them aren't even used any more, but tracing, which of them can be deleted, is a hairy task of its own. It is messy and I thought, there might be a feature in bash, that'll make it easier for me to sort out...
comment on: http://stackoverflow.com/q/78409604
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138283449
type: QuestionComment
score: 4
comment on: http://stackoverflow.com/q/78437542
type: Comment
has text: `declare -p mapped allCollections` is an easy way to print the actual value of both variables in unambiguous form.

http://stackoverflow.com/comment/138078574
type: Comment
score: 0
type: AnswerComment
has text: @jhnc, thanks, I think I've got it now. Better?
comment on: http://stackoverflow.com/a/78320229

http://stackoverflow.com/comment/138134780
score: 1
type: QuestionComment
type: Comment
has text: Sorry, it's not a reproduction. Your pipeline1 would fail with an error because `sh` step is not allowed outside of `node` block.
comment on: http://stackoverflow.com/q/78348524

http://stackoverflow.com/comment/138228977
type: Comment
has text: Try `cd -- "$(< /home/user/Documents/save_path.txt)"`.
score: 1
comment on: http://stackoverflow.com/q/78406644
type: QuestionComment

http://stackoverflow.com/comment/138257990
has text: Using `echo "$w" >> for-test` is unsafe. First it can interpret dash options from the string, it will also alter the original content with a newline. Use `printf %s "$w"` instead with predictable result and no added newline.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78417916

http://stackoverflow.com/comment/138133996
score: 0
type: QuestionComment
has text: Well, first of all, it seems to be mainly a problem with the batch script idf_cmd_init.bat, so I would remove the _bash_ tag from your question. As you see from the code you have posted, if export.bat exists, this batch file is executed, and the control is not returned to the caller. This is a Windows-"feature". I'm not a Windows expert, but from this I would conclude that idf_cmd_init.bat also does not return to your master bash script anymore, which corresponds to your observations. Can't you throw away the bat scripts and rewrite everything in bash?
type: Comment
comment on: http://stackoverflow.com/q/78343975

http://stackoverflow.com/comment/138267058
type: Comment
has text: Can you try `source ./bash-if-trouble.sh` ?
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118

http://stackoverflow.com/comment/138270287
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
type: Comment
has text: I should have suggested https://repl.it/; since that can use any package available in Nix, one can select a specific bash version there (including requesting that completely arbitrary builds be constructed from source).
score: 0

http://stackoverflow.com/comment/138198444
score: 0
has text: My history is linear. No merge commits.
comment on: http://stackoverflow.com/q/78378370
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138115665
comment on: http://stackoverflow.com/q/78341760
type: QuestionComment
type: Comment
has text: I did it in two lines. That works. Yes what I wrote might not be valid syntax
score: 0

aws-ssm
type: Tag
tags question: http://stackoverflow.com/q/78423404
tag name: aws-ssm

http://stackoverflow.com/a/78431169
accepted answer of: http://stackoverflow.com/q/78429844
has comment: http://stackoverflow.com/comment/138273826
type: AcceptedAnswer
has body: Let's first establish that the jq command works. #!/bin/bash URL=https://www.google.com jq --arg url "$URL" '.defaultOptions.environmentVariableEntries += [{"key": "URL", "value": $url}]' json.xctestplan The output is: { "defaultOptions": { "environmentVariableEntries": [ { "key": "OS_VERSION", "value": "13" }, { "key": "URL", "value": "https://www.google.com" } ] } } So that appears to be doing what you want. I think I understand why you are wrapping your jq command in an echo command. Is that to allow you to redirect to the same file that you're reading from? Without the echo the input file would be truncated before reading commences. How about updating your Jenkins command to something like this (untested): pipeline { agent any environment { URL = 'https://www.google.com' } stages { stage('Update XCTestPlan') { steps { script { sh "jq --arg url \"$URL\" '.defaultOptions.environmentVariableEntries += [{\"key\": \"URL\", \"value\": \$url}]' json.xctestplan > json.xctestplan.tmp" sh "mv json.xctestplan.tmp json.xctestplan" } } } } } That enables you to avoid using echo and so simplifies the quoting. As a possible refinement you could combine the two sh commands using the && operator.
answers question: http://stackoverflow.com/q/78429844
score: 0
type: Answer

http://stackoverflow.com/comment/138252797
comment on: http://stackoverflow.com/q/78420131
has text: Is there a reason why checking `$?` after the echo isn't sufficient?
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78419600
has body: Because when your shell sees calculator 1 2 *, it will first expand all glob patterns. The wildcard * means: 0 or more characters, any characters (with the exception of leading . denoting hidden files). Only after all expansions have run, your command will be invoked. So if you have a file with the name 0 in your directory, * will first be replaced with 0, and then calculator 1 2 0 is invoked. If you have multiple files in your directory, such as 0, file.txt, image.png, then calculator 1 2 0 file.txt image.png will be invoked. A similar problem applies to your line echo [ $1 $3 $2 ]. First, parameters are expanded and then path names are expanded for unquoted parameters. So even if you initially called calculator 1 2 '*', this line will first be expanded to echo [ 1 * 2 ], and subsequently expanded further to echo [ 1 0 2 ] (or echo [ 1 0 file.txt image.png 2 ], depending on the files in your working directory).
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78419450

http://stackoverflow.com/a/78347014
has body: Change: quarkus.jib.jvm-additional-arguments=-XX:InitialRAMPercentage=50, -XX:MaxRAMPercentage=90 into quarkus.jib.jvm-additional-arguments="-XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=90" PS: you missed the quotes around the arguments. Also I think, I may be wrong, you should remove the ,.
answers question: http://stackoverflow.com/q/78346697
score: 0
type: Answer

http://stackoverflow.com/comment/138266148
has text: See ["Why does non-equality check of one variable against many values always return true?"](https://stackoverflow.com/questions/26337003/why-does-non-equality-check-of-one-variable-against-many-values-always-return-tr). Also, `array=( "${array[@]/$delete}" )` doesn't delete any elements, it just deletes the string in `$delete` from each element; this replaces the element you're trying to delete with an empty string, and can also delete that string from any other elements that happen to contain it as a substring. Use `declare -p array` to see what `array` actually contains at the end.
type: QuestionComment
comment on: http://stackoverflow.com/q/78427584
score: 2
type: Comment

http://stackoverflow.com/comment/138238565
score: 0
comment on: http://stackoverflow.com/a/78411906
has text: That feature was apparently added in bash 5.1 (see https://unix.stackexchange.com/questions/366581/bash-associative-array-printing)
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78373011
score: 1
answers question: http://stackoverflow.com/q/78372639
downvote count: 0
upvote count: 1
type: Answer
has body: Sorting per version numbers is more difficult than it seems because 1.10 shall come after 1.9. GNU sort has a dedicated option: -V. With GNU awk and its coprocesses you can implement all this in one single awk script: #!/bin/bash # Path to the configuration file config_file="app.config" awk -v v="$1" ' BEGIN { cmd = "sort -V" } go { n = patsplit($0, a, @/[0-9]+(\.[0-9]+)*/, s) a[n + 1] = v; s[n + 1] = s[n]; s[n] = ", " for(i = 1; i <= n + 1; i++) print a[i] |& cmd close(cmd, "to") i = 0; while(cmd |& getline) printf("%s%s", s[i++], $0) print s[n + 1]; go = 0; next } /^\[version\]$/ {go = 1} 1' "$config_file" Once happy with the result you can add the awk -i inplace option to edit in place. Explanations: We detect the [version] line (last rule) and use the go variable to process specially only the line that follows. The other lines are printed unmodified (this is what the 1 at the end does). The line with version numbers is first split with patsplit in versions (array a) and separators (array s). We add the new version number at the end of array a and insert a new , separator in second to last position in array s. We do this because the last separator looks different from the others and you may want to preserve that. We print all version numbers, one per line, and pipe this to the sort -V coprocess. We close the to way of the coprocess (else sort waits forever the end of the input stream). We read the from way of the coprocess until the end and print the sorted version numbers interleaved with the separators. Still with GNU awk we could also take benefit of its advanced sorting capabilities that allow to provide a custom sorting function. In the following we completely avoid sort and coprocesses. The vsort function compares 2 version numbers as sort -V does, and the asort GNU awk function uses it to sort the a array: #!/bin/bash # Path to the configuration file config_file="app.config" awk -v v="$1" ' function vsort(i1, v1, i2, v2, n1, n2, x, y, i) { n1 = split(v1, x…

http://stackoverflow.com/q/78330348
tagged with: grep
has comment: http://stackoverflow.com/comment/138101068
has title: Recursive search and replace a string with dot in text files on Mac
tagged with: bash
answer count: 1
has comment: http://stackoverflow.com/comment/138097910
tagged with: find
tagged with: sed
has comment: http://stackoverflow.com/comment/138104191
has comment: http://stackoverflow.com/comment/138095104
has body: Team, I see there are multiple similar questions but I did try some answers and still not able to get what I want. I want to replace a text as "product-ui-test-creds.json" to "vaulted-product-ui-test-creds.json" from all files in directory and sub dirs sample grep Command> grep product-ui-test-creds.json * -r ci/product/verify-ui/e2e.jenkinsfile: product_Test_User = credentials('product-ui-test-creds.json') deployments/product-ui/e2e/e2e.jenkinsfile: product_Test_User = credentials('product-ui-test-creds.json') deployments/product-stuff/ui-ci/Jenkinsfile: CREDS = credentials('product-ui-test-creds.json') expected output Command> grep vaulted-product-ui-test-creds.json * -r ci/product/verify-ui/e2e.jenkinsfile: product_Test_User = credentials('vaulted-product-ui-test-creds.json') deployments/product-ui/e2e/e2e.jenkinsfile: product_Test_User = credentials('vaulted-product-ui-test-creds.json') deployments/product-stuff/ui-ci/Jenkinsfile: CREDS = credentials('vaulted-product-ui-test-creds.json') I tried this LC_ALL=C find . -type f -name '*.txt' -exec sed -i '' s/product-ui-test-creds.json/vaulted-product-ui-test-creds.json/g {} + or find . -type f -name '*.txt' -exec sed -i '' s/this/that/g {} + does not give any output and neither it changes anything in files.
score: 0
type: Question
has answer: http://stackoverflow.com/a/78469404
has comment: http://stackoverflow.com/comment/138094856
has comment: http://stackoverflow.com/comment/138097811
has comment: http://stackoverflow.com/comment/138094874
type: UnansweredQuestion

http://stackoverflow.com/a/78385706
type: AcceptedAnswer
upvote count: 1
has body: The problem is, sed is trying to interpret the special characters as part of the replacement string. What you need is a "dumb substitution". Here is a one liner that should work to replace the <secret_pass> string with your password: bash -c 'replace_pw () { pw="$1"; while read line; do var=$(echo $line | cut -d= -f1); value=$(echo $line | cut -d= -f2); if [ "$value" == "<secret_pass>" ]; then echo "$var=$pw"; else echo "$var=$value"; fi; done }; cat some_config_file | replace_pw '\''${{secrets.SECRET_PASSWORD}}'\' > junk.$$; mv junk.$$ some_config_file As a side note, I noticed that you have: run: sed -i 's/<secret_pass>/${{secrets.SECRET_USER}}/' some_config_file I assume you meant to use something else besides secrets.SECRET_USER. I used secrets.SECRET_PASSWORD in my example above.
score: 1
accepted answer of: http://stackoverflow.com/q/78385195
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/138199386
answers question: http://stackoverflow.com/q/78385195

http://stackoverflow.com/comment/138253251
type: QuestionComment
has text: Maybe just indirectly related, but if you want to compare two commits by the Git tree they point to, i.e., ignore commit metadata like parent SHA, author, date etc., you can append `^{tree}` to the revision; for example, `git rev-parse C1^{tree}` and `git rev-parse C2^{tree}`, and they would return the same hash.
comment on: http://stackoverflow.com/q/78419971
type: Comment
score: 0

http://stackoverflow.com/comment/138226360
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78405034
type: Comment
has text: Thanks! @F.Hauri-GiveUpGitHub ! Both of your suggestion and Gordon Davison's were required to get this to work.

http://stackoverflow.com/comment/138106781
comment on: http://stackoverflow.com/q/78337303
score: 3
type: QuestionComment
has text: The other thing is that if someone is using, say, `git log -p -- main.cpp` they presumably want to see changes _made by humans_, not polluted with a version bump for every single change. Keep your version updates in `version.h` and folks reviewing history can choose to look at them only when they want to.
type: Comment

http://stackoverflow.com/comment/138259322
has text: Occasionally, the ID containing the desired string might be positioned where the cluster number in the first column is labeled as 0. This positioning is entirely arbitrary, and it's important to note that this dataset is merely a subset of a much larger dataset. I've included some extra rows in the provided dataset for context.
score: 0
comment on: http://stackoverflow.com/a/78423908
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138267523
type: QuestionComment
type: Comment
has text: So, is it Bash or a POSIX shell ("sh")? Please remove the faulty tag. Also, is curl actually relevant here?
score: 1
comment on: http://stackoverflow.com/q/78428595

http://stackoverflow.com/comment/138174193
has text: It's not clear if you want absolute path that already exists or you have the intention to create them
comment on: http://stackoverflow.com/q/78366773
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138252993
score: 0
comment on: http://stackoverflow.com/q/78420308
type: QuestionComment
type: Comment
has text: if you're trying to get the usual table formatting of output, you can force that with the `--table` option.

http://stackoverflow.com/comment/138230367
type: QuestionComment
comment on: http://stackoverflow.com/q/78406644
type: Comment
score: 0
has text: Thanks for the explanation. I'm a newbie so I was just stumbling along trying to make it work.

http://stackoverflow.com/comment/138074465
comment on: http://stackoverflow.com/a/78317659
has text: _nod_. I'd expect from a code read that this one would be slower to start (gotta fork the subprocesses) but faster once it's running (not constantly setting up and tearing down stack frames, and you've got separate processes handling different stages in the pipeline). OTOH, the `read`s are a bit of a wildcard; I could see there being an alternate universe where they make this one slower.
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/comment/138290991
has text: I always have the same problem. Yes, the first script executes, but once it gets to the second script, it says the file doesn't exist, even though it's already been combined in Easy.sh
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78441790
score: 0

http://stackoverflow.com/comment/138206241
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78393978
has text: Or whipe unwanted spaces by `if [[ ${column4// } == 123 ]]; then` ... (prefer double braces...)
score: 1

http://stackoverflow.com/comment/138102348
type: QuestionComment
comment on: http://stackoverflow.com/q/78334722
score: 0
type: Comment
has text: @Ctx: Of course it is. It is software, not hardware, and it makes the terminal interface work.

http://stackoverflow.com/comment/138179587
type: QuestionComment
comment on: http://stackoverflow.com/q/78378844
type: Comment
has text: @MarkReed It does, but not in this case. In production I use it for bash filepath expansion, to alllow globbing patterns in ${file}.
score: 0

http://stackoverflow.com/comment/138181166
has text: I intended to ask if the pod will have to wait for the grace period time because of the sidecar container.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78366908

http://stackoverflow.com/a/78364311
type: Answer
answers question: http://stackoverflow.com/q/78361550
score: 0
has body: I remove quotes for conditions and it work execute_versioning_script: stage: execute_versioning_script before_script: - project_url=$(echo $CI_PROJECT_URL | sed 's/https:\/\///') - git remote set-url origin https://oauth2:$VERSIONING_TOKEN@$project_url script: - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash - python .secure_files/main.py rules: - if: $CI_COMMIT_TAG != null when: never - if: $CI_COMMIT_BRANCH == 'main' - if: $CI_COMMIT_BRANCH == 'dev' - if: $CI_COMMIT_BRANCH == 'hot-fix' - if: $CI_COMMIT_BRANCH =~ /^feature\/[A-Z]{3,8}-[0-9]{1,4}-fix$/

http://stackoverflow.com/comment/138294083
comment on: http://stackoverflow.com/q/78443452
type: QuestionComment
type: Comment
score: 1
has text: Not just the last component -- _all_ pipeline components end up in individual subshells (by default). This is [BashFAQ #24](https://mywiki.wooledge.org/BashFAQ/024).

http://stackoverflow.com/comment/138119764
type: Comment
has text: Do ALL the future readers of this the benefit of adding it to your answer, please!
type: AnswerComment
comment on: http://stackoverflow.com/a/78344420
score: 0

http://stackoverflow.com/a/78406219
type: AcceptedAnswer
has body: The first command in your script (sudo apt update) is failing because another instance of apt is running -- likely one spawned by the VM's native bootstrapping process -- and holding apt's internal lock file: E: Could not get lock /var/lib/apt/lists/lock. It is held by process 700 (apt-get) Try adding this at the top of your script to wait for the other apt to finish: #!/bin/sh timeout=600 # (10 minute timeout) i=0 while sudo fuser /var/lib/apt/lists/lock &gt; /dev/null 2&gt;&amp;1; do sleep 1 (( i+=1 )) if $i == $timeout ; then exit 1 # Exit with error if timeout value is reached fi done The while loop polls the lock file until it is no longer being held open by the other apt, sleeping for 1 second between attempts. If the timeout value is reached, the script exits with error.
score: 4
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/78393852
has comment: http://stackoverflow.com/comment/138255221
type: Answer
accepted answer of: http://stackoverflow.com/q/78393852

ubuntu-22.04
tag name: ubuntu-22.04
type: Tag
tags question: http://stackoverflow.com/q/78438850
tags question: http://stackoverflow.com/q/79268904
tags question: http://stackoverflow.com/q/79269485
tags question: http://stackoverflow.com/q/79302612

http://stackoverflow.com/comment/138226163
has text: The value has a space before it. It's " DYNAMIC", not "DYNAMIC". You could use `value="${value# }"` to trim off the space.
score: 1
comment on: http://stackoverflow.com/q/78405034
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138079708
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78321765
has text: One approach to fixing this would be to consider the question a duplicate of [using bash process substitution for a sudo command](https://stackoverflow.com/questions/13672420/using-bash-process-substitution-for-a-sudo-command) -- but note that the proper fix requires `/etc/sudoers` to be configured a particular way.
score: 0

http://stackoverflow.com/comment/138169477
comment on: http://stackoverflow.com/a/78373052
type: Comment
type: AnswerComment
has text: Did you try my solution [commented here](https://stackoverflow.com/questions/78372639/append-value-in-ascending-order-using-sed?noredirect=1#comment138169319_78372639)
score: 0

http://stackoverflow.com/comment/138183096
comment on: http://stackoverflow.com/q/78378370
has text: BTW, I think your test is a little different than the wording of your ask, which sounds like you want to "drop" the commits when that is the only change. But your test did a "fixup" instead of a "drop", which means that it modified an earlier commit with the higher version numbers. With fixup, those commits that you wish to keep would be modified by later commits that only changed the version. My gut feeling is "drop" is better than "fixup" here, and maybe you add one commit at the end for the final version that you are at now.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138130286
comment on: http://stackoverflow.com/a/78350523
has text: I'd probably skip the `bash -c` here; the point of explicitly running bash was to get a well-understood parser, but since we don't know what the outer shell is (but do know that it's un-POSIX-y) and so can't reliably craft quoting intended to get data passed through it, keeping the command as simple as possible (depending on nothing more than splitting on spaces) is probably to the better.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/138242752
score: 0
type: QuestionComment
has text: Does this answer your question? [Get autocompletion when invoking a "read" inside a Bash script](https://stackoverflow.com/questions/4819819/get-autocompletion-when-invoking-a-read-inside-a-bash-script)
comment on: http://stackoverflow.com/q/78359720
type: Comment

http://stackoverflow.com/comment/138139710
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78353316
has text: I hit the character limit, so I will continue. The link provided to me tells me that my previous success was simply a matter of the right race conditions. More code meant that everything had more time to finish. So the real issue with my example is that it's to simple :D The race condition aspect of it is why I was bothered. The damn thing had been working for me the past year without issues in a large cron script. Then for some reason it just don't in another script. So thanks for the link, I did try looking for similar examples, but without the right keywords, it's not always easy.
score: 0

http://stackoverflow.com/comment/138157054
comment on: http://stackoverflow.com/a/78364778
has text: Line endings on a mac are actually `\n` by default as well, and within the shell, that should be what the result is. However, when `do shell script` was implemented, the situation was murkier, and so it modifies what the script returns. Apple ended up adding an option, `altering line endings` which lets you decide how you want `do shell script` to return the result. To get `\n`, append `without altering line endings` to the command. Personally, I wish they'd done the reverse but…
score: 2
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138106864
comment on: http://stackoverflow.com/q/78337303
type: QuestionComment
has text: (also, git has its own features for managing version numbers -- have you considered using `git describe` to build a version number at compile time by looking at whether the commit corresponds with any tags, and not embedding it in the source at all?)
type: Comment
score: 0

http://stackoverflow.com/comment/138286640
comment on: http://stackoverflow.com/a/78438921
has text: @tjm3772 My bad fixed.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/138233884
comment on: http://stackoverflow.com/q/78409475
score: 3
type: QuestionComment
type: Comment
has text: You seem to be saying that `whisper` itself is inconsistent about whether it terminates with a failure status when the input file is bad. In that case, that's primarily an issue with `whisper`.

http://stackoverflow.com/comment/138226263
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78405034
has text: _grumbles in @F.Hauri's direction about [BashPitfalls #50](https://mywiki.wooledge.org/BashPitfalls#hosts.3D.28_.24.28aws_.2BICY.29_.29)_ -- granted, the more explicit/robust approach (populating an array item-by-item in a loop) is longer, and might not fit in a comment.

http://stackoverflow.com/comment/138238260
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78411166
score: 0
has text: `grep -Eixv '.{0,3}|[^u]*|.*[^bluntam].*' /usr/share/dict/words`

http://stackoverflow.com/comment/138255057
type: Comment
has text: BTW, using `echo -n` is problematic, _especially_ with `/bin/sh` -- [the POSIX spec for echo](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html) explicitly describes output as undefined when `-n` is present. `printf '%s' "..."` is a more portable and reliable alternative to `echo -n "..."`; see also https://unix.stackexchange.com/a/65819/3113
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78421398

history
tags question: http://stackoverflow.com/q/78402822
type: Tag
tag name: history
tags question: http://stackoverflow.com/q/79153351

http://stackoverflow.com/comment/138269150
score: 0
type: QuestionComment
type: Comment
has text: thanks knittl that explains the behaviour. using jq for some reason didn't cross my mind. How can I accept this answer?
comment on: http://stackoverflow.com/q/78428595

rest
type: Tag
tags question: http://stackoverflow.com/q/78383368
tag name: rest
tags question: http://stackoverflow.com/q/78671977
tags question: http://stackoverflow.com/q/79002737
tags question: http://stackoverflow.com/q/79160239

http://stackoverflow.com/a/78429509
score: 0
answers question: http://stackoverflow.com/q/78424358
type: Answer
has body: While I would suggest to go with Renaud's solution as it is really neat, here is another solution idea: variable="38"; ls -1 *cfc_|sed -r "s,^(.*_)N(_.*)_$,cp & \1$variable\2,e" Basically get file names from ls -1 and ^(.*_)N(_.*)_ - starting from beginning of the line creates two capture groups First one is until the _ , then a not captured "N", and the second one from the _ till the end of the line without the last _ character at the end of the line. In sed the & means the whole matched string from the previous section which means the whole file name, then capturing group 1, followed by the value of the shell variable, followed by capturing group 2. Sed e option will execute it. If you would like to see the whole command for each execution then put an extra p next to the e (front or behind, doesn't matter). If you would like to see the command only then either you put an echo front of the cp in sed or you remove the e at the end of the sed.

http://stackoverflow.com/comment/138171982
type: Comment
score: 1
type: QuestionComment
has text: when I run your `sed` script against your first 8-line file I get `70` and `69`, as opposed to `69` and `68`; do the lines of interest actually start with the `>` character?
comment on: http://stackoverflow.com/q/78371799

http://stackoverflow.com/comment/138067090
score: 0
has text: `echo $status echo $status_column3 echo "-$status_column3-"` result: `UP UP -UP- UP DOWN -DOWN-`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78314716

microphone
tag name: microphone
type: Tag
tags question: http://stackoverflow.com/q/78316769

http://stackoverflow.com/comment/138167794
type: QuestionComment
has text: Hi @Iterokun, I detected by your idea witrh `echo`'s testing workflow that only not execute a for statement located on sh block bash outside of it all execute ok. Updated question again :S thanks!
type: Comment
comment on: http://stackoverflow.com/q/78348524
score: 0

http://stackoverflow.com/a/78430483
type: Answer
score: 0
has body: A simpler solution to your problem can be implemented by using a temporary array to hold the array elements to be kept, and by taking advantage of the pattern matching and logical operators available with the [[ ... ]] command. This Shellcheck-clean program demonstrates the idea: #! /bin/bash -p array=(8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t) tmparr=() for v in "${array[@]}"; do | $v == *bar && tmparr+=( "$v" ) done array=( "${tmparr[@]}" ) declare -p array The program outputs: declare -a array=([0]="8669648574foo" [1]="231649bar" [2]="8594792682foo") declare -p var is one of the best ways to display the value of any variable because it displays it in an unambiguous way that can be used as shell code.
answers question: http://stackoverflow.com/q/78427584

conftest
tag name: conftest
type: Tag
tags question: http://stackoverflow.com/q/78421398

http://stackoverflow.com/comment/138251847
has text: @RenaudPacalet: Yes, but it only works in bash and in `[[ ... ]]`, i.e. not in other shells and not in `[ ... ]` or `test`.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78419614

http://stackoverflow.com/comment/138102460
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78334722
has text: @AnassAbidar Did you try to redirect the output from your program to a file and then compare that new file with your original file?
score: 0

http://stackoverflow.com/comment/138228290
type: Comment
type: AnswerComment
has text: @kmt *nameref* implie `declare -n`: You missed `declare -n arrvar="array_$i"`
score: 0
comment on: http://stackoverflow.com/a/78401596

http://stackoverflow.com/comment/138190591
score: 0
comment on: http://stackoverflow.com/q/78385269
type: QuestionComment
type: Comment
has text: The file you get errors from has DOS newlines

http://stackoverflow.com/comment/138153669
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78350564
has text: `$(echo b)` is a form of command substitution not parameter expansion and in indirect expansions you reference "valid parameter references"; not those having `$` in them already. `x='a[$(ls>&2)]'; echo "${!x}"` works because index expressions are interpreted in another level. See [valid_array_reference](https://github.com/bminor/bash/blob/f3b6bd19457e260b65d11f2712ec3da56cef463f/arrayfunc.c#L1330).

http://stackoverflow.com/comment/138252288
score: 0
comment on: http://stackoverflow.com/q/78419884
type: QuestionComment
type: Comment
has text: That said, we don't follow links here (and also don't consider screenshots) for purposes of determining whether a question follows our rules. You need to have a [MRE] in the **text of the question itself** for that question to be on topic

http://stackoverflow.com/comment/138170709
has text: Pipe to `tr , \\n`, look for a version number that is larger than the one you are entering, print the version being inserted into the stream, put the commas back in.
type: QuestionComment
comment on: http://stackoverflow.com/q/78372639
score: 0
type: Comment

http://stackoverflow.com/comment/138072498
comment on: http://stackoverflow.com/q/78317514
has text: No worries. BTW, none of this is stuff I would consider someone unhireable for if it happened in a job interview. It's a place where you'd get bonus points for getting it right, but not be written off for getting it wrong; the way to fail one of my interviews on shell scripting is more about writing scripts with injection vulnerabilities or other major security issues.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138184262
comment on: http://stackoverflow.com/q/78375308
score: 0
type: QuestionComment
type: Comment
has text: Add a newline before `\r`, thus `expect "OLT01>" { send "comamnd 1\n\r" }`

http://stackoverflow.com/comment/138149867
score: 0
comment on: http://stackoverflow.com/q/78361451
type: QuestionComment
type: Comment
has text: Can't reproduce here with a fresh install. Uninstall termux and install again

http://stackoverflow.com/a/78361002
has body: This might work for you (GNU sed): sed -E 's/v|rs|-?.\./ &amp;/ig' file Turn on extended regexp by setting -E. Using alternation look for either a v or rs or a possible - followed by a character followed by a period and insert a space before the match globally throughout the line throughout the file. N.B. The i flag in the substitution command allows the LHS of the command to match either case. The v caters for the VALUE in the header as does the rs for RSID1and RSID2 by chance. Of course this is based on the data given so to be bullet proof perhaps: sed -E '1s/V|RS/ &amp;/g;1!s/rs|-?.\./ &amp;/g' file
accepted answer of: http://stackoverflow.com/q/78359494
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78359494
downvote count: 0
score: 1
upvote count: 1
type: Answer

tr
type: Tag
tags question: http://stackoverflow.com/q/78392006
tag name: tr
tags question: http://stackoverflow.com/q/79333123

http://stackoverflow.com/comment/138214663
has text: Thank you for the hint. Like I said. It is my first question and answer, so I'm happy to get your input and format it better in the future! However, one thing I want to uderstand: I the printf command works perfectly fine. Why should I add `"%s", $0"`? Just to have a proper command because it is defined this way or is there a reason. The output is the same for, no matter if I use it or not.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78396833
score: 1

http://stackoverflow.com/a/78321507
upvote count: 4
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78319238
accepted answer of: http://stackoverflow.com/q/78319238
has body: The confusion arises because behind the scenes, obscure things happen when one attempts to execute a text file (ie. a file that is not a binary executable). Additionally, the output of pgrep -a regex may not be the string it used to search for the match. Processes are generally invoked by execve(2). Its manpage notes: The process name, as set by prctl(2) PR_SET_NAME (and displayed by ps -o comm), is reset to the name of the new executable file Text files are not directly executable; When one attempts to run a text file, behind the scenes the kernel notices that the start of the file is not the normal magic string that indicates a program (typically E L F \002 \001 \001 \0 \0 \0 \0 \0 \0 \0 \0 \0). If the kernel sees the file starts with # !, it splits the remainder of the first line into two and tries to execute the first part (the interpreter), passing as arguments the second part (often empty, or a flag telling the interpreter to expect a script), and the original process name (typically used by the interpreter as the filename of the script it should run). The kernel does not reset the ps comm value. pgrep regex tries to match a regular expression against the "process name" (ps comm value). This can be confusing in presence of processes invoked as above, if one expects that "process name" should be the name of the interpreter (as pgrep -a regex and the pgrep manpage could lead one to believe is the case). I don't know Rust so can't follow the alacritty source code but running under strace, I see that alacritty -e ./myscript does eventually do execve("./myscript", [...]). As an example, here is a bash script that invokes a Perl script that resets its process name. See the confusion that results when searching for it with pgrep. Note the different values of /proc/#pid/exe, /proc/#pid/comm and /proc/#pid/cmdline: tester: #!/bin/bash cat >myscript <<'EOD' #!/usr/bin/perl use Linux::Prctl(set_name); sleep 1; set_name("gotcha!"); sleep 3; EOD chmod +x myscript myinfo()(…
score: 3
type: Answer
downvote count: 1

google-assistant-sdk
tag name: google-assistant-sdk
tags question: http://stackoverflow.com/q/78316769
type: Tag

http://stackoverflow.com/comment/138306562
comment on: http://stackoverflow.com/q/78445380
score: 0
type: QuestionComment
type: Comment
has text: @phuclv They're *not* parsing `ls`, they're trying to get the list from a file. The only mention of `ls` is that they were able to create the file successfully from it.

android
type: Tag
tags question: http://stackoverflow.com/q/78361451
tag name: android
tags question: http://stackoverflow.com/q/78388693
tags question: http://stackoverflow.com/q/78402467
tags question: http://stackoverflow.com/q/78315911
tags question: http://stackoverflow.com/q/78519993
tags question: http://stackoverflow.com/q/78720340
tags question: http://stackoverflow.com/q/78801730
tags question: http://stackoverflow.com/q/78792841
tags question: http://stackoverflow.com/q/79123653
tags question: http://stackoverflow.com/q/79069445
tags question: http://stackoverflow.com/q/79188623
tags question: http://stackoverflow.com/q/79126424

http://stackoverflow.com/comment/138222442
comment on: http://stackoverflow.com/q/78402103
score: 0
type: QuestionComment
has text: The above provides a possible explanation for the behavior you're asking about, but we can't tell you for sure without example input, including database data. Possibly the terminal output of the original version of the script would suffice for conveying the relevant database content.
type: Comment

http://stackoverflow.com/comment/138255461
type: Comment
score: 0
type: QuestionComment
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
comment on: http://stackoverflow.com/q/78421398

http://stackoverflow.com/comment/138183986
type: QuestionComment
comment on: http://stackoverflow.com/q/78378844
has text: Just curious - why do you store your awk script in a variable (`var='BEGIN{echo "hello"}'; awk "$var"`) instead of interpreting it in-place (`awk 'BEGIN{echo "hello"}'`) in the midst of the rest of your code or wrapping the call in a function (`prthello() { awk 'BEGIN{echo "hello"}'; }; prthello`) to avoid cluttering where it's called?
type: Comment
score: 0

http://stackoverflow.com/comment/138154134
comment on: http://stackoverflow.com/q/78363909
score: 0
has text: Thank you for that suggestion. I tried LOAD_FILE() early on, and could not get it to work. I've been playing with it for the past couple hours, and still can't get it to work. I have proper permissions, I have FILE privilege, I even edited my.cnf—>secure-file-priv=/tmp/ and re-started the whole computer — still says LOAD_FILE() returned NULL. AAARRRGGGHHH!!!
type: QuestionComment
type: Comment

io-redirection
type: Tag
tags question: http://stackoverflow.com/q/78420131
tags question: http://stackoverflow.com/q/78401442
tag name: io-redirection
tags question: http://stackoverflow.com/q/78519611
tags question: http://stackoverflow.com/q/78885319
tags question: http://stackoverflow.com/q/79234334
tags question: http://stackoverflow.com/q/79519709

http://stackoverflow.com/comment/138232490
type: QuestionComment
has text: I have updated the question with the steps taken to generate the `docker.tar` to when it actually gets loaded
type: Comment
comment on: http://stackoverflow.com/q/78405506
score: 0

jupyter-notebook
tags question: http://stackoverflow.com/q/78313378
type: Tag
tag name: jupyter-notebook

http://stackoverflow.com/comment/138293957
type: QuestionComment
comment on: http://stackoverflow.com/q/78441613
has text: Neither of these is in any way Linux-specific, removed the according tag.
type: Comment
score: 0

http://stackoverflow.com/comment/138159606
has text: wow that is quite a surprise, it would have taken me hours too ... I was thinking that something external was deleting the `/var/run/flag.txt` on every reboot ... so the solution is simply to put it in another location
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78366286

http://stackoverflow.com/comment/138092493
comment on: http://stackoverflow.com/q/78329053
score: 1
type: QuestionComment
has text: ...whereas something that _is_ a proper match is [check if a string contains element of array with a shell script](https://stackoverflow.com/questions/60005122/check-if-a-string-contains-element-of-array-with-a-shell-script). (Granted, they're using `&&` there to combine the results, but the important missing piece behind this question -- being able to do substring matches on content found by iterating through an array -- is present)
type: Comment

http://stackoverflow.com/comment/138109536
type: Comment
has text: thank you for the comment, I will probably remove that section of the answer :)
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78331936

vpn
tag name: vpn
tags question: http://stackoverflow.com/q/78342422
type: Tag
tags question: http://stackoverflow.com/q/78869464

http://stackoverflow.com/comment/138284770
type: QuestionComment
score: 0
type: Comment
has text: And `awk` can also do its own `cut`, using `split()`.
comment on: http://stackoverflow.com/q/78438262

http://stackoverflow.com/comment/138099241
type: Comment
comment on: http://stackoverflow.com/q/78333123
type: QuestionComment
score: 0
has text: `if [ "$?" -ne 0 ] || [ "$commandOutput" = "string" ] || [ "$commandOutput" = "strong" ]; then doStuffOnError; else dontDoStuffOnError; fi`

http://stackoverflow.com/comment/138290793
type: QuestionComment
type: Comment
has text: The problem is that the second script is called with the establishment of the SSH connection ssh <user_name>@<IP> source ./Call.sh , which is why I had to combine the entire set of commands into one script.
comment on: http://stackoverflow.com/q/78441672
score: 0

http://stackoverflow.com/comment/138155148
has text: @deceze I think you're right, but this solution can possibly be adapted to do what I want
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78364736

http://stackoverflow.com/comment/138118517
has text: unfortunately, i can't really understand all that stuf, but i can understand that you have no time for that... I'll keep searching and parying for someone who can really help !
comment on: http://stackoverflow.com/a/78342527
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138221987
type: QuestionComment
has text: Maybe zsh. Yes, the default terminal.
comment on: http://stackoverflow.com/q/78402822
type: Comment
score: 0

http://stackoverflow.com/comment/138077833
type: QuestionComment
comment on: http://stackoverflow.com/q/78320604
type: Comment
has text: short of combing through system logs (looking for error messages) consider adding `>> /home/user/linuxconfig/startup.cronlog 2>&1` on the end of your crontab entry; this should capture all output (stdout + stderr) to the *.cronlog file and hopefully you'll find something useful in said file; my $0.02 guess is you'll find an error message similar to `chromium-browser: command not found`
score: 2

http://stackoverflow.com/comment/138100334
comment on: http://stackoverflow.com/a/78333360
has text: I did a mistake in my first reply sorry. It should be `||` not `&&`. `if ! commandOutput=$(command) || [[ $commandOutput = *"str"[io]"ng"* ]]`. I tested it this time. Also this is a perfect example of why I prefer declaring the variables on their own separate lines, to keep the code clean and easier to read/understand.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78424582
type: AcceptedAnswer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/78424358
type: Answer
has body: Note that bash supports true regular expressions with the =~ operator of conditional expressions ([[ ... ]]); the nice aspect is that the test to skip non-matching file names comes for free: for files in *.cfc_; do $files =~ (.*)_N_(.*)_ && cp "$files" "${BASH_REMATCH[1]}_${theID}_${BASH_REMATCH[2]}" done With extended pattern matching (in a subshell to automatically restore the extglob option): ( shopt -s extglob for files in *.cfc_; do cp "$files" "${files%%_N_*}_${theID}_${files//!(*.*)_}cfg" done ) ${files%%_N_*} is a regular substitution that deletes the longest suffix starting with _N_; in your example it leaves myFile. ${files//!(*.*)_} is an extended pattern-matching and substitution that replaces all _-terminated substrings not containing a period with the empty string; in your example this leaves something.. We could also split the file name on _ using IFS (in a subshell to automatically restore IFS): for files in *.cfc_; do ( IFS=_; a=( $files ); cp "$files" "${a[0]}_${theID}_${a[2]}" ) done
accepted answer of: http://stackoverflow.com/q/78424358
score: 4

http://stackoverflow.com/comment/138137511
type: QuestionComment
type: Comment
has text: @DaveButler There's overlap, but my general criteria is that it belongs over there if the problem is unrelated to the program's use in programming. Similarly, if you're having a problem using `apt-get`, it doesn't usually become on-topic here because the package you're trying to install is used for programming.
comment on: http://stackoverflow.com/q/78349529
score: 0

http://stackoverflow.com/comment/138129844
has text: The main idea is to use `cmd.exe << EOF`. Does that work ?
score: 0
comment on: http://stackoverflow.com/a/78344012
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138204557
comment on: http://stackoverflow.com/q/78392914
has text: As a separate aside -- any time you use square brackets in an argument, it's safer to quote it. That is to say, `-R 'rusage[mem=8G]'` is safer than `-R rusage[mem=8G]`, since the latter can be parsed as a glob, which would make its behavior depend on filesystem content in the current directory (for example, if you ran that command in a directory containing a file named `rusagem` or `rusagee`, the shell could replace the word with either or both of those names).
score: 0
type: QuestionComment
type: Comment

formatting
tags question: http://stackoverflow.com/q/78419985
tag name: formatting
type: Tag
tags question: http://stackoverflow.com/q/79028351
tags question: http://stackoverflow.com/q/79514807

http://stackoverflow.com/a/78317198
answers question: http://stackoverflow.com/q/78316829
score: 0
has body: I cannot check as I do not have macOS, but I think the line missing from your input might go to stderr, but operator $( ... ) only capture stdout I could try to redirect stderr to stdout: updates=( $(softwareupdate --list 2&gt;&amp; 1) ) Also, I am surprise by the example you give: you set updates as an array, but displayed it as a string. It should only display the first word
has comment: http://stackoverflow.com/comment/138072128
type: Answer

http://stackoverflow.com/q/78388395
tagged with: snmp
type: Question
tagged with: snmp-trap
has answer: http://stackoverflow.com/a/78390328
answer count: 1
tagged with: cpu
score: 0
accepted answer: http://stackoverflow.com/a/78390328
tagged with: bash
has body: When a trap arrives to my system I execute a bash script automatically. Problem is sometimes a lot of traps arrive simultaneously making a lot executions of the script and generating system cpu pikes Do you know how could avoid that situation? I thought some mechanism that only executes a determined scripts and the rest waiting like a FIFO queue but I don’t know if that is possible Thanks
has title: Limit execution number of bash script triggered by snmp trap
type: AnsweredQuestion

http://stackoverflow.com/comment/138269977
has text: Hauri: I found a solution based on your examples, thanks!
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78428136
type: AnswerComment

cpu
tag name: cpu
type: Tag
tags question: http://stackoverflow.com/q/78388395
tags question: http://stackoverflow.com/q/79312013
tags question: http://stackoverflow.com/q/79485736

http://stackoverflow.com/comment/138092458
score: 2
type: Comment
type: AnswerComment
has text: `[ $found == false ]` is better written as be `[ "$found" = false ]`. Yes, we know that in this particular case `[` will be an extended one with (nonstandard) support for `==` as a comparison operator, and that `found` will always have the exact string `true` or `false`... but better practice to demonstrate code that will work in other shells and handle surprising circumstances (like when IFS contains characters from either `true` or `false`) correctly.
comment on: http://stackoverflow.com/a/78329104

http://stackoverflow.com/comment/138312066
has text: "it can be posix" != "it has to be posix". Sounds like you're saying it doesn't have to be posix. And, again, why does it have to be sed given sed isn't the best choice of even just the mandatory POSIX tools for this?
comment on: http://stackoverflow.com/q/78441613
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78354347
score: 2
upvote count: 2
downvote count: 0
has body: You can use namerefs to access global arrays by name, rather than by value. test_it() { info=$1 type=$2 declare -n files=$3 declare -n options=$4 optdesc=$5 declare -n precond=$6 for idx in "${!files[@]}" do filename="log/$type/$filed-$optdesc.log" if ! -f $filename ; then touch "$filename" fi ./prog $file "${options[@]}" -precondition "${precond[idx]}" > "$filename" done } type="termination" info="info1" files=("tests/termination/boolean.c" "tests/termination/cacm2009a.c" "tests/termination/cav2006.c" "tests/termination/example1.c" "tests/termination/example2a.c" "tests/termination/tacas2013a.c" ) precond=("${files[@]/*/"true"}") options=("-ctl-cfg" "AF{exit: true}") optdesc="termCFG" test_it "$info" "$type" files options "$optdesc" precond Note that you don't need to test the length of options inside test_it (though if you did, I would use (( ${#options[@]} == 0 )) instead); "${options[@]}" produces no words, not a single empty string, if the array is empty.
type: Answer
answers question: http://stackoverflow.com/q/78353017

http://stackoverflow.com/comment/138181596
type: Comment
score: 0
type: AnswerComment
has text: Thanks! with the instructions you gave me, i found the problem!
comment on: http://stackoverflow.com/a/78374597

http://stackoverflow.com/comment/138129919
type: Comment
has text: Each process can only have stdin connected to one place. It can come from the heredoc, _or_ it can come from the pipeline, but not both at the same time.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78350497

http://stackoverflow.com/comment/138203582
score: 1
has text: @Shayan If you MUST use indirection, you could abuse `declare` for that, e.g. `declare -- "${x}" 2>/dev/null || echo error`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78392419

http://stackoverflow.com/comment/138296628
type: QuestionComment
type: Comment
has text: Maybe add `echo "qtr: \"$qtr\""` so you can examine the contents. I would also add curly braces `file_name_${qtr}.csv`
score: 0
comment on: http://stackoverflow.com/q/78444871

http://stackoverflow.com/a/78426600
downvote count: 0
answers question: http://stackoverflow.com/q/78424828
upvote count: 1
has body: Is there anyway to solve this by any change inside shell script. So that user can pass ./test.sh $-123 without single quote. Actually, it is impossible in this way because shell will perform all this variable expansion, wildcard expansion, etc, before calling the script. It is how shell works - parses command line, and then executes it, so the script will receive already expanded value. So if you want to send anything to script as argument, you must put it in quotes. In the script you can use "read" command to read something interactively, in this case you can pass anything without quotes
type: Answer
score: 1

http://stackoverflow.com/a/78464354
downvote count: 0
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78442690
has body: Using declare -A "varname=($compound)" is a kind of eval!! If you have to create an associative variable from variable input, you have to be conscient that this syntax is a kind of eval: compound='[lv_home_oracle]=20480 [test]=$(uptime)' declare -A "y=($compound)" declare -p y declare -A y=([lv_home_oracle]="20480" [test]=" 12:38:47 up 250 days, 16:41, 1 user, load average: 1.36, 1.48, 1.33" ) How to populate an associative array without having to loop over each element? Here is my solution. Using bash builtin printf and a temporary format string: mapfile -t outlines < <(lvs --noheadings --units m -o name,size) printf -v fmtStr '[%q]=%%q ' "${outlines[@]/%+( )[0-9]*}" printf -v fmtStr "$fmtStr" "${outlines[@]/#* }" declare -A "myLVM=(${fmtStr//\\ })" declare -p myLVM declare -A myLVM=([lv_home_oracle_swdepot]="40960.00m" [lv_home_oracle]="20480.0 0m" [lv_opt_crs]="40960.00m" [lv_home_oracle_app]="40960.00m" ) Then you could do a 2nd pass for dropping .00m: printf -v fmtStr '[%q]=%%q ' "${!myLVM[@]}" printf -v fmtStr "$fmtStr" "${myLVM[@]%.00m}" declare -A "myLVM=($fmtStr)" declare -p myLVM declare -A myLVM=([lv_home_oracle_swdepot]="40960" [lv_home_oracle]="20480" [lv_ opt_crs]="40960" [lv_home_oracle_app]="40960" ) Whatif, with a faked lvs: lvs() { /sbin/lvs "$@" echo ' Test $(uptime)' } Then: mapfile -t outlines < <(lvs --noheadings --units m -o name,size) printf -v fmtStr '[%q]=%%q ' "${outlines[@]/%+( )[0-9]*}" printf -v fmtStr "$fmtStr" "${outlines[@]/#* }" declare -A "myLVM=(${fmtStr//\\ })" declare -p myLVM declare -A myLVM=([lv_home_oracle_swdepot]="40960.00m" [lv_home_oracle]="20480.0 m" [lv_opt_crs]="40960.00m" ["test\$(uptime)"]="\$(uptime)" [lv_home_oracle_app ]="40960.00m" ) printf -v fmtStr '[%q]=%%q ' "${!myLVM[@]}" printf -v fmtStr "$fmtStr" "${myLVM[@]%.00m}" declare -A "myLVM=($fmtStr)" declare -p myLVM declare -A myLVM=([lv_home_oracle_swdepot]="40960" [lv_home_oracle]="20480" [lv_ opt_crs]="40960" ["test\$(uptime)"]="\$(uptime)" [lv_home_oracle_a…
has comment: http://stackoverflow.com/comment/140216668

http://stackoverflow.com/comment/138073752
type: Comment
has text: Might consider `(( curr_level == 0 ))` -- if writing bash-only code, might as well take advantages of extensions that improve clarity.
type: AnswerComment
comment on: http://stackoverflow.com/a/78318419
score: 0

http://stackoverflow.com/comment/138137195
comment on: http://stackoverflow.com/q/78351058
type: QuestionComment
type: Comment
score: 0
has text: Thank you for your engagement on this post, I appreciate it!

http://stackoverflow.com/q/78359185
tagged with: bash
has body: My use case: I have Terraform code that spins up a GCP VM. Within the Terraform code, there is a startup script that creates a user and adds a password, and does several other bits, like changing the user permissions to one folder. The goal is to have an automatic spin server for SFTP data exchange for several data providers. Everything is working nicely, but the missing bit is when the files get uploaded, I want them to transfer to GCP Bucket automatically. This is needed for other pipeline runs related to Cloud Functions and Vertex AI. I have a bash script that uses inotifywait and it is operational when I run it. However, the thing is that I want this script to run itself. Script example: #!/usr/bin/bash dir1=/home/data/ while inotifywait -qqre "attrib,modify,close_write,move,move_self,create,delete,delete_self" "$dir1"; do gsutil cp -r "$dir1" gs://bucket_name done Now, in the startup script, I am trying to run this as part of a big startup script (adding only this part): "#! /bin/bash\nsudo while inotifywait -qqre \"attrib,modify,close_write,move,move_self,create,delete,delete_self\" \"/home/$folder_name/\"; do gsutil cp -r \"/home/$folder_name/\" gs://bucket_name done\ncat <<EOF > /var/www/html/index.html\n Linux startup script added directly. \n EOF" Can I open the process as such or should I add this and write to a file? Should it be in /etc/profile so that it is always executed when a file is uploaded or do I have a cron setup to run every hour or so?
tagged with: google-cloud-platform
has title: Where to output a bash script that tracks changes in a folder
tagged with: inotify
score: 0
type: Question
tagged with: shell
answer count: 0
tagged with: linux
type: UnansweredQuestion

http://stackoverflow.com/comment/138198263
score: 1
type: QuestionComment
has text: Can you `source` the file?
comment on: http://stackoverflow.com/q/78389511
type: Comment

http://stackoverflow.com/comment/138214214
comment on: http://stackoverflow.com/q/78384843
score: 0
has text: can also use ControlMaster technique with `rsync -e`
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138213865
type: Comment
has text: `/\/table/` should be `/<\/table>/`, and `/\/tr/ && a` should be `b && /<\/tr>/` (yes `b`, not `a`) for improved robustness regarding what the regexps match and the context they will match in, and efficiency by only doing the regexp comparison if in the target section of input.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78396833

http://stackoverflow.com/comment/138195970
score: 0
has text: What do you mean by "just reduce Y"? Your desired image showed that you wanted a gap at the top. Why is the white arrow there if you did not want that? If you do not want that gap, remove `-background black -splice 0x20`. Or decrease 20. It would be better if your desired example showed exactly what you really wanted for the output or you explained it better.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78387161

http://stackoverflow.com/comment/138256821
type: QuestionComment
has text: Include input json text for those of us who don't do aws?
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78422524

http://stackoverflow.com/a/78442965
answers question: http://stackoverflow.com/q/78442690
has body: Just assign the values, line by line. tmp=$(lvs --noheadings --units m --nosuffix -o name,size vg_oracle | cut -d. -f1) declare -A oralvs while read -r a b; do oralvs["$a"]="$b" done <<<"$tmp"
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/comment/138288821
comment on: http://stackoverflow.com/q/78438850
type: QuestionComment
has text: BTW, are you really sure that you want to put your `.` into your PATH? In general, the PATH variable should only contain absolute pathes.
type: Comment
score: 0

http://stackoverflow.com/comment/138200534
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78389737
type: AnswerComment
has text: There was a bug in an older version of bash that could break this -- which release are you trying to use? It should be fine in modern (5.x) builds.

http://stackoverflow.com/comment/138115261
type: QuestionComment
comment on: http://stackoverflow.com/q/78341760
score: 1
has text: `trap _term EXIT` may do you better.
type: Comment

http://stackoverflow.com/comment/138246381
has text: How are you running the container? The entrypoint wrapper script seems fine, though I might avoid the non-standard `source` command. The `ENTRYPOINT` declaration runs `./entrypoint.sh` out of the current directory but in the previous line you copy it to `/entrypoint.sh` in the filesystem root; is that a problem?
type: Comment
comment on: http://stackoverflow.com/q/78416125
type: QuestionComment
score: 0

calculation
type: Tag
tags question: http://stackoverflow.com/q/78326945
tag name: calculation

http://stackoverflow.com/comment/138275411
has text: Try `kill -s SIGINT -28923`
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78432948
type: Comment

http://stackoverflow.com/comment/138187761
comment on: http://stackoverflow.com/q/78383368
type: QuestionComment
score: 2
type: Comment
has text: Don't store commands in variables. Variables are for data, not executable code. If you need to store executable code, use a function, or for simple commands an array. See [BashFAQ #50: "I'm trying to put a command in a variable, but the complex cases always fail!"](http://mywiki.wooledge.org/BashFAQ/050), ["Why does shell ignore quoting characters in arguments passed to it through variables?"](https://stackoverflow.com/questions/12136948), and many other previous questions. But ignore all suggestions to use `eval`, it's a massive bug magnet.

http://stackoverflow.com/a/78359508
answers question: http://stackoverflow.com/q/78359494
type: Answer
score: 2
upvote count: 2
downvote count: 0
has body: Assumptions: 2nd and 3rd fields always start with the letters rs the letters rs do not show up anywhere else in the data (other than as the 1st two characters of the 2nd/3rd fields) the 4th field always starts with (optional -) + 0. Tweaking and combining OP's sed scripts: $ sed 's/rs/ &amp;/g; s/-*0[.]/ &amp;/g' sample.txt GENERSID1RSID2VALUE ENSG00000242220 rs2826052 rs2826052 0.20961262553802 ENSG00000242220 rs2826052 rs79893204 0.00583452893352463 ENSG00000242220 rs2826052 rs117256228 -0.003012912482066 As for the header row, some assumptions: 2nd and 3rd fields always start with the letters RS the letters RS do not show up anywhere else in the data (other than as the 1st two characters of the 2nd/3rd fields) the 4th field always starts with the letters VAL the letters VAL do not show up anywhere else in the data (other than as the 1st three characters of the 4th field) Adding some additional code to address the header: $ sed 's/rs/ &amp;/g; s/-*0[.]/ &amp;/g; s/RS/ &amp;/g; s/VAL/ &amp;/g' sample.txt #### adding the `i` flag (`gi`) to indicate case insensitive matching on `rs` vs `RS` $ sed 's/rs/ &amp;/gi; s/-*0[.]/ &amp;/g; s/VAL/ &amp;/g' sample.txt Both of these generate: GENE RSID1 RSID2 VALUE ENSG00000242220 rs2826052 rs2826052 0.20961262553802 ENSG00000242220 rs2826052 rs79893204 0.00583452893352463 ENSG00000242220 rs2826052 rs117256228 -0.003012912482066 Implementing the same approach in awk: $ awk '{ gsub(/rs|RS|VAL|-*0[.]/,&quot; &amp;&quot;) } 1' sample.txt GENE RSID1 RSID2 VALUE ENSG00000242220 rs2826052 rs2826052 0.20961262553802 ENSG00000242220 rs2826052 rs79893204 0.00583452893352463 ENSG00000242220 rs2826052 rs117256228 -0.003012912482066

http://stackoverflow.com/comment/138078729
comment on: http://stackoverflow.com/a/78320229
has text: Eh, if it's a missing feature (a case where excluding parents is only available on some implementations but not others) then it's not a bug report; I'm rechecking the documentation.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138137582
comment on: http://stackoverflow.com/q/78354730
has text: The array is the correct solution. How you *build* that array from your input file is another question that needs to be answered.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138276042
type: Comment
has text: Try using `py` instead of `python3` in your PowerShell script e.g. `py -c "print(1)"`
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78433313

http://stackoverflow.com/a/78469404
type: Answer
has body: suggesting to try: sed -i 's/product-ui-test-creds.json/vaulted-product-ui-test-creds.json/g' $(find -type f)
score: 0
answers question: http://stackoverflow.com/q/78330348

http://stackoverflow.com/comment/138173414
score: 0
type: Comment
has text: That's storing file *names*, not file handles. Also, it's environment specific. Not all environments where Bash can be found provide `/dev/stdin` or `/dev/stdout`.
type: AnswerComment
comment on: http://stackoverflow.com/a/78375051

http://stackoverflow.com/comment/138159396
has text: the fact that the startup script runs tells me that terraform is not the problem, all terraform will do is create the VM with that `metadata_startup_script` so maybe is something with that code some how that `IF` statement is not doing what you think
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78366286

http://stackoverflow.com/comment/138296879
score: 0
comment on: http://stackoverflow.com/q/78444871
has text: shellcheck.net says no issues detected on file_name_"${qtr}".csv, but error persists
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138149645
comment on: http://stackoverflow.com/q/78361173
type: QuestionComment
type: Comment
score: 0
has text: if I add a trailing `fi` and run against a file with the contents `www.google.com \n abc.def.ghi.jkl` I get `Domain name: www.google.com \n IP Address: 142.250.190.100 \n No domain names found`; if I run against an empty file the script returns immediately (with no output generated); net result: the script works (for me); I'd recommend adding some debugging to figure out where the script is hanging; would also help if you were to provide us with a sample file (2-3 sample domains) that your script hangs on

http://stackoverflow.com/comment/138129478
type: Comment
type: AnswerComment
score: 0
has text: Not quite I'm afraid. I've added an update to show what this does.
comment on: http://stackoverflow.com/a/78344012

http://stackoverflow.com/comment/138257814
score: 0
type: QuestionComment
type: Comment
has text: The part after the `&&` does not make sense to me. Don't you get a syntax error?
comment on: http://stackoverflow.com/q/78422019

http://stackoverflow.com/comment/138258286
type: Comment
score: 0
comment on: http://stackoverflow.com/a/78423240
has text: `"true"` will work just as well of course, but the common idiom is simply `1`. But this fails to capture the requirement to only replace on lines which do not start with `#`
type: AnswerComment

http://stackoverflow.com/comment/138181950
score: 4
comment on: http://stackoverflow.com/q/78380184
type: QuestionComment
type: Comment
has text: The exclamation mark is not a part of the `if` command, it negates the exit status of the pipeline following it. Try `! false; echo $?` and you'll see. You can access the exit values of pipeline components through the `PIPESTATUS` array if you have to.

http://stackoverflow.com/a/78392023
answers question: http://stackoverflow.com/q/78392006
has comment: http://stackoverflow.com/comment/138202841
has comment: http://stackoverflow.com/comment/138202759
downvote count: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/138202776
type: Answer
has body: tr is not the right tool for this as it replaces one character with another. You may use sed like this: echo '"hello workd"' | sed -E 's/"/\\&/g' \"hello workd\" In s/"/\\&/g we are matching a " and replacing with a \ followed by the full match i.e. " itself.
score: 1

http://stackoverflow.com/comment/138079887
has text: this works! thanks! It's also quite complex, more than I thought!
score: 0
comment on: http://stackoverflow.com/a/78321913
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78329104
has comment: http://stackoverflow.com/comment/138092458
accepted answer of: http://stackoverflow.com/q/78329053
type: AcceptedAnswer
upvote count: 2
answers question: http://stackoverflow.com/q/78329053
downvote count: 0
type: Answer
has body: Try with: #!/bin/bash email="john.brown@google.com" list=("app-1" "app-2" "john") found=false for item in "${list[@]}"; do if $email == *"$item"* ; then echo "Found!" found=true break fi done if [ $found == false ]; then echo "Not found." fi
score: 2

http://stackoverflow.com/a/78431203
downvote count: 0
score: 1
upvote count: 1
has body: This might work for you (GNU sed): sed '1!s/^[^#]/E_&amp;/' file If it is not the first line and does not begin with a # character insert E_ at the front of the line.
answers question: http://stackoverflow.com/q/78423090
type: Answer

http://stackoverflow.com/a/78367150
downvote count: 0
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78366286
has comment: http://stackoverflow.com/comment/138159838
type: Answer
score: 1
has body: So it turns out that /var/run is symbolically linked to /run which is created at startup. I fixed this by writing the flag.txt file to /etc.
answers question: http://stackoverflow.com/q/78366286
type: AcceptedAnswer

http://stackoverflow.com/comment/138216882
has text: Thank you for the explanation! You are right, I get different error messages, but as you said only the last one works. I have no idea why it works in my posted code though. It still works with the single printf command. I changed in my script though!
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78396833

http://stackoverflow.com/comment/138189493
score: 1
has text: I'm confused by `line=$(echo $*)`. Is your input 1 line of text or multiple lines of text as shown in your question? Is your tool being called with that input as arguments as implied by `line=$(echo $*)`` or does it read it from a file or pipe? Please [edit] your question to show how the code currently present in it is called as I strongly suspect that's a better way to do THAT as well as solve the problem you're asking about.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78383503

http://stackoverflow.com/a/78428136
type: AcceptedAnswer
upvote count: 2
accepted answer of: http://stackoverflow.com/q/78427584
has comment: http://stackoverflow.com/comment/138269226
score: 1
has comment: http://stackoverflow.com/comment/138269977
has comment: http://stackoverflow.com/comment/138270574
has body: Playing with array under bash 0. Preamble Care using bash as a programming language! If you plan do work on big entries, maybe some filter could be more efficients. For sample: mapfile -t array < <(grep -v '\(foo\|bar\)$' < <(/bin/yourCommand -args)) will populate your $array variable from the output of yourCommand, after deleting lines ended by foo or bar. And ask yourself if you need to store whole array in a variable, or if you may have to pass this output as a stream to any next command... 1. Quick drop in (submited) array shopt -s extglob array=(8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t) array=(${array[@]/%*([0-9])bar}) array=(${array[@]/%*([0-9])foo}) declare -p array declare -a array=([0]="86696485745u" [1]="23164919a1" [2]="859479268209t") Revert job, deleting all but not bar nor foo: Sorry, miss readed... shopt -s extglob array=(8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t) toDel=(${array[@]/%*([0-9])bar}) toDel=(${toDel[@]/%*([0-9])foo}) toDel=("${toDel[*]}") array=(${array[@]/#?(${toDel// /|})}) declare -p array declare -a array=([0]="8669648574foo" [1]="231649bar" [2]="8594792682foo") 2. Using unset in a loop: Note: for matching multiple variation of same variable, you'd better use case switches, instead of multiple == whith || or &&! array=(8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t) for i in ${!array[@]};do case ${array[i]: -3} in foo | bar ) unset "array[i]" ;; esac done declare -p array declare -a array=([1]="86696485745u" [3]="23164919a1" [5]="859479268209t") Notice the index keys: 1, 3 and 5, instead of 0, 1 and 2. Then, to invert the job: array=(8669648574foo 86696485745u 231649bar 23164919a1 8594792682foo 859479268209t) for i in ${!array[@]};do case ${array[i]: -3} in foo | bar ) ;; * ) unset "array[i]" ;; esac done declare -p array declare -a array=([0]="8669648574foo" [2]="231649bar" [4]="8594792682foo") 3. Using associative arrays This solution is…
type: Answer
downvote count: 1
answers question: http://stackoverflow.com/q/78427584

http://stackoverflow.com/comment/138226356
has text: Thanks @GordonDavisson ! Both your suggestion and F.Hauri's were applied to get this to work.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78405034
type: Comment

http://stackoverflow.com/comment/138260632
has text: In the solution code you added, there's no point having `if (matched) {` in all the blocks that set variables since you test `if (matched) {` before using those variables.
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78419985

http://stackoverflow.com/comment/138268064
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78428595
has text: `echo` is not a reliable way to examine the value of a variable (especially when passed unquoted). try something like `printf '%q\n' "$SESSION"`
score: 4

http://stackoverflow.com/comment/138135900
comment on: http://stackoverflow.com/q/78353316
score: 1
type: QuestionComment
type: Comment
has text: Does this answer your question? [Bash process substitution and syncing](https://stackoverflow.com/questions/4489139/bash-process-substitution-and-syncing). If not, it is for sure related.

http://stackoverflow.com/a/78380299
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78380184
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138190578
has comment: http://stackoverflow.com/comment/138191324
upvote count: 2
answers question: http://stackoverflow.com/q/78380184
type: Answer
score: 2
has body: ! does not reset the exit code. It negates the exit code of the command that follows and produces the final exit code of the pipeline. It is explained in section "3.2.3 Pipelines" of Bash documentation (it is also on man bash but without section numbers). A pipeline is a sequence of one or more commands separated by one of the control operators | or |&. The format for a pipeline is [time [-p]] [!] command1 [ | or |& command2 ] ... ... The exit status of a pipeline is the exit status of the last command in the pipeline [...]. If the reserved word ! precedes the pipeline, the exit status is the logical negation of the exit status as described above. ! is not part of the syntax of the if statement. The syntax of the if statement is: if list; then list; [ elif list; then list; ] ... [ else list; ] fi A list of commands is a sequence or one or more pipelines, separated by one of the operators ;, &, &&, or ||. Usually, a single pipeline is used to describe the condition in an if statement. Because ! is part of a pipeline, the results that you get can also be described without using an if statement: $ echo foo foo $ echo $? 0 $ ! echo foo foo $ echo $? 1 Update As user @oguz-ismail describes in a comment on the question, the array variable PIPESTATUS contains a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command). Let's try some examples: $ echo foo | cat; echo "${#PIPESTATUS[@]}" foo 2 The pipeline contains two commands, the array PIPESTATUS contains two items (${#X[@]} is the number of items in the array variable X). $ echo foo | cat; echo "${PIPESTATUS[@]}" foo 0 0 Both commands exit successfully. $ echo foo | cat; echo -e "$?\n" "${PIPESTATUS[@]}" foo 0 0 0 The pipeline completed successfully (the second line, printed by $?), each command completed successfully ("${PIPESTATUS[@]}" produces the items of PIPESTATUS as separate parameters for echo). $ ! echo foo | cat; echo -e "$?\n" "${P…

http://stackoverflow.com/comment/138278116
score: 0
comment on: http://stackoverflow.com/q/78433528
has text: Also, the result from `dig` will have double-quotes around it, which will be treated as part of the value unless you remove them.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138169969
score: 0
comment on: http://stackoverflow.com/a/78373052
has text: I don't agree, [this could be written in a more readable way, anyway!](https://stackoverflow.com/a/78373323/1765658)
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138201899
score: 0
has text: `tail -f` keeps the stream open. Otherwise, if you do an `echo "extrainput" > fifo`, the fifo will close.
comment on: http://stackoverflow.com/a/78390677
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138290721
score: 0
has text: It would be possible but there you would be parsing a more complex CSV format. What if you have escaped double quotes in some fields? I don't recommend parsing complex CSV without a dedicated parser. You could try the `--csv` option of GNU `awk` but even this has limitations. Or you could try one of the many CSV toolkits (e.g., [`csvkit`](https://csvkit.readthedocs.io/en/latest/index.html)).
type: Comment
comment on: http://stackoverflow.com/a/78441170
type: AnswerComment

http://stackoverflow.com/comment/138072417
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78317514
has text: Your assignment is written by someone who doesn't know what they're doing. `jobs` is specified in the optional interactive annex of POSIX sh -- noninteractive shells aren't required to have a `jobs` command at all. The proper way for noninteractive shells to read the PID of processes they started is using `$!`.
score: 2

http://stackoverflow.com/comment/138187838
comment on: http://stackoverflow.com/a/78383369
score: 3
has text: Please don't use `eval` for things like this, it tends to solve simple problems but cause unexpected weird problems later on, in particular when unexpected shell syntax characters show up in your data -- and `eval` parses (and maybe executes) them as shell syntax. See ["Why should eval be avoided in Bash, and what should I use instead?"](https://stackoverflow.com/questions/17529220)
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138215569
comment on: http://stackoverflow.com/a/78396041
type: Comment
type: AnswerComment
score: 0
has text: tried both steps, the `cloud-init-output.log` is the same "Could not get lock..."

http://stackoverflow.com/comment/138265844
score: 0
type: QuestionComment
type: Comment
has text: Let me test this
comment on: http://stackoverflow.com/q/78422019

http://stackoverflow.com/comment/138290745
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78441672
type: Comment
has text: Why not jst share the folder with all required scripts ? Also is this a one off case or u need it to be automated ? If one off jst copy all contents to the primary script.

http://stackoverflow.com/comment/138251710
score: 3
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78419614
has text: _Wildcard expansion is for finding names of files in the actual file system_. Not only. In this case `=~` is not needed. `$FI == *.l* ` is enough because there is no word splitting and no pathname expansion in conditional expressions and pattern matching is used for `==`. If I remember well it should even work with older bash versions than `=~`.

http://stackoverflow.com/q/78409749
has comment: http://stackoverflow.com/comment/138234379
has comment: http://stackoverflow.com/comment/138234677
type: Question
has title: what would be efficient way to to some job while waiting for a bash background process
tagged with: background-process
has answer: http://stackoverflow.com/a/78409972
has body: I know how wait and & work but Instead of stalling at Wait Command I want to do some other job meanwhile. For example this is my main code that sleeps for 10 seconds (background process). #!/bin/bash sleep 10 & pid1=$! ./loading_bar.sh $pid1 echo "Finished Loading Stuff" exit 0 While the main script sleeps for 10 seconds I print a Loading bar and in while loop check for Background process to finish. This Methods works perfectly but I would ask if there is any efficient way of doing this task as while (( 1 )); is a poor programming practice and can lead to infinite Looping if something goes wrong let's say the child process DEMONIZES or never exits for instance. #!/bin/bash proc_main=$1 tput civis echo -e " ----------------------------------" echo -ne "Loading | "; tput sc; echo -e " |" echo -e " ----------------------------------" tput rc tput cuu1 tput cuu1 while (( 1 )); do for (( i=0; i<25; i++ )); do echo -ne "*"; sleep 0.010 done tput rc tput cuu1 tput cuu1 tput ech 25 sleep 0.1 if ! ps -p $proc_main > /dev/null; then echo " Process Completed ! " break fi done echo -e "" tput cnorm ``
type: UnansweredQuestion
answer count: 1
has comment: http://stackoverflow.com/comment/138234485
has comment: http://stackoverflow.com/comment/138234503
has comment: http://stackoverflow.com/comment/138234725
score: 0
tagged with: linux
tagged with: bash

jib
tags question: http://stackoverflow.com/q/78346697
tag name: jib
type: Tag

http://stackoverflow.com/comment/138129944
comment on: http://stackoverflow.com/a/78350523
has text: So what they probably need is `ssh server bash -c 'cd blah && tar -zxf -'`
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138240990
has text: i tried to use nth(1) as below declare -A mymap=([name]="test" [age]="13") `jq -n ' $ARGS.positional | [_nwise(length/3)] | transpose | map({NewAttributes: first, OptionName: nth(1), Value: last}) ' --args "test" "${!MYMAP[@]}" "${MYMAP[@]}" > option.json` but the out put result is wrong in the second element ` [ { "NewAttributes": "test", "OptionName": "name", "Value": "test" }, { "NewAttributes": "age", "OptionName": "13", "Value": null } ] `
score: 0
comment on: http://stackoverflow.com/a/78411906
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138131909
has text: `$PIPESTATUS` hold the result of the last *forked* command (`false` in this case), `$?` contain de status of the last *script* command (`while ...;do ...;done`).
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78351657

http://stackoverflow.com/comment/138366860
score: 0
has text: The problem is, I'm not really sure what the end goal is script is. If you just need all the lines from the tbl_service table that have the configure_name, service_description and check_name that match the other file, the SQL statement you have does that, except I would change it to `select * FROM tbl_service WHERE config_name='$configname' and check_command='$newcommand' and service_description='$servicename'` that way you'd get all the fields from each line in the tbl_service table that has those values. Otherwise, it is just going to each those three fields for each match.
type: Comment
comment on: http://stackoverflow.com/a/78403450
type: AnswerComment

http://stackoverflow.com/comment/138223249
type: QuestionComment
comment on: http://stackoverflow.com/q/78402822
score: 0
has text: So they did this in Windows too? I implemented this as a feature in the interactive listener of the TXR Lisp programming language. If you hit Enter, then it behaves in the traditional way like the shells. To maintain position (actually: to the next command in sequence at the history position), you can use Ctrl-X Enter. The need for this is totally obvious: you need to repeat a 5 command sequence that is 100 commands back; searching back for each one is a non-starter.
type: Comment

http://stackoverflow.com/comment/138284799
score: 4
has text: Regarding "I want to create a oneliner..." - asking for a oneliner will discourage people from helping you as it's telling us you favor brevity over all the things that actually matter in software such as robustness, conciseness, efficiency, portability, etc. and so are likely to accept a brief solution over one that's better in every meaningful way. So, you might want to remove that part of your question, get help creating a good solution, and then think about how to cram it all onto 1 line if that still matters to you.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78438262

http://stackoverflow.com/comment/138078009
has text: @simbioz, have you considered using tmux's capabilities for listing active sessions? That way you can check not just whether there's a copy of tmux running anywhere else on the same machine, but specifically whether there's a tmux session _with a given name_ and avoid pgrep giving you incorrect results.
type: Comment
comment on: http://stackoverflow.com/q/78319238
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138104571
comment on: http://stackoverflow.com/q/78335326
type: Comment
score: 0
has text: @rzwitserloot's comment - my comment was regarding this [comment](https://stackoverflow.com/questions/78335326/is-there-an-alternative-way-to-run-succesfully-a-java-program-without-commentin?noredirect=1#comment138103565_78335326) - I rephrase: `java com.estudio.ejerciciosclase.sumScanner` will only work if: 1) the working directory is `build/classes` and the CLASSPATH environment variable is empty or contains `.`; **or** 2) the CLASSPATH env-var. contains the `build/classes` directory. This is NOT A SUGGESTION, just a fact. Use: `java -cp build/classes com.estudio.ejerciciosclase.sumScanner`
type: QuestionComment

http://stackoverflow.com/a/78417457
type: Answer
answers question: http://stackoverflow.com/q/78417099
score: 0
has body: You have to wrap $w with "" than it'll work, like this: #!/bin/bash SSH_CMD=xxx # suppose `SSH_CMD` is my ssh command w=$(cat word) SSH_CMD <<EOF1 cd /data00 touch for-test echo "$w" >> for-test echo "abc" >> for-test EOF1 Also note that "" around $(cat word) are not needed.

http://stackoverflow.com/a/78361234
has body: ...pauses action and does not continue... I suspect that it's hanging in host because you've fed it a domain that takes a long time to check. You could override the default timeout time by using the -W <seconds> option: is_valid_domain() { local domain="$1" host -W 1 "$domain" > /dev/null }
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78361173

synology
tag name: synology
tags question: http://stackoverflow.com/q/78436832
type: Tag
tags question: http://stackoverflow.com/q/78488507
tags question: http://stackoverflow.com/q/78450852
tags question: http://stackoverflow.com/q/78981695

http://stackoverflow.com/comment/138090174
score: 0
comment on: http://stackoverflow.com/a/78325122
type: Comment
type: AnswerComment
has text: "... and it printed nothing". Did you define a value for `a`? `a=3; exec eval echo '$a'` outputs 3 (then exits) as expected.

http://stackoverflow.com/comment/138192602
type: QuestionComment
has text: I can do the nested loop, but I don't know how to access to the files included in the file of names in order If I run cat, all 48 files appear ¿How can I select only the 4 first ones?, Then the 4 seconds, and so on
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78386230

http://stackoverflow.com/comment/138251554
has text: The `dc` utility already provides a desk calculator with reverse Polish notation. (Though you need `1 2 * p` to actually print the result.)
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78419450
type: QuestionComment

hostname
tags question: http://stackoverflow.com/q/78336037
tag name: hostname
type: Tag

http://stackoverflow.com/comment/138080034
type: QuestionComment
has text: Don't use braces; `if ! is_number "$1" && ! is_number "$2"; then echo both...`! ,,, And have a look [How do I test if a variable is a number in Bash?](https://stackoverflow.com/a/61835747/1765658)
type: Comment
score: 3
comment on: http://stackoverflow.com/q/78322081

http://stackoverflow.com/comment/138137488
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78354730
has text: Thanks @F.Hauri-GiveUpGitHub. This is indeed working, but I would have preferred not to have to store my criteria in an array as I take them from a text file :) . But thanks for your idea.

http://stackoverflow.com/comment/138142803
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78356050
has text: Too bad no awk yet for you: `awk -F, '$5<100{$5="none"}{print}'`
score: 0

http://stackoverflow.com/comment/138277911
score: 1
type: QuestionComment
has text: Add before your `while` loop `declare -i count` to make `count=$count+1` work. See `help declare`.
type: Comment
comment on: http://stackoverflow.com/q/78434093

assembly
tag name: assembly
type: Tag
tags question: http://stackoverflow.com/q/78374908
tags question: http://stackoverflow.com/q/79478204

associative
tag name: associative
type: Tag
tags question: http://stackoverflow.com/q/78442690

http://stackoverflow.com/a/78422422
answers question: http://stackoverflow.com/q/78422398
upvote count: 1
downvote count: 0
has body: export PS1=&quot;\[\e[32;40m\]\$?\[\e[35;40m\]\$(date +%d%H%M)\[\e[36;40m\]\W&gt;\[\e[38;5;113;40m\]&quot; missing [ at the begining of ps1
score: 1
type: Answer

http://stackoverflow.com/comment/138129339
comment on: http://stackoverflow.com/q/78349366
type: QuestionComment
type: Comment
has text: @larsks Well, my expectation is that the shell scripts runs the commands, and restarts redsoscks in the container. However, it is not doing so. But if I were to docker exec and run the shell script inside the running container, it works. I want this done automatically instead of me having to do it manually.
score: 0

http://stackoverflow.com/a/78373568
type: Answer
has body: From unzip man page: file(s)] An optional list of archive members to be processed, separated by spaces. (VMS versions compiled with VMSCLI defined must delimit files with commas instead. See -v in OPTIONS below.) Regular expressions (wildcards) may be used to match multiple members; see above. Again, be sure to quote expressions that would otherwise be expanded or modified by the operating system. So, you can use wildcards as long as you escape them.
answers question: http://stackoverflow.com/q/78372933
score: 0

http://stackoverflow.com/comment/138273826
has text: I have one more case where the env var is a json like this: `export ADMIN_API_CREDS='{"name": "some (name)", "clientId":"some|var","password":"some|pwd", "created":"2020-11-05T19:04:07.529606Z","tenant": "some-value"}'` same sh is now failing with `syntax error near unexpected token `('` so I think the json needs to be escaped somehow ? I tried with `jq -r` with same result
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78431169
score: 0

http://stackoverflow.com/comment/138104315
score: 0
comment on: http://stackoverflow.com/q/78335326
type: QuestionComment
has text: @Juan your question is being voted-to-close because what you say cannot possibly be true. You are not running _that_ file with `java EjerciciosClase`. You're running it either with `java EjerciciosClase.java` which is a very different mode, or you are running it with `java sumScanner`, or you're running a different file. We can't help you if the question is ambiguous, confusing, and/or inconsistent.
type: Comment

http://stackoverflow.com/a/78359047
score: 0
has body: One hack I thought of for this is to just put the options as dummy files in the directory. In the example above, this would replace the script.autocomplete.txt. Here's the updated example: ~/working_directory$ cat script.sh #!/bin/bash if "$1" == "opt1" ; then echo "performing action 1" fi if "$1" == "opt2" ; then echo "performing action 2" fi ~/working_directory$ ls opt* opt1 opt2 ~/working_directory$ ./script.sh op opt1 opt2 ~/working_directory$ ./script.sh opt One problem is if an option conflicts with a file. To solve this, you could put the options in a directory: ./options/opt{1,2} and check for those as options: ~/working_directory$ cat script.sh #!/bin/bash if "$1" == "options/opt1" ; then echo "performing action 1" fi if "$1" == "options/opt2" ; then echo "performing action 2" fi This is still pretty hacky, but might be a fine solution since it is a hacky problem anyway.
type: Answer
answers question: http://stackoverflow.com/q/78330326

http://stackoverflow.com/comment/138167438
has text: `db_version` is already a string so you don't need `str()` - `db_version_short = db_version.split('.')[0]`
comment on: http://stackoverflow.com/q/78371491
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138150343
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78361451
type: QuestionComment
has text: Your script contains a UTF-8 BOM, it won't work like that. Run `tail -c +4 <test.sh >test2.sh` and try `bash test2.sh`. Or use a proper editor

crop
tags question: http://stackoverflow.com/q/78385603
tag name: crop
type: Tag

http://stackoverflow.com/comment/138175813
type: Comment
type: AnswerComment
score: 0
has text: Hmm, but the OP's problem was that they (weirdly!) used an `if` statement. I'm not asking why this works, I'm asking why theirs didn't.
comment on: http://stackoverflow.com/a/78376416

http://stackoverflow.com/comment/138105891
score: 0
has text: @Barmar ah, sorry, I meant to post this in Unix&Linux... Should I delete this? Or can a mod move it?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78330326

http://stackoverflow.com/comment/138174084
type: QuestionComment
has text: One more point, I know bash, I do not **need** bash, I do not know if bash commands will work in PHOTON OS.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78344853

http://stackoverflow.com/comment/138162183
comment on: http://stackoverflow.com/q/78368689
score: 1
has text: Spaces are not optional. `[$i` and `[ "$i"` are two different things.
type: QuestionComment
type: Comment

termux
tags question: http://stackoverflow.com/q/78361451
type: Tag
tags question: http://stackoverflow.com/q/78315911
tag name: termux
tags question: http://stackoverflow.com/q/78519993
tags question: http://stackoverflow.com/q/78720340

http://stackoverflow.com/comment/138232220
score: 0
has text: Another note is that in general tar might not be the right file format for your job -- it's not designed for random access, so it's harder to parallelize than archive formats that have a header or footer with offsets/indices. (zip is perhaps the most common file format that _is_ indexed; for something less popular but much more modern, see the [catar](https://0pointer.net/blog/casync-a-tool-for-distributing-file-system-images.html) format created by systemd's author, and the 3rd-party implementation [which, disclosing interest, I had a hand in creating] at https://github.com/folbricht/desync)
type: QuestionComment
comment on: http://stackoverflow.com/q/78405506
type: Comment

http://stackoverflow.com/a/78343860
has body: In this from your input: start_times: “06:00,08:00,10:00,12:00,14:00,16:00” Those things that look like double quotes aren't, they are "smart quotes", “ and ”, probably added quietly by some Windows editor you used and so YMMV with what any text processing tool such as awk does with them. Replace those with textual double quotes " as a first step. Then for your code, you need 2 changes: When reading the input you need to ensure no value is already wrapped in double quotes since you'll be wrapping all values in double quotes when producing output. So, both places it occurs, change this: tag2val[tag] = val to this: gsub(/^"|"$/,"",val) tag2val[tag] = val When printing output you need to ensure that any double quotes remaining mid-val get escaped by doubling them since unescaped double quotes are invalid within a double-quoted CSV field per RFC 4180 (and common sense). So change this: val = tag2val[tag] to this: val = tag2val[tag] gsub(/"/,"\"\"",val) Here's the whole updated script: $ cat tst.sh #!/usr/bin/env bash awk ' BEGIN { OFS = "," numTags = split("insert_job job_type box_name command machine owner date_conditions condition run_calendar exclude_calendar days_of_week run_window start_times start_mins resources profile term_run_time watch_file watch_interval",tags) for ( tagNr=1; tagNr<=numTags; tagNr++ ) { tag = tags[tagNr] printf "\"%s\"%s", tag, (tagNr<numTags ? OFS : ORS) } } !NF || /^\/\*/ { next } { gsub(/^[[:space:]]+|[[:space:]]+$/,"") } match($0,/[[:space:]]job_type:/) { if ( jobNr++ ) { prt() delete tag2val } # save "insert_job" value tag = substr($1,1,length($1)-1) val = substr($0,length($1)+1,RSTART-(length($1)+2)) gsub(/^[[:space:]]+|[[:space:]]+$/,"",val) gsub(/^"|"$/,"",val) tag2val[tag] = val # update $0 to start with "job_type" to look like all other input $0 = substr($0,RSTART+1) } { tag = val = $0 sub(/:.*/,"",tag) sub(/[^:]+:[[:space:]]*/,"",val) gsub(/^"|"$/,"",val) tag2val[tag] = val } END { prt() } function prt( tagNr,tag,val) { for ( tagNr…
type: Answer
answers question: http://stackoverflow.com/q/78339485
score: 0

raspberry-pi3
tags question: http://stackoverflow.com/q/78316769
tag name: raspberry-pi3
type: Tag

http://stackoverflow.com/comment/138129460
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78349366
type: Comment
has text: A container only runs one process normally. If it's running your script, then it's not running a SOCKS proxy to be restarted. Do you need to `exec` the proxy, as a foreground process, as the last thing in your script?

http://stackoverflow.com/a/78389556
type: Answer
has comment: http://stackoverflow.com/comment/138200152
has comment: http://stackoverflow.com/comment/138199416
has comment: http://stackoverflow.com/comment/138198399
answers question: http://stackoverflow.com/q/78389511
has body: Let me show you how source works: Prompt> cat file1.txt v1=11 v2=222 v3=33333 Prompt> source file1.txt Prompt> echo $v1 11 Prompt> echo $v2 222 Prompt> echo "v3=$v3" v3=33333 Have fun.
score: 0

llamacpp
tag name: llamacpp
type: Tag
tags question: http://stackoverflow.com/q/78436977

http://stackoverflow.com/comment/138092479
has text: [checking if a string exists in an array of strings in bash](https://stackoverflow.com/questions/59897745/checking-if-a-string-exists-in-an-array-of-strings-in-bash) is a close fit -- not _quite_ a match because substrings are acceptable.
comment on: http://stackoverflow.com/q/78329053
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138208902
type: Comment
type: AnswerComment
has text: Agreed. Piping into `xargs` has little advantage over `find -exec` in this case, where the main objective is to execute a single command on each file matched, separately. This alternative not only stops file processing as soon as one fails, but it also stops the file *search*, which could be valuable if the tree being searched is large.
score: 0
comment on: http://stackoverflow.com/a/78390580

hpc
tag name: hpc
tags question: http://stackoverflow.com/q/78398806
type: Tag
tags question: http://stackoverflow.com/q/78634545
tags question: http://stackoverflow.com/q/78686318
tags question: http://stackoverflow.com/q/78761415
tags question: http://stackoverflow.com/q/79025201
tags question: http://stackoverflow.com/q/79048675
tags question: http://stackoverflow.com/q/79248883
tags question: http://stackoverflow.com/q/79525482

http://stackoverflow.com/comment/138137926
has text: Was any of this AI-generated?
score: 0
comment on: http://stackoverflow.com/a/78351090
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138254261
score: 0
comment on: http://stackoverflow.com/a/78420840
has text: `foo` was what I called the script file on my system. The script fails because stdout was closed before `echo` ran. Here it was closed by the script itself to be self contained, but it doesn't necessarily need to happen in the script
type: Comment
type: AnswerComment

bed
tag name: bed
type: Tag
tags question: http://stackoverflow.com/q/78326945

http://stackoverflow.com/comment/138090055
score: 0
has text: Is any reference available for this special behaviour of running builtins in the same environment? Just looking for confirmation
comment on: http://stackoverflow.com/a/78325122
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138179364
has text: Detecting such a change is probably easiest using `git show -G<regex>` and/or some stream text editor
score: 1
comment on: http://stackoverflow.com/q/78378370
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138202873
score: 0
has text: Only ways I could think about (assuming you are using a graphical env) : if using xterm, make use of xterm*VT100.Translations (X11 resources) else use a test automation tool, like xdotool, to mimic user interactions, key typing
type: QuestionComment
comment on: http://stackoverflow.com/q/78359720
type: Comment

http://stackoverflow.com/q/78324080
score: 0
has comment: http://stackoverflow.com/comment/138086935
answer count: 0
type: UnansweredQuestion
has title: Script doesnt recognize bars / length right for cutting audio , ffmpeg terminal
has body: This terminal script doesn't recognize bars / length right for cutting audio, maybe somebody knows what's wrong with the calculation ... Would be happy about any help the cutting already works! #!/bin/bash # Function to extract BPM from filename get_bpm() { local filename="$1" local bpm=$(echo "$filename" | grep -oE '[0-9]{1,3}' | head -n1) echo "$bpm" } # Function to cut audio based on BPM cut_audio() { local input_file="$1" local bpm="$2" local output_file="${input_file%.*}_cut.${input_file##*.}" # Appends "_cut" to original filename # Define the number of beats per bar (assuming 4 beats per bar) beats_per_bar=4 # Calculate the duration of each bar in seconds bar_duration=$((60 * beats_per_bar / bpm)) # Define start and end times for each bar range start_times=(0 21 33 45 57 69 81 93 105 117 129 141) end_times=(20 29 41 53 65 77 89 101 113 125 137 149) # Iterate through each bar range for ((i = 0; i < ${#start_times[@]}; i++)); do start_time=${start_times[$i]} end_time=${end_times[$i]} echo "Cutting audio file $input_file at $bpm BPM for bar $((i + 1)) ($start_time-$end_time) for $bar_duration seconds..." # Cut audio for current bar range using ffmpeg ffmpeg -i "$input_file" -ss "$start_time" -to "$end_time" -c copy "$output_file"_"$((i + 1)).${input_file##*.}" -y done # Check if the output files are empty and delete them if so for output_file in "${output_file}"_*; do if [ ! -s "$output_file" ]; then echo "Output file $output_file is empty. Deleting..." rm "$output_file" fi done echo "Audio cut and saved as $output_file" } # Main script if [ "$#" -eq 0 ]; then echo "Usage: $0 [audio_file1] [audio_file2] ..." exit 1 fi for file in "$@"; do bpm=$(get_bpm "$file") if [ -z "$bpm" ]; then echo "Error: No BPM found in filename $file" else cut_audio "$file" "$bpm" fi done Maybe its only the math calc in the beginning but idk :) If you need more details just lmk
tagged with: ffmpeg
tagged with: bash
tagged with: audio
type: Question

http://stackoverflow.com/comment/138195872
has text: Yeah, great answer. Now at least I have an idea of the tool.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78387161

http://stackoverflow.com/a/78427832
score: 0
has body: This should do the trick. #!/bin/bash VPC_ID=vpc-05ae0495871281736 NETWORK_INTERFACE=$(aws ec2 describe-network-interfaces --filters Name=vpc-id,Values="${VPC_ID}" --output json | jq -r '[.NetworkInterfaces[] | {AvailabilityZone, Description, Groups}]') echo $NETWORK_INTERFACE Substitute your own value for VPC_ID. Based on your sample output I have filtered out the fields AvailabilityZone, Description and Groups. The output from the script will just be a single line of valid JSON. You can prettify that by passing it through jq .. For example: [ { "AvailabilityZone": "eu-west-2c", "Description": "test", "Groups": [ { "GroupName": "VNC", "GroupId": "sg-030848ac470abe56f" } ] }, { "AvailabilityZone": "eu-west-2c", "Description": "", "Groups": [ { "GroupName": "MOSH", "GroupId": "sg-06dff26a1939d90d7" }, { "GroupName": "http(s)", "GroupId": "sg-048d4d5554f4a7da6" } ] } ]
answers question: http://stackoverflow.com/q/78422524
type: Answer

http://stackoverflow.com/comment/138159928
score: 0
has text: @Mockman Good stuff to know. Thanks again!
comment on: http://stackoverflow.com/a/78364778
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138173554
comment on: http://stackoverflow.com/q/78373696
type: QuestionComment
type: Comment
has text: I really advise against that; we're no longer in the Bad Old Days of self-daemonizing software (with each program having its own unique mechanism for trying to restart after failures/reboot/etc, its own mechanism for trying to manage locking / mutexes / control, its own mechanism for waiting for dependencies to be available, &c) for a reason. Again, it's not that it absolutely can't be done, _but if you don't have enough background to answer this question yourself_ -- familiarity with cgroups, process accounting, &c &c -- you're probably not in a good place to weigh the tradeoffs.
score: 1

http://stackoverflow.com/comment/138255787
comment on: http://stackoverflow.com/a/78420842
has text: You should mention that requires GNU awk for time functions (mktime and strftime).
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138123415
comment on: http://stackoverflow.com/q/78343975
type: QuestionComment
type: Comment
score: 0
has text: So, does it at least **start** the batchfile? Or does it execute it, but never returns? Your question is IMO pretty unclear, and you don't show what you did for debugging.

http://stackoverflow.com/comment/138198393
has text: @pmf Thanks, but that file is not a script and doesn't have a syntax with only such declarations. There are various types of data in there.
type: QuestionComment
comment on: http://stackoverflow.com/q/78389511
score: 0
type: Comment

http://stackoverflow.com/comment/138095018
comment on: http://stackoverflow.com/q/78330653
type: QuestionComment
type: Comment
has text: That said, you should probably investigate why the directory has a name like this. I doubt it's intended.
score: 0

http://stackoverflow.com/comment/138102280
has text: Redirect the output to a file and compare that new file with your original file.
type: QuestionComment
comment on: http://stackoverflow.com/q/78334722
score: 0
type: Comment

http://stackoverflow.com/comment/138128689
comment on: http://stackoverflow.com/q/78349366
score: 1
type: QuestionComment
has text: Two things: Docker normally fully controls the container's environment, and I'd expect all of these `iptables` commands to fail; and it looks like your script will otherwise run to the end and exit, and when it does, the container exits too. You need some process running in the foreground, not an init script.
type: Comment

http://stackoverflow.com/comment/138327827
score: 0
has text: `echo $0` definitely doesn't work in the default shells in Windows (cmd and powershell)
comment on: http://stackoverflow.com/a/78462615
type: Comment
type: AnswerComment

ps1
tags question: http://stackoverflow.com/q/78422398
tag name: ps1
type: Tag
tags question: http://stackoverflow.com/q/78681361
tags question: http://stackoverflow.com/q/79182624

http://stackoverflow.com/comment/138298901
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78445380
has text: https://mywiki.wooledge.org/ParsingLs, [why not parse `ls`](https://unix.stackexchange.com/q/128985/44425)
type: Comment

http://stackoverflow.com/comment/138215161
comment on: http://stackoverflow.com/q/78396373
type: QuestionComment
score: 0
has text: I'm using the current macOS 14.4.1 version which is 20200816
type: Comment

http://stackoverflow.com/comment/138228966
score: 1
has text: `cd` doesn’t use STDIN.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78406644

http://stackoverflow.com/comment/138075803
score: 0
comment on: http://stackoverflow.com/q/78317617
type: QuestionComment
type: Comment
has text: @ruakh Absolutely. To be accurate, if 10-character strings are stored on 11 bytes, that would be `11*26^10` bytes (`1552838052187136`, about `1.55` peta-bytes). If we add the 1-character to 9-characters strings all this amounts to `1609079023095439` (about `1.6` peta-bytes).

http://stackoverflow.com/comment/138283456
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78437542
type: QuestionComment
has text: And the original assignment is to a _scalar_ `allCollections` - you want `allCollections=($(mongosh …))`.

http://stackoverflow.com/a/78409050
score: 0
type: Answer
has body: There's no need to use docker pull; docker save; docker load; docker tag; docker push in this scenario. All of those steps are transforming the content, moving it in an out of the backend storage system, extracting it to temporary directories, etc, that isn't needed to simply move an image between two registries with an air-gap. The common solution these days is to use an OCI Layout to store the image on the filesystem, optionally tarring up the content (if you already tar up some other files in the process of packaging the scripts, I'd skip that as redundant). Multiple tools allow you to copy images to or from an OCI Layout, including crane from Google, oras from Microsoft, skopeo from RedHat, and regctl from myself. E.g. with regctl, the commands would look like: # in the CI job regctl image copy $source ocidir://$dir:$tag # ... package scripts and $dir into a tar file to ship ... # on the destination # ... unpack scripts and $dir from tar ... regctl image copy ocidir://$dir:tag $dest
answers question: http://stackoverflow.com/q/78405506

azure-virtual-machine
tags question: http://stackoverflow.com/q/78393852
type: Tag
tag name: azure-virtual-machine

http://stackoverflow.com/comment/138130415
type: Comment
comment on: http://stackoverflow.com/q/78344853
score: 0
has text: I have paraphrase it, the question is about the script..
type: QuestionComment

http://stackoverflow.com/q/78372779
downvote count: 0
score: 1
answer count: 1
has comment: http://stackoverflow.com/comment/138169117
favorite count: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/138169057
has body: I want to get the expected output from the input. I have written below program to get the expected output and I almost got the output but the only problem i'm facing here is the placement of comma. The program is randomly inserting comma in the output. Help me to correct it. input: Tenant : PROD Application : PROD_ANP AEPg : EPG_VL-408 BD : BD-VL-408 uSeg EPG : no Intra EPG Isolation : unenforced Proxy ARP : none Policy Tag : 49165 Vlan Domains : PROD_PhysDom Consumed Contracts : Cont_EPG_VL-408_EPG_VL-491,Cont_EPG_VL-408_EPG_VL-450,Cont_ EPG_VL-408_EPG_VL-492,Cont_EPG_VL-408_EPG_VL-446,Cont_EPG_VL -408_EPG_VL-471,Cont_EXT_EPG,Cont_EPG_VL-408_EPG_VL-443,Cont _EPG_VL-408_EPG_VL-454,Cont_EPG_VL-408_EPG_VL-449,Cont_EPG_V L-408_EPG_VL-445,Cont_EPG_VL-408_EPG_VL-444,Cont_EPG_VL-408_ EPG_VL-452,Cont_EPG_VL-408_EPG_VL-451,Cont_EPG_VL-408_EPG_VL -447,Cont_EPG_VL-408_EPG_VL-448,Cont_EPG_VL-408_EPG_VL-441,C ont_EPG_VL-408_EPG_VL-442 Provided Contracts : Cont_EPG_VL-408_EPG_VL-491,Cont_EPG_VL-408_EPG_VL-450,Cont_ EPG_VL-408_EPG_VL-492,Cont_EPG_VL-408_EPG_VL-446,Cont_EPG_VL -408_EPG_VL-471,Cont_EXT_EPG,Cont_EPG_VL-408_EPG_VL-454,Cont _EPG_VL-408_EPG_VL-441,Cont_EPG_VL-408_EPG_VL-447,Cont_EPG_V L-408_EPG_VL-445,Cont_EPG_VL-408_EPG_VL-444,Cont_EPG_VL-408_ EPG_VL-452,Cont_EPG_VL-408_EPG_VL-451,Cont_EPG_VL-408_EPG_VL -443,Cont_EPG_VL-408_EPG_VL-448,Cont_EPG_VL-408_EPG_VL-449,C ont_EPG_VL-408_EPG_VL-442 Tenant : PROD Application : PROD_ANP AEPg : EPG_VL-409 BD : BD-VL-409 uSeg EPG : no Intra EPG Isolation : unenforced Proxy ARP : none Policy Tag : 49165 Vlan Domains : PROD1_PhysDom Consumed Contracts : Cont_EPG_VL-499_EPG_VL-491,Cont_EPG_VL-499_EPG_VL-450,Cont_ EPG_VL-499_EPG_VL-492,Cont_EPG_VL-499_EPG_VL-446,Cont_EPG_VL -499_EPG_VL-471,Cont_EXT_EPG,Cont_EPG_VL-499_EPG_VL-443,Cont _EPG_VL-499_EPG_VL-454,Cont_EPG_VL-499_EPG_VL-449,Cont_EPG_V L-499_EPG_VL-445,Cont_EPG_VL-499_EPG_VL-444,Cont_EPG_VL-499_ EPG_VL-452,Cont_EPG_VL-499_EPG_VL-451,Cont_EPG_VL-499_EPG_VL -447,Cont_EPG_VL-499_E…
has title: Need help in printing the correct contract output in shell program
tagged with: bash
type: Question
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78372901

vercel
type: Tag
tag name: vercel
tags question: http://stackoverflow.com/q/78309717

http://stackoverflow.com/comment/138201919
has text: Why not simply `p1 < fifo | ...` ?
score: 0
comment on: http://stackoverflow.com/a/78390677
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78541981
type: Answer
has body: I would do something like this: doit() { # Possibly make and clean up processing dir here jpeg2txt "$1" "$outputDir" } export -f doit export outputDir inotifywait -qmre MOVED_TO -e CLOSE_WRITE --format %w%f inputdir | parallel --tag doit >"$outputDir/logs/log" 2>&1
score: 0
answers question: http://stackoverflow.com/q/78388939

http://stackoverflow.com/comment/138074239
type: Comment
type: AnswerComment
has text: I changed `2` to `4` and ran a few times; two issues ... *a)* it doesn't output the desired sequential series and *b)* repeated runs generate different output; for example, 2 sets of output for the `CBA - CBC` series: `CBA AAAA CBB AAAB CBC` vs `CBA CBB AAAA CBC` (out of order, not the same); if I then change from `{A..C}` to `{A..Z}` these issues occur throughout the output (eg, `BP AAAYA AAAYB AAAYC AAAYD ABL AAAYE`; I sorted the `4 / {A..Z}` output (and diff'd against the sorted sets of other answers) and all strings are there
comment on: http://stackoverflow.com/a/78317659
score: 0

azure
tags question: http://stackoverflow.com/q/78393852
type: Tag
tag name: azure
tags question: http://stackoverflow.com/q/78435782
tags question: http://stackoverflow.com/q/78491375
tags question: http://stackoverflow.com/q/78551049
tags question: http://stackoverflow.com/q/78615747
tags question: http://stackoverflow.com/q/78647254
tags question: http://stackoverflow.com/q/78788249
tags question: http://stackoverflow.com/q/79054869
tags question: http://stackoverflow.com/q/79143919
tags question: http://stackoverflow.com/q/79237461
tags question: http://stackoverflow.com/q/79099308
tags question: http://stackoverflow.com/q/79141453
tags question: http://stackoverflow.com/q/79100748
tags question: http://stackoverflow.com/q/79410139
tags question: http://stackoverflow.com/q/79265910
tags question: http://stackoverflow.com/q/79431393

http://stackoverflow.com/comment/138252720
has text: @tjm3772 Thank for the comment 1) I want a more reliable script that is not overly complex. 2) I am wondering if I need `2>&1` at the end of the echo commands or if it is completely useless. 3) I want it to go to email or to a Slack notification (post to an http hook url), but I want that message to be relatively brief and to the point. I think it would take too much code trying to handle every error scenario. I hope this makes sense.
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78420131
type: Comment

http://stackoverflow.com/comment/138297720
comment on: http://stackoverflow.com/q/78445411
has text: Beyond that, of the three uses you show, **only** `source script.sh` is expected to set variables in the parent shell. Running `./script.sh` or `bash script.sh` runs the script inside a new interpreter, sets the variables there... and then throws away the variables (and the effects of operations like `unset`) when that new interpreter exits at the end of the script.
type: QuestionComment
score: 2
type: Comment

cluster-computing
tags question: http://stackoverflow.com/q/78398806
type: Tag
tag name: cluster-computing
tags question: http://stackoverflow.com/q/79025201

http://stackoverflow.com/comment/138252309
has text: Ok, thanks for explaining the :? part. What about the argument not being numeric? Why does the `declare -i` not fail, when fed with a non-numeric assignment?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78419189
type: AnswerComment

open-policy-agent
type: Tag
tags question: http://stackoverflow.com/q/78421398
tag name: open-policy-agent

http://stackoverflow.com/comment/138210604
type: QuestionComment
type: Comment
score: 1
has text: awk is the wrong tool for this job. Please [Don't Parse XML/HTML With Regex.](https://stackoverflow.com/a/1732454/3776858) I suggest to use an XML/HTML parser (xmlstarlet, xmllint ...).
comment on: http://stackoverflow.com/q/78396373

http://stackoverflow.com/comment/138251303
has text: Yes, it expands to the files in your directory, you can check it like this ````#!/bin/bash calculator(){ echo "$@" } ````
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78419450

http://stackoverflow.com/comment/138104913
type: Comment
has text: As is the case with most shell "best practices" pages the referenced page contains some bad advice, including the recommendation to always use `set -eo pipefail`. See [Bash Pitfalls #60 (set -euo pipefail)](https://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail). (The [Greg's Wiki](https://mywiki.wooledge.org/) site is one of the few, and arguably the only, reliable source of good information about Bash programming.) Questions about problems (that turn out to be) caused by `set -e` and/or `set -o pipefail` are *very* common on this site.
type: AnswerComment
comment on: http://stackoverflow.com/a/78331936
score: 0

http://stackoverflow.com/comment/138214132
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78384843
type: Comment
has text: `tmpl=/tmp/sshctl/'%L-%r@%h:%p'; ssh -nNf -o ControlMaster=yes -o ControlPath="$tmpl" user@host` / `scp -o ControlPath="$tmpl" ...` / `ssh -O exit -o ControlPath="$tmpl" user@host`

http://stackoverflow.com/comment/138295317
comment on: http://stackoverflow.com/q/78443452
type: QuestionComment
score: 0
has text: We would literally see about 90% fewer bash questions if the instructions from the [tag:bash] tag were enforced by the forum. Anyway, here it is again... "For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting them here."
type: Comment

warnings
tags question: http://stackoverflow.com/q/78409604
type: Tag
tag name: warnings

http://stackoverflow.com/comment/138255110
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78421472
has text: `syntax error: bad substitution` is certainly not a path issue.
score: 0

http://stackoverflow.com/comment/138179574
comment on: http://stackoverflow.com/q/78378844
has text: Why are you calling bash to call awk at the bottom? you're already in bash. The extra layer of `bash -c` doesn't help anything
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138196005
has text: I meant that it cuts off the red border to the outline of the text, but should leave space on top (red) as in the original. The top black border is also needed. In general, I did it, I just subtracted 10 from Y.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78387161

http://stackoverflow.com/comment/138236502
score: 0
has text: I feel for you, my company also has enormous technical debt. Unfortunately, I think you're SOL.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78409604

http://stackoverflow.com/comment/138140132
has text: The one thing I am not understanding from your solution though is why the `'...'` ends where it does in this line `sed -Ei 's/^(#define VER_BUILD[[:space:]]+)[0-9]+$/\1'$VER_BUILD/ main.cpp`. I would have expected it to happen after the final / and that you would have to somehow escape the $VER_BUILD.
comment on: http://stackoverflow.com/a/78346403
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138170622
has text: Are you saying that _the service itself_ is trying to run a script that restarts that same service? Because in general, I'd avoid doing that at all. Can you tell us more about `other_command`? If it's doing something like cleanup, make it an `ExecStopPost` for the service; if it's doing setup, make it an `ExecStartPre`; if it's only conditionally needed, have an `ExecStartPre` that checks whether it needs it and runs it, etc (keeping a flag on disk for "do we need to do this operation before starting back up?" is straightforward enough).
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78373696

http://stackoverflow.com/comment/138203716
comment on: http://stackoverflow.com/q/78392466
has text: perhaps a redesign/rethink .... 1) spawn a background process to start the spinner (making note of the backgrounded process's pid), 2) run the remote/ssh call (in the foreground) and then 3) when the remote/ssh call completes you kill of the backgrounded spinner process
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/138237900
type: Comment
type: AnswerComment
has text: @thanks for your help, it works, I'm trying to adapt it to my actual data but seems to work.
comment on: http://stackoverflow.com/a/78411665
score: 0

http://stackoverflow.com/comment/138102270
has text: I suspect your actual problem is not “the max size of the Kernel I/O queues” but that your terminal software is not accepting lines longer than 4096 characters.
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78334722

http://stackoverflow.com/comment/138228150
comment on: http://stackoverflow.com/q/78403621
has text: The fifo file is feeded with snmp traps
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/a/78317231
answers question: http://stackoverflow.com/q/78316829
upvote count: 1
downvote count: 0
score: 1
has body: That some parts of the output are not captured probably means that those parts are written to the command's standard error stream instead of its standard output stream. This is a feature, not a bug, but if you want to catch both ordinary and diagnostic output together then you can simply redirect the command's standard error stream to be the same as its standard output stream: softwareupdate --list 2&gt;&amp;1 The 2&gt;&amp;1 says to make file descriptor 2 (standard error) refer to the same open file description as file descriptor 1 (standard output). It can appear at any point on the command line, including before the command, but it is conventional to put redirections at the end. As a separate matter, using the output directly to initialize an array, as in your example, is probably going to cause you trouble. As written, you will get each whitespace-delimited word as a separate array element, but I anticipate that what you really want is one array element for each whole line of input. The mapfile builtin serves that purpose. For instance, you might do this: updates=() mapfile -t updates &lt; &lt;(softwareupdate --list 2&gt;&amp;1) The first &lt; is the usual input redirection operator. The &lt;(some command) is a bashism that designates the name of a file from which the standard output of some command can be read. This somewhat unusual thing works around an issue that your particular script would have with the usual mechanism (piping) for feeding the output of one command into the input of a different one.
type: Answer

http://stackoverflow.com/comment/138158755
type: QuestionComment
score: 2
type: Comment
has text: Split by Directory Seperator?
comment on: http://stackoverflow.com/q/78366773

http://stackoverflow.com/comment/138239294
has text: As Gairfowl says, I would try to find all files with names which contain a character, which is not in the 0x20 ... 0x7A range, i.e. something like `find BASEDIR -name '*[^ -z]*'`, and then rename them. Pray that they aren't plenty!
score: 0
comment on: http://stackoverflow.com/q/78399997
type: QuestionComment
type: Comment

exec
tags question: http://stackoverflow.com/q/78325081
type: Tag
tag name: exec
tags question: http://stackoverflow.com/q/78573688

http://stackoverflow.com/comment/138268316
has text: [edit] your question to show the output of `curl http://172.21.0.4:4444/status` so we can see what `SESSION` contains and help you extract just the session ID from the curl output as piping that to grep+cut+tr is not a good approach. Also, are you sure you want to add any stderrr being output from that `curl` into the stout you're then trying to extract a sessionId from (and presumably discard any of that stderr text)? Seems like that'd hide possible errors and make that extraction part fragile.
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/78428595

http://stackoverflow.com/comment/138297860
has text: *...However, when I store the results in a var, the output is:..* and how do show the output from the var?
score: 3
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78444623

http://stackoverflow.com/comment/138197261
score: 0
comment on: http://stackoverflow.com/q/78388939
type: QuestionComment
type: Comment
has text: To solve the second problem, the upload should go to a file named something like `xxx.jpg.temp`. When it's done uploading, rename it to `xxx.jpg`. The script should look only for `xxx.jpg`, so it won't try to process files that are partially uploaded.

http://stackoverflow.com/comment/138201857
type: Comment
has text: Why did you use `tail`?
comment on: http://stackoverflow.com/a/78390677
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138072518
score: 0
comment on: http://stackoverflow.com/q/78317514
has text: (Also, not just here but in general, think about running your code through http://shellcheck.net/ -- which is also a downloadable/locally-installable tool -- and reading the wiki pages linked for any warnings it identifies).
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138269072
comment on: http://stackoverflow.com/a/78422867
has text: FreeBSD 10.4 `make` doesn’t have any way to select the shell; you’re stuck with `/bin/sh` so you have to clean your Makefile from any bashisms
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138192744
score: 0
type: QuestionComment
type: Comment
has text: The solution is using awk. Bash does not have (maybe) that capability
comment on: http://stackoverflow.com/q/78386230

http://stackoverflow.com/comment/138260544
score: 2
has text: @MoritzSchäfer MacOS does support gawk, it just doesn't come with it by default. You can easily install it and it'll save you a lot of time and effort in future if you need to use awk for additional projects.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78420842

http://stackoverflow.com/comment/138137161
score: 0
has text: This worked great, thank you! In implementing this, I realized that I can probably make even the excluded directories list dynamic because the directories I want to exclude have a `lib` folder nested directly in them, whereas the directories to include just have other directories underneath them...so I'll figure out how to exclude by that parameter. I appreciate your help!
comment on: http://stackoverflow.com/a/78351159
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138171671
has text: "I was under the assumption that `set -e` would do X" is wrong for almost all values of X. https://mywiki.wooledge.org/BashFAQ/105
type: Comment
score: 7
type: QuestionComment
comment on: http://stackoverflow.com/q/78373828

http://stackoverflow.com/comment/138149068
type: QuestionComment
comment on: http://stackoverflow.com/q/78361035
type: Comment
score: 0
has text: Do not confuse regex and glob patterns, you are using globs.

http://stackoverflow.com/comment/138180155
score: 0
has text: @MarkusWMahlberg, exactly, do you have recommendations based on my scenario ? is it possible to start the bash as a new process so that it may continue even if the calling process is terminated ? Thank you!
comment on: http://stackoverflow.com/q/78373696
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138214096
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78385555
has text: I don't use SLES but the manpage suggests something like `zypper search -r your-repo-uri -s NAME.ARCH` might give useful output
type: Comment

ocr
type: Tag
tag name: ocr
tags question: http://stackoverflow.com/q/78385603

http://stackoverflow.com/a/78375522
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78371799
has body: This might work for you (GNU sed, wc &amp; parallel): parallel sed \''2~4!d;s/&gt;//;s/.*/echo -n &quot;&amp;&quot;|wc -m/e'\' {} \&gt;{}.len ::: *.fastq For each fastq file in the current directory run a sed program that outputs its result to a file taken from the input file name plus .len. The sed program, processes every fourth line of the file starting at line 2. Each line processed, removes the first &gt; character and passes the output to another substitution command that evokes the evaluated pipeline. This echos the line via a pipe to the wc command which counts the number of characters in the amended line. N.B. The echo command uses the n option to remove any newline added.
type: Answer

http://stackoverflow.com/comment/138318937
comment on: http://stackoverflow.com/a/78433171
type: Comment
type: AnswerComment
score: 0
has text: Sorry, I might have not been very clear. I'm running these in a docker and want to have as few processes as possible. My issue is that I need command1 to run in the background, and have the subshell (mainscript running as 48) be replaced by command1.

http://stackoverflow.com/comment/138215227
comment on: http://stackoverflow.com/q/78396373
score: 0
has text: As I'm new to posting things at stack overflow. Why has the question received two downvotes? Is it because I'm not using the "correct" tool to get my data? Downvote explanation is "shows no research effort: unclear or not useful". I searched for a solution here and on google for 6 hours before posting, and couldn't find anything. Apart from using awk with this might not be the best way to solve my issue, I think it is still a valid awk question which can be used easily with any other text where you might have the same task. Can someone elaborate, why people don't like my question?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138134876
type: Comment
comment on: http://stackoverflow.com/q/78353017
type: QuestionComment
has text: Check your scripts with shellcheck and fix issues reported by it.
score: 4

http://stackoverflow.com/comment/138203479
has text: As you are using `bash`, how about switching to an array?
score: 0
comment on: http://stackoverflow.com/q/78392419
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138206820
type: Comment
has text: The problem is the spaces after the commas; that's not part of the CSV format, and the the spaces are being treated as part of the column value. `echo $column4` doesn't show this because the variable reference isn't double-quoted (variable references should almost always be double-quoted). See ["I just assigned a variable, but `echo $variable` shows something else"](https://stackoverflow.com/questions/29378566) and ["When should I double-quote a parameter expansion?"](https://stackoverflow.com/questions/55023461)
comment on: http://stackoverflow.com/q/78393978
type: QuestionComment
score: 2

http://stackoverflow.com/comment/138222067
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78402923
has text: Isn't the question *"How can the macOS terminal be reconfigured to maintain its position in the command history?"*? Your answer does not seem to answer that...
score: 0

http://stackoverflow.com/comment/138192489
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78386230
has text: I need to limit the cat operation is such way that only the first files of the 4 files of names are concatenated together. Then, only the second files in each of the 4 files with names, then only the third files and so on with the 48 files included in each of the 4 files containing the names e.g L001 L002 L003 L004 (these are the files with the names of files) file1 file1 file1 file1 (these are the names of the files I want to concatenate file2 file2 file2 file2 (these again, with a name such as All_files2 ......

http://stackoverflow.com/comment/138120689
comment on: http://stackoverflow.com/q/78342895
type: QuestionComment
type: Comment
has text: What if you try to run `sed` directly from ssh: `ssh cloudwaysuser@198.246.246.246 sed -ne \''/DB_NAME\|DB_USER/{ s/.*, *\o47\(.*\)\o47.*/\1/;H;};${x;s/^\n//;s|\n|/|g;p}'\' /some-path/wp-config.php` Note path file isn't quoted. not needed if your path don't contain spaces.
score: 0

bin
tag name: bin
tags question: http://stackoverflow.com/q/78433528
type: Tag
tags question: http://stackoverflow.com/q/79241790

http://stackoverflow.com/comment/138115189
score: 1
has text: `echo $json` is itself buggy.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78342087

http://stackoverflow.com/comment/138129459
comment on: http://stackoverflow.com/q/78349529
score: 0
type: QuestionComment
has text: Easy to reproduce the problem when you add `-e` to the `echo` cmd. Is your `echo` command and alias for `echo -e`? run `alias` and see if it is
type: Comment

http://stackoverflow.com/comment/138230488
type: Comment
comment on: http://stackoverflow.com/q/78406644
score: 1
type: QuestionComment
has text: You guys are the best. Thank you very much for helping out. Had tried the approach suggested by Jens and it worked. I was stumped though over what might be causing the input redirection not to work.

http://stackoverflow.com/comment/138091700
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78328611
type: QuestionComment
has text: "I can't send the query from my machine to sqlpus. No such file" -- that's not a good error description. Please tell us precisely what you did (after simplifying as far as possible, see [mcve]) and what the results where. Don't just dump your intention and interpretation here, provide verifiable facts!

http://stackoverflow.com/comment/138137283
comment on: http://stackoverflow.com/a/78350523
has text: _When the remote shell is bash_, I consider `ssh somehost "$(declare -f funcname); $(declare -p var1 var2 var3); funcname"` a quite solid solution (assuming the function `funcname` depends on variables `var1`, `var2` and `var3`).
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/138254936
type: AnswerComment
comment on: http://stackoverflow.com/a/78421472
has text: See latest comment ^
type: Comment
score: 0

http://stackoverflow.com/comment/138102818
comment on: http://stackoverflow.com/q/78334722
score: 0
has text: @Ctx well it is what it is, thanks for the help. thank you everyone for the discussion learned a lot
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138236881
has text: @d-b, inasmuch as your question seems indeed to be about the bash script part, please go back and re-read my second comment, which explains the behavior here. In particular, that a command executed by your bash script fails does not imply that the script itself fails, or should do.
comment on: http://stackoverflow.com/q/78409475
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138065990
type: Comment
has text: There is no problem with searching a tag for the current commit, but the fact, that when Vercel ignore build steps script runs it can't see any tags as the list of tags is empty for some reason.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78313113

http://stackoverflow.com/comment/138109899
type: QuestionComment
comment on: http://stackoverflow.com/q/78335326
score: 0
has text: @Juan, **javac** needs the file (example `javac sumScanner.java`) ; **java** needs a *full class name* (example `java com.estudio.ejerciciosclase.sumScanner`) || Alternative since Java 11, without compiling (explicitly) and single file only: **java** with file (example `java sumScanner.java`)
type: Comment

http://stackoverflow.com/comment/138094025
score: 0
has text: Look at [my SQL answer](https://stackoverflow.com/a/8649732/620097) for a understanding on how to get one query working. You should do that first. Then adding the loop "around" that should be much easier. Good luck.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78328611

http://stackoverflow.com/comment/138072457
has text: @Aaron The built-in variable `$!` is the PID of the last background process that was started. `sleep 900 &` starts a background process, and `sleep_pid=$!` saves its PID in the variable.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78317514

http://stackoverflow.com/comment/138131318
type: Comment
has text: bravo using the underappreciated `select` feature even though you *"have a limited working proficiency in shell scripts"*. You'll probably like `case ; esac` as well. Good luck.
comment on: http://stackoverflow.com/q/78351058
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138076325
score: 1
has text: as workaround you could try `if pidof tmux >&-` instead of your pgrep test
type: Comment
comment on: http://stackoverflow.com/q/78319238
type: QuestionComment

stdio
tag name: stdio
tags question: http://stackoverflow.com/q/78359720
type: Tag

http://stackoverflow.com/comment/138202908
has text: What's problem with `cat`?? Jiust tried now: `cat < namedFifo | > namedFifo ./ping.sh` work fine!? Note: `cat < namedFifo | > namedFifo cat` work too, but it's not very relevant...
score: 0
type: Comment
comment on: http://stackoverflow.com/a/78390677
type: AnswerComment

http://stackoverflow.com/comment/138137571
has text: `-f` and `1-8,20,22` are two separate arguments; you cannot supply them using a single quoted (regular) parameter expansion.
comment on: http://stackoverflow.com/q/78354730
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/comment/138306458
has text: strange that I am getting error with .csv but not with .txt so. try to create file with .txt and then rename it to .csv using mv command
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78444871
type: QuestionComment

quarkus
tag name: quarkus
type: Tag
tags question: http://stackoverflow.com/q/78346697

http://stackoverflow.com/comment/138104191
score: 0
has text: user1934428: `-r, --recursive like --directories=recurse` same as if you put it ahead of the file arguments.
comment on: http://stackoverflow.com/q/78330348
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138200295
type: QuestionComment
score: 2
type: Comment
has text: Get rid of the `[ "$filter ] || filter=.`. Instead, just use `${filter:-.}` on its first occurrence. `${var:-default}` expands to "$var" if "$var" is non-empty, and to `default` otherwise.
comment on: http://stackoverflow.com/q/78390223

http://stackoverflow.com/comment/138135140
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment
has text: See that `[Pipeline] sh` in your log? The `sh` step was executed, but didn't print anything. Easy to confirm by adding an `echo From Inside` command at the very start of that script.

http://stackoverflow.com/comment/138104324
score: 0
comment on: http://stackoverflow.com/q/78336037
has text: there is non need of *regex*: `case ${hostname#mngmnt} in *presto[]0-9]* ) memory=23G;; *hadoop[0-9]* ) ...`
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138153612
type: QuestionComment
has text: The shell doesn't entertain quotes after word splitting. Just keep it in mind. This is why you store raw unescaped values unless you plan to run `eval` against them. You're doing everything wrong with these strategies and presumption.
score: 0
comment on: http://stackoverflow.com/q/78363374
type: Comment

http://stackoverflow.com/comment/138101767
type: QuestionComment
has text: Use a YAML tool to manipulate YAML documents. `yq` is fairly popular and well supported.
score: 1
comment on: http://stackoverflow.com/q/78334609
type: Comment

http://stackoverflow.com/comment/138264300
type: Comment
has text: (mind, the above assertion is true _on UNIXlike platforms_; Windows is different -- there command-line parsing is done within the program being called, and an application can override the usual libc-provided logic -- but you'd need to patch bash itself to make that true for shell scripts, and that patched version of bash would of course be Windows-only).
type: QuestionComment
comment on: http://stackoverflow.com/q/78424828
score: 0

http://stackoverflow.com/comment/138202260
score: 0
has text: You're welcome. AFAIK there are only 2 "reasons" to store a script in a variable and they are a) because you use a shell syntax highlighting editor that gets confused by inline awk scripts, or b) because when you do a `ps` on some system (maybe old Solaris versions?) it shows the whole awk script in the output and your sys admins don't like it for some reason. Neither are issues I've actually come across myself in the past 40+ years of shell programming and if I did I still wouldn't store a script in a variable, I'd use a different editor and/or tell the sys admins to get over it.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78385408

heroku-cli
tags question: http://stackoverflow.com/q/78388698
tag name: heroku-cli
type: Tag

http://stackoverflow.com/comment/138202841
comment on: http://stackoverflow.com/a/78392023
has text: To store output in a variable use: `var="$(sed -E 's/\"/\\"/g file)"`
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138130472
type: QuestionComment
comment on: http://stackoverflow.com/q/78350564
score: 2
type: Comment
has text: Consider `a=b; b=foo; printf "%s\n" "${!a:0:2}"`

http://stackoverflow.com/comment/138255571
has text: `exec >&-` means "close stdout in the current shell process". It's the same `A>&B` syntax as `2>&1`, but "A" is not specified (default 1), and B is "-" meaning "close instead of copying the given FD".
type: Comment
comment on: http://stackoverflow.com/a/78420840
type: AnswerComment
score: 1

http://stackoverflow.com/comment/138239020
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78405506
has text: 44GB of container image. I think you have to question the whole process. Container images are not made to deal with data, but with applications.
type: Comment

http://stackoverflow.com/comment/138269682
has text: Also see [Bash Pitfalls #60 (set -euo pipefail)](https://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail).
type: QuestionComment
comment on: http://stackoverflow.com/q/78427625
type: Comment
score: 0

laravel
tags question: http://stackoverflow.com/q/78324242
type: Tag
tag name: laravel
tags question: http://stackoverflow.com/q/78983275
tags question: http://stackoverflow.com/q/79528967

http://stackoverflow.com/comment/138105732
type: Comment
comment on: http://stackoverflow.com/q/78336169
has text: What does the fact that it is running in CI have to do with whether you can manipulate `.bashrc`? Do you mean that it is unmodifiable? That it is shared with other projects that don't want the same settings? Something else? And is that related to why you are using the `-l` option? Are you relying on that to get you needed shell configuration?
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138270104
has text: Another thing you might do, though, is set `PS4=':$BASH_SOURCE:$LINENO+'; set -x` before the `source` command, and check whether the filename in the xtrace output matches the name of the file you dumped.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78427118
type: Comment

http://stackoverflow.com/comment/138155046
type: QuestionComment
has text: The first `awk` command you show is not the same as the `awk` command in your applescript script. Why?
comment on: http://stackoverflow.com/q/78364618
score: 0
type: Comment

django
type: Tag
tags question: http://stackoverflow.com/q/78348089
tag name: django
tags question: http://stackoverflow.com/q/79014732
tags question: http://stackoverflow.com/q/79139077

snmp
type: Tag
tags question: http://stackoverflow.com/q/78388395
tag name: snmp

http://stackoverflow.com/a/78429634
has body: As I mentioned in my first post, I also tried using unset: for ((i=0; i<${#array[@]}; i++)); do chomp=${array[i]: -3} echo chomp: $chomp if [ $chomp != "foo" ] || [ $chomp != "bar" ]; then echo "i: $i, element: ${array[i]}" unset array[$i] fi done array=( "${array[@]}" ) echo "Fourth run: ${array[@]}" Output: not expected chomp: foo i: 0, element: 8669648574foo chomp: 45u i: 1, element: 86696485745u chomp: bar i: 2, element: 231649bar Fourth run: 23164919a1 8594792682foo 859479268209t # not expected Changing that to && also did not work as expected: for ((i=0; i<${#array[@]}; i++)); do chomp=${array[i]: -3} echo chomp: $chomp if [ $chomp != "foo" ] && [ $chomp != "bar" ]; then echo "i: $i, element: ${array[i]}" unset array[$i] fi done array=( "${array[@]}" ) echo "Fifth run: ${array[@]}" Output: extra unwanted element chomp: foo chomp: 45u i: 1, element: 86696485745u chomp: bar chomp: 9a1 i: 3, element: 23164919a1 Fifth run: 8669648574foo 231649bar 8594792682foo 859479268209t Found a solution (indirect expansion - thanks to F. Hauri): for i in ${!array[@]}; do chomp=${array[i]: -3} echo chomp: $chomp if [ $chomp != "foo" ] || [ $chomp != "bar" ]; then echo "i: $i, element: ${array[i]}" unset array[$i] fi done array=( "${array[@]}" ) echo "Sixth run: ${array[@]}" Output: expected result chomp: foo chomp: 45u i: 1, element: 86696485745u chomp: bar chomp: 9a1 i: 3, element: 23164919a1 chomp: foo chomp: 09t i: 5, element: 859479268209t Sixth run: 8669648574foo 231649bar 8594792682foo
type: Answer
answers question: http://stackoverflow.com/q/78427584
has comment: http://stackoverflow.com/comment/138269972
upvote count: 0
score: -2
has comment: http://stackoverflow.com/comment/138297576
downvote count: 2

http://stackoverflow.com/comment/138285628
score: 0
comment on: http://stackoverflow.com/a/78438409
has text: It's useless searching for heght group hex digit, in `/proc/net/tcp6`!! ;-)
type: Comment
type: AnswerComment

numbers
type: Tag
tag name: numbers
tags question: http://stackoverflow.com/q/78368689

http://stackoverflow.com/comment/138204507
comment on: http://stackoverflow.com/q/78392914
type: Comment
has text: @CharlesDuffy thanks for the reply! How can I differentiate the bsub command from the script itself? I tried wrapping the commands in double quotes and it doesn't help.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138129617
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78349529
has text: Not related to `echo` though
type: Comment

http://stackoverflow.com/comment/138132641
has text: If you add an `echo 'Hello World'` step after the allegedly skipped `sh` step, do you see `'Hello World'` in the logs?
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524
type: Comment

http://stackoverflow.com/comment/138171180
comment on: http://stackoverflow.com/q/78373696
score: 1
has text: @yvs2014, `systemd-run` provides a modern alternative that works for anyone with systemd already active (as we know the OP has) without relying on atd.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138192422
comment on: http://stackoverflow.com/q/78386230
score: 0
has text: Please [edit] your question to show us a [mcve] with concise, testable sample input and expected output that we can copy/paste as-is to test with. Right now I can image a few different things your textual description might mean.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138236749
score: 0
has text: Yes, you damned right! Thx a lot. I wasn’t sure but it is obvious I have to rely on _read_ too. Have a nice day.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78410973

http://stackoverflow.com/comment/138169966
has text: Are you saying you have zip files inside of zip files? That is going to make hard, if not impossible, to look at the contents of the embedded zip files.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78372933
type: QuestionComment

http://stackoverflow.com/comment/138285503
comment on: http://stackoverflow.com/q/78438262
type: Comment
score: 0
has text: Try this: `awk -F '[:[:space:]]+' '$7=="0A"{ print strtonum("0x"$4);} ' "/proc/net/tcp" "/proc/net/tcp6" | sort -n`
type: QuestionComment

http://stackoverflow.com/comment/138173771
type: QuestionComment
has text: If you disable TTY emulation, that may well be the easy solution here (no TTY == there's no such thing as a screen size at all, and more intelligent systems will disable pager support in that scenario -- no knowing if your network hardware is "more intelligent" in that context, but it's worth testing). That should be the `-T` argument to ssh.
comment on: http://stackoverflow.com/q/78375308
type: Comment
score: 1

http://stackoverflow.com/comment/138294085
type: QuestionComment
has text: Try: `declare -iA "oralvs=($(lvs --noheadings --units m --nosuffix -o name,size vg_oracle |awk -F'[.[:space:]]+' '{printf "[%s]=%s ",$2,$3;}'))"`
comment on: http://stackoverflow.com/q/78442690
score: 0
type: Comment

http://stackoverflow.com/comment/138259804
type: QuestionComment
comment on: http://stackoverflow.com/q/78423981
type: Comment
score: 0
has text: `openssl enc -d -aes-256-cbc -in test.sh.enc -k "$Password" | bash`

http://stackoverflow.com/comment/138242198
score: 0
comment on: http://stackoverflow.com/a/78390328
has text: Sorry I’ve explained very bad. I mean with method tail -f. Anyway. Won’t be better with regular file than FIFO file? Thanks
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138197276
comment on: http://stackoverflow.com/q/78388939
has text: If you want to do something continuously like this, don't use `cron`. Write a script that runs a continuous loop and run it from `systemd`. It can use `inotifywait` to wait for new files instead of polling. This solves both problems, because you won't have any overlap, and you can wait for the file to be closed.
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/comment/138104318
score: 0
comment on: http://stackoverflow.com/q/78335326
type: QuestionComment
type: Comment
has text: continuation from previous comment: the CLASSPATH (environment variable) must contain the `build/classes` directory; or be empty and working directory be `build/classes` to use `java com.estudio.ejerciciosclase.sumScanner`; If that is not the case, use `java -classpath build/classes com.estudio.ejerciciosclase.sumScanner`

http://stackoverflow.com/comment/138297718
score: 0
has text: Separate issue, which may or may not have any impact depending on how your input is formatted: Always quote your expansions: `echo "$OUTPUT_RULE"`, not `echo $OUTPUT_RULE` -- see [I just assigned a variable, but `echo $variable` shows something else!](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else)
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78445411

vsphere
type: Tag
tags question: http://stackoverflow.com/q/78344853
tag name: vsphere

http://stackoverflow.com/a/78336467
type: Answer
has comment: http://stackoverflow.com/comment/138106061
has comment: http://stackoverflow.com/comment/138105381
has body: Keep it simple, use the absolute path of the script C:\msys64\usr\bin\bash -lc '/absolute/path/to/super_duper_script.sh' Edit Alternatively, as it seems you know the script is in the current directory C:\msys64\usr\bin\bash -l ./super_duper_script.sh
has comment: http://stackoverflow.com/comment/138106161
has comment: http://stackoverflow.com/comment/138105824
score: 0
answers question: http://stackoverflow.com/q/78336169

http://stackoverflow.com/comment/138150390
score: 1
comment on: http://stackoverflow.com/q/78361451
type: QuestionComment
has text: Yeah I realized my mistake and edited the comment. Glad to have helped, have a nice day
type: Comment

http://stackoverflow.com/comment/138252280
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78419884
type: Comment
has text: (and `read -s` is likewise a feature that sh isn't guaranteed to offer)

http://stackoverflow.com/comment/138131047
comment on: http://stackoverflow.com/a/78351090
type: Comment
score: 0
type: AnswerComment
has text: OP wants to remove certain directories so they don't show up in the `select` prompt.

http://stackoverflow.com/tag/xml
type: Tag
tags question: http://stackoverflow.com/q/78341846
tag name: xml
tags question: http://stackoverflow.com/q/78965550
tags question: http://stackoverflow.com/q/79123653
tags question: http://stackoverflow.com/q/79505924

emoji
tag name: emoji
type: Tag
tags question: http://stackoverflow.com/q/78399997

xampp
tags question: http://stackoverflow.com/q/78444401
type: Tag
tag name: xampp

http://stackoverflow.com/comment/138095024
comment on: http://stackoverflow.com/q/78330653
score: 0
has text: BTW, if you want to ignore the directory `stockdress` and the directory `oldstockdress`, it's much more efficient to put `-name stockdress -prune -o -name oldstockdress -prune -o` at the beginning of your predicate set (right after `-maxdepth 1`, rather, since `-maxdepth` is a global setting; _before_ the `-type f`); pruning them means that `find` doesn't even traverse them, whereas `-not -path` does the work of looking inside those directories and then throws away the results.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138100180
score: 0
comment on: http://stackoverflow.com/a/78333360
type: Comment
has text: @tripleee Right, I didn't think of it, but generally I prefer to declare/initialize variables on their own separate lines. Also, if you are going that way, remember we are checking if the command exited with error (and in Shell, zero-exit code are considered as "true"). So you should negate the exit status with `!`: `if ! commandOutput=$(command) && [[ $commandOutput = *"str"[io]"ng"* ]]`
type: AnswerComment

http://stackoverflow.com/a/78340597
score: 0
has body: Not sure if this will work as I don't have time to create a sample project and recreate the bug but if you alter the code: tag = val = $0 sub(/:.*/,&quot;&quot;,tag) sub(/[^:]+:[[:space:]]*/,&quot;&quot;,val) tag2val[tag] = val where the split of the values is being done you can alter the tag2val code like the following to escape the characters: gsub(/&quot;/, &quot;\&quot;\&quot;&quot;, val) tag2val[tag] = val As I said I haven't tested anything.
type: Answer
answers question: http://stackoverflow.com/q/78339485

http://stackoverflow.com/comment/138317677
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78433171
has text: I do not follow. So do not start the child at all. Your question shows how to replace it - using exec. Also, your computer has gigabytes of memory, who cares about one process.

http://stackoverflow.com/comment/138252148
has text: Can you also show the corresponding part of the script?
score: 2
type: QuestionComment
comment on: http://stackoverflow.com/q/78419884
type: Comment

performance
tags question: http://stackoverflow.com/q/78403621
tag name: performance
type: Tag
tags question: http://stackoverflow.com/q/78461484
tags question: http://stackoverflow.com/q/79132706
tags question: http://stackoverflow.com/q/79403402
tags question: http://stackoverflow.com/q/79312013
tags question: http://stackoverflow.com/q/79534222
tags question: http://stackoverflow.com/q/79452603

http://stackoverflow.com/comment/138153332
type: Comment
score: 0
type: AnswerComment
has text: Thank you! I've imbedded numquotes into quotenum since it's used once and I don't care too much about readability. I've also used \n%\n to split on, since I learned it allows me more flexibility
comment on: http://stackoverflow.com/a/78354221

http://stackoverflow.com/comment/138229187
type: QuestionComment
has text: Are you aware that the instruction `pwd` just shows you the value of the environment variable `$PWD`? (Just do `echo $PWD > /home/user/Documents/save_path.txt` for saving the path)
score: 1
comment on: http://stackoverflow.com/q/78406644
type: Comment

http://stackoverflow.com/a/78362140
has body: The test.sh file was saved in UTF-8 with a BOM (Byte Order Mark) at the beginning. When saved in UTF-8 format with no BOM, it works correctly. Thank you to @oguz-ismail for help identifying the issue in comments (above)
answers question: http://stackoverflow.com/q/78361451
score: 1
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/comment/138129953
type: Comment
has text: To paraphrase Barbie: "Distributed computing is hard!"
type: AnswerComment
comment on: http://stackoverflow.com/a/78350523
score: 0

http://stackoverflow.com/comment/138171884
has text: Also see [Bash Pitfalls #60 (set -euo pipefail)](https://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail).
type: QuestionComment
comment on: http://stackoverflow.com/q/78373828
score: 2
type: Comment

http://stackoverflow.com/comment/138137384
type: Comment
comment on: http://stackoverflow.com/q/78350497
score: 0
type: QuestionComment
has text: It's worth figuring that out. If they're passing content _direct_ to a shell we can figure out what that shell's behavior is. If they're using some custom code to try to do shell-like parsing (maybe as an attempt to look for commands sent by common malware or such -- the wordpress ecosystem is a popular attack target) before content gets passed off to an actual shell... well, again, we can't come up with a _good_ workaround until we know exactly what it is we're working around.

http://stackoverflow.com/a/78366889
downvote count: 0
score: 1
upvote count: 1
type: Answer
has body: Using GNU or BSD sed for -E: $ sed -E 's/[Rr][Ss]|V|-?.\./ &/g' file GENE RSID1 RSID2 VALUE ENSG00000242220 rs2826052 rs2826052 0.20961262553802 ENSG00000242220 rs2826052 rs79893204 0.00583452893352463 ENSG00000242220 rs2826052 rs117256228 -0.003012912482066 or more robustly as it only matches specific text on the exact lines where you want that text to match, using any awk: $ awk '{ gsub( (NR==1 ? "RS|V" : "rs|-?.[.]"), " &" ) } 1' file GENE RSID1 RSID2 VALUE ENSG00000242220 rs2826052 rs2826052 0.20961262553802 ENSG00000242220 rs2826052 rs79893204 0.00583452893352463 ENSG00000242220 rs2826052 rs117256228 -0.003012912482066
answers question: http://stackoverflow.com/q/78359494

http://stackoverflow.com/comment/138185696
comment on: http://stackoverflow.com/q/78378844
has text: @EdMorton Just for readability's sake. And for not needing to escape characters. I'm curious: What would your general scriptfile look like?
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138269090
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78428595
has text: It means that SESSION starts with a space. That will cause `curl` to receive two arguments: `curl http://host/[ ]session` (`[ ]` denotes the space). `echo [ ]session` will simply ignore the space. Another way to easily find out: `printf '[%s]' "$SESSION"` or `echo "[$SESSION]"`. You will see the space printed after the opening bracket. The rule is really simple: _ALWAYS_ quote your parameters when expanding (this would have gotten you a different error with your command, but probably had made it easier to spot the mistake). Also `set -x` can really be helpful when troubleshooting shell errors.
score: 3

http://stackoverflow.com/comment/138078963
has text: @jhnc, isn't `/proc/#pid/exe` a symlink to the binary? That has to be placed there after the terminal has decided what the command is no? That should not be relevant then, or am I missing something? BTW, you're right, it uses `/proc/#/cmdline` as a source. Updated again. Also, thanks, I'm learning quite a bit here!
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78320229
score: 0

http://stackoverflow.com/comment/138155132
type: QuestionComment
score: 0
has text: It's a strange question for sure, but I found it perfectly reasonable. In a world where somebody implemented [`sl`](https://www.cyberciti.biz/tips/displays-animations-when-accidentally-you-type-sl-instead-of-ls.html) to catch `ls` typos, this is almost a good idea.
comment on: http://stackoverflow.com/q/78364647
type: Comment

named-pipes
type: Tag
tag name: named-pipes
tags question: http://stackoverflow.com/q/78410973
tags question: http://stackoverflow.com/q/79305057

parallel-processing
type: Tag
tag name: parallel-processing
tags question: http://stackoverflow.com/q/78316544
tags question: http://stackoverflow.com/q/78609174
tags question: http://stackoverflow.com/q/78759826
tags question: http://stackoverflow.com/q/78761415
tags question: http://stackoverflow.com/q/78923603
tags question: http://stackoverflow.com/q/79188455
tags question: http://stackoverflow.com/q/79193786
tags question: http://stackoverflow.com/q/79147567
tags question: http://stackoverflow.com/q/79297468
tags question: http://stackoverflow.com/q/79475480
tags question: http://stackoverflow.com/q/79466711

http://stackoverflow.com/comment/138139943
score: 0
has text: Otherwise it matches the first 2 digits of a larger number, and the rest of the number goes into `\3`, so `1234` becomes `12none`
type: QuestionComment
comment on: http://stackoverflow.com/q/78356050
type: Comment

http://stackoverflow.com/comment/138297067
score: 4
has text: What do you mean by unreadable? Wrong csv format? Empty? Etc.
comment on: http://stackoverflow.com/q/78444871
type: QuestionComment
type: Comment

find
tags question: http://stackoverflow.com/q/78330348
tag name: find
type: Tag
tags question: http://stackoverflow.com/q/78503576
tags question: http://stackoverflow.com/q/78741961
tags question: http://stackoverflow.com/q/78712681
tags question: http://stackoverflow.com/q/78983069
tags question: http://stackoverflow.com/q/79207537
tags question: http://stackoverflow.com/q/79348421
tags question: http://stackoverflow.com/q/79252854
tags question: http://stackoverflow.com/q/79396825
tags question: http://stackoverflow.com/q/79490486
tags question: http://stackoverflow.com/q/79423976
tags question: http://stackoverflow.com/q/79467597
tags question: http://stackoverflow.com/q/79483250
tags question: http://stackoverflow.com/q/79423387
tags question: http://stackoverflow.com/q/79481716

http://stackoverflow.com/comment/138155197
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78364736
has text: I'd not disable other combinations of `#! /usr/bin/python`, etc., but instead probably just check to see if the first line starts with `#!`. That will handle most of the cases

lamp
type: Tag
tag name: lamp
tags question: http://stackoverflow.com/q/78385537

http://stackoverflow.com/comment/138274988
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78431101
has text: Thanks a lot for the explanation, datawookie. It definitely wasn't paying attention to the details of what I was doing - it was the classical stick some code in and hope it runs.
score: 1

http://stackoverflow.com/comment/138189937
type: QuestionComment
comment on: http://stackoverflow.com/q/78384843
score: 2
type: Comment
has text: Did you look at `rsync`? This might be what you need. It can copy anything in one single run, can include/exclude directories at will... Try `man rsync`.

http://stackoverflow.com/comment/138255168
comment on: http://stackoverflow.com/q/78420308
has text: @Barmar, yes, I did that purposefully and intentionally to make it more obvious the commonality and difference between the `then` block and the `else` block. The question is about parameterizing the difference so as to be able to eliminate the `if`/`then`/`else` altogether
type: QuestionComment
type: Comment
score: 0

switch-statement
tag name: switch-statement
type: Tag
tags question: http://stackoverflow.com/q/78361035
tags question: http://stackoverflow.com/q/78579093
tags question: http://stackoverflow.com/q/79538280

http://stackoverflow.com/comment/138224202
comment on: http://stackoverflow.com/a/78403776
score: 0
has text: @CharlesDuffy until the first successful read, it actually does block instead of fail. after the first successful read, it fails instead of block, causing 100%-cpu-of-1-core. dunno why (tested on Ubuntu 24.04 WSL, kernel 5.15.146.1-microsoft-standard-WSL2 )
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/139018693
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78383369
has text: wrapping the curl command in $(curl... ) is the solution. Thank you!
score: 0

http://stackoverflow.com/comment/138210812
has text: It shouldn't. You can easily test which print/printf it prints from by adding an additional string to one of the prints. Maybe its a line break from the shell window?
comment on: http://stackoverflow.com/a/78396452
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138103123
score: 0
has text: your class name is `sumScanner`, not `EjerciciosClase`
type: QuestionComment
comment on: http://stackoverflow.com/q/78335326
type: Comment

http://stackoverflow.com/comment/138215763
comment on: http://stackoverflow.com/a/78396833
has text: a) would give you an error message like `awk: cmd. line:1: (FILENAME=- FNR=1) fatal: printf: no arguments`, b) an error message like `awk: cmd. line:1: (FILENAME=- FNR=1) fatal: not enough arguments to satisfy format string`, and then c) would do what you'd want and output `10% off` without a terminating newline.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138122444
score: 0
type: QuestionComment
has text: What is _the latest file_? The file with the most recent modification time (this is suggested by your use of `-t`, but better saying it explicitly)? The file with name highest in sorting order? The file last in directory order? Another point to consider: Can the filenames contain newline characters?
type: Comment
comment on: http://stackoverflow.com/q/78341621

http://stackoverflow.com/comment/138173893
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78374908
has text: extending PeterCorde's comment with one further demonstration: `printf "%s\n" ...... "quotes 'inside' quotes aren't removed" 'same "for dbls" inside singles'` Good luck to all.

http://stackoverflow.com/comment/138173601
type: Comment
comment on: http://stackoverflow.com/q/78373696
has text: ...at least with everyone using systemd there's a completely uniform way to be notified or run an arbitrary hook when any software changes state, a uniform way to indicate which components should be started at boot, a unified way to view per-process logs, a unified way to give a process a private copy of tmpfs or lock it off from inspecting/changing home directory contents or sandbox which syscalls it can invoke or configure something else to be started only after it's finished initializing; &c, &c. &c. Pick a competitor and those too will have unified ways to do most of things.
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138352430
score: 0
comment on: http://stackoverflow.com/a/78403450
type: Comment
has text: My intention in sharing this script which i inherited from previous admin is to understand the "correct way" to write a script for this purpose.
type: AnswerComment

http://stackoverflow.com/comment/138138821
comment on: http://stackoverflow.com/q/78353017
type: QuestionComment
has text: You can't pass arrays as arguments. You can pass the elements (strings) *in* an array, each as a separate argument, but if you pass the elements of more than one array it's going to be hard to tell where one array stops and the next starts, since the function just gets one big undifferentiated list of strings.
type: Comment
score: 1

http://stackoverflow.com/a/78443211
score: 1
upvote count: 1
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/78442690
has body: Do it with declare: #!/usr/bin/env bash # Capture output in compound and check return code at the same time if compound=$( lvs \ --noheadings \ --units m \ --nosuffix \ -o name,size vg_oracle | awk -F. '{split($1,f," ");printf"[%s]=%d ",f[1],f[2]}' ) then # Use the declare statement with a string as de declaration argument declare -A "oralvs=($compound)" fi

http://stackoverflow.com/a/78429282
has comment: http://stackoverflow.com/comment/138277877
upvote count: 1
type: Answer
has body: As others have already pointed out, no, there is no way within a command to let the caller of the command not use appropriate quoting as by the time your command sees it, the shell has already processed the arguments to then pass the results of that processing to your command. Regarding "and rest without any single quote" - you're thinking of this backwards. In shell quotes aren't something you add when you need to, they're something you remove when you need to. Every string should be enclosed in single quotes by default. Change those to double quotes if you need to, e.g. to let variables expand, and change them to no quotes if you need to, e.g. to perform globbing, word splitting, etc. So you shouldn't tell your customers to add quotes around specific arguments, you should tell them to put single quotes around every argument unless they need to. Having said that, if you think "there are huge chances that customer might miss to pass single quote" then you're saying they can't be trusted to use shell correctly and so instead of allowing them to pass arguments to your command you should have them provide data on stdin which your command then reads without the shell getting involved in interpreting their data before your command sees it. Consider instead of letting them call your commands directly, create a higher level command "shell" for them which they call first and that puts them into an environment where they can then call your lower level commands, e.g. let's say you currently have scripts named foo and bar that your customers call, instead you could do: $ cat cmdenv #!/usr/bin/env bash foo() { printf '%s: %s\n' "$FUNCNAME" "$*" } bar() { printf '%s: %s\n' "$FUNCNAME" "$*" } while read -p 'cmd> ' -r cmd args; do "$cmd" "$args" done $ ./cmdenv cmd> foo $-123 $PWD foo: $-123 $PWD cmd> bar $(date) bar: $(date) So your customer calls cmdenv and then instead of calling foo from a shell, your customer would be "calling" foo from your while-read loop and so no shell wo…
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/78424828

http://stackoverflow.com/comment/138173719
has text: (Which is all to say -- `set -e` and ERR traps and equivalents are all hopelessly broken; get in the habit of explicitly using `|| return` and `|| exit`, and checking for presence of same during code review).
type: QuestionComment
comment on: http://stackoverflow.com/q/78373828
score: 2
type: Comment

http://stackoverflow.com/comment/138134390
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78344853
type: QuestionComment
has text: To find someone for writing a program for you, Stackoverflow is not the right place. you could post such a request at [freelancer](https://www.freelancer.com/); I've never tried it myself, but have been told that this platform even works for tiny "pocket" projects. If you want to stick with Stackoverflow, you would pick the first step from your list (detect all VMs), and try to do it by yourself. Then post the code you have tried, and explain in what respect it doesn't work. You will most likely get helpful answers to improve it. Then, do the same with the next step ("create dictionary").

http://stackoverflow.com/comment/138173576
score: 1
type: QuestionComment
has text: (I'm not a fan of systemd particularly -- if you ask me to build an embedded system from scratch I'm more likely to use [runit](https://smarden.org/runit/) or [s6](https://skarnet.org/software/s6/) for process supervision -- but I'm _much more_ not a fan of the wild west where every piece of software builds a completely bespoke mechanism for managing itself, and half of them do it very badly or outright ignore major parts of the problem space)
type: Comment
comment on: http://stackoverflow.com/q/78373696

http://stackoverflow.com/comment/138129936
type: Comment
has text: Oh, you're right!
type: AnswerComment
comment on: http://stackoverflow.com/a/78350523
score: 0

http://stackoverflow.com/comment/138203688
comment on: http://stackoverflow.com/q/78392419
type: QuestionComment
score: 0
type: Comment
has text: @pmf I'm amazed how this works! Would you please write an answer? Thank you!

http://stackoverflow.com/comment/138173223
score: 1
type: QuestionComment
type: Comment
has text: The double-quotes shouldn't be part of the actual string. When you run `/bin/bash -c "echo hello; ls -la"` in bash or sh, the quotes protect that part of the command line from word-splitting, but quote-removal happens before passing that string to argv of the child process. Try it yourself with `printf "%s\n" -c "hello world" 'hi mom' "quotes 'inside' quotes aren't removed"` on a bash command line.
comment on: http://stackoverflow.com/q/78374908

http://stackoverflow.com/comment/138169205
score: 2
has text: `sed` is not the right tool for this job.
type: Comment
comment on: http://stackoverflow.com/q/78372639
type: QuestionComment

insert
tags question: http://stackoverflow.com/q/78381387
type: Tag
tag name: insert
tags question: http://stackoverflow.com/q/78685693
tags question: http://stackoverflow.com/q/78643499
tags question: http://stackoverflow.com/q/79320316

http://stackoverflow.com/comment/138135990
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78353316
has text: @kvantour While this reading is interesting, this does *not* answer to the question because.. the OP does not even use process substitution.

http://stackoverflow.com/comment/138200343
score: 0
comment on: http://stackoverflow.com/q/78390223
type: QuestionComment
type: Comment
has text: If you want terminal escape codes to add color or attributes, query the terminfo database with `tput`. (eg, instead of `echo "\033[1;34m"`, use `tput bold; tput setaf 4`

cmd
tag name: cmd
tags question: http://stackoverflow.com/q/78343975
type: Tag

http://stackoverflow.com/comment/138168732
score: 2
type: Comment
has text: Use `C_CYAN=$(tput setf 3)` instead of hard-coding terminal-specific escape codes.
type: QuestionComment
comment on: http://stackoverflow.com/q/78372273

http://stackoverflow.com/comment/138210737
has text: Thank you for this hint. And I totally agree with you. However sometimes there are situations where you don't have said XML/HTML parsers. I know it is not optimal.
type: Comment
comment on: http://stackoverflow.com/q/78396373
score: 1
type: QuestionComment

shebang
type: Tag
tag name: shebang
tags question: http://stackoverflow.com/q/78364647

http://stackoverflow.com/comment/138274530
score: 0
comment on: http://stackoverflow.com/a/78423240
has text: Indeed any nonempty string or 0 is considered true.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138250386
type: Comment
has text: You could produce the output you want from your config file with just `sed 's@.*@C:/project/test/&.xml@' 'C:/xxxx/load.config'`, no need for multiple loops, arrays etc.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78416162

http://stackoverflow.com/comment/138129224
comment on: http://stackoverflow.com/q/78349529
score: 0
type: QuestionComment
type: Comment
has text: I reproduced it on my system with $COLUMNS == 180

http://stackoverflow.com/comment/138133878
has text: @There is nothing related to ANSI C here. Of course, bash has its quoting rules. I am not aware that there would be any "standard" across languages about quoting. In particular, C and bash have fairly different quoting rules. `a b` or `xxx` or `' a b'` would be valid strings in bash, but not in C. Further, the C string "a\nb" would be syntactically valid in bash, but their content would differ. The so called "ANSI C" quoting mentioned in the bash manual refers solely to the specific `$'...'`construct. My guess is that, since bash is written in C, they just use `sprintf` from the C-library.
comment on: http://stackoverflow.com/q/78344372
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138203968
score: 0
type: QuestionComment
has text: It's a lot less problem-prone to define the code you want to run remotely in a function and let bash serialize that function for you. `spinner() { ...; }`, then `ssh remote_server "$(declare -f spinner); spinner ${pid@Q}"` (assuming bash 5.x for the @Q). No extra escapes/backslashes/etc needed that way; you just write the code the exact same way you'd run it locally.
comment on: http://stackoverflow.com/q/78392466
type: Comment

http://stackoverflow.com/comment/138269338
comment on: http://stackoverflow.com/a/78428119
type: Comment
type: AnswerComment
score: 0
has text: good explanation of my bad logic. I tried this and it still did not work for reasons unknown to me. Please see my next post.

termux-linux
tag name: termux-linux
type: Tag
tags question: http://stackoverflow.com/q/78361451

http://stackoverflow.com/a/78543432
score: 0
answers question: http://stackoverflow.com/q/78354041
type: Answer
has body: version without awk - check amount of lines with wc, generate random number and read line. DICTIONARY_SIZE=$(wc -l &lt;file.txt) RANDOM_LINE=$((1 + $RANDOM % $DICTIONARY_SIZE)) counter=0 while [ $counter -lt $RANDOM_WORD ]; do read LINE counter=$(($counter+1)) done&lt;file.txt echo $LINE

http://stackoverflow.com/comment/138199386
has text: This worked, though just a few additions I made -Blank lines or other lines that do not contain = will be changed to <line>=<line> . A simple check to see if the line does not contain - and echoing the line as-is , otherwise doing the rest of the function. -The last line does not get added to the newly created file due to cat not adding one. Simply changing cat some_config_file to (echo ; cat some_config_file) fixes that
score: 1
comment on: http://stackoverflow.com/a/78385706
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138257835
score: 0
has text: Please remove the _bash_ tag. There is no bash involved in your code.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78421398

http://stackoverflow.com/comment/138094525
type: QuestionComment
has text: Doesn't sound like a good idea.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78330326

http://stackoverflow.com/comment/138253724
score: 0
has text: @Barmar, `${STDOUT}` may evaluate to a filename depending on parameters to the script
comment on: http://stackoverflow.com/q/78420308
type: QuestionComment
type: Comment

heap-dump
type: Tag
tag name: heap-dump
tags question: http://stackoverflow.com/q/78365034

http://stackoverflow.com/comment/138287252
has text: Doh! That is the problem. `alias fi='finger -i'`. Once I eliminate that alias, the script works as expected.
comment on: http://stackoverflow.com/a/78438016
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138251638
comment on: http://stackoverflow.com/q/78419580
type: QuestionComment
has text: note there's a difference between ending with `foo.l`, containing `test.list.txt`, and the extension starting with `foo.la` which you may want to consider
score: 0
type: Comment

http://stackoverflow.com/comment/138176975
score: 0
comment on: http://stackoverflow.com/q/78373722
type: QuestionComment
type: Comment
has text: But I don't use nohup. And looking at the behaviour of the program when I run it from the terminal I understand that it doesn't either. Unless spawn uses it, it is not used directly.

http://stackoverflow.com/comment/138225283
type: Comment
type: AnswerComment
score: 0
has text: @Urza_tron No worries. I edited your question to make it clearer. You'll have to redirect the output from oguz's `sed` to a file to get the new file you want: `sed '9{N;s/\n/ /}' inputfile > outputfile`
comment on: http://stackoverflow.com/a/78404326

http://stackoverflow.com/comment/138167402
score: 0
type: QuestionComment
has text: maybe use `"> /home/postgres/.bash_profile"` instead of `"> .bash_profile"`. Eventually run two commands separated by `;` - `"cd /home/postgres ; other coomand"`
type: Comment
comment on: http://stackoverflow.com/q/78371491

http://stackoverflow.com/comment/138596845
score: 2
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78603441
has text: (to be explicit, `whisper` is a 3rd-party tool -- see https://github.com/openai/whisper/blob/main/README.md#command-line-usage)

http://stackoverflow.com/comment/138222340
comment on: http://stackoverflow.com/q/78402103
score: 0
type: QuestionComment
has text: Also, note that your output and error logs are clobbered on every iteration of the loop, and that you have no validation at all. *At best* you'll get the output of the last query, but note that if, say, the last query yields 0 rows, maybe because the last line in the file is blank, then the final `.log` files will be empty.
type: Comment

http://stackoverflow.com/a/78425903
has body: If you have rename tool, try this rename -n 's/_N_/_$ENV{theID}_/; s/_$//' *.cfc_ Remove -n if suggestions are correct.
has comment: http://stackoverflow.com/comment/138271677
score: 0
has comment: http://stackoverflow.com/comment/138264915
answers question: http://stackoverflow.com/q/78424358
type: Answer

nbconvert
tag name: nbconvert
tags question: http://stackoverflow.com/q/78313378
type: Tag

http://stackoverflow.com/comment/138099140
score: 0
has text: As stated in the man page for Bash: `? Expands to the exit status of the most recently executed foreground pipeline.`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78333123

http://stackoverflow.com/comment/138181371
score: 0
has text: `disable session pager` -- see page 284 of https://paultclark.com/network/calix/Calix%20E-Series%20(E7%20OS%20R2.5)%20Command-Line%20Interface%20(CLI)%20Reference.pdf
type: QuestionComment
comment on: http://stackoverflow.com/q/78375308
type: Comment

http://stackoverflow.com/comment/138127807
type: Comment
type: AnswerComment
has text: This worked well for doing a version bump and gave me a good push to learn more about regular expression and sed. I do however need the version number in a script to run some additional git commands to create tags. I have updated the question to add more context to the approach I am thinking of. Let me know if you have any ideas or other approaches I should consider. Thanks!
comment on: http://stackoverflow.com/a/78346403
score: 0

http://stackoverflow.com/comment/138288195
score: 0
has text: In my case PID 48 remains as mainscript and then creates a child process for command1. When would this happen?
comment on: http://stackoverflow.com/a/78433171
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78371835
type: Answer
has body: It sounds like this might be what you're trying to do: awk ' FNR == 1 { close(out); out="len."FILENAME } ((FNR-2) % 4) == 0 { print length() > out } ' *.fastq The above would not produce an output file given an input file that is empty or contains fewer than 2 lines. If that's an issue then update your question to include such cases in your sample input/output and state there how it should be handled plus which awk variant you use (as that'd be easier to handle with GNU awk for BEGINFILE/ENDFILE). I'm assuming when you say "I have a directory of many fastq files" the "many" isn't enough to exceed your systems ARG_MAX limit. If it can be then you'd get the list of files to process by doing printf '%s\n' *.fastq | awk 'BEGIN{ populate ARGV from getline calls } {...}' (google it). If your file names can contain newlines then you'd need GNU awk or similar to handle NUL-terminated input and then printf '%s\0' *.fastq | awk -v RS='\0' 'BEGIN{ populate ARGV from getline calls } { as above }' I'd recommend that, given an input file foo.fastq, instead of creating an output file named len.foo.fastq you create one named foo.fastq.len or foo.len so that if you have to run the tool again or run any other tool that operates on .fastq files the *.fastq shell globbing doesn't pick up your len files. To do that, instead of out="len."FILENAME use either of: out=FILENAME".len" out=FILENAME; sub(/\.[^.]+$/,".len",out)
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/78371799

http://stackoverflow.com/comment/138236616
type: Comment
score: 0
has text: Yes it does! Look in [Best way to divide in bash using pipes?](https://stackoverflow.com/a/13182139/1765658), just under ***Introducing shell connector***, the sample show precisely what you're trying to do.
type: QuestionComment
comment on: http://stackoverflow.com/q/78410973

http://stackoverflow.com/comment/138202851
has text: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/257544/discussion-between-f-hauri-give-up-github-and-ljm-dullaart).
comment on: http://stackoverflow.com/a/78390677
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138067414
score: 0
has text: Thanks. Output: `+ '[' $'UP\r' '!=' UP ']'`. If I can ask, how can I fix it? --- `+ '[' $'UP\r' '!=' 'UP\r' ']' (new_line) + echo 'Status is changed!'` - `status_column3="UP\r"` it dont work.
type: QuestionComment
comment on: http://stackoverflow.com/q/78314716
type: Comment

http://stackoverflow.com/comment/138291762
type: Comment
type: AnswerComment
score: 0
has text: Adding something everywhere then removing it under some condition is always a worse (less clear and/or more fragile and/or less efficient) approach than only adding something under some condition. In this case if the first input line started with `E_#7` then `'s/^/E_/'` would change it to `E_E_#7` then `'1s/E_//'` would change it back to `E_#7` and then `'s/E_#/#/'` would change it to `#7` thereby corrupting it. You did say "However it works only with the lines provided." - obviously posting a script that only works with a specific set of input isn't useful.
comment on: http://stackoverflow.com/a/78438129

http://stackoverflow.com/comment/138252283
score: 0
comment on: http://stackoverflow.com/a/78420010
type: Comment
has text: Rebasing makes new commits yet again, so you would end up with a different F2. So what is gained, really? Basically you're having worries you should not have, because you are not quite grasping what a commit is (or what Git is). History is history, just live with it.
type: AnswerComment

http://stackoverflow.com/comment/138236475
score: 0
comment on: http://stackoverflow.com/q/78410973
has text: Have a look at [Best way to divide](https://stackoverflow.com/a/13182139/1765658) and see how I use multiple parallelized `bc` to drawn a fractal at [Is bash a programming language?](https://stackoverflow.com/a/67498861/1765658)
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138296675
comment on: http://stackoverflow.com/q/78444871
type: QuestionComment
type: Comment
score: 1
has text: Paste your script into shellcheck.net, fix any problems it identifies.

http://stackoverflow.com/comment/138262394
type: QuestionComment
comment on: http://stackoverflow.com/q/78424828
type: Comment
has text: It's not just not possible _in bash_, it's not possible _in any language whatsoever_. No matter what language you implement `test.sh` in -- even if it's really a C program -- it gets arguments as they were parsed by the parent shell.
score: 1

http://stackoverflow.com/comment/138198682
has text: `cat file | grep variable1` is a *"Useless Use of cat"*. You can replace it with `grep variable1 file`
type: QuestionComment
comment on: http://stackoverflow.com/q/78389511
score: 2
type: Comment

xml-parsing
tags question: http://stackoverflow.com/q/78341846
tag name: xml-parsing
type: Tag
tags question: http://stackoverflow.com/q/78454731

echo
tags question: http://stackoverflow.com/q/78420131
type: Tag
tag name: echo
tags question: http://stackoverflow.com/q/78538377
tags question: http://stackoverflow.com/q/78533115
tags question: http://stackoverflow.com/q/78807685
tags question: http://stackoverflow.com/q/78772491
tags question: http://stackoverflow.com/q/78885332
tags question: http://stackoverflow.com/q/78820603
tags question: http://stackoverflow.com/q/79105586
tags question: http://stackoverflow.com/q/79076717
tags question: http://stackoverflow.com/q/79178079
tags question: http://stackoverflow.com/q/79395000

http://stackoverflow.com/comment/138285884
score: 4
comment on: http://stackoverflow.com/q/78438850
has text: Don't prepend you variable name by a `$` in `export CWPROOT=/home/felipe/Work/Seismic_Unix_Hub` command !
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138280532
comment on: http://stackoverflow.com/q/78435782
score: 0
has text: You can pass an error message from your script to Terraform by writing the error message to the standard error (stderr) stream. In your script, you can write the error message to stderr using the ">&2" redirection operator. Ex: >&2 echo "Error: Environment variable SOME_ENV is missing"Here is the [output](https://i.imgur.com/kYJD9kw.png)
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138226370
score: 0
has text: Thanks @CharlesDuffy for the link and set -x suggestion!
comment on: http://stackoverflow.com/q/78405034
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78450931
has body: In the future, you can always run the following command from the instance to get logs on the script execution: journalctl -u google-startup-scripts.service
type: Answer
answers question: http://stackoverflow.com/q/78366286
score: 0

http://stackoverflow.com/comment/138222621
comment on: http://stackoverflow.com/q/78402103
has text: Additionally, the script presented outputs the queries themselves in addition to their results, but it captures only the results. Is this intentional?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138090159
has text: Yes, in the description of `exec` in `man zshbuiltins`.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78325122

http://stackoverflow.com/comment/138225265
score: 0
comment on: http://stackoverflow.com/a/78404326
has text: Those lines are just numbers, sorry for the confusion. But does that code modify the initial file into a new file with the desired change?
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138072430
type: Comment
score: 0
has text: Well, as I wrote: I tried Total Commander and it deleted.the file perfectly. But if the file was deleted by bash it doesn't show it, however you still cannot create a file with the name of the deleted file. So there IS something in the filesystem but Total Commender does not show it, like the Android explorer does not show it. With the Android explorer you have to use "search" for the file name to see it.
comment on: http://stackoverflow.com/q/78315911
type: QuestionComment

conditional-operator
type: Tag
tags question: http://stackoverflow.com/q/78405034
tag name: conditional-operator

http://stackoverflow.com/comment/138254421
score: 0
has text: @NoelYap But you're `> ${outfile}` after confirming that it's equal to `/dev/stdout`. If you're trying to get CSV form with `\N`, the recommended way is to use `SELECT ... INTO OUTFILE ...`.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78420308

http://stackoverflow.com/comment/138169201
has text: please update the question to show *a)* the (wrong) output generated by your script and *b)* the (correct) expected output
comment on: http://stackoverflow.com/q/78372639
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138154649
has text: Nothing too do with PostScript.
type: QuestionComment
comment on: http://stackoverflow.com/q/78362703
type: Comment
score: 0

http://stackoverflow.com/comment/138269965
score: 1
has text: @Azeem thanks for pointing me into the right direction. I've been able to reduce bash complexity by moving vars and expressions to env: first.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78412927

http://stackoverflow.com/comment/138115279
has text: Beyond that, `declare export` doesn't make sense. If you want everything to be exported, make it `declare -x` -- take out the `export`.
type: Comment
comment on: http://stackoverflow.com/q/78342087
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138159838
comment on: http://stackoverflow.com/a/78367150
has text: See if you can find any official documentation and paste a link to it in the answer
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78414181
has body: A reimplementation of Ivan's solution that preserves your formatting - $: mymap=( [name]=test [age]=13 ) $: fmt='%s {\n "OptionName": "%s",\n "Value": "%s"\n }' $: for k in ${!mymap[@]}; do printf -v list "$fmt" "${list:+$list,$'\n'}" "$k" "${mymap[$k]}"; done $: printf '[\n%s\n]\n' "$list" [ { "OptionName": "age", "Value": "13" }, { "OptionName": "name", "Value": "test" } ] But I point again to Glenn's comment - it's easy for odd data to break.
answers question: http://stackoverflow.com/q/78411838
type: Answer
score: 0

http://stackoverflow.com/comment/138169601
type: Comment
has text: ok sorry, i will go to do it Thanks for all
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78348524

http://stackoverflow.com/comment/138191264
type: Comment
score: 0
has text: I don't know the difference between a newline and a DOS newline. printing these lines and reading them individually on Python seems to give the same output. Even utilities, like `meld`, say they are the same. I don't know exactly what program what program was used to create the problem-causing file. But this was created on Windows and accessed by bash source in a WSL environment.
type: QuestionComment
comment on: http://stackoverflow.com/q/78385269

http://stackoverflow.com/comment/138079613
has text: Have you considered using sudo to run not just openvpn itself but your wrapper? It's the privilege boundary that breaks process substitution; if both parts are on the same side of that boundary there's no issue.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78321765

http://stackoverflow.com/comment/138183985
type: Comment
comment on: http://stackoverflow.com/q/78381387
has text: Don't put the variable in quotes if you want it to be evaluated.
score: 3
type: QuestionComment

http://stackoverflow.com/comment/138067543
comment on: http://stackoverflow.com/q/78314716
type: QuestionComment
score: 2
type: Comment
has text: The canonical question for that problem seems to be https://stackoverflow.com/q/39527571/6770384 here on stackoverflow. If that solved your problem, we can close your question here as a duplicate.

http://stackoverflow.com/comment/138191382
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78385603
type: QuestionComment
has text: Make everything that is not red become black. Find the trim box.

http://stackoverflow.com/comment/138232178
has text: How do the images get into the docker engine before saving them? Please don't describe the solution you have created, we need the higher level problem you are solving. https://xyproblem.info/
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78405506
type: Comment

http://stackoverflow.com/comment/138172415
score: 0
comment on: http://stackoverflow.com/q/78374366
type: QuestionComment
has text: Can you add information about what directory you're in and what `docker compose` command you use, please?
type: Comment

http://stackoverflow.com/comment/138252763
comment on: http://stackoverflow.com/q/78419985
type: Comment
has text: please update the question with the output from the `curl -s "$ics_url"` call; also update the question to show the expected result; if the `curl` output contains 'too many' entries then remove all but a couple entries (one that matches your requirement, one that does not match your requirement)
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138294004
comment on: http://stackoverflow.com/a/78438177
has text: For me the command returns an error in bash and zsh on my Mac. `magick identify -format "%f: %m\n" *.{jp*,png,webp}(N) bash: syntax error near unexpected token \`('`
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138289831
has text: Try to replace `input_file="$input/"$series_name - S${season_no}E${i}.mkv""` with `input_file="$input/$series_name - S${season_no}E${i}.mkv"`. Same for the output.
comment on: http://stackoverflow.com/q/78440831
score: 4
type: QuestionComment
type: Comment

anaconda
type: Tag
tags question: http://stackoverflow.com/q/78387338
tag name: anaconda

http://stackoverflow.com/comment/138201681
type: Comment
type: AnswerComment
score: 0
has text: Many thanks for your help. My problem is there are many concurrents traps and server freezes, with these method I think I don't have any problem. Maybe the script that I need to execute with every trap will do slow the script results because it should go one by one. But best that that system freeze.
comment on: http://stackoverflow.com/a/78390328

http://stackoverflow.com/comment/138295124
score: 1
comment on: http://stackoverflow.com/q/78444070
type: QuestionComment
type: Comment
has text: What does `type disconnect` say?

http://stackoverflow.com/a/78440546
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78440219
has body: == file: chk.awk == @load "filefuncs" { #// input: file=xxx.csv #// check if $file defined if (file=="") { printf ("Please use `-v file=xxx.csv` to define a csv file\n"); exit 2; } #// check if inout file exist ret=stat(file,fdata) if (ret<0) { printf ("File '%s' seems not exist !?\n", file); exit 3; } printf ("* NR=%d\n", NR); printf ("1st file:'%s'\n", $0); #// Read from 2nd file ret = getline sec < file if (ret) printf ("2nd file:'%s'\n", sec); else printf ("2nd file already EOF\n"); #//? Terminated ? } END { #// 1st file END, but how about 2nd? if (ret) { printf ("2nd left: --\n"); while (ret) { ret = getline sec < file if (ret) printf ("2nd: '%s'\n", sec ); } } } undre commandline: $ gawk -k -v file=2.csv -f chk.awk 1.csv * NR=1 1st file:'Account,Entity,Data' 2nd file:'Account,Entity,Data' * NR=2 1st file:'A1101,E101,1000' 2nd file:'A1101,E101,2000' 2nd left: -- 2nd: 'A1101,E102,2000' 2nd: 'A1101,E102,2000' 2nd: 'A1101,E102,2000' 2nd: 'A1101,E102,2000' or $ gawk -k -v file=1.csv -f chk.awk 2.csv * NR=1 1st file:'Account,Entity,Data' 2nd file:'Account,Entity,Data' * NR=2 1st file:'A1101,E101,2000' 2nd file:'A1101,E101,1000' * NR=3 1st file:'A1101,E102,2000' 2nd file already EOF * NR=4 1st file:'A1101,E102,2000' 2nd file already EOF * NR=5 1st file:'A1101,E102,2000' 2nd file already EOF * NR=6 1st file:'A1101,E102,2000' 2nd file already EOF You can compare the different between these 2 files by yourself now

authentication
tags question: http://stackoverflow.com/q/78384843
tag name: authentication
type: Tag

sqlplus
type: Tag
tags question: http://stackoverflow.com/q/78328611
tag name: sqlplus

http://stackoverflow.com/comment/138199666
has text: Try named pipes (`mkfifo`).
score: 2
comment on: http://stackoverflow.com/q/78390318
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138192862
score: 0
type: QuestionComment
has text: if you explicitly want an `awk` solution then you should *a)* add the `awk` tag, *b)* state you want an `awk` solution and *c)* update the question with your own `awk` attempt (along with a description of how it does not do what you want)
type: Comment
comment on: http://stackoverflow.com/q/78386230

http://stackoverflow.com/comment/138068037
score: 0
type: QuestionComment
has text: yeah, or create a git command of your own in a different path which takes precedence
comment on: http://stackoverflow.com/q/78308913
type: Comment

http://stackoverflow.com/comment/138297581
has text: "Unfortunately, it still doesn't work; see my next answer please." - **This is not how the site works**. The purpose of a question here is to **ask a question, not** to get your code working. It's your responsibility before posting to do basic debugging work to isolate a single problem to ask about. The underlying problem here is exactly what @GordonDavisson pointed out. Anything else is a separate question.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78427584
score: 0

http://stackoverflow.com/comment/138100178
comment on: http://stackoverflow.com/q/78328611
type: QuestionComment
type: Comment
score: 0
has text: if I wright ```ssh user@server sqlplus -S -L user/pwd@oracleSrv``` I still get sqlplus command not found... do I use ssh incorrectly ?

http://stackoverflow.com/comment/138155126
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78364647
has text: Use an editor that automatically adds `#!/usr/bin/env python3` to any new python file (like most allow already). Don't remove that line.
type: Comment

http://stackoverflow.com/comment/138298058
has text: One of the reasons listed to close a question on this forum is "Needs debugging details" which would apply in this case as there's no code and no [mcve], plus asking for tool suggestions rather than asking for help with your code is another of the specific reasons listed to close a question.
type: QuestionComment
score: 2
type: Comment
comment on: http://stackoverflow.com/q/78445450

posix
tags question: http://stackoverflow.com/q/78441613
type: Tag
tag name: posix
tags question: http://stackoverflow.com/q/78533122
tags question: http://stackoverflow.com/q/79500887
tags question: http://stackoverflow.com/q/79526397

image
type: Tag
tag name: image
tags question: http://stackoverflow.com/q/78363909

apache
tag name: apache
tags question: http://stackoverflow.com/q/78444401
type: Tag
tags question: http://stackoverflow.com/q/79070045
tags question: http://stackoverflow.com/q/79542463

http://stackoverflow.com/comment/138219147
has text: @CharlesDuffy Thanks! Indeed, I don't. I've changed my code and will edit the answer.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78390608

http://stackoverflow.com/comment/138285657
score: 2
type: Comment
has text: sure, but nothing OP is (currently) doing addresses that issue so I'll leave that up to OP to decide how to proceed; assuming OP is only dealing with ipv4 then I'd expect them to figure out that tcp6 can be ignored (or realize the `awk` script is efectively ignoring tcp6 anyway)
type: AnswerComment
comment on: http://stackoverflow.com/a/78438409

http://stackoverflow.com/comment/138237221
has text: @Fattie simple is best?
score: 0
comment on: http://stackoverflow.com/q/78411166
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138272231
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78431133
type: Comment
has text: Add your cronjob to your question.

http://stackoverflow.com/comment/138152829
has text: Never use an alias that tries to execute commands in its definition. That way lies madness.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78363374
type: QuestionComment

http://stackoverflow.com/comment/138252279
score: 0
has text: What problem are you trying to solve here?
comment on: http://stackoverflow.com/q/78419971
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138150021
comment on: http://stackoverflow.com/q/78361451
type: QuestionComment
score: 0
type: Comment
has text: what is output of `type env` ?

http://stackoverflow.com/comment/138192177
score: 2
comment on: http://stackoverflow.com/q/78385809
has text: It has no benefits and several downsides compared to the equivalent function.
type: QuestionComment
type: Comment

pwd
tag name: pwd
type: Tag
tags question: http://stackoverflow.com/q/78336169

http://stackoverflow.com/comment/138058883
type: QuestionComment
has text: What an odd close-vote. If it were clear that the answer to this question is "you need to wrap 'git' in a function and that calls it within as a command", this detail would have surely appeared in the title or content of the question.
comment on: http://stackoverflow.com/q/78308913
type: Comment
score: 0

http://stackoverflow.com/comment/138286132
type: Comment
type: AnswerComment
has text: @F.Hauri-GiveUpGitHub I'm just using the information the OP provided for us to test with, if they provided the wrong information then please let them know about it so they can fix the sample input/output in their question.
comment on: http://stackoverflow.com/a/78438419
score: 2

http://stackoverflow.com/comment/138300676
type: Comment
comment on: http://stackoverflow.com/q/78444561
score: 1
type: QuestionComment
has text: Anyways, it should be easy to exclude PowerShell from the issue by trying the command from a different terminal/console: `plink.exe -pw password account@server "rm file_path"`. If it concerns a variable path, I suspect a special character in the path as e.g. a space ... or an ampersand (`&`)

http://stackoverflow.com/comment/138250506
score: 0
comment on: http://stackoverflow.com/q/78417099
type: QuestionComment
has text: Rather than the content of `word` disappearing from the output file, it seems more likely to me that the file `word` has DOS line endings and so when you `cat` it after the `ssh` all you **see** is `abc` because the CRs from `word` are overwriting the content of `word` in the display. See [why-does-my-tool-output-overwrite-itself-and-how-do-i-fix-it](https://stackoverflow.com/questions/45772525/why-does-my-tool-output-overwrite-itself-and-how-do-i-fix-it) for more information on that. Not quoting `$w` isn't helping any, see https://mywiki.wooledge.org/Quotes.
type: Comment

http://stackoverflow.com/comment/138134595
score: 0
type: QuestionComment
has text: @Barmar I can delete this post if you want. I sympathize with your position, however I think that shell scripting really blurs the line between using utilities and programming. IMO, practically speaking, this is very relevant to shell scripting as you would almost certainly use this in a script, as I was. Furthermore I am composing commands together which is inherently within the domain of scripting
comment on: http://stackoverflow.com/q/78349529
type: Comment

http://stackoverflow.com/comment/138256062
has text: I gave you a link to a question that answers how to fix the loop. But be aware that many Unix text utilities expect all lines to end with newline. The POSIX specification says that this is required for valid text files. So it's best to fix the file rather than the script (although there's no reason not to do both for robustness).
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78422072

http://stackoverflow.com/comment/138265402
score: 0
has text: My code still looks broken. Not sure where it’s wrong
comment on: http://stackoverflow.com/q/78422019
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138458189
score: 0
comment on: http://stackoverflow.com/q/78399997
has text: Thank you! This is exactly what I’m looking for! But it will show filenames with Chinese characters too. Can you help change the command a bit so it won’t include Chinese characters?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138192150
score: 0
type: QuestionComment
has text: Use public key authentication rather than passwords, then you won't have to authenticate manually.
comment on: http://stackoverflow.com/q/78384843
type: Comment

http://stackoverflow.com/comment/138268321
score: 1
comment on: http://stackoverflow.com/a/78419699
has text: `}` isn't special, except in command position. With `{ cmdA && cmdB }`, `}` is just another argument to `cmdB`, and the command group started with `{` remains incomplete. The `;` terminates the `cmdB` command, so that `}` *is* in command position, and so interpreted as the end of the current command group.
type: Comment
type: AnswerComment

java-11
tag name: java-11
tags question: http://stackoverflow.com/q/78398495
type: Tag

http://stackoverflow.com/comment/138463889
has text: @RAREKpopManifesto Ah yes, okay. The original Algorithm L has a `k` parameter which we set to 1, since we are only getting one random item. The original formula is `exp(log(random())/k)`. So indeed, since k is 1, we can simplify that.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78355289

http://stackoverflow.com/comment/138139941
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78356050
type: Comment
has text: The regexp needs to match the `,` after the number. Change `\([^,]*\)` to `\(,[^,]*\)`

matillion
tags question: http://stackoverflow.com/q/78409095
type: Tag
tag name: matillion

http://stackoverflow.com/comment/138073349
score: 0
comment on: http://stackoverflow.com/q/78317514
type: QuestionComment
has text: [Why can't I use job control in a bash script?](https://stackoverflow.com/questions/690266/why-cant-i-use-job-control-in-a-bash-script) might be useful background for understanding what I was saying earlier.
type: Comment

http://stackoverflow.com/comment/138101361
comment on: http://stackoverflow.com/q/78334264
type: QuestionComment
score: 2
type: Comment
has text: I cannot repro this. Perhaps you have `alias echo='echo -e'` or some such; but this behavior is not reproducible out of the box. Tested with 3.2.57(1)-release from MacOS Sonoma and 5.2.26(1)-release from Homebrew.

http://stackoverflow.com/comment/138202394
type: QuestionComment
type: Comment
score: 0
has text: My guess is one of the command typed in terminal reset the PATH environment variable. PATH is usually set to a list of folders where binaries/commands are found. Without this variable properly set, you get the kind of errors message you mention. I am more familiar with Linux than MacOS, thus I'll suggest to consult pages like https://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/
comment on: http://stackoverflow.com/q/78388693

http://stackoverflow.com/comment/138191324
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78380299
score: 0
has text: @Fonic I wrote my answer based on my previous knowledge about how the pipelines work. I didn't know about `PIPESTATUS` (probably I never needed this functionality). Today I learned about it, from your comment. I updated the answer to include this information. Thank you.

http://stackoverflow.com/a/78354221
has body: You can use awk to extract records from a file using arbitrary record delimiters. You have a file that looks something like this: This is quote 1 % This is quote 2 % This is quote 3 By telling awk that % is the record separator, we can extract specific quotes. E.g.: $ for i in {1..3}; do echo === quote $i ===; awk -vRS=% -vquotenum=$i 'NR==quotenum {print}' quotes.txt; done === quote 1 === This is quote 1 === quote 2 === This is quote 2 === quote 3 === This is quote 3 The only thing we need to know is the number of quotes contained in the file. We can get that with grep -c. To extract a random quote from the file, we can combine the above to do something like this: # Get the total number of quotes numquotes=$(grep -c '^%$' quotes.txt) # Pick a random number in that range quotenum=$(((RANDOM % numquotes) + 1)) # Extract the selected quote awk -vRS=% -vquotenum=$quotenum 'NR==quotenum {print}' quotes.txt
has comment: http://stackoverflow.com/comment/138153332
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78354041
upvote count: 1
type: Answer

http://stackoverflow.com/comment/138276249
score: 1
comment on: http://stackoverflow.com/q/78433528
type: QuestionComment
has text: Variables inside single quotes don't expand. See https://stackoverflow.com/questions/13799789/expansion-of-variables-inside-single-quotes-in-a-command-in-bash
type: Comment

replace
tags question: http://stackoverflow.com/q/78441613
type: Tag
tag name: replace
tags question: http://stackoverflow.com/q/78592814
tags question: http://stackoverflow.com/q/78917700
tags question: http://stackoverflow.com/q/79160173
tags question: http://stackoverflow.com/q/79531693

autocomplete
tag name: autocomplete
tags question: http://stackoverflow.com/q/78330326
type: Tag
tags question: http://stackoverflow.com/q/78875294
tags question: http://stackoverflow.com/q/78898168
tags question: http://stackoverflow.com/q/78875305
tags question: http://stackoverflow.com/q/78846718
tags question: http://stackoverflow.com/q/78946361
tags question: http://stackoverflow.com/q/79363107
tags question: http://stackoverflow.com/q/79409439

http://stackoverflow.com/comment/138251307
has text: In addition to quoting `*` on the command line, you will need to (double-)quote the expansions of the corresponding parameter. In fact, you should pretty much *always* quote expansions of any variables containing data provided by the user.
comment on: http://stackoverflow.com/q/78419450
type: QuestionComment
score: 0
type: Comment

audio
tags question: http://stackoverflow.com/q/78324080
tag name: audio
type: Tag

http://stackoverflow.com/comment/138089642
type: QuestionComment
comment on: http://stackoverflow.com/q/78327616
has text: Bash doesn't support floating point numbers. Use an external tool like `bc`.
type: Comment
score: 0

image-processing
type: Tag
tags question: http://stackoverflow.com/q/78385603
tags question: http://stackoverflow.com/q/78437863
tag name: image-processing
tags question: http://stackoverflow.com/q/78689971

http://stackoverflow.com/comment/138175800
has text: @triplee I added the explanation.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78376416

http://stackoverflow.com/comment/138301521
score: 1
has text: When you set the variable in a child process, how should the parent process be aware of it? An environment variable is accessible in the process, where it is set, and is by default copied to its child processes (but even this can be suppressed). You are doing it the other way round: Setting it in a script, and trying to access it in the parent process of the script.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78445411

http://stackoverflow.com/comment/138148920
comment on: http://stackoverflow.com/q/78361035
type: QuestionComment
has text: Do you want to match `presto01` and `presto-data1` but **not** `presto-data1-01` ? Or do you want a partial match in for `presto-data1` in `presto-data1-01` ?
score: 0
type: Comment

http://stackoverflow.com/comment/138129042
type: QuestionComment
has text: I have the same version on my system and it works. `Every 2.0s: echo 0\\n1\\n2\\... localhost.localdomain: Thu Apr 18 13:05:05 2024 0\n1\n2\n3\n4\n5\n6\n7\n8\n9 `
comment on: http://stackoverflow.com/q/78349529
type: Comment
score: 0

http://stackoverflow.com/comment/138240811
type: Comment
has text: Now @pmf if i want to add a third attributes with below option `jq -n ' $ARGS.positional | [_nwise(length/2)] | transpose | map({OptionName: first, Value: last}) ' --args "${!mymap[@]}" "${mymap[@]}" > option.json` how do I do the mapping part , i am new to jq, so not sure how to make ` map({OptionName: first, Value: last})` to ` map({NewAttribute: first, OptionName: second???, Value: last})` the NewAttribute is not part of the `mymap` instead it is just a static value
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78411906

http://stackoverflow.com/comment/138100192
has text: Uh, what? That would only proceed if the command failed.
comment on: http://stackoverflow.com/a/78333360
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138200031
comment on: http://stackoverflow.com/q/78390223
type: QuestionComment
has text: something like `set -o` ; set pipefail`?
type: Comment
score: 0

sudo
tag name: sudo
tags question: http://stackoverflow.com/q/78401442
type: Tag
tags question: http://stackoverflow.com/q/78321765
tags question: http://stackoverflow.com/q/78576313
tags question: http://stackoverflow.com/q/78474553
tags question: http://stackoverflow.com/q/78628280
tags question: http://stackoverflow.com/q/78846569
tags question: http://stackoverflow.com/q/78942549

http://stackoverflow.com/comment/138202745
score: 1
comment on: http://stackoverflow.com/q/78392006
type: QuestionComment
type: Comment
has text: Note that if your real goal is to make a string suitable to include in a JSON literal, this is not the only transform needed, and it would be much better ot use a real JSON-aware tool like jq rather than try to build a piecemeal one-off replacement.

http://stackoverflow.com/comment/138115108
comment on: http://stackoverflow.com/q/78341760
type: QuestionComment
score: 0
type: Comment
has text: Handler seems to be registered as far as I can tell `rt_sigaction(SIGINT, {sa_handler=0x563b73dcb690, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fe414fd7dd0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fe414fd7dd0}, 8) = 0`

http://stackoverflow.com/comment/138460238
has text: @Kaz : maybe I'm missing something, but doesn't `exp(log(rand()))` just cancel each other out, and it *should* output something very close to the original output from `rand()` (assuming the unlikely scenario where no precision is lost after being routed through 2 transcendental functions)
comment on: http://stackoverflow.com/a/78355289
type: Comment
score: 0
type: AnswerComment

flags
tag name: flags
type: Tag
tags question: http://stackoverflow.com/q/78390602

ros
type: Tag
tag name: ros
tags question: http://stackoverflow.com/q/78416125

http://stackoverflow.com/comment/138277011
type: Comment
score: 0
has text: Thank you very much. You have pointed me in the right direction and I have added this answer to better clarify:: https://stackoverflow.com/a/78433914/1277576
comment on: http://stackoverflow.com/a/78432970
type: AnswerComment

console
tag name: console
type: Tag
tags question: http://stackoverflow.com/q/78390318

http://stackoverflow.com/a/78454643
has comment: http://stackoverflow.com/comment/138313372
answers question: http://stackoverflow.com/q/78451797
downvote count: 0
score: 1
upvote count: 1
type: Answer
has body: It seems the entire script could be a single awk call: awk ' /Closest Day:/ && !seen[ $(NF-2) ]++ { counts[ $NF ]++ } END { for (i in counts) printf "Number %d: %d\n", i, counts[i] } ' "$1" If storing arrays of email and counts would consume too much memory, you could do: awk '/Closest Day:/ { print $(NF-2),$NF }' "$1" | sort -u -k1,1 | cut -d' ' -f2 | sort -n | uniq -c | awk '{ printf "Number %d: %d\n", $2, $1 }' (sort only keeps a limited amount of data in memory and the other commands only need to buffer a single line.)

http://stackoverflow.com/comment/138330012
has text: not a big performance issue but the `cat` is unnecessary here - `cat $dir/latest.log | sed -e ... -e ...` - since `sed` is capable of reading directly from the file; instead consider `sed -e ... -e ... "$dir/latest.log"` (also get in the habit of wrapping variable references in double quotes (run a test to see what happens if `dir` contains spaces and you don't use double quotes); in your 2nd script you have `echo $last` but if `$last` has embedded linefeeds (`\n`) then take a look at the output diff between `echo $last` and `echo "$last"`
comment on: http://stackoverflow.com/q/78461484
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78464749
possible better answer: http://stackoverflow.com/a/78465059
answer count: 4
tagged with: linux
tagged with: http://stackoverflow.com/tag/c
tagged with: bash
has answer: http://stackoverflow.com/a/78465027
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138330206
has comment: http://stackoverflow.com/comment/138330174
has title: Is it possible to use cat with execl inside a c program to print out its code without knowing the file path
has body: As a part of my asigment i have to print out the source code of my c program using the cat command which needs to be coded into the code itself.I have understood that I need to use some variation of the execl function to achieve that but what is bothering me is that to do that I need to know the path of my file which could change, so i was wondering if there is a way to find the path of the file inside the program. I tried running the pwd command to find my current path but i couldnt get it to store the result in a variable and i dont know why execl("/bin/pwd", "pwd", NULL);. Also the program is executed in linux if that helps.
has comment: http://stackoverflow.com/comment/138330100
type: Question
has comment: http://stackoverflow.com/comment/138330296
has answer: http://stackoverflow.com/a/78464908
has answer: http://stackoverflow.com/a/78465150
has comment: http://stackoverflow.com/comment/138330518
has comment: http://stackoverflow.com/comment/138330255
has answer: http://stackoverflow.com/a/78465059
score: 0
accepted answer: http://stackoverflow.com/a/78465027

http://stackoverflow.com/q/78527966
score: 0
tagged with: conda
type: Question
answer count: 0
type: UnansweredQuestion
tagged with: bash
has body: I am having some troubles with the instalations of PolSpice for two different versions, and for my conda enviroment py_cmb. I have been following the steps by https://www.zonca.dev/posts/2020-10-14-install-healpix-polspice-conda-nersc.html. Once I have installed Healpix_3.70 and cfitsio libraries, the procedure coudn't continue when I tried to run bash run.sh file. Then, the shell shows me the following message: CMake Error at CMakeLists.txt:164 (message): HEALPix library not found in /lib/* Use the cmake flags -DHEALPIX=/correct/path/to/healpix/top/directory (and -DSUFFIX=suffix) to use {HEALPIX}/lib{SUFFIX}/* and {HEALPIX}/include{SUFFIX}/* instead or -DHEALPIX_LIB=/correct/path/to/healpix/library/directory and -DHEALPIX_INCLUDE=/correct/path/to/healpix/include/directory to use {HEALPIX_LIB}/* and {HEALPIX_INCLUDE}/* For more information see the file INSTALL -- Configuring incomplete, errors occurred! I have followed the message's instructions, but the problem continues. How should I solve this problem? I was trying to unistall and re-install healpix and corroborating that the message's libraries are well instaled. I have also been trying to carry out the manual procedure with make. I don't really what are the problems with installation. Thank you.
has title: Why does PolSpice show this message during instalation procedure?
tagged with: libraries
tagged with: include
tagged with: python

http://stackoverflow.com/q/78506946
has answer: http://stackoverflow.com/a/78512759
tagged with: docker
has comment: http://stackoverflow.com/comment/138413849
has title: Docker ENTRYPOINT script not receiving SIGTERM
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138404486
answer count: 1
tagged with: dockerfile
score: 0
type: Question
has body: I am trying to make a container that saves data to a folder on the container linking to the host os on exit. However, it doesn’t trigger the trapped command. This is the ENTRYPOINT format of the Dockerfile: ENTRYPOINT ["/bin/bash","start.sh"] And this is start.sh: trap 'echo "replace with command that saves data"' SIGTERM java -jar program.jar However, it doesn't catch the signal at all. Keep in mind I am trying to let start.sh receive the signal and save data, not the program.

http://stackoverflow.com/q/78524211
has answer: http://stackoverflow.com/a/78524329
tagged with: awk
answer count: 3
has comment: http://stackoverflow.com/comment/138434243
score: 0
has answer: http://stackoverflow.com/a/78524750
has title: File header is not being processed by awk in bash loop
has comment: http://stackoverflow.com/comment/138434240
has body: I have a csv file with header, that is expected to have 14 fields. My gawk script checks the file and writes good and bad lines to 2 separate files. However, the header line is not output to either file. It's the only missing line. while read -r line; do gawk -k '{if (NF==14) print $0 > "good_file.csv"; \ else print "["NR"]", "["NF"]", $0 > "bad_file.csv"}'; done < hd.csv csv input file sample: hd.csv test_id,vehicle_id,test_date,test_class_id,test_type,test_result,test_mileage,postcode_area,make,model,colour,fuel_type,cylinder_capacity,first_use_date 1645480751,1374211238,2016-01-01,4,NT,P,117033,SM,VOLKSWAGEN,POLO,BLACK,PE,1600,2000-06-23 1393462389,1153769898,2016-01-01,4,NT,P,99292,NE,VOLKSWAGEN,PASSAT,BLUE,DI,1968,2006-11-30 1863202023,1485039300,2016-01-01,7,NT,PRS,170320,E,MERCEDES,SPRINTER 313 CDI LWB,WHITE,DI,2148,2005-01-14 1304292863,1097073904,2016-01-01,4,RT,P,70623,NN,MINI,MINI,GREY,PE,1598,2004-04-08 845810407,1166548800,2016-01-01,4,NT,P,21567,DL,NISSAN,JUKE,BLUE,PE,1612,2011-07-07 I can see that the header row has 14 fields. gawk -k '{print NF, $0}' hd.csv 14 test_id,vehicle_id,test_date,test_class_id,test_type,test_result,test_mileage,postcode_area,make,model,colour,fuel_type,cylinder_capacity,first_use_date 14 1645480751,1374211238,2016-01-01,4,NT,P,117033,SM,VOLKSWAGEN,POLO,BLACK,PE,1600,2000-06-23 I don't understand why the header row is getting skipped.
upvote count: 1
linked to: http://stackoverflow.com/q/45420535
favorite count: 0
tagged with: http://stackoverflow.com/tag/csv
has comment: http://stackoverflow.com/comment/138434302
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138434357
has answer: http://stackoverflow.com/a/78524735
downvote count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138435156

http://stackoverflow.com/comment/138537488
has text: You didn't show the value of your variables. Aside from this, your first example (with the double quotes) looks most promising. _no one works_ is a pretty meaningless error description. It would be very rare, that `psql` simply refuses to do anything, but would not produce at least an error message.
comment on: http://stackoverflow.com/q/78580571
type: QuestionComment
score: 1
type: Comment

http://stackoverflow.com/comment/138547395
score: 0
comment on: http://stackoverflow.com/q/78572680
type: QuestionComment
has text: I ended up going with `direnv`. Thank you!
type: Comment

http://stackoverflow.com/q/78479842
has comment: http://stackoverflow.com/comment/138358202
has comment: http://stackoverflow.com/comment/138472842
score: -1
has comment: http://stackoverflow.com/comment/138475778
has comment: http://stackoverflow.com/comment/138366292
linked to: http://stackoverflow.com/q/10067266
has comment: http://stackoverflow.com/comment/138359510
tagged with: loops
tagged with: bash
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138362141
has comment: http://stackoverflow.com/comment/138472766
has answer: http://stackoverflow.com/a/78545843
has comment: http://stackoverflow.com/comment/138375867
has comment: http://stackoverflow.com/comment/138475780
has title: how to store/append multiple dates in Bash
has comment: http://stackoverflow.com/comment/138419391
accepted answer: http://stackoverflow.com/a/78545843
has body: How can I store values and concatenate them to one variable? all_dt (final variable) should take this into account that it is possible that output of both variables in A or output from B or both A, and B may not have any date values but A) start_dt_inc and end_dt variables store two date values: start_dt_incr=$(psql -q -A -t -c "select cast(coalesce(max(date_key),'1900-01-01')+ interval '1 day' as varchar (10)) from target table;" -d ${database_name}) end_dt=$(psql -q -A -t -c "select process_dt from process_table;" -d ${database_name}) For this example, assume stored values are: start_dt_incr='2024-05-02' end_dt='2024-05-03' B) Can I store the output of this sql in variable "start_end_dt_hist" like below (please see attempt#1)? SELECT concat(cast(MIN(g.dt)::date as CHAR(10)), '|',cast(MAX(g.dt)::date as CHAR(10))) FROM generate_series(date '2019-06-25', '2024-01-15', '1 day') g(dt) GROUP BY EXTRACT(YEAR FROM g.dt) ORDER BY MIN(g.dt)::date; Result: 2019-06-25|2019-12-31 2020-01-01|2020-12-31 2021-01-01|2021-12-31 2022-01-01|2022-12-31 2023-01-01|2023-12-31 2024-01-01|2024-01-15 Attemtp#1: store historical dates in variable: start_end_dt_hist=$(psql -q -A -t -c "SELECT concat(cast(MIN(g.dt)::date as CHAR(10)), '|',cast(MAX(g.dt)::date as CHAR(10))) FROM generate_series(date '2019-06-25', '2024-01-15', '1 day') g(dt) GROUP BY EXTRACT(YEAR FROM g.dt) ORDER BY MIN(g.dt)::date;" -d ${database_name}) C) How can I concatenate values from A, and B (start_dt_incr, end_dt and start_end_dt_hist) as following, assuming variable to hold all of this will be called "all_dt". all_dt= 2024-05-02|2024-05-03 2019-06-25|2019-12-31 2020-01-01|2020-12-31 2021-01-01|2021-12-31 2022-01-01|2022-12-31 2023-01-01|2023-12-31 2024-01-01|2024-01-15
downvote count: 2
type: Question
has comment: http://stackoverflow.com/comment/138435864
linked to: http://stackoverflow.com/q/29378566
has comment: http://stackoverflow.com/comment/138472641

http://stackoverflow.com/comment/138380603
comment on: http://stackoverflow.com/q/78490432
has text: when running external datasource, my shell script fails while execution, Updated description
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138552080
comment on: http://stackoverflow.com/q/78588816
type: QuestionComment
type: Comment
score: 0
has text: @AlanP., btw, if you use `IFS=, read` _all on the same command_ (as compared to `IFS=,; read` making the assignment and the `read` two separate commands), the assignment will be scoped to the `read` command and not apply to anything subsequent. (Obviously, there are still valid reasons to sometimes need to use `IFS=,` on its own; but if you were just setting it for `read`'s benefit, one can scope it to that single operation and not need to explicitly reset later).

http://stackoverflow.com/q/78451035
type: AnsweredQuestion
tagged with: wget
score: 2
has comment: http://stackoverflow.com/comment/138307592
has body: I'm trying to download a bash script using wget and pipe it over to sh but I'm running into problems. It works fine in separate steps (wget to download, then execute), but not when piping to sh. The script can be found in this gist, but I'll include it at the bottom of this question for convenience. I'm running the following to: download the script pipe it to sh pass in a parameter of linux wget -q --no-cache https://gist.githubusercontent.com/devklick/be9cbe0b384958a7e7ce115f7df25e5a/raw/27153ef3109e7561e45f0fe43e9a10276da78252/install.sh -O - | sh -s linux When I run the above, the script fails trying to parse some JSON returned from Githubs REST API. We can see that the last few lines logged look like this: GDMan/zipball/v1.3.1", "body": "## [1.3.1](https://github.com/devklick/GDMan/compare/v1.3.0...v1.3.1) (2024-05-07) ### Bug Fixes * fixes [#15](https://github.com/devklick/GDMan/issues/15), --help is not a known command ([ddd78f2](https://github.com/devklick/GDMan/commit/ddd78f2a92da239bab9a08658b732d1460b19dc3)) " } parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 150, column 1 Found download '' I'm guessing that the line breaks shown here are the problem. However this problem does not exist when using wget to download and save the file, then execute it: wget -q --no-cache https://gist.githubusercontent.com/devklick/be9cbe0b384958a7e7ce115f7df25e5a/raw/27153ef3109e7561e45f0fe43e9a10276da78252/install.sh chmod +x ./install.sh ./install.sh linux Running these steps separately we can see that the last few lines output looks a little different: GDMan/zipball/v1.3.1", "body": "## [1.3.1](https://github.com/devklick/GDMan/compare/v1.3.0...v1.3.1) (2024-05-07)\n\n\n### Bug Fixes\n\n* fixes [#15](https://github.com/devklick/GDMan/issues/15), --help is not a known command ([ddd78f2](https://github.com/devklick/GDMan/commit/ddd78f2a92da239bab9a08658b732d1460b19dc3))\n\n\n\n" } Found download 'https://github.com/devklick/…
type: Question
tagged with: shell
tagged with: pipe
has title: Pipe wget into sh - issue with line breaks
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/78451108
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138307512
tagged with: bash
has comment: http://stackoverflow.com/comment/138307526
has answer: http://stackoverflow.com/a/78451108

nextflow
type: Tag
tags question: http://stackoverflow.com/q/78450649
tag name: nextflow
tags question: http://stackoverflow.com/q/78786031
tags question: http://stackoverflow.com/q/79392835

http://stackoverflow.com/comment/138436737
comment on: http://stackoverflow.com/q/78525458
type: Comment
has text: I'm sorry if I mislead you, but now you know the nature of the problem. I don't entirely understand how my question translates to the two questions you mentioned.
score: 0
type: QuestionComment

http://stackoverflow.com/q/78481642
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138366227
tagged with: docker
score: 0
type: Question
has title: How to import many fsLayers into docker as one image
answer count: 1
has comment: http://stackoverflow.com/comment/138362954
accepted answer: http://stackoverflow.com/a/78501138
has body: I have downloaded several fsLayers images for a given docker image. How can I import them as a single image in docker? Consider the following commands, which will download all of the fsLayers for the nextcloud image from Docker Hub curl -so "token.json" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/nextcloud:pull"; token=$(cat token.json | jq -jr ".token") curl -o manifest.json -#H "Authorization: Bearer ${token}" https://registry-1.docker.io/v2/library/nextcloud/manifests/stable fsLayers=$(cat manifest.json | jq -r ".fsLayers[].blobSum") for layer in $fsLayers; do echo $layer; file="$(echo "${layer}" | cut -d: -f2).tar.gz" curl -o "${file}" -#LH "Authorization: Bearer ${token}" https://registry-1.docker.io/v2/library/nextcloud/blobs/${layer} done After executing the above commands, I now have all the layers downloaded in separate gz-compressed tarballs. user@disp7148:~$ ls 09f376ebb190216b0459f470e71bec7b5dfa611d66bf008492b40dcc5f1d8eae.tar.gz 1693466e4cc6edc54994f2c9c9e1989f28b0df6243b3c709876e36a999aac7ee.tar.gz 29e89bc69515a29ca19a9f9d5159e84862484ce94772369f8eb8ea55471b22ae.tar.gz 35129b4567fb01bf2ed62b98beeb738072c263291f0efaf238c50af3dcbb5ee3.tar.gz 43af3fe8136ad9261342f5add4a18489a3ffc70ba50f2651ea7cc1b3d0e45875.tar.gz 501c476418a820ad744262168cc1942997c004938bca4411e76c9fd2423f78b6.tar.gz 57c8d94a4882fa141e8c25a4a5ea1f1188629cc772674bdc7dcd69c13a07bd25.tar.gz 5b819af798e29a5411463ff791375a52cc270c442dec56cb1fae2365a3033d56.tar.gz 76afcdc8655129b4b8245d674820f06020b8a54f3db6c8d9147234b985f3c923.tar.gz 8d0c9118b5f56bd64e1ff9a579351c1c0cdc78cd5480b421affe8ef4df774970.tar.gz 9ec84be954b08b2782f93426799a585ad7b33b0e7d57b3f725218d450ea5d20d.tar.gz a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.tar.gz a4ba0bdbbf0a7e73b6acc7dcd82c8dbc4635884963f73bbebcbac1a2f988cf99.tar.gz b760377fd0ccbf30765bec3415200ae24b35c6da60725aa6dd49a74b737af10b.tar.gz bdad2781572257d109331576ace9e6292ca5bab9a8d069e9f59bf185db3c1b29.tar.…
tagged with: bash
has answer: http://stackoverflow.com/a/78501138

http://stackoverflow.com/comment/138373561
comment on: http://stackoverflow.com/a/78465027
score: 0
has text: @CharlesDuffy you are correct with your observation. I corrected it in my program so that it would get the name of the file name on its own.
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78518786
downvote count: 1
has body: Funds There is this app that has been outdated for quite some time and unsupporeted: https://github.com/pdf2htmlEX/pdf2htmlEX The last release was in July 2020. But since then there has been a poppler and fontforge update, which some people in the repo have updated (just no new release...) So I thought I would make a custom image for my own project with a Dockerfile. I read about the problems with building and went through the fixed steppes one by one. Dockerfile FROM ubuntu:latest RUN apt-get update &amp;&amp; apt-get -y install \ bash \ git-all WORKDIR /tmp RUN git clone https://github.com/pdf2htmlEX/pdf2htmlEX WORKDIR /tmp/pdf2htmlEX ENV DEBIAN_FRONTEND=noninteractive # These 9 steps equal with the ./buildScripts/buildInstallLocallyApt (I tried that one too) RUN ./buildScripts/versionEnvs RUN ./buildScripts/reportEnvs RUN ./buildScripts/getBuildToolsApt RUN ./buildScripts/getDevLibrariesApt RUN ./buildScripts/getPoppler RUN ./buildScripts/buildPoppler RUN ./buildScripts/getFontforge RUN ./buildScripts/buildFontforge RUN ./buildScripts/buildPdf2htmlEX Problem All steps run well, except the buildPdf2htmlEx. [ 22%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/HTMLRenderer/outline.cc.o [ 25%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/HTMLRenderer/state.cc.o [ 28%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/HTMLRenderer/text.cc.o [ 31%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/BackgroundRenderer/BackgroundRenderer.cc.o [ 34%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/BackgroundRenderer/SplashBackgroundRenderer.cc.o [ 37%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/BackgroundRenderer/CairoBackgroundRenderer.cc.o [ 40%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/util/const.cc.o [ 42%] Building CXX object CMakeFiles/pdf2htmlEX.dir/src/util/encoding.cc.o [ 45%] Building C object CMakeFiles/pdf2htmlEX.dir/src/util/ffw.c.o In file included from /tmp/pdf2htmlEX/pdf2htmlEX/../fontforge/fontforge/baseviews.h:31, from /tmp/pdf2…
score: -1
has comment: http://stackoverflow.com/comment/138425437
tagged with: bash
has comment: http://stackoverflow.com/comment/138424915
accepted answer: http://stackoverflow.com/a/78519493
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138425324
tagged with: dockerfile
tagged with: docker
type: Question
has comment: http://stackoverflow.com/comment/138424951
has answer: http://stackoverflow.com/a/78519493
tagged with: ubuntu
upvote count: 0
has comment: http://stackoverflow.com/comment/138424971
has comment: http://stackoverflow.com/comment/138424964
answer count: 1
favorite count: 0
has title: pdf2htmlEX custom docker image - building problems with fatal error
tagged with: pdf2htmlex

http://stackoverflow.com/comment/138313030
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78451797
has text: what if a file contains multiple values for an email? eg. `... email0987@yahoo.com is: 1` and also `... email0987@yahoo.com is: 2` ?
type: QuestionComment

http://stackoverflow.com/comment/138436637
has text: Any reason why you can't `( eval "cmd" )` instead?
comment on: http://stackoverflow.com/q/78525458
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78485715
has comment: http://stackoverflow.com/comment/138371318
has title: Use script output with quotes as commandline arguments
has comment: http://stackoverflow.com/comment/138367535
has comment: http://stackoverflow.com/comment/138367497
upvote count: 1
duplicate of: http://stackoverflow.com/q/15691942
has comment: http://stackoverflow.com/comment/138367483
has comment: http://stackoverflow.com/comment/138367854
has answer: http://stackoverflow.com/a/78485788
duplicate of: http://stackoverflow.com/q/3811345
has body: I want to write a script that generates commandline arguments for another program. Until know I have written a script that simply echo the arguments and use it in the following way: external_program $(generate arguments) This stops working as soon as the generated arguments require quotes. To be clear what I mean: The resulting function call should be equivalent to external_program "First argument with spaces" "Second argument with spaces" How can I write and call a script to achieve such behavior? EDIT: The things that I cam change is the exact commandline to connect the output of generate with the input of external_program (which should be short because that is something that I will have to type in) and the generate script which can be as complex as required to do the job. EDIT: The duplicates does not match my problem because I already know how to pass all input arguments to another script and I know how to print variables, but my question is how I can get the output of one program copied over to the input of another program, so that quotes string stay as one input argument of the second program. EDIT2: "input of another program" was bad phrasing. What I actually mean was commandline arguments of another program.
duplicate of: http://stackoverflow.com/q/255898
accepted answer: http://stackoverflow.com/a/78485788
linked to: http://stackoverflow.com/q/255898
has comment: http://stackoverflow.com/comment/138371169
downvote count: 0
has comment: http://stackoverflow.com/comment/138371118
score: 1
has comment: http://stackoverflow.com/comment/138367469
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138371354
type: AnsweredQuestion
duplicate of: http://stackoverflow.com/q/4651437
has comment: http://stackoverflow.com/comment/138371233
has comment: http://stackoverflow.com/comment/138371391
has comment: http://stackoverflow.com/comment/138371408
tagged with: bash
has comment: http://stackoverflow.com/comment/138371553
type: Question
has comment: http://stackoverflow.com/comment/138371464
has comment: http://stackoverflow.com/comment/138371179

http://stackoverflow.com/q/78454731
has title: XPath not working when value has equal operator using virt-xml
score: 0
type: Question
has answer: http://stackoverflow.com/a/78528931
has comment: http://stackoverflow.com/comment/138313435
type: UnansweredQuestion
tagged with: bash
has body: I'm running command: cat ./xml | virt-xml --edit --xml ./tag1/tag2="a=b" > output.xml it should add text a=b in tag2 but it is creating <tag2=a>b</tag2=a> which is incorrect. I tried to escape equal character as well but no success. How can I achieve this ? the command I mentioned above should add text a=b in tag2 but it is creating <tag2=a>b</tag2=a> which is incorrect. I tried to escape equal character as well but no success.
answer count: 1
tagged with: virsh
has comment: http://stackoverflow.com/comment/138440125
tagged with: libvirt
tagged with: debian
has comment: http://stackoverflow.com/comment/138313518
tagged with: xml-parsing

http://stackoverflow.com/comment/138394468
type: Comment
score: 0
type: AnswerComment
has text: @tuqueque, ... The other thing to keep in mind about pipes is that each piece of a pipeline runs in a separate process from the other pieces, so if you set a variable in a pipeline component it's usually (subject to some exceptions that aren't important here) discarded after the pipeline exits. That's only relevant if you use pipes in places they aren't appropriate, so just be careful not to do that; **only** use pipes to connect the stdout of one process to the stdin of another.
comment on: http://stackoverflow.com/a/78501116

http://stackoverflow.com/a/78451344
has body: From the Bash Manual description of -c: If there are arguments after the command_string, the first argument is assigned to $0 and any remaining arguments are assigned to the positional parameters. So $1 is set to /home/usr/rob/abc.sh and $2 is set to ARG1, and $@ contains both of those.
answers question: http://stackoverflow.com/q/78451308
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/138308503
has comment: http://stackoverflow.com/comment/138308349

http://stackoverflow.com/q/78506003
has comment: http://stackoverflow.com/comment/138402670
tagged with: nohup
has comment: http://stackoverflow.com/comment/138411727
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78507913
upvote count: 1
has comment: http://stackoverflow.com/comment/138403536
tagged with: auto-update
has comment: http://stackoverflow.com/comment/138405060
has comment: http://stackoverflow.com/comment/138402795
has comment: http://stackoverflow.com/comment/138402650
linked to: http://stackoverflow.com/q/77937092
has comment: http://stackoverflow.com/comment/138411780
has comment: http://stackoverflow.com/comment/138402652
has comment: http://stackoverflow.com/comment/138402478
tagged with: bash
tagged with: java
linked to: http://stackoverflow.com/q/78281758
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138402612
downvote count: 1
has body: I have a java application which is running as background service on a ubuntu system. The application is running under root account and is started/stopped via systemctl. The application has an auto-update feature. To run the update the application starts a runupdate.sh script. public void installUpdate() { final List<String> cmd = List.of("sh",script.getAbsolutePath()); final Process process = new ProcessBuilder(cmd) .directory(script.getParentFile()) .inheritIO() .start(); } Then runupdate.sh calls dpkg with nohup runupdate.sh #!/bin/sh BASEDIR=$(dirname "$0") chmod -R +x $BASEDIR/myapplication_3.23.99_amd64.deb nohup dpkg -i $BASEDIR/myapplication_3.23.99_amd64.deb >update.log 2>&1 & But it looks like the update process is interrupted when the service is stopped. This is the content of update.log. (unfortunately my system is in german) (Lese Datenbank ... 275752 Dateien und Verzeichnisse sind derzeit installiert.) Vorbereitung zum Entpacken von .../myapplication_3.23.99_amd64.deb ... Removed /etc/systemd/system/multi-user.target.wants/myapplication.service. The package remains in this state: Status: install reinstreq half-configured When I start runupdate.sh from the terminal directy, everything works fine. Has anyone an explanation for this behaviour or an idea how to prevent interruption of the update process?
has comment: http://stackoverflow.com/comment/138421913
tagged with: sh
has comment: http://stackoverflow.com/comment/138402545
has title: nohup has no effect when called from background service?
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138411474
has comment: http://stackoverflow.com/comment/138402506

http://stackoverflow.com/q/78448804
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138303400
has comment: http://stackoverflow.com/comment/138303381
tagged with: bash
type: Question
has body: This is my first time posting anything here, so if I forget something or you need more info to answer my question, please let me know. So I am trying to make a small bash script, that echoes all files in a folder into an array using a for-loop. The snippet looks like this: romList=(*) for line in * do romList+="($(echo "$line\n"))" done Then when I try to echo out each value with this code: for entry in "${romList[@]}" do echo $entry done I get a result that looks like this: $ file1 file2 file3 file2 file3 So for the first iteration it puts all of the files found into the first value and then continues as expected for the subsequent iterations. For context I am trying to cleanup my roms folders, by removing language descriptions in the individual filenames. So my plan was to echo the filename into an array as a string, check up against an array of patterns and then remove that pattern from the string, so I can use it as a new filename. That also means that the filenames have spaces and parenthesis in them, but I don't understand if that should affect only the first iteration. If you have another (read better) solution for achieving that, also please let me know.
has answer: http://stackoverflow.com/a/78448885
has comment: http://stackoverflow.com/comment/138303516
accepted answer: http://stackoverflow.com/a/78448885
score: 0
has title: Bash echoes all itterations from for-loop into first value. Then continues normally

http://stackoverflow.com/comment/138404486
score: 1
comment on: http://stackoverflow.com/q/78506946
has text: How are you starting and stopping the container? Can you have the program directly write to the bind-mounted directory; or can you run the program directly on the host with a JVM there, so that you don't need this added complexity?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138356725
has text: I'm not familiar with Azure devops pipelines, but when you assign a variable in a shell, it's a shell variable -- it only exists in that particular shell process. Using `export` makes it into an environment variable, which'll be inherited by subprocesses of that shell, but there's no way for a shell (or any other program) to create variables in its parent process.
score: 0
comment on: http://stackoverflow.com/q/78477819
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138549341
type: Comment
score: 0
type: QuestionComment
has text: @CharlesDuffy i have added a screenshot of the sendmail too. If you notice, the hyperlink is ok. But the attachment is converted to some random text in the email body.
comment on: http://stackoverflow.com/q/78587549

http://stackoverflow.com/a/78540325
answers question: http://stackoverflow.com/q/78539498
has body: Maybe this will help. Try to break the parts down into smaller pieces. How to print username? How to print top level project dir? How to print current project dir relative to top level? How to print working dir (combination of top level and current dir)? How to print the branch name? Post suggests __git_ps1 which might imply an environment variable already exist. Also, the branch master (a git defalt value) suggest that maybe this is all centered around git. If git isn't what you are seeking then the value in this post might be that it presents a recipe to create a solution given a tool that reports the variables specified, username, project dir, relative dir, and branch name. function ps1_username() { echo "username"; } function ps1_top_level() { basename $(git rev-parse --show-toplevel); } function ps1_show_prefix() { git rev-parse --show-prefix; } function ps1_working_dir() { echo $(ps1_top_level)/$(ps1_show_prefix); } function ps1_branch() { git rev-parse --abbrev-ref HEAD; } PS1='\n\[\033[32m\]$(ps1_username)\n' PS1='\n\[\033[33m\]$(ps1_top_level)\n' PS1='\n\[\033[33m\]$(ps1_show_prefix)\n' PS1='\n\[\033[33m\]$(ps1_working_dir)\n' PS1='\n\[\033[36m\]$(ps1_branch)\n' # ALL TOGETHER NOW PS1='\n\[\033[32m\]$(ps1_username) \[\033[33m\]$(ps1_working_dir) \[\033[36m\]$(ps1_branch)\[\033[0m\]\n' Expected Output: username projectDir/Dir_x/Dir_y/ develop
upvote count: 4
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138462814
has comment: http://stackoverflow.com/comment/138468840
has comment: http://stackoverflow.com/comment/138468821
has comment: http://stackoverflow.com/comment/138462918
accepted answer of: http://stackoverflow.com/q/78539498
has comment: http://stackoverflow.com/comment/138463531
score: 3
type: AcceptedAnswer

http://stackoverflow.com/comment/138307526
type: Comment
score: 0
has text: @Barmar thanks for pointing this it, it literally fixes the problem! I dont know why, mind you
type: QuestionComment
comment on: http://stackoverflow.com/q/78451035

http://stackoverflow.com/comment/138376646
type: QuestionComment
comment on: http://stackoverflow.com/q/78490743
has text: `GNU bash, version 5.1.4(1)-release (x86_64-apple-darwin18.7.0)`
type: Comment
score: 0

http://stackoverflow.com/q/78519611
linked to: http://stackoverflow.com/q/78539667
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138426936
accepted answer: http://stackoverflow.com/a/78524163
has comment: http://stackoverflow.com/comment/138427343
has body: I want to write a script based on dialog programbox (or others) and capture a command's stderr and the stdout passed to dialog into an array (if any), as well as the command's exit status (as last array element). For this, I'm using prepared command strings, command substitution and fd3 redirection. Basically, this works nicely, as long as there're no chained commands with if involved - then I get error messages, like, in this case 'command not found'. Here's a (simplified) example: # Prepare command strings declare cmd0='if -e . ; then echo TRUE; fi' cmd1=($("$cmd0") 2>&1) cmd2=(dialog --colors --no-collapse --programbox "\Zb\Z1List local folders..." 20 160) # Redirect stdout and stderr to dialog, while executing cmd1 > cmd2, capturing cmd1 exit status exec 3>&1 tmp=($(${cmd1[@]} 2>&1 | "${cmd2[@]}" 1>&3; echo ${PIPESTATUS[0]})) exec 3>&- # Print results printf '%s\n' "${tmp[@]}" The command declaration seems to require an array declaration, but then special chars like ';' will also add to the problem. This is what I tried; directly using c instead of cmd1 will print the whole line as error. What needs to be changed, to make the command substituion for chained commands (including if) in cmd1 work?
has comment: http://stackoverflow.com/comment/138474073
tagged with: io-redirection
has title: Bash dialog: chained command substitution if problem
has comment: http://stackoverflow.com/comment/138426226
tagged with: bash
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138426566
linked to: http://stackoverflow.com/q/7586589
tagged with: command-substitution
tagged with: dialog
linked to: http://stackoverflow.com/q/5615717
has comment: http://stackoverflow.com/comment/138426218
has answer: http://stackoverflow.com/a/78524163
has comment: http://stackoverflow.com/comment/138426222

http://stackoverflow.com/q/78520070
has comment: http://stackoverflow.com/comment/138427303
score: -1
has comment: http://stackoverflow.com/comment/138426847
has comment: http://stackoverflow.com/comment/138427618
has comment: http://stackoverflow.com/comment/138426882
has comment: http://stackoverflow.com/comment/138426865
tagged with: bash
has comment: http://stackoverflow.com/comment/138427407
has comment: http://stackoverflow.com/comment/138427389
has comment: http://stackoverflow.com/comment/138426853
has comment: http://stackoverflow.com/comment/138429586
has comment: http://stackoverflow.com/comment/138427587
has comment: http://stackoverflow.com/comment/138427573
has comment: http://stackoverflow.com/comment/138427449
has comment: http://stackoverflow.com/comment/138427044
downvote count: 1
has title: How to print name of third subdirectory of /home directory?
has comment: http://stackoverflow.com/comment/138426845
has comment: http://stackoverflow.com/comment/138426854
has comment: http://stackoverflow.com/comment/138427047
has comment: http://stackoverflow.com/comment/138427450
has comment: http://stackoverflow.com/comment/138426877
tagged with: subdirectory
has comment: http://stackoverflow.com/comment/138427637
has comment: http://stackoverflow.com/comment/138427085
has comment: http://stackoverflow.com/comment/138427549
has comment: http://stackoverflow.com/comment/138427445
has comment: http://stackoverflow.com/comment/138427363
has comment: http://stackoverflow.com/comment/138427540
type: Question
upvote count: 0
type: UnansweredQuestion
has body: How to print name of (for example) third subdirectory of /home directory in Bash? I have this from Chat GPT, but I am not sure about that. ls -d /home/*/ | sed -n '3p' | xargs basename
has answer: http://stackoverflow.com/a/78520178
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138427430
has comment: http://stackoverflow.com/comment/138426862

http://stackoverflow.com/q/78457962
has comment: http://stackoverflow.com/comment/138319263
tagged with: shell
has comment: http://stackoverflow.com/comment/138319000
tagged with: makefile
has comment: http://stackoverflow.com/comment/138318933
type: UnansweredQuestion
has body: I wrote a makefile like below: .SILENT: test3: PARAM_3=$(shell echo "Shell variable") When i run make test3, it gives below error: /bin/sh: 1: variable: not found make: *** [Makefile:5: test3] Error 127 But i run it on the terminal like below: $ PARAM_3=$(echo "Shell variable")
has comment: http://stackoverflow.com/comment/138319173
linked to: http://stackoverflow.com/q/42157800
has title: Makefile In which cases does it work from the shell?
linked to: http://stackoverflow.com/q/10067266
answer count: 0
has comment: http://stackoverflow.com/comment/138318951
tagged with: bash
has comment: http://stackoverflow.com/comment/138319553
has comment: http://stackoverflow.com/comment/138322481
duplicate of: http://stackoverflow.com/q/7128542
duplicate of: http://stackoverflow.com/q/42157800
has comment: http://stackoverflow.com/comment/138319578
score: 0
type: Question

http://stackoverflow.com/comment/138332715
score: 0
has text: Use `` and ``. See https://stackoverflow.com/a/85903/3776858
type: QuestionComment
comment on: http://stackoverflow.com/q/78465704
type: Comment

video-processing
tags question: http://stackoverflow.com/q/78465874
type: Tag
tag name: video-processing

http://stackoverflow.com/comment/138388717
type: Comment
has text: With `1 * * * *` your script will always be executed one minute after the hour. Replace `1` with `*` to get it executed every minute. See `man 5 crontab` for more details on a system with a common Linux derivative.
type: QuestionComment
comment on: http://stackoverflow.com/q/78497806
score: 1

http://stackoverflow.com/q/78556921
score: 1
upvote count: 1
answer count: 1
favorite count: 0
linked to: http://stackoverflow.com/q/402377
has comment: http://stackoverflow.com/comment/138493745
has comment: http://stackoverflow.com/comment/138499612
has answer: http://stackoverflow.com/a/78557282
tagged with: case
tagged with: linux
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138493201
type: Question
has comment: http://stackoverflow.com/comment/138493233
has title: bash scripting using getopts with a read input of multiple inputs on the same line
has comment: http://stackoverflow.com/comment/138493480
has comment: http://stackoverflow.com/comment/138493205
has comment: http://stackoverflow.com/comment/138493194
has body: Been a long time since I scripted, but here's what I'm trying to do. There are 5 or more inputs. The person selects them on the line after starting the script, like 1 2 3 4 5, I then run that through a case statement to execute specific functions. I had something like this but it doesn't work. I tried different args for getopts but nothing seems to get it into the case statement. read opt while getopts ":1234567:" opt do case "$opt" in 1) print "you selected option 1" ;; 2) print "you selected option 2" ;; 3) print "you selected option 3" ;; 4) print "you selected option 4" ;; 5) print "you selected option 5" ;; # \?) echo "unknown Option -$OPTARG" ; exit ;; # :) echo "missing required parameter for Option -$OPTARG" ; exit 1 ;; esac done shift $(($OPTIND -1)) print "Your value testing $opt" } Tried the above code, no luck
type: UnansweredQuestion

http://stackoverflow.com/a/78502506
score: 0
answers question: http://stackoverflow.com/q/78496979
has body: You may use find command and its -execdir option for this. To run multiple commands with -execdir you would have to repeat the -execdir option for each command which could be a bit clumsy. One way to go around that is using sh -c like this: find matt paul -type f -name kustomization.yaml -execdir sh -c ' echo "Executing in directory $(pwd)" somecommand1 {} somecommand2 {} ' \; If you want to store some state between the directories or modify variables in the scope of the script executing the find command, something like this might work: #!/bin/bash set -e # Fail the whole script if any subcommand fail total=0 # Example of a variable that is modified in the loop while read -r -d '' dir; do pushd "$dir" >/dev/null # Change to the directory somecommand1 kustomization.yaml somecommand2 kustomization.yaml total=$((total+1)) popd >/dev/null # Change back to the original directory done < <(find matt paul -type f -name kustomization.yaml -printf "%h\0") echo "Total $total directories processed" That needs Bash whereas the first example should probably work with bare sh so it's more portable.
type: Answer
has comment: http://stackoverflow.com/comment/138396391

http://stackoverflow.com/a/78447927
upvote count: 1
type: Answer
has body: Using any awk: $ awk ' BEGIN { FS=OFS=&quot;,&quot; } NR==1 { print; next } !seen[$1,$2]++ { depts[$1] = depts[$1] seps[$1] $2 seps[$1] = &quot;/&quot; } END { for (srvr in depts) { print srvr, depts[srvr] } } ' file Server,Department testserver,Fin Tech/HR
downvote count: 0
answers question: http://stackoverflow.com/q/78447882
score: 1

http://stackoverflow.com/q/78558739
has body: path3="a/b/c" command="ls -1q ${!path3}* | wc -l " length="$(command)" echo $length I am trying to move to folder assigned to variable path3, I am not getting any value of length when executing this code. What is the issue in my code? I am expecting some value for length variable
answer count: 1
has comment: http://stackoverflow.com/comment/138496520
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138496481
tagged with: bash
has comment: http://stackoverflow.com/comment/138496559
has comment: http://stackoverflow.com/comment/138496669
has comment: http://stackoverflow.com/comment/138496526
has title: Shell script: Not getting value of command evaluated in variable
has comment: http://stackoverflow.com/comment/138518305
score: -1
type: Question
upvote count: 0
tagged with: shell
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78558798
has comment: http://stackoverflow.com/comment/138496519

http://stackoverflow.com/q/78580571
has comment: http://stackoverflow.com/comment/138538652
score: 0
tagged with: linux
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138537488
answer count: 1
has body: I'm trying to create a script to create a database, but I don't know how write the -c part: psql -w -h ${HOST} -U ${USER} ${DATABASE} -c CREATE DATABASE ${DATABASE} WITH OWNER = ${USER} ENCODING = 'UTF8' CONNECTION LIMIT = -1 IS_TEMPLATE = False; I tried: psql -w -h ${HOST} -U ${USER} ${DATABASE} -c "CREATE DATABASE ${DATABASE} WITH OWNER = ${USER} ENCODING = 'UTF8' CONNECTION LIMIT = -1 IS_TEMPLATE = False;" psql -w -h ${HOST} -U ${USER} ${DATABASE} -c ""CREATE DATABASE ${DATABASE} WITH OWNER = ${USER} ENCODING = 'UTF8' CONNECTION LIMIT = -1 IS_TEMPLATE = False;"" psql -w -h ${HOST} -U ${USER} ${DATABASE} -c {CREATE DATABASE ${DATABASE} WITH OWNER = ${USER} ENCODING = 'UTF8' CONNECTION LIMIT = -1 IS_TEMPLATE = False;} psql -w -h ${HOST} -U ${USER} ${DATABASE} -c (CREATE DATABASE ${DATABASE} WITH OWNER = ${USER} ENCODING = 'UTF8' CONNECTION LIMIT = -1 IS_TEMPLATE = False;) But no one works for me...
has comment: http://stackoverflow.com/comment/138537281
linked to: http://stackoverflow.com/q/673055
type: Question
tagged with: postgresql
has answer: http://stackoverflow.com/a/78582352
has comment: http://stackoverflow.com/comment/138536107
has comment: http://stackoverflow.com/comment/138537249
has comment: http://stackoverflow.com/comment/138536470
has title: Execute psql command in bash script with -c command

http://stackoverflow.com/comment/138543916
has text: It is not clear from your problem description, which statement in your loop produces the error message.
score: 0
comment on: http://stackoverflow.com/q/78583045
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138333252
comment on: http://stackoverflow.com/a/78466056
type: Comment
type: AnswerComment
score: 0
has text: Thank you so much! I will have to digest the code for a while, perl is literally a word I searched and brew-installed a few days ago, with a command copied/pasted from this forum when I searched for answers:)...curious about the one-line command you suggested previously, run it a dozen of times, each time feed with a new url link, it exits randomly each time, from the result list, every time it will follow "previous/next" url links both ways from the start, for the first couple hundred links, then it will "decide" to go just one direction to the end after that, wondering how it "decide"?

http://stackoverflow.com/q/78454806
has answer: http://stackoverflow.com/a/78455551
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/138313486
tagged with: bash
has title: Can't get variable assigned in Bash case statement
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138314346
accepted answer: http://stackoverflow.com/a/78454855
answer count: 2
has comment: http://stackoverflow.com/comment/138314318
type: Question
has answer: http://stackoverflow.com/a/78454855
possible better answer: http://stackoverflow.com/a/78455551
has comment: http://stackoverflow.com/comment/138313473
tagged with: case
has body: I need to be able to use a variable value that's assigned in a bash case statement. My input file has a single line. 30.xx.xx.xx,Bill Here's my code #!/bin/bash MyList=IPlist.csv while IFS=, read -r myIP UserName _ do case $UserName in Tom) echo "Case is Tom and the IP address is $myIP..." UserName="Tom" echo "Username is $UserName" ;; Bill) echo "Case is Bill and the IP address is $myIP..." UserName="Bill" echo "Username is $UserName" ;; *) echo "Case is incorrect..." echo "Exiting line read...." esac done <$MyList echo "$UserName" This is the output I want Tom@hostname ~ $ ./MyTest3.sh Case is Bill and the IP address is 30.xx.xx.xx... Username is Bill Bill Here's the output I'm getting Tom@hostname ~ $ ./MyTest3.sh Case is Bill and the IP address is 30.xx.xx.xx... Username is Bill I've been searching for the past hour and everything I find describes the code as I have it. I even checked shellcheck and it says "No errors detected!" Thanks in advance for any help. Edit - 5-11-24 I forgot to mention that his is a test of case. Ultimately I need read an 16,000 line comma delimited file and based on the username do snmpget to the devices to get the snmpv3 engineID. In case that makes any difference to the method used in the case statement.

http://stackoverflow.com/comment/138411498
type: AnswerComment
score: 1
has text: [Don't put commands in variables.](https://mywiki.wooledge.org/BashFAQ/050) In this particular case, it prevents you from even being able to quote `"$1"` properly. See also [When to wrap quotes around a shell variable](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable)
comment on: http://stackoverflow.com/a/78511400
type: Comment

http://stackoverflow.com/q/78458050
answer count: 2
has answer: http://stackoverflow.com/a/78458513
downvote count: 0
has comment: http://stackoverflow.com/comment/138327296
type: Question
type: UnansweredQuestion
score: 3
upvote count: 3
linked to: http://stackoverflow.com/q/36313216
linked to: http://stackoverflow.com/q/32684119
tagged with: pipe
tagged with: bash
has title: How can I get a pipe to *completely* stop if a command fails?
favorite count: 0
has answer: http://stackoverflow.com/a/78458061
has comment: http://stackoverflow.com/comment/138326994
has body: I was using this code to use jq to format a json file in place jq . foo.json | sponge foo.json It works great, but has one fatal flaw - if jq . foo.json fails (due to, say, a parsing error), the pipe just keeps on tickin and writes nothing to foo.json, wiping the file. The behavior I want is something that is the same as foo | bar, but if foo fails, bar will not be executed. set -o pipefail seemed promising, but it turns out that's not what it does. This feels like a common enough use case that there would be some clever shorthand for it, but I can't figure it out. Requested example json data: I want "foo" to be turned into "foo" and "foo to be left alone, whereas my program will wipe the file.

http://stackoverflow.com/comment/138427223
type: AnswerComment
score: 0
has text: @thatotherguy, this answer is not generated by AI, but that small bit I quote is. Let me reformat the answer to make this more obvious. I don't think my answer violates the policy since it is not AI-generated. I wrote it. Update: Done. Answer reworded.
type: Comment
comment on: http://stackoverflow.com/a/78520260

http://stackoverflow.com/comment/138505545
type: QuestionComment
has text: Reading `...ew.ttf : Failed...` notice the **space** between `ttf` and `:`! This mean the space wasn't correctly dropped by `awk`! As @EdMorton said: *don't do that*! Btw this `awk` syntax will replace multiple space by only one space and so on (if they work)...
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78562624

http://stackoverflow.com/q/78575374
score: 1
has comment: http://stackoverflow.com/comment/138526989
has comment: http://stackoverflow.com/comment/138526401
favorite count: 0
has comment: http://stackoverflow.com/comment/138527188
has answer: http://stackoverflow.com/a/78575426
has comment: http://stackoverflow.com/comment/138526524
has comment: http://stackoverflow.com/comment/138526886
tagged with: escaping
has comment: http://stackoverflow.com/comment/138527268
tagged with: bash
has answer: http://stackoverflow.com/a/78575456
tagged with: onedrive
type: Question
tagged with: visual-studio-code
has comment: http://stackoverflow.com/comment/138526803
has comment: http://stackoverflow.com/comment/138527035
has comment: http://stackoverflow.com/comment/138526631
has comment: http://stackoverflow.com/comment/138526931
has comment: http://stackoverflow.com/comment/138526366
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/138527366
has title: apostrophe in the path name of python file
tagged with: python
has comment: http://stackoverflow.com/comment/138527237
has comment: http://stackoverflow.com/comment/138526594
answer count: 2
has body: I am trying to run a python script which is saved on OneDrive. The name of OneDrive is set by my organisation and so I cannot change it. My problem is when I try to run any script it fails because of the apostrophe. I click on the arrow in vscode to run the file, which results in this bash command: /usr/bin/python3 /Users/username/the organisation's name/Desktop/scripts/mycode.py In the terminal it just says quote> and it looks like it's waiting for input. When I click run again then the second apostrophe closes the quote and I get the output /Library/Developer/CommandLineTools/usr/bin/python3: can't open file '/Users/username/the organisations name/Desktop/scripts/mycode.py /Users/username/theorganisationsname/Desktop/scripts/mycode.py': [Errno 2] No such file or directory The only way it works is if I type in the terminal: /usr/bin/python3 [path] and use the esc character for the apostrophy, but it's not a sustainable solution. I could do an alias I guess, but I'd need to do that for all scripts I have on onedrive. I can also store files locally, not on OneDrive, but I don't like the idea of being defeated by an apostrophe. Weirdly when I tried to replicate the problem on my laptop (I created a path /Users/username/Desktop/Code/Julia's folder/test.py) the code runs fine. The bash command is /usr/bin/python3 "/Users/username/Desktop/Code/Julia's folder/test.py" - the path is in quotation marks. This doesn't happen when I run the file saved on onedrive. Added info: The example path should actually be: /Users/username/CloudStorage/the organisation's name/Desktop/scripts/mycode.py to be more precise. I notices that when I change the path in vscode so it doesn't include "CloudStorage" then everything is working (see my answer below for detail). I also created a matlab file /Users/username/CloudStorage/the organisation's name/Desktop/scripts/test.m it runs fine with the original path (not sure if that indicates anything).
downvote count: 0

http://stackoverflow.com/q/78466816
has answer: http://stackoverflow.com/a/78475452
has title: Tar piping creates error during run and stops
has comment: http://stackoverflow.com/comment/138334317
has comment: http://stackoverflow.com/comment/138334300
tagged with: http://stackoverflow.com/tag/tar
has answer: http://stackoverflow.com/a/78475852
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138334549
has comment: http://stackoverflow.com/comment/138337021
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138337165
linked to: http://stackoverflow.com/q/24058544
has comment: http://stackoverflow.com/comment/138334234
tagged with: xargs
has comment: http://stackoverflow.com/comment/138334333
has comment: http://stackoverflow.com/comment/138350499
has comment: http://stackoverflow.com/comment/138428263
has comment: http://stackoverflow.com/comment/138334427
answer count: 2
has comment: http://stackoverflow.com/comment/138339799
has comment: http://stackoverflow.com/comment/138337248
has comment: http://stackoverflow.com/comment/138334101
tagged with: bash
has body: I am running a larger copy job online. I am using tar for that piped to xargs. My command looks like this: tar cvf - --sort=name --ignore-failed-read -C /pathto/source . | pv | xargs -n 1 -P 32 $(tar xvf - --keep-newer-files -C /pathto/destination) The command works and does what it should be doing. However at times it stops with following error messeage: tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now sh: 1: xargs: Argument list too long I suscpect this could happen when there is a change like deletion of a file in the source folder. Files are small but many. So when this happens I can only start from the beginning which goes over all files that have been already copied which takes half a day at least. So I wonder if there is a way to tell this command that it should go on instead of breaking. It should simply go on with the next file. Errors like missing or corrupted files from this run will be straightend out later. I had added --ignore-failed-read to the command but it did not help. Maybe I added it wrong or it does not do what I thought it would be doing.

http://stackoverflow.com/a/78511400
has comment: http://stackoverflow.com/comment/138411726
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138411711
has comment: http://stackoverflow.com/comment/138411498
upvote count: 0
answers question: http://stackoverflow.com/q/78508971
has body: It seems you have some issues with special characters and variable substitutions. I have found that it often makes things easier when you break long one-liners into multiple steps. In Bash (and other shell languages), single quotes behave differently from double quotes. When having trouble with running non-trivial commands over ssh, it is a good idea to "dry-run" your code, i.e. echo the ssh command instead of running it to see what is actually being run. Syntax highlighting and a good linter helps too. Here is a fixed version of your function. Take a good look at how the quotes are placed. #!/bin/bash function installed (){ query="dpkg-query -W ${1} 2>&1" awkCmd="awk '{if (\$0 ~ /no packages/) {print \"not installed\"} else {print \"installed\"}}'" cmd="$query | $awkCmd" ssh "secondnode" "$cmd" } installed "somepackage"
score: -1

http://stackoverflow.com/comment/138345198
comment on: http://stackoverflow.com/q/78473026
type: QuestionComment
has text: @JamesStarlight, ...so, it's possible to fix the issue, _if_ you use an operating system that supports better filesystems; anything natively UNIXy (XFS, ZFS, ext3/4, btrfs, ...) won't have this problem.
type: Comment
score: 3

http://stackoverflow.com/comment/138317683
score: 0
comment on: http://stackoverflow.com/q/78457170
type: QuestionComment
type: Comment
has text: Sorry, that's impossible. A variable assignment does not produce any output. Explain how you go from `FILEDIR=...` to obtaining `public/2024...`

http://stackoverflow.com/q/78576344
has title: running bash command through python script
score: 0
has comment: http://stackoverflow.com/comment/138528914
type: Question
answer count: 0
tagged with: shell
has comment: http://stackoverflow.com/comment/138528909
type: UnansweredQuestion
upvote count: 1
tagged with: python
downvote count: 1
has comment: http://stackoverflow.com/comment/138528878
has body: i have a problem with running bash command through python script. my task is that i have to find a minimum possible woring combination of "instrumentations" and "within": instrumentations = [ "kamon.instrumentation.akka.instrumentations.EnvelopeInstrumentation", "kamon.instrumentation.akka.instrumentations.SystemMessageInstrumentation", "kamon.instrumentation.akka.instrumentations.RouterInstrumentation", "kamon.instrumentation.akka.instrumentations.ActorInstrumentation", "kamon.instrumentation.akka.instrumentations.ActorLoggingInstrumentation", "kamon.instrumentation.akka.instrumentations.AskPatternInstrumentation", "kamon.instrumentation.akka.instrumentations.EventStreamInstrumentation", "kamon.instrumentation.akka.instrumentations.ActorRefInstrumentation", "kamon.instrumentation.akka.instrumentations.akka_25.DispatcherInstrumentation", "kamon.instrumentation.akka.instrumentations.akka_26.DispatcherInstrumentation", "kamon.instrumentation.akka.instrumentations.akka_26.ActorMonitorInstrumentation", "kamon.instrumentation.akka.instrumentations.SchedulerInstrumentation", "kamon.instrumentation.akka.instrumentations.ClusterInstrumentation" ] within = [ "^akka.dispatch..*", "^akka.event..*", "^akka.actor..*", "^akka.pattern..*", "^akka.cluster..*", "^akka.routing..*", "kamon.instrumentation.akka.instrumentations..*" ] so to check my combination manually i have to run this two commands: sbt assembly DATADOG_AGENT_IP=127.0.0.1 JAVA_HEAP_MS=1024m JAVA_HEAP_MX=2048m JAVA_HEAP_MS=1024m java -Dconfig.resource=/local-staging-db.conf -Xloggc:./log/gc.log -XX:+PrintGCDetails -javaagent:kanela-agent-1.0.17.jar -Djava.library.path=native -Duser.timezone=GMT -jar target/scala-2.12/sharaku-web-assembly-0.1-SNAPSHOT.jar and if the server is breaking, i have to try another combination. as there are a lot of combinations, i decided to write a script. so now im stuck on running my command two through the skript: command2 = """ java -Dconfig.resource=/local-staging-db.conf \ -Xloggc:./lo…
has comment: http://stackoverflow.com/comment/138528257
tagged with: bash
has comment: http://stackoverflow.com/comment/138529809
favorite count: 0

http://stackoverflow.com/q/78583045
has comment: http://stackoverflow.com/comment/138540829
tagged with: awk
tagged with: http://stackoverflow.com/tag/csv
upvote count: 3
has comment: http://stackoverflow.com/comment/138550302
has answer: http://stackoverflow.com/a/78583213
has comment: http://stackoverflow.com/comment/138541035
tagged with: arrays
type: Question
has comment: http://stackoverflow.com/comment/138540892
answer count: 4
has comment: http://stackoverflow.com/comment/138543916
possible better answer: http://stackoverflow.com/a/78583213
has comment: http://stackoverflow.com/comment/138540774
score: 3
has title: Printing command by reading CSV file with AWK into a bash array
has comment: http://stackoverflow.com/comment/138550341
has comment: http://stackoverflow.com/comment/138540781
has comment: http://stackoverflow.com/comment/138540904
has answer: http://stackoverflow.com/a/78583828
accepted answer: http://stackoverflow.com/a/78583629
has answer: http://stackoverflow.com/a/78584884
has body: I have the following CSV file (mycsv.csv): love,hate,--command yes this is bad --other-command fox,duck,--command yes this is bad --other-command turtle,rabbit This means the command would be --command "command_argument" --other-command Then I'm creating an array: my_csv="/home/sometimesihatebash/mycsv.csv" first_column=( $(awk -F "\"*,\"*" '{print $1}' $my_csv) ) second_column=( $(awk -F "\"*,\"*" '{print $2}' $my_csv) ) IFS=$'\n' command=( $(awk -F "\"*,\"*" '{print $3}' $my_csv) ) Then printing all columns into a command for i in "${!first_column[@]}"; do echo "${first_column[i]}" echo "${second_column[i]}" echo "${command[i]}" execute_program_name --first "${first_column[i]}" --second "${second_column[i]}" "${command[i]}" done But then, for the third row (which has an empty third column), I get: error: 1 unrecognized argument: ' And for the first two rows, I get: no such option: --command yes this is bad --other-command When echoing each array element, I don't see any problems. Pasting the exact output of echo also runs the program normally. Running the for loop with just the first_column and second_column arrays works fine Probably this has something to do with special characters in the last array but I`m lost Any ideas?
tagged with: for-loop
has comment: http://stackoverflow.com/comment/138541655
tagged with: bash
linked to: http://stackoverflow.com/q/12136948
downvote count: 0
has answer: http://stackoverflow.com/a/78583629
has comment: http://stackoverflow.com/comment/138541052
has comment: http://stackoverflow.com/comment/138540758
favorite count: 0
has comment: http://stackoverflow.com/comment/138540752
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138540768
has comment: http://stackoverflow.com/comment/138541465
has comment: http://stackoverflow.com/comment/138540698
has comment: http://stackoverflow.com/comment/138550567

http://stackoverflow.com/comment/138398164
type: Comment
has text: I just run it using './start_processes.sh' and no it doesn't save it into a file, I just want to see the print on terminal. I'm not closing the terminal. Yes if I run one instance if the python program it still prints the program into the terminal.
score: 0
comment on: http://stackoverflow.com/q/78503442
type: QuestionComment

http://stackoverflow.com/q/78551049
has comment: http://stackoverflow.com/comment/138484555
tagged with: azureportal
downvote count: 1
has comment: http://stackoverflow.com/comment/138483677
tagged with: azure
has comment: http://stackoverflow.com/comment/138483388
has title: Azure CLI - Bash script with variables not working
has comment: http://stackoverflow.com/comment/138483598
has comment: http://stackoverflow.com/comment/138483290
has answer: http://stackoverflow.com/a/78552987
tagged with: bash
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/39527571
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138483408
has comment: http://stackoverflow.com/comment/138483727
has comment: http://stackoverflow.com/comment/138483425
has comment: http://stackoverflow.com/comment/138483108
tagged with: azure-cli
score: 0
type: Question
has body: I'm trying to run a simple Bash script file from Azure CLI in Azure portal. But it is throwing error as "Operation returned an invalid status 'Bad Request'" . What is the correct syntax for the below Azure CLI command with varible for Bash? #!/bin/bash rgName="my-train-rg01" serverName="test-db-svc-primary" #echo $rgName #echo $serverName #echo "Hellow Wrold!" az sql db list --resource-group $rgName --server $serverName

http://stackoverflow.com/comment/138496481
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78558739
has text: What do you think `${!path3}` does? Also, `$(command)` and `$($command)` are not the same thing.
score: 1

http://stackoverflow.com/comment/138632341
comment on: http://stackoverflow.com/q/78549319
type: Comment
score: 0
has text: That's a LOT of code. Please create and post a [mcve] that's **only** about just the specific problem you'd like help with so we can help provide a solution to that without having to read/understand all of the currently surrounding irrelevant (to your problem) code. Having said that, it looks like you may be trying to store a command in a variable to execute later, if so please read https://mywiki.wooledge.org/BashFAQ/050 (and https://mywiki.wooledge.org/BashFAQ/048 for general advice on when [not] to use `eval`).
type: QuestionComment

http://stackoverflow.com/comment/138339178
comment on: http://stackoverflow.com/q/78469768
has text: What does `openssl version` print on the two systems? (Please add that information to the question.)
type: QuestionComment
score: 2
type: Comment

http://stackoverflow.com/a/78583954
upvote count: 1
type: Answer
has body: Did you consider using a XPath processor instead of hxselect | grep | sed | etc… As long as the processor understands HTML5 you can use XPath to extract data from the URL that you provided. With that in mind, I would recommend xidel (available here for a few OSs) for your task. So here's a solution that extracts the data with XPath 3.1 and outputs it as JSON (CSV is also possible); then you just have to import it in SQlite using the method provided in this post: edit: replaced exit 1 with exit for keeping the exit status of the xidel command in case of failure (Thanks @CharlesDuffy) xidel --xpath ' array{ //li//div[@class => contains-token("in-listingCardPropertyContent")] ! ( let $priceStrings := div[contains-token(@class,"in-listingCardPrice")]/string(), $sizeStrings := div/div[svg/use/@href = "#size"]/string(), $titleNodes := a[@class => contains-token("in-listingCardTitle")], $linkStrings := $titleNodes/@href/string(), $descStrings := $titleNodes/@title/string() return map{ "price" : $priceStrings => tokenize() => filter(matches(?,"^[\d.,]+$")), "link" : $linkStrings => replace("^\s+|\s+$",""), "description" : $descStrings => replace("^\s+|\s+$",""), "size" : $sizeStrings => tokenize() => filter(matches(?,"^[\d.,]+$")), "auction" : $descStrings => contains("auction") } ) } ' "$url" > data.json || exit sqlite3 "$db_file" " INSERT INTO "$sGDomain" (price, link, description, size, auction) SELECT json_extract(value, '\$.price'), json_extract(value, '\$.link'), json_extract(value, '\$.description'), json_extract(value, '\$.size'), json_extract(value, '\$.auction') FROM json_each(readfile('data.json')); " note: I made the script exit when the XPath query fails because it's important to not import junk into the DB. The current XPath code is already quite finicky but it won't fail when some data is missing (which can happen if the site decide to update their front-end). Dowloading the HTML page into a file with curl and passing that file to xidel might become handy for…
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/78582686

http://stackoverflow.com/q/78473026
has comment: http://stackoverflow.com/comment/138345198
duplicate of: http://stackoverflow.com/q/4814040
linked to: http://stackoverflow.com/q/4814040
score: 0
has body: I am trying to create a directory contained &quot;:&quot; mkdir MD_6nax_apo_POPC:POPE_110A mkdir: impossible de créer le répertoire «MD_6nax_apo_POPC:POPE_110A»: Argument invalide While just mkdir MD_6nax_apo_POPCPOPE_110A works OK. is it possible to fix the issue ?
has comment: http://stackoverflow.com/comment/138344817
tagged with: bash
type: Question
has title: bash: make dir contained ":" or other special characters
type: UnansweredQuestion
tagged with: mkdir
has comment: http://stackoverflow.com/comment/138344858
answer count: 0

http://stackoverflow.com/comment/138538988
comment on: http://stackoverflow.com/a/78576845
type: Comment
type: AnswerComment
score: 0
has text: FYI -- there's no need for `cd ~` at the end of your script, because working directory is process-local: when a script you run invokes `cd`, that doesn't change which directory is active for the parent shell that _started_ that script (unless you explicitly invoked the script with `source`, but that's something people should only do when they _want_ side effects modifying parent process state).

http://stackoverflow.com/comment/138457361
score: 0
type: QuestionComment
has text: I can't reproduce this either. Run bash --norc and try again, perhaps something else in your .bashrc is causing this
type: Comment
comment on: http://stackoverflow.com/q/78535384

http://stackoverflow.com/comment/138308303
has text: For reference, I'm on `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)`.
score: 0
comment on: http://stackoverflow.com/q/78451463
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138546548
has text: What about `"a'b(c|c)b'a"` ?
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78586078
type: QuestionComment

http://stackoverflow.com/comment/138444475
score: 0
type: QuestionComment
has text: I deleted my comment, because it actually worked. Thanks a lot!
type: Comment
comment on: http://stackoverflow.com/q/78529571

http://stackoverflow.com/q/78581308
tagged with: zsh
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138546518
score: 0
tagged with: shell
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138542928
has title: How to write a shorthand for localhost in curl?
tagged with: curl
has body: I want to write just curl 8000 to work as curl localhost:8000. I've come up with the following zsh function so far: function curl() { local first_arg="$1" if [[ "$first_arg" =~ ^([0-9]{4})(.*)$ ]]; then local modified_url="localhost:${first_arg}" command curl "$modified_url" "${@:2}" else command curl "$@" fi } But obviously, the url is not guaranteed to be the first argument, such as curl -H '...' localhost:8000. Is there a robust existing solution for such needs?
has comment: http://stackoverflow.com/comment/138537321

http://stackoverflow.com/a/78478727
accepted answer of: http://stackoverflow.com/q/78478726
type: Answer
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138354931
answers question: http://stackoverflow.com/q/78478726
score: 0
has body: Answer: Bash evaluates $A prior to running A=1. Demonstration: $ export A=1 $ A=2 echo $A 1 One workaround: $ cat &gt; echoa.sh #!/bin/bash echo $A ^D $ chmod +x echoa.sh $ A=5 ./echoa.sh 5

http://stackoverflow.com/q/78496979
favorite count: 0
answer count: 2
has body: I have 2 directories paul &amp; matt with some subfolders within each which potentially contains (or will contain) a kustomization.yaml file. What I am trying to do is to run multiple commands in the path where a kustomization.yaml is found in paul/* and matt/*. So if I was to do this manually: cd paul somecommand1 kustomization.yaml somecommand2 kustomization.yaml cd paul/test somecommand1 kustomization.yaml somecommand2 kustomization.yaml cd paul/test/test1 somecommand1 kustomization.yaml somecommand2 kustomization.yaml --- cd matt somecommand1 kustomization.yaml somecommand2 kustomization.yaml cd matt/test somecommand1 kustomization.yaml somecommand2 kustomization.yaml cd matt/test/test1 somecommand1 kustomization.yaml somecommand2 kustomization.yaml I am still learning bash but I know that a Bash script I can call on my GitLab pipeline with some steps that will do something like a loop to find any kustomization.yaml in those 2 directories recursively, then run x, y, and z against any found kustomization.yaml file will do the job.
has title: Execute multiple commands against a specific file if found in a directory recusively
duplicate of: http://stackoverflow.com/q/5119946
tagged with: gitlab-ci
accepted answer: http://stackoverflow.com/a/78500841
tagged with: linux
downvote count: 0
tagged with: bash
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78500841
has answer: http://stackoverflow.com/a/78502506
has comment: http://stackoverflow.com/comment/138387220
possible better answer: http://stackoverflow.com/a/78502506
tagged with: for-loop
type: Question
score: 1
upvote count: 1
linked to: http://stackoverflow.com/q/5119946

http://stackoverflow.com/comment/138314179
has text: 1 sample input line and no expected output given that input doesn't demonstrate your requirements and so isn't adequate to test a potential solution with. Please [edit] your question to provide a [mcve] including cases where 1 email address is associated with 2 different end of line numbers.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78451797
type: QuestionComment

http://stackoverflow.com/comment/138506794
comment on: http://stackoverflow.com/q/78564469
score: 0
type: QuestionComment
type: Comment
has text: where is `TOTAL` defined?

http://stackoverflow.com/q/78517962
tagged with: linux
has comment: http://stackoverflow.com/comment/138424329
tagged with: bash
has comment: http://stackoverflow.com/comment/138424328
tagged with: ansible
has comment: http://stackoverflow.com/comment/138423801
has comment: http://stackoverflow.com/comment/138423882
tagged with: ldap
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138423365
has answer: http://stackoverflow.com/a/78518676
has comment: http://stackoverflow.com/comment/138423697
has comment: http://stackoverflow.com/comment/138424185
type: UnansweredQuestion
tagged with: redhat
answer count: 1
favorite count: 0
upvote count: 1
has title: unable to create home directory for new user using Ansible
has comment: http://stackoverflow.com/comment/138424064
has body: i try to use ansible ldap for connet my domain lab.local to my redhat 9.4 servers. isuccess to connect with my domain user but i can't create a home diretory in /home/%u, i have this error message "Could not chdir to home directory /home/trio01: No such file or " this is my integration file: - hosts: all become: yes vars: pkgs: - sssd - sssd-tools - sssd-ldap - sssd-ad - adcli - realmd - krb5-workstation - openldap-clients - cyrus-sasl-gssapi - oddjob - oddjob-mkhomedir AD_Domain: LAB.LOCAL AD_Domain_alt: lab.local Join_OU: OU=Linux,DC=LAB,DC=LOCAL SRV_ADM_GRP_OU: OU=Linux,DC=lab,DC=local vars_prompt: - name: username prompt: "Veuillez entrer votre nom d'utilisateur AD admin?" private: no - name: password prompt: "Veuillez entrer le mot de passe d'utilisateur AD admin?" private: yes - name: adhostname prompt: "Veuillez entrer le nom simple de la machine , pas de format fqdn format" private: no tasks: - name: V�rification de la version de distribution du serveur (RedHat) fail: msg: Le system ne n'�xecute pas RedHat, arr�t when: ansible_facts['distribution'] != 'RedHat' # - name: Installation des packages n�cessaires pour joindre le domaine AD # yum: name={{ pkgs }} state=present update_cache=yes - name: Configuration du nom de la machine shell: hostnamectl set-hostname {{ adhostname }}.{{ AD_Domain_alt }} - name: Int�gration au domaine AD (cr�ation du compte AD computer et mise a jour du fichier /etc/krb5.keytab) shell: echo '{{ password }}' | adcli join --stdin-password {{ AD_Domain }} -v -U {{ username }} --domain-ou={{ Join_OU }} - name: Configuration du fichier sssd.conf template: src: sssd.j2 dest: /etc/sssd/sssd.conf owner: root group: root mode: 0600 - name: Ensure PAM configuration for mkhomedir lineinfile: path: /etc/pam.d/common-session line: 'session required pam_mkhomedir.so skel=/etc/skel umask=0077' create: yes - name: Ensure oddjobd service is enabled and started service: name: oddjobd enabled: yes state: started - name: Configuration du fichier nsswit…
has comment: http://stackoverflow.com/comment/138424188
downvote count: 1

http://stackoverflow.com/comment/138528878
type: Comment
comment on: http://stackoverflow.com/q/78576344
score: 0
has text: I don't see any use of `instrumentations` or `within` in the code.
type: QuestionComment

http://stackoverflow.com/comment/138402670
comment on: http://stackoverflow.com/q/78506003
type: QuestionComment
type: Comment
score: 0
has text: @life888888: The background process already runs as root.

http://stackoverflow.com/q/78451308
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78451344
tagged with: bash
has answer: http://stackoverflow.com/a/78451330
has body: I have the following bash script: abc.sh #!/bin/bash echo First Arg: $0 echo Second Arg: $1 a=$(ls) echo Directory contents: $a And I invoke the below command: /usr/bin/bash -c 'source "$0" && exec "$@" ' /home/usr/rob/abc.sh /home/usr/rob/abc.sh ARG1 As per the documentation, with -c option, commands are read from the given string; and if we have anything outside the string, the first arg is passed to $0. So above source "$0" will become: source /home/usr/rob/abc.sh. So the expected output would be: First Arg: /home/usr/rob/abc.sh Second Arg: Directory contents: abc.txt abc.sh <-- The dir has only these two files First Arg: /home/usr/rob/abc.sh Second Arg: ARG1 Directory contents: abc.txt abc.sh But what actually gets printed is: First Arg: /home/usr/rob/abc.sh Second Arg: /home/usr/rob/abc.sh Directory contents: abc.txt abc.sh First Arg: /home/usr/rob/abc.sh Second Arg: ARG1 Directory contents: abc.txt abc.sh The question is: when I print $0 and $1, how the first command (source /home/usr/rob/abc.sh) prints the name of the script? for both echo statements' Ideally, it should print blank for $1; because we dont pass anything as argument. As the same time the exec $@ prints the values (for $0 and $1) as expected.
score: 0
answer count: 2
has title: Bash script -c option behavior
type: Question

http://stackoverflow.com/q/78559080
tagged with: bash
has comment: http://stackoverflow.com/comment/138497059
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138513934
score: 0
has comment: http://stackoverflow.com/comment/138497343
type: Question
has comment: http://stackoverflow.com/comment/138513412
has answer: http://stackoverflow.com/a/78559288
has comment: http://stackoverflow.com/comment/138497329
answer count: 1
has comment: http://stackoverflow.com/comment/138497102
has comment: http://stackoverflow.com/comment/138497309
has body: I am getting comma seperated IPs as a string in my application from terraform. I need to replace variable in a conf file with array of ips. Number ips can be anything. I have taken 2 as an example. Script.sh: #!/bin/bash var_ips="10.10.10.177,10.10.10.181" IFS=',' read -ra ip_array <<< "$var_ips" form_hosts=() for item in "${ip_array[@]}";do form_hosts+=("\"$item\"") done sed -i "s/^hosts: \"from_terraform_hosts\"$/hosts: [${form_hosts[*]}]/g" host.conf host.conf hosts: "from_terraform_hosts" //file truncated Here i want entry in host.conf as hosts: ["10.10.10.177","10.10.10.181"] but i am getting hosts: ["10.10.10.177" "10.10.10.181"] Comma is missing when i substitute the values. Can anyone help to fix above issue. The difference is due to below echo [${form_hosts[*]}] echo "[${form_hosts[*]}]" Output ["10.10.10.177" "10.10.10.181"] ["10.10.10.177", "10.10.10.181"] Here under double quotes only comma is coming but i cant use this way inside sed command.
has comment: http://stackoverflow.com/comment/138498718
accepted answer: http://stackoverflow.com/a/78559288
has comment: http://stackoverflow.com/comment/138497223
has title: Bash: convert comma seperated ips into array of ip

http://stackoverflow.com/a/78597330
answers question: http://stackoverflow.com/q/78576313
type: Answer
has body: Go to System Settings / Privacy & Security / Full Disk Access and grant the script access to the full disk. I don't think the script's location matters, but many LaunchDaemons use /Library/Application Support/... for their executables. On some Macs, I've had to await storage mounting, and so instead of directly executing the script, I resorted to executing sh with something like ProgramArguments sh -c while [ ! -x /Users/Shared/MyScript.sh ]; do echo StartWait; sleep 6; done; sleep 5; /Users/Shared/MyScript.sh arguments
score: 0

http://stackoverflow.com/q/78515934
has comment: http://stackoverflow.com/comment/138419475
type: UnansweredQuestion
answer count: 3
score: 2
has body: I have run the following command successfully, to calculate the total CPU usage using the ps command: ps -A -o pcpu | tail -n+2 | awk '{sum+=$1}END{print sum}' However, when I tried to create an alias for this command alias totalcpu="ps -A -o pcpu | tail -n+2 | awk '{sum+=$1} END {print sum}'" awk threw the following error when I tried executing the alias (totalcpu): awk: line 1: syntax error at or near } I tried executing the alias in the same shell, so that I don't need to update the .bashrc file.
upvote count: 2
downvote count: 0
tagged with: bash
favorite count: 0
has comment: http://stackoverflow.com/comment/138430837
has answer: http://stackoverflow.com/a/78518167
tagged with: alias
has comment: http://stackoverflow.com/comment/138419346
tagged with: awk
has answer: http://stackoverflow.com/a/78516302
has comment: http://stackoverflow.com/comment/138419363
has answer: http://stackoverflow.com/a/78516011
type: Question
has title: awk throwing syntax error only when used as alias

http://stackoverflow.com/comment/138526803
comment on: http://stackoverflow.com/q/78575374
type: QuestionComment
has text: @OldBoy I don't know what those json files are. Which path you want be to put in quotes? The OneDrive directory, or each specific .py file on OneDrive?
type: Comment
score: 0

http://stackoverflow.com/q/78465704
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138336524
has comment: http://stackoverflow.com/comment/138331937
has title: Bash wants unary operator
has comment: http://stackoverflow.com/comment/138337469
answer count: 1
has comment: http://stackoverflow.com/comment/138332332
has comment: http://stackoverflow.com/comment/138332837
has comment: http://stackoverflow.com/comment/138332310
has comment: http://stackoverflow.com/comment/138336048
has comment: http://stackoverflow.com/comment/138332689
has comment: http://stackoverflow.com/comment/138331938
has comment: http://stackoverflow.com/comment/138332087
has answer: http://stackoverflow.com/a/78471577
has comment: http://stackoverflow.com/comment/138332024
has comment: http://stackoverflow.com/comment/138332715
has body: I am using the following code to test if a function exists but Bash gives the following diagnostic: [: =: unary operator expected The code is: if [ $(type -t deactivate) != function ]; How should this be expressed in a shell script independent manner?
has comment: http://stackoverflow.com/comment/138334721
tagged with: compare
tagged with: bash
accepted answer: http://stackoverflow.com/a/78471577
has comment: http://stackoverflow.com/comment/138334085
has comment: http://stackoverflow.com/comment/138333044
has comment: http://stackoverflow.com/comment/138332295
has comment: http://stackoverflow.com/comment/138331975
has comment: http://stackoverflow.com/comment/138333053
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/85880
has comment: http://stackoverflow.com/comment/138332034
has comment: http://stackoverflow.com/comment/138331989
has comment: http://stackoverflow.com/comment/138333540
has comment: http://stackoverflow.com/comment/138331813
has comment: http://stackoverflow.com/comment/138331955
has comment: http://stackoverflow.com/comment/138331963

http://stackoverflow.com/a/78485450
has body: I think your issue here is that PECL creates a registry file of what it thinks is currently installed, so as soon as you switch to a different PHP version, that registry file is no longer appropriate. After each build step, remove the registry file that PECL just created, so that it doesn't use that existing file for the next step -- and I think you'll be good to go: rm /usr/share/php/.registry/.channel.pecl.php.net/oci8.reg Note this will show incorrect output for pecl list in the future. Alternatively, you can build the packages manually, without using the pecl install wrapper: pecl download oci8-3.3.0 # (or whatever version is appropriate for your PHP) tar xzf oci8-3.3.0.tgz cd oci8-3.3.0 phpize ./configure --with-oci8=instantclient,/path/to/dir make mv modules/oci8.so $(php-config --extension-dir) chmod 644 $(php-config --extension-dir)/oci8.so # might need this And then you'd have to also manually adjust your php.ini to load the module.
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/138367369
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78484913
accepted answer of: http://stackoverflow.com/q/78484913
upvote count: 1
type: Answer

http://stackoverflow.com/q/78573908
has body: I made a script that setups a LEMP stack: #!/usr/bin/env bash if tput colors >/dev/null 2>&1; then RED='\033[0;31m' YELLOW='\033[1;33m' CYAN='\033[1;35m' NC='\033[0m' # No Color else RED='' GREEN='' YELLOW='' NC='' fi print_help() { echo -e "Usage: ${YELLOW}$0${NC} [options]" echo -e "${CYAN}Options:${NC}" echo " --php_ver <version> Specify PHP version (default is 8.2)" echo " --nodb Do not install any database" echo " --db_root_password <pass> Set root password for the database" echo " -h, --help Show this help message" } cleanup () { echo -e "${CYAN}Cleanup${NC}" apt-get autoremove && apt-get autoclean exit 0; } if [ "$EUID" -ne 0 ]; then echo -e "${RED}ERROR: Run this script as root or via using sudo.${NC}" echo print_help exit 1; fi export DEBIAN_FRONTEND=noninteractive PHP_VERSION="8.2" DB_TYPE="mariadb" while [ "$1" != "" ]; do case $1 in "--php_ver") PHP_VERSION=$2 shift 2 ;; "--nodb") DB_TYPE="none" shift ;; "--db_root_password") DB_ROOT_PASSWORD=$2 shift 2 ;; "-h" | "--help") print_help exit 0 ;; *) echo -e " ${RED}Invalid option: ${YELLOW}$1${NC}" exit 1 ;; esac done apt-get update && apt-get upgrade -y if [ "$PHP_VERSION" == "" ]; then echo -e "${RED}No php version provided defaulting into 8.2${NC}" PHP_VERSION="8.2" fi echo -e "${CYAN}PHP ${YELLOW}$PHP_VERSION${CYAN} will be installed ${NC}" apt-get install -y nginx ca-certificates apt-transport-https software-properties-common add-apt-repository -y ppa:ondrej/php apt-get update apt-get install -y php${PHP_VERSION}-fpm \ php${PHP_VERSION}-mbstring \ php${PHP_VERSION}-mysql \ php${PHP_VERSION}-oauth \ php${PHP_VERSION}-opcache \ php${PHP_VERSION}-readline \ php${PHP_VERSION}-xml if [ "$DB_TYPE" == 'none' ];then echo -e "${YELLOW}No Db support will be installed${NC}" cleanup exit 0; fi POOL_CONF="/etc/php/${PHP_VERSION}/fpm/pool.d/www.conf" if [ -f "$POOL_CONF" ]; then echo -e "${CYAN}Configuring PHP-FPM to listen on ${YELLOW}127.0.0.1:9000${NC}" sed -i "s|^listen = .*|listen = 127.0.0.1:9000|" "$POOL_CONF…
tagged with: terraform
accepted answer: http://stackoverflow.com/a/78576357
score: 0
has title: How I can provide arguments into my script if run as userdata in terraform?
possible better answer: http://stackoverflow.com/a/78579389
answer count: 2
tagged with: linux
has comment: http://stackoverflow.com/comment/138524077
tagged with: bash
has answer: http://stackoverflow.com/a/78576357
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78579389
tagged with: cloud-init
type: Question

http://stackoverflow.com/comment/138432327
has text: @WilliamPursell: Reformulated using "replaced" as in `man bash`.
comment on: http://stackoverflow.com/a/78522891
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/q/78579093
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138536536
has comment: http://stackoverflow.com/comment/138533272
has body: I am trying to write a shell script which has a part where I have to use some kind of loop to execute some commands if condition satisfy. I want to understand what is the best way to approach this problem. Lets say there are 3 flags #export flag1=1 #export flag2=1 #export flag3=1 These are commented in the beginning. While running the script, I want to enable these flags one after the other. So for that I have written a if else loop in such way. if [[ -n ${flag1} ]]; then #some commands elif [[ -n &quot;${flag2}&quot; ]]; then #some commands elif [[ -n ${flag3} ]]; then #some commands else #some commands fi But, when I enable flag1 it goes to else loop and it's giving different result than expected. What's the best way to approach this issue? Should I use case instead of if else loop ?
has comment: http://stackoverflow.com/comment/138536149
has answer: http://stackoverflow.com/a/78579342
tagged with: loops
tagged with: switch-statement
tagged with: bash
has comment: http://stackoverflow.com/comment/138533244
upvote count: 1
accepted answer: http://stackoverflow.com/a/78579342
downvote count: 1
type: AnsweredQuestion
tagged with: if-statement
has comment: http://stackoverflow.com/comment/138536581
has comment: http://stackoverflow.com/comment/138533294
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138533532
tagged with: shell
has title: Which is better in this scenario - if else loop or case in shell scripting?

http://stackoverflow.com/q/78508971
has comment: http://stackoverflow.com/comment/138407305
has title: Why my bash script works in the terminal but fails in a script with a function involved and ssh call?
has answer: http://stackoverflow.com/a/78509705
has body: I have #!/bin/bash function installed (){ ssh "secondnode" 'echo $(dpkg-query -W ${1} 2>&1|awk '\''{if ($0 ~ /no packages/) {print "not installed"} else {print "installed"}}'\'')') } VAR1=$(installed "somepackage") echo $VAR1 The output is correct for the first run. To get a correct output for a new run I need to modify the function command, for instance add "${1}" and save. However the same line of myfunction in the terminal (not a script) runs perfectly, of course, replacing ${1} with "somepackage". It seems like the previous output is stored somewhere and never changed... On the other hand, how can I improve my code with a function to know if a package is installed or not in a remote node? Seems like mine doesn't work properly.
tagged with: awk
has comment: http://stackoverflow.com/comment/138409086
linked to: http://stackoverflow.com/q/10067266
has comment: http://stackoverflow.com/comment/138411018
tagged with: bash
downvote count: 2
linked to: http://stackoverflow.com/q/673055
has comment: http://stackoverflow.com/comment/138411524
has answer: http://stackoverflow.com/a/78511496
has comment: http://stackoverflow.com/comment/138407274
score: -1
type: Question
has comment: http://stackoverflow.com/comment/138407382
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78511400
has comment: http://stackoverflow.com/comment/138407677
favorite count: 0
has comment: http://stackoverflow.com/comment/138411028
answer count: 3
upvote count: 1

http://stackoverflow.com/comment/138354588
has text: BTW, the code as posted fails, if `VAR` contains spaces, or has the value `x`. Don't tell me that you found this in real, productive code???
type: QuestionComment
comment on: http://stackoverflow.com/q/78477621
type: Comment
score: 0

http://stackoverflow.com/comment/138334300
type: Comment
comment on: http://stackoverflow.com/q/78466816
type: QuestionComment
has text: BTW, this is an example of [the XY problem](https://xyproblem.info/) (Ask about X, not Y.) If source and destination are on different file systems, `rsync -a /source/ /destination` could help. (I’d go with `rsync -aAXUNHS ...` to preserve as much metadata as possible.) If source and destination share the same filesystem and if it’s a proper copy-on-write filesystem (as it should be), always prefer taking snapshots over massive copying. As long as `source` is a subvolume: `btrfs subvolume snapshot /source /destination`. _Half a day_ becomes half a second. (Add `-r` for a read-only snapshot.)
score: 2

http://stackoverflow.com/q/78503442
has comment: http://stackoverflow.com/comment/138398137
has comment: http://stackoverflow.com/comment/138398164
has comment: http://stackoverflow.com/comment/138398972
has comment: http://stackoverflow.com/comment/138398062
has comment: http://stackoverflow.com/comment/138398072
has comment: http://stackoverflow.com/comment/138398102
has comment: http://stackoverflow.com/comment/138398108
has comment: http://stackoverflow.com/comment/138398086
has comment: http://stackoverflow.com/comment/138398093
has comment: http://stackoverflow.com/comment/138398141
tagged with: bash
type: Question
answer count: 0
type: UnansweredQuestion
tagged with: terminal
has comment: http://stackoverflow.com/comment/138400910
has title: How do I start a python program x times at the same time from terminal and print the output?
has comment: http://stackoverflow.com/comment/138398118
has comment: http://stackoverflow.com/comment/138409038
tagged with: zsh
has body: I am on Mac, and I need to execute this python program 5 times at the same time while giving each of them a parameter like this. python program.py instance-1 python program.py instance-2 python program.py instance-3 python program.py instance-4 python program.py instance-5 I am thinking I should do this asynchronously, so I do this from a .sh file. #!/bin/zsh for i in {1..5} python program.py instance-$i &amp; done I think the ampersand (&amp;) makes it async but now it only works in the background? Meanwhile I want to see the output in my terminal. How do I achieve this? I already tried the following and it also doesn't work. #!/bin/zsh for i in {1..5} python program.py instance-$i | tee /dev/tty &amp; done wait Does anyone have any idea? I am not exactly familiar with bash command in general. Also, I think it's zsh but I am not sure if there is any difference.
has comment: http://stackoverflow.com/comment/138398977
has comment: http://stackoverflow.com/comment/138398111
score: 0
has comment: http://stackoverflow.com/comment/138398965
tagged with: command-line-interface
tagged with: macos

http://stackoverflow.com/comment/138502499
has text: See [How can I debug a Bash script?](https://stackoverflow.com/q/951336/4154375).
type: Comment
comment on: http://stackoverflow.com/q/78561775
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138398941
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78465027
has text: But it's not the same thing, __FILE__ gives you the path to the source no matter where you are executing from while getcwd() it's a runtime value
type: Comment

http://stackoverflow.com/q/78491313
linked to: http://stackoverflow.com/q/66908468
tagged with: bash
has comment: http://stackoverflow.com/comment/138377701
type: Question
has comment: http://stackoverflow.com/comment/138377553
has comment: http://stackoverflow.com/comment/138381236
has answer: http://stackoverflow.com/a/78491920
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138377767
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/138377496
has comment: http://stackoverflow.com/comment/138377559
has comment: http://stackoverflow.com/comment/138377582
has comment: http://stackoverflow.com/comment/138377637
has comment: http://stackoverflow.com/comment/138377542
has comment: http://stackoverflow.com/comment/138377648
has comment: http://stackoverflow.com/comment/138377554
has comment: http://stackoverflow.com/comment/138511213
has comment: http://stackoverflow.com/comment/138377364
has title: Format JSON Date Value with Quotes for Bash Script
score: 0
has comment: http://stackoverflow.com/comment/138377666
has comment: http://stackoverflow.com/comment/138377875
has comment: http://stackoverflow.com/comment/138377529
answer count: 1
has comment: http://stackoverflow.com/comment/138377286
has comment: http://stackoverflow.com/comment/138377485
has comment: http://stackoverflow.com/comment/138377610
has body: Hi I have a bash script which i am reading from a JSON using jq and writing to another JSON object. The dates from he feed are formatted in ISO8601 like "2024-05-16T08:00:00-05:00", bash doesnt like. I can convert the dates from epoch time to friendly format. An example line from my script reading the raw JSON epoch time: 1715864400 from the feed and format to friendly with this one liner. dt=$(date -d @$(cat "${DrawC}" | jq '.[].EpochTime | .')) But it is not quoted, I need to have it double quoted to read the string in my new file otherwise I get an Invalid numeric literal error. I've tried formatting, using quotes in all kinds of ways around the variable. Cant seem to get it, searched but most of the results seem to think I'm asking how to use quotes in a bash script. Thanks
has comment: http://stackoverflow.com/comment/138377810

http://stackoverflow.com/q/78462933
favorite count: 0
downvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78466548
has comment: http://stackoverflow.com/comment/138333354
possible better answer: http://stackoverflow.com/a/78465427
linked to: http://stackoverflow.com/q/6696842
has comment: http://stackoverflow.com/comment/138327573
has comment: http://stackoverflow.com/comment/138328442
has comment: http://stackoverflow.com/comment/138328540
has answer: http://stackoverflow.com/a/78466548
has comment: http://stackoverflow.com/comment/138327269
has comment: http://stackoverflow.com/comment/138330862
score: 0
type: Question
has answer: http://stackoverflow.com/a/78466056
has comment: http://stackoverflow.com/comment/138328645
has comment: http://stackoverflow.com/comment/138327283
has title: bash "while read line" loop, with variables as file input
has comment: http://stackoverflow.com/comment/138327546
answer count: 3
has comment: http://stackoverflow.com/comment/138331045
has comment: http://stackoverflow.com/comment/138327264
has comment: http://stackoverflow.com/comment/138327267
has comment: http://stackoverflow.com/comment/138327263
tagged with: loops
tagged with: bash
has answer: http://stackoverflow.com/a/78465427
has body: The sample code, and the idea as follows while read url; do wget -q $url -O - | grep -o -E 'href="([^"#]+)"' | grep "magazine/" | grep "https" | sort -u | sed -r 's/.*href="([^"]+).*/\1/g' >> list1 perl -ne 'print unless $dup{$_}++;' list1 > list done < list The initial line of the list is https://abc.xyz/issues/, from here wget wants to find one particular url link to the previous "issue", of the exact format of https://abc.xyz/issues/yyyy/mm/dd (filter by grep, remove duplicates by sort, and extract the url link by sed), then add the url link to the "list", such url link then be used to get the next url link in the "while read line" loop...and the perl line wants to remove duplicates in the list once new url link(s) added to the list, before new url link being processed in the loop. So this is the idea, and the ideal result should be a list with hundreds of url links for all past issues. Would appreciate some suggestions or better, a simple solution (myself has very basic knowledge of shell command)
upvote count: 1

http://stackoverflow.com/comment/138436693
comment on: http://stackoverflow.com/q/78525043
type: QuestionComment
type: Comment
has text: If you get many consecutive notifications, you'll keep starting and killing impressive.
score: 0

http://stackoverflow.com/comment/138502170
has text: Immediate problems I see: you're using `FILE` in the `for` loop, but `file` inside it; these are different variable names. Also, wildcards won't expand when inside quotes, so you want `for file in "${fp}"/*`. `$file` will include the path (`$fp`), so adding it *again* with `filepath=$fp$file` doesn't make sense (especially since you then remove it with `basename`). I'd recommend fixing these, running your script through [shellcheck.net](https://www.shellcheck.net) and fixing what it points out, then running it with debug tracing (`set -x` or `set -xv`) to see what's happening as it runs.
type: QuestionComment
comment on: http://stackoverflow.com/q/78561775
type: Comment
score: 0

http://stackoverflow.com/comment/138411018
comment on: http://stackoverflow.com/q/78508971
score: 0
type: QuestionComment
has text: You are right. I fixed the typo. the function is `function installed (){...}`
type: Comment

http://stackoverflow.com/comment/138355677
comment on: http://stackoverflow.com/q/78478782
has text: @LéaGris Try this: `echo -n Enter password:\ ;echo Password is: $(sed 1q)` ( under `sh` too ;-)
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138331045
has text: Shouldn't it be `wget -q "$url"` ...` ? Also, it's a good idea to copy/paste your code into https://shellcheck.net and fix any flagged problems. Be sure to include #!/bin/bash (or other) as your first line of scripting.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78462933
score: 0

http://stackoverflow.com/q/78574995
has comment: http://stackoverflow.com/comment/138525626
tagged with: shell
answer count: 1
favorite count: 0
score: -5
tagged with: bash
has title: AWK command to print names of files an hour old
type: Question
has body: I want to print the file names that start with file from a given directory that are at least 1 hour old using AWK, the way find /tmp/test/ -mmin +60 does. Please help me out with the awk command.
type: UnansweredQuestion
tagged with: awk
has answer: http://stackoverflow.com/a/78576279
has comment: http://stackoverflow.com/comment/138526922
has comment: http://stackoverflow.com/comment/138525571
has comment: http://stackoverflow.com/comment/138527594
upvote count: 0
downvote count: 5

http://stackoverflow.com/q/78471612
has title: Repository version storage issues
tagged with: linux
tagged with: spanish
has comment: http://stackoverflow.com/comment/138342596
type: UnansweredQuestion
tagged with: bash
tagged with: git
has comment: http://stackoverflow.com/comment/138342425
has comment: http://stackoverflow.com/comment/138342467
has answer: http://stackoverflow.com/a/78472225
answer count: 1
has body: I have a problem with my code, I need to extract the release version of my program in order to compare versions and, if necessary, update it. My full program is in this repository:autonetplan The specific file I need help is this one: autonetplan.sh Line 296-320 I'm having problems on the update system, the input is: autonetplan -u And the output is: jq: parse error: Invalid numeric literal at line 8, colum 10 # Revisar actualización y comparar # Obtener la última versión desde GitHub sobre el programa latest_release=$(curl -s "https://github.com/Nisamov/autonetplan/releases/tag/autonetplan" | jq -r '.tag_name') # Obtener ultima version # Extraer el número de versión del nombre del release latest_version=$(echo "$latest_release" | sed -n 's/.*v\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p') # Verificar si hay una nueva versión disponible if "$latest_version" != "$current_version" ; then echo "¡Nueva versión disponible! Versión actual: $current_version, Última versión: $latest_version" # Solicitar actualizacion read -p "¿Desea actualizar el programa? [s/n]: " updaterequest if $updaterequest == "s" ; then # Código para actualizar el programa echo "Actualizando el programa..." elif $updaterequest == "n" ; then # Cancelacion de actualizacion echo "[#] Se ha cancelado la actualizacion" exit 1 else echo "[#] Se ha añadido un parámetro no registrado, cancelando actualización..." exit 1 fi else echo "Tu programa ya está actualizado. Versión actual: $current_version" fi
tagged with: github
score: 0
type: Question

mplab-x
tag name: mplab-x
tags question: http://stackoverflow.com/q/78485242
type: Tag

http://stackoverflow.com/q/78522211
tagged with: bash
has answer: http://stackoverflow.com/a/78527839
favorite count: 0
has comment: http://stackoverflow.com/comment/138441202
type: Question
answer count: 4
type: UnansweredQuestion
has title: How to get string "arm64" on an aarch64 Linux system?
has comment: http://stackoverflow.com/comment/138441124
upvote count: 1
has answer: http://stackoverflow.com/a/78522229
has comment: http://stackoverflow.com/comment/138431869
has answer: http://stackoverflow.com/a/78522376
has body: I want to get the string arm64 in a bash script. root@ubuntu-arm-test:# uname -a Linux ubuntu-arm-test 5.15.0-105-generic #115-Ubuntu SMP Mon Apr 15 09:52:04 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux I could do something like this: #!/bin/bash # Get the machine hardware name arch=$(uname -m) # Convert aarch64 to arm64 if [ "$arch" == "aarch64" ]; then echo "arm64" else echo "$arch" fi But I would like to have a simpler way. root@ubuntu-arm-test:~# cat /proc/sys/kernel/arch cat: /proc/sys/kernel/arch: No such file or directory root@ubuntu-arm-test:~# uname -a Linux ubuntu-arm-test 5.15.0-105-generic #115-Ubuntu SMP Mon Apr 15 09:52:04 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux` Update I am very confused. The string arm64 is very common in package names, and there is no straight forward way to get to this string.
tagged with: linux
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/78537876

http://stackoverflow.com/comment/138463902
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78540951
has text: `PROMPT_COMMAND` doesn't need to be exported and arguably shouldn't be: If a child-process shell inherits the PROMPT_COMMAND but doesn't inherit the functions it uses, it'll throw errors. Leave it as a regular shell variable, not an environment variable; that way, child processes can get it by running `.bashrc` themselves if they want to.

http://stackoverflow.com/comment/138359510
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78479842
has text: Thank you so much for sharing shellcheck, I've updated the code with fixes where required.
score: 0

http://stackoverflow.com/comment/138509666
comment on: http://stackoverflow.com/q/78562624
has text: Also try adding `export LC_ALL=C` at the top of your script to see if your problem is related to your locale.
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/138514045
comment on: http://stackoverflow.com/q/78567995
score: 0
has text: I don't see anything in your code which would mysteriously remove codes, but I would not exclude a problem with the way you construct `-Dexec.args`. I don't know maven, but if the argument passed here would undergo word splitting somewhere, you would break up your json strings on the whiute spaces.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138424648
type: Comment
score: 0
has text: If the server returns different results to the same request, that's an issue with the server, not your code. Most likely it's some kind of rate limiting.
comment on: http://stackoverflow.com/q/78515364
type: QuestionComment

http://stackoverflow.com/q/78570866
has comment: http://stackoverflow.com/comment/138518518
tagged with: cron
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78571173
has comment: http://stackoverflow.com/comment/138518879
has comment: http://stackoverflow.com/comment/138518112
score: 0
has title: cron log shows the job is running but actually the job is failing
has comment: http://stackoverflow.com/comment/138518080
tagged with: amazon-ec2
answer count: 1
tagged with: python
has body: I have a cron job in aws ec2 instance defined as: 0 2 * * * /home/ec2-user/scripts/backup.sh 0 3 * * 0 /home/ec2-user/scripts/cleanup.sh 0 * * * * /home/ec2-user/scripts/health_check.sh I checked whether the jobs are running by : $ tail -f /var/log/cron Jun 3 02:00:01 ip-172-31-0-123 CROND[1234]: (ec2-user) CMD (/home/ec2-user/scripts/backup.sh) Jun 3 03:00:01 ip-172-31-0-123 CROND[1235]: (ec2-user) CMD (/home/ec2-user/scripts/cleanup.sh) Jun 3 04:00:01 ip-172-31-0-123 CROND[1236]: (ec2-user) CMD (/home/ec2-user/scripts/health_check.sh) Jun 3 05:00:01 ip-172-31-0-123 CROND[1237]: (ec2-user) CMD (/home/ec2-user/scripts/health_check.sh) It looked like the jobs are running. But on manually running one of the jobs, I found that the job was actually failing and throwing an error: $ /home/ec2-user/scripts/clean_up.sh Traceback (most recent call last): File "/home/ec2-user/scripts/worker_script.py", line 15, in <module> connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) File "/usr/local/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 360, in __init__ self._impl = self._create_connection(parameters, _impl_class) File "/usr/local/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection raise self._reap_last_connection_workflow_error(error) pika.exceptions.AMQPConnectionError: Connection to 127.0.0.1:5672 failed: [Errno 111] Connection refused Is there any way to know that the jobs are running successfully or not? and log the errors accordingly?
tagged with: linux
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138518175

http://stackoverflow.com/comment/138509713
has text: Stop using all upper case names for non-exported variables or you will shoot yourself in the foot some day if you aren't doing to already, see https://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization
comment on: http://stackoverflow.com/q/78564469
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/q/78529571
score: 0
type: Question
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138444036
has comment: http://stackoverflow.com/comment/138444475
linked to: http://stackoverflow.com/q/19570413
has comment: http://stackoverflow.com/comment/138444437
has comment: http://stackoverflow.com/comment/138444488
duplicate of: http://stackoverflow.com/q/19570413
has comment: http://stackoverflow.com/comment/138444024
has comment: http://stackoverflow.com/comment/138444048
tagged with: bash
has body: I have the following data that my grep command gives: $ grep match data.txt match key1 value1 match key2 value2 match key3 value3 I'd like to have an associative array that is the equivalent of: declare -A map=( ["key1"]="value1" ["key2"]="value2" ["key3"]="value3"). I managed to extract the key and value using awk e.g: $ grep match data.txt | awk '{print $2}' key1 key2 key3 I tried to populate the associative array, but I don't know what the syntax is: $ declare -A map $ grep match data.txt | map[$(awk '{print $2}')]=$(awk '{print $3}') # doesn't work
has title: How to create an associative array from grep result?
has comment: http://stackoverflow.com/comment/138444580

http://stackoverflow.com/a/78496236
type: Answer
answers question: http://stackoverflow.com/q/78495016
score: 2
has body: There might be some CRLF or leading/trailing blanks in the files, try stripping them: #!/bin/bash sed -e $'s/\r$//; s/^[[:space:]]*/; s/[[:space:]]*$//' a.txt b.txt | sort -b | uniq -u output: a.b.c.com c.d.e.com i.j.k.com
upvote count: 2
downvote count: 0

http://stackoverflow.com/comment/138427450
type: Comment
score: 0
type: QuestionComment
has text: No, I'm really not very interested in this age-old topic but if you have a question then please just ask it as a question.
comment on: http://stackoverflow.com/q/78520070

http://stackoverflow.com/a/78560669
type: Answer
answers question: http://stackoverflow.com/q/78560562
type: AcceptedAnswer
has body: A web search on bash find exec function should bring up several hits that cover various ways to slice-n-dice this. One idea: export -f fastq_countGzReads # export the function so it can be # referenced in a follow-on subshell ### and now a tweak to OP's find/-exec find . -iname "*gz" -exec bash -c 'fastq_countGzReads {}' \;
downvote count: 0
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78560562

http://stackoverflow.com/comment/138546518
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78581308
has text: I can't see a way to do this robustly that did not depend on reimplementing all of `curl`'s argument parsing. Maybe it's not too complex but it seems like more work than it's worth.
score: 0

http://stackoverflow.com/comment/138367469
comment on: http://stackoverflow.com/q/78485715
type: QuestionComment
has text: how does generate arguments work? what does it return?
type: Comment
score: 0

http://stackoverflow.com/comment/138463236
comment on: http://stackoverflow.com/q/78534641
has text: @EdMorton I would say that it's typical of SO; when there's a sample input and expected output for illustrating the problem, the answers tend to get overly simplified to just handle of the sample data (sometimes right on the bullet). Here I can only blame myself for not having chosen a better sample.
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138415740
comment on: http://stackoverflow.com/q/78513595
has text: the question has been tagged `bash` but the script's shebang is `#!/bin/sh` (not necessarily `bash`); please update the question to explicitly state the shell you're using
score: 3
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78448081
type: Answer
score: 0
has body: The issue might be that the == operator in the [[ ]] test is doing pattern matching, not substring matching. If you want to check if current_Department contains Department, you should use the =~ operator instead. Here is an example: departments="" lineNumber=0 # Header Line while IFS=',' read -r server department; do # Skip the header if (( lineNumber == 0 )); then lineNumber=1 continue fi # Trim whitespace (example has entries with space in the end) department=$(echo "$department" | xargs) # Check if the department is already in the list if ! $departments =~ /$department/ ; then departments+="/$department/" fi done < input.csv # Remove the extra slashes echo ${departments:1:-1} | tr -s '/'
answers question: http://stackoverflow.com/q/78447882

http://stackoverflow.com/comment/138526624
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78572114
has text: @EdMorton, ...true, but if `./orca_stdin.sh <test.inp` worked, we know that an explicit `-` isn't needed in this particular case.

http://stackoverflow.com/q/78447803
has title: Create a bash script with multiple arguments using getopts
type: UnansweredQuestion
has body: I want to create a bash script that accepts some arguments and has the following usage: $ ./execute.sh add person --id 123 --name John I found getopts and was trying to use it to parse the options but without success. My current code is: #!/bin/bash command=$1 entity=$2 while getopts ":id:name:" opt; do echo "opt: ${opt}" case ${opt} in id) id=$OPTARG ;; name) name=$OPTARG ;; \?) echo "Invalid option: $OPTARG" 1>&2 ;; :) echo "Option -$OPTARG requires an argument." 1>&2 ;; esac done if [ -z "${id}" ] || [ -z "${name}" ]; then echo "Missing required options" 1>&2 echo "Usage: $0 <command> <entity> --id <number> --name <string>" exit 1 fi case $command in add) echo "adding entity $entity..." ;; *) echo "invalid command: $command" exit 1 ;; esac But with that, the output I have is: Missing required options Usage: ./execute.sh <command> <entity> --id <number> --name <string> So, it seems that it's not parsing the options at all, but I'm not sure why. Any help and tips appreciated.
tagged with: command-line-arguments
tagged with: command-line-interface
tagged with: bash
duplicate of: http://stackoverflow.com/q/192249
has comment: http://stackoverflow.com/comment/138304526
score: 0
type: Question
tagged with: shell
answer count: 0

http://stackoverflow.com/comment/138456561
score: 0
type: QuestionComment
type: Comment
has text: On a closing note, the issue may be related to using WSL in some way. I tried configuring it to use Windows COM as the Terminal, but it seemed to auto-detect Ubuntu and git-bash.exe.
comment on: http://stackoverflow.com/q/78530614

http://stackoverflow.com/q/78553320
type: Question
score: 3
has body: I have a file with the contents: manufacturer,model,year,mileage,price plym fury 1970 73 2500 chevy malibu 1999 60 3000 ford mustang 1965 45 10000 volvo s80 1998 102 9850 ford thundbd 2003 15 10500 chevy malibu 2000 50 3500 bmw 315i 1985 115 450 honda accord 2001 30 6000 ford taurus 2004 10 17000 toyota rav4 2002 180 750 chevy impala 1985 85 1550 ford explor 2003 25 9500 I'm asked to sort the file by the name of the manufacturer first and then by the price in reverse. I've implemented the same by the command: (head -n 1 a) &amp;&amp; (tail +2 a | sort -k1,1 -k5nr) And gives me the correct output: manufacturer,model,year,mileage,price bmw 315i 1985 115 450 chevy malibu 2000 50 3500 chevy malibu 1999 60 3000 chevy impala 1985 85 1550 ford taurus 2004 10 17000 ford thundbd 2003 15 10500 ford mustang 1965 45 10000 ford explor 2003 25 9500 honda accord 2001 30 6000 plym fury 1970 73 2500 toyota rav4 2002 180 750 volvo s80 1998 102 9850 However if I modify sort -k1,1 -k5nr to sort -k1,1 -nrk5, I get manufacturer,model,year,mileage,price ford taurus 2004 10 17000 ford thundbd 2003 15 10500 ford mustang 1965 45 10000 volvo s80 1998 102 9850 ford explor 2003 25 9500 honda accord 2001 30 6000 chevy malibu 2000 50 3500 chevy malibu 1999 60 3000 plym fury 1970 73 2500 chevy impala 1985 85 1550 toyota rav4 2002 180 750 bmw 315i 1985 115 450 How does one subtle difference change the entire output and what difference does it make? I tried referring to various sources but none of them help.
upvote count: 3
tagged with: bash
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/78553404
type: AnsweredQuestion
tagged with: gnu-sort
has title: Does the order of GNU sort command arguments matter?
has answer: http://stackoverflow.com/a/78553404
downvote count: 0

http://stackoverflow.com/q/78585407
has title: Build Dpkg from bitbucket pipeline gives "dpkg-deb: error: control directory has bad permissions 777 (must be >=0755 and <=0775)"
type: UnansweredQuestion
downvote count: 0
has body: I'm trying to build .deb package from the bitbucket pipeline but end up with this error msg. dpkg-deb: error: control directory has bad permissions 777 (must be &gt;=0755 and &lt;=0775) tried to change the folder's permission with 755 but it didn't help either. I also tried to build with different Debian docker images but nothing helped. this is the bitbucket pipeline yaml I use. image: debian:buster-slim pipelines: default: - step: name: Build dpkg and push to S3 bucket image: debian:buster-slim deployment: Test caches: - pip script: - apt-get update &amp;&amp; apt-get install -y - cd .. - mkdir process-mgmt-svc - cp -rp build/. process-mgmt-svc - chmod 755 process-mgmt-svc - dpkg-deb --build process-mgmt-svc services: - docker
has comment: http://stackoverflow.com/comment/138545300
answer count: 1
favorite count: 0
tagged with: bitbucket-pipelines
tagged with: linux
has comment: http://stackoverflow.com/comment/138544984
tagged with: bash
score: 1
has comment: http://stackoverflow.com/comment/138545478
tagged with: deb
upvote count: 1
tagged with: dpkg-buildpackage
type: Question
has answer: http://stackoverflow.com/a/78611366

http://stackoverflow.com/comment/138356308
type: Comment
score: 0
has text: See [How to check if a variable is set in Bash](https://stackoverflow.com/q/3601515/4154375) and [How to check if a variable is set in Bash](https://stackoverflow.com/q/3601515/4154375).
comment on: http://stackoverflow.com/q/78477621
type: QuestionComment

http://stackoverflow.com/comment/138411792
type: Comment
has text: `awk '/no packages/{f=1; exit} END{print (f ? "not " : "") "installed"; exit f}'` would eliminate the duplicate code FWIW. Usually tools that search for anything (e.g. if you were using `grep 'no packages'` instead of `awk '/no packages/'` for this) exit with success (0) if that thing is found, not failure (1), and so then `exit f` would be `exit !f` (but I understand that then the shell function would need to negate it again, thereby introducing a double negative, so maybe having awk flip the usual exit status as you're doing is better in this case, idk).
type: AnswerComment
comment on: http://stackoverflow.com/a/78511496
score: 0

http://stackoverflow.com/comment/138416887
comment on: http://stackoverflow.com/q/78514371
type: QuestionComment
has text: Thank you all for your answers and your insightful remarks, I edited the post to correct everything that you pointed, I still don't get anything displayed on stdout though so I don't know if I made something wrong. Unfortunately, set -x is not helping very much since var has a lot of characters.
type: Comment
score: 0

http://stackoverflow.com/comment/138436003
score: 0
comment on: http://stackoverflow.com/a/78523083
type: Comment
has text: Right, redirection of output from a function or script cannot affect what happens within that function or script. Imagine you have a script named `foo` containing `echo 'hello' | sed 's/h/H/'`. When you run it as `./foo`, internally `echo 'hello'`s output feeds into the pipe and then becomes the input for `sed`. Externally `Hello` is printed to stdout and displayed on your terminal. If you run it as `./foo > file` then externally `foo`s output will now go to `file` instead of your terminal but within `foo` the output of `echo 'hello'` still goes to the pipe+sed, it doesn't go to `file`.
type: AnswerComment

http://stackoverflow.com/comment/138450908
comment on: http://stackoverflow.com/q/78533115
type: Comment
has text: @markp-fuso Added 3 examples of .md files that are shown in output. Corrected dir_in and dir_out. Groups are numbered for clarification. In reality they are names (foo, bar, etc). All items belonging to particular group are in folder named after the group. I will build a for loop over all folders (hence groups), make it a variable and name the group name in .md file after it. It is not present in here, just to keep it as brief as possible and I still working on it. Here the problem lies that I do not understand how to \newpage into file preserving the \n so it would be interpreted in markdown.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138520558
type: Comment
has text: Similar/duplicate questions include [How to prevent a background process from being stopped after closing SSH client in Linux](https://stackoverflow.com/q/285015/4154375), [How to make a program continue to run after log out from ssh?](https://stackoverflow.com/q/954302/4154375), and [Getting ssh to execute a command in the background on target machine](https://stackoverflow.com/q/29142/4154375).
score: 0
comment on: http://stackoverflow.com/q/78571808
type: QuestionComment

http://stackoverflow.com/q/78480751
type: Question
has comment: http://stackoverflow.com/comment/138367387
has title: How to pull from a remote repo to a local repo, when the local repo is not empty?
type: UnansweredQuestion
score: 1
has comment: http://stackoverflow.com/comment/138358745
has comment: http://stackoverflow.com/comment/138405790
tagged with: version-control
tagged with: remote-server
answer count: 0
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138367606
tagged with: git
upvote count: 1
has body: I have a remote server, with a directory containing files. I have a local machine with a directory containing different files. I want to link these two directories so I can run git pull and git push in my local directory. How can I achieve this ? I run git init on both local and remote. I run git remote add originName www.server.com:/path/to/remote/dir/ on local. I run git fetch originName. I create a new branch git branch test. I checkout this new branch git checkout test. I merge with the remote git merge remotes/originName/master. I would expect to see the remote files in the local repo at this stage, but I only have my local files. After running git merge remotes/originName/master again git returns with a message `Already up to date. What am I doing wrong or misunderstanding ? In case it is relevant, my local machine is behind a firewall so I cannot run git pull or git push from my remote to my local. Update So far I have achieved the following: Execute: a) git init b) git add * c) git commit * -m"git commit message." On both local and remote. Add the remote on local: git remote add remoteName www.url.com:/path/to/repo Download remote: git fetch remoteName Create new branch locally: git branch localBranch Move to local branch: git checkout localBranch Merge the local branch with the remote: git merge --allow-unrelated-histories remoteName/master Address merge conflicts I now have two branches locally - one containing local files, and one containing remote files. Update II I have been able to create a local and remote copy on my local machine by the following process: Create a backup of the local directory mv dirName dirNameBackup clone the remote repo that is also named dirName with git clone www.url.com:/path/to/dirName Move into dirName locally and create a new local branch with git branch local Checkout local branch git checkout local. Remove all remote files from local with rm -r * and git add -u * I now have the remote directory under the branch master and …
favorite count: 0
tagged with: local
has comment: http://stackoverflow.com/comment/138366825
has comment: http://stackoverflow.com/comment/138367837

http://stackoverflow.com/comment/138537321
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78581308
has text: Isn't the URL the only argument you can specify that *isn't* an option (i.e., an argument beginning with `-`)?

http://stackoverflow.com/comment/138411524
has text: Your edit to add the `function` keyword was not an improvement. It basically adds no value, and reduces the portability of code which could otherwise work in shells which do not use this essentially superfluous Bash-only keyword.
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78508971
type: QuestionComment

http://stackoverflow.com/a/78566339
answers question: http://stackoverflow.com/q/78564469
has body: Not an answer but too long for a comment. Try running: step=50 (( i = -step )) (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & (( i += step )); curl -s -g -X GET 'https://url.com?filter='"$i"'_filter' & then edit your answer to tell is if that produces the expected output or not and, if not, what is wrong with the output, what error messages do you get, etc.
score: 2
upvote count: 2
downvote count: 0
type: Answer

http://stackoverflow.com/comment/138497059
has text: Couldn’t you just replace commas in `$var_ips`, rather than converting to and from a Bash array, e.g. something like `echo "[\"${var_ips/,/\",\"}\"]"`?
type: Comment
comment on: http://stackoverflow.com/q/78559080
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138317779
comment on: http://stackoverflow.com/q/78457170
type: QuestionComment
has text: Unable to reproduce: https://ideone.com/R9ubBK
score: 2
type: Comment

http://stackoverflow.com/comment/138391627
score: 1
comment on: http://stackoverflow.com/q/78499350
type: QuestionComment
type: Comment
has text: Surely the original command does not work properly on host `Computer`. Even if you take out the comment, whose embedded quotes mess up your quoting, the outer double quotes will prevent word splitting separating the `bash`, `-c`, and quoted block of commands. Even if `eval` worked the way you hoped, then, the proposed alternative wouldn't work on host `Computer` either.

http://stackoverflow.com/comment/138545528
comment on: http://stackoverflow.com/q/78576313
score: 0
type: QuestionComment
type: Comment
has text: That's exactly why I keep suggesting to put them elsewhere.

http://stackoverflow.com/comment/138377081
type: Comment
has text: [Shellcheck](https://www.shellcheck.net/) identifies several problems with the code. The report that it produces includes links to more information about the problems and how to fix them. It's a good idea to run [Shellcheck](https://www.shellcheck.net/) on all new and modified shell code.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78489249

http://stackoverflow.com/comment/138502149
comment on: http://stackoverflow.com/q/78561876
has text: Does this really need an answer? This is basic shell syntax for substituting the output of a command. There have been plenty of similar questions in the past.
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/138501730
type: Comment
comment on: http://stackoverflow.com/q/78561294
score: 0
has text: But be aware that `x=3; y=7; chessboard["$x, $y"]` is identical to `foo='3, 7'; chessboard["$foo"]` - it is NOT a 2-dimensional array, it's a 1-dimensional array with a concatenated index and if you want to use that as a pseudo-2-dimensional array like POSIX awk has, I'd strongly recommend you find some character other than `,` to separate the index substrings, e.g. at least `$'\n'` or something more exotic.
type: QuestionComment

http://stackoverflow.com/q/78464004
has comment: http://stackoverflow.com/comment/138330515
has body: I want to search and replace strings but keep the case intact using sed For example, if I want to replace all occurrences of foo with bar, it should work like this: foo --&gt; bar FoO --&gt; BaR fOO --&gt; bAR FOO --&gt; BAR
has answer: http://stackoverflow.com/a/78464855
type: Question
has comment: http://stackoverflow.com/comment/138329974
has comment: http://stackoverflow.com/comment/138329071
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/29613304
has answer: http://stackoverflow.com/a/78464583
has comment: http://stackoverflow.com/comment/138329104
downvote count: 3
tagged with: awk
tagged with: sed
score: -1
upvote count: 2
has comment: http://stackoverflow.com/comment/138330291
has comment: http://stackoverflow.com/comment/138330504
tagged with: bash
answer count: 5
has answer: http://stackoverflow.com/a/78467468
favorite count: 0
has answer: http://stackoverflow.com/a/78464547
has title: Find and replace while preserving case with sed
has answer: http://stackoverflow.com/a/78470155
has comment: http://stackoverflow.com/comment/138329500
has comment: http://stackoverflow.com/comment/138329901
tagged with: unix

macos-big-sur
tags question: http://stackoverflow.com/q/78452463
tag name: macos-big-sur
type: Tag

http://stackoverflow.com/comment/138464301
score: 1
has text: `PROCINFO["sorted_in_place"] = 1` isn't some undocumented feature - it's you manually creating a new array cell with an index that *sorta* looks like the `gawk` one but doesn't actually do anything. `gawk` allows you to add superfluous entries to `PROCINFO` and simply ignores anything not documented. You can even do `PROCINFO["sorted_by_FS"] = ""` too if you like. `gawk` wouldn't complain at all, but also nothing happens as a result since `sorted_by_FS` isnt part of its lingo
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78539085

http://stackoverflow.com/q/78525458
has body: I'm looking for a simple way to run bash -c 'cmd' from the current bash shell such that all variables and functions defined in the current shell are available in the bash -c 'cmd' sub-process (i.e. as if everything were exported for just this one sub-process). P.S. Anything that relies on double quotes (e.g bash -c "cmd $parent_var") won't work. Also I wasn't able to get these answers to work either: Bash export variables but only for current command (primarily because it assumes I already have all the appropriate variables/functions in a nice clean text file)
has answer: http://stackoverflow.com/a/78525480
score: 0
has title: How to export everything for just one bash -c "cmd" command?
has comment: http://stackoverflow.com/comment/138436657
has comment: http://stackoverflow.com/comment/138442154
accepted answer: http://stackoverflow.com/a/78525480
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138437137
has comment: http://stackoverflow.com/comment/138436681
has comment: http://stackoverflow.com/comment/138437146
has comment: http://stackoverflow.com/comment/138436918
has comment: http://stackoverflow.com/comment/138436637
has comment: http://stackoverflow.com/comment/138437329
has comment: http://stackoverflow.com/comment/138436986
has comment: http://stackoverflow.com/comment/138437336
has comment: http://stackoverflow.com/comment/138436840
has comment: http://stackoverflow.com/comment/138436737
answer count: 1
linked to: http://stackoverflow.com/q/62223386
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138436879

http://stackoverflow.com/comment/138364863
comment on: http://stackoverflow.com/q/78484156
type: Comment
score: 0
has text: @knittl I wanted to construct an array out of that, which apparently failed I think.
type: QuestionComment

http://stackoverflow.com/comment/138436879
comment on: http://stackoverflow.com/q/78525458
type: Comment
has text: Your assertions about what "won't work" are suspect. `"$(declare -p varname)"`, for example, evaluates to code that, when run, defines that variable. `$(declare -f funcname)"` likewise for functions. Call then with all variables or all functions listed on the command line, and why wouldn't that work? (Yes, naively expanding a single variable isn't workable, but it's not as if that's all one can do).
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138498718
type: Comment
has text: Why don't you define it as array in the first place? `var_ips=( 10.10.10.177 10.10.10.181 )"`
comment on: http://stackoverflow.com/q/78559080
score: 1
type: QuestionComment

http://stackoverflow.com/a/78570500
answers question: http://stackoverflow.com/q/78570217
has comment: http://stackoverflow.com/comment/138517908
has body: 1) awk 1 Place this in mathew.awk. The first sub removes the final ; in $2 and the second sub removes everything up to the last ; remaining in $2 and finally print $2. { sub(/;[[:space:]]*$/, "", $2); sub(/.*;/,"",$2); print $2 } and then run it with the following where mathew.dat is the data file. awk -f mathew.awk mathew.dat 2) awk 2 An alternative is the following. First split $0 into fields where spaces and/or semicolons are separators and then print the field before the last. awk -F"[[:space:];]+" "{print $(NF-1)}" mathew.dat 3) R In R read the data, take the second column, trim off junk at the end of the lines, remove everything up to the last ; and write it back out. "mathew.dat" |> read.table() |> _$V2 |> trimws(whitespace = "[;[:space:]]") |> sub(".*;", "", x = _) |> writeLines() 4) qsv The qsv utility (releases) is available for Linux, Mac and Windows. squeeze runs of whitespace down to a single space, trim whitespace off ends and replace remaining whitespace with semicolons, insert empty semicolon separated fields after the first field giving 20 fields and then pick off field 19. 20 can be replaced with any number equal or greater than the largest number of fields in any row after spaces are replaced with semicolons and 19 can then be replaced with one less. Below we have used the Windows ^ continuation character but if on Linux use backslash instead. qsv apply -n operations squeeze,trim,replace 1 ^ --comparand " " --replacement ; mathew.dat | ^ qsv fixlengths -d; -i1 -l20 | ^ qsv select 19 5) choose The choose utility is similar in purpose to cut but also supports negative fields numbered from the end. This extracts the second field (which is referred to as 1 since it is zero based) and then from that selects the last semicolon separated field. It seems to ignore the empty field at the end. choose 1 < mathew.dat | choose -f ; -1 Update Add (2) and simplify. Add (3). Add (4) and simplify. Deal with tabs as suggested in comments by @Ed Morton. Add (5)
has comment: http://stackoverflow.com/comment/138517961
type: Answer
has comment: http://stackoverflow.com/comment/138521987
has comment: http://stackoverflow.com/comment/138517978
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/138520000
upvote count: 5

http://stackoverflow.com/comment/138425634
type: Comment
comment on: http://stackoverflow.com/q/78515364
score: 0
has text: You should also consider A/B testing
type: QuestionComment

http://stackoverflow.com/comment/138462667
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78534641
has text: I see you're getting some answers that assume you want to print from where the string `data` appears in the input on rather than wanting to print from the 3rd field on. Those are 2 very different problems that each can benefit from quite different solutions. If you change one of the 2nd field values, e.g. `1.2` to `data` and one of the 3rd field values from `data` to `foodatabar` that should make what you're asking about even clearer (though I thought it was already clear that you wanted "a method in awk for splitting only the first N columns").
score: 0

http://stackoverflow.com/comment/138483727
score: 0
type: Comment
has text: Try to put quotes like `az sql db list --resource-group "$rgName" --server "$serverName"`
comment on: http://stackoverflow.com/q/78551049
type: QuestionComment

http://stackoverflow.com/comment/138327546
type: QuestionComment
has text: @Barmar it doesn't work...running it returns back to prompt immediately, and without any new link in the list...after grep filter, the wget line sometimes still return url links more than just one, and the perl command try to remove such duplicates...thanks for the grep suggestion, I will try it later
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78462933

http://stackoverflow.com/comment/138473918
has text: Oh, my manager did something similar to that: ``` cut -f 2 -d , the_file.csv | tr -c '[:alnum:]' '[\n*]' | sort | uniq -c | sort -nr | head -10 ``` his numbers differed from mine, but at least at the top, we had the same 4 or 5, in a different order (the only one that kept the order was the one with 27k items)
score: 0
comment on: http://stackoverflow.com/a/78545793
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138526524
has text: What does your `launch.json` look like?
score: 0
comment on: http://stackoverflow.com/q/78575374
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138502529
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78561775
type: QuestionComment
has text: You are using test operator in wrongw way here: `[[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]`, you should use internal test -o option `$confrm == y -o $confirm == Y ` then you are trying to use regexp in wrong way with, So my final recommendation is: `[[ $confirm =~ [yY][eE]?[sS]? ]]`

http://stackoverflow.com/comment/138418318
comment on: http://stackoverflow.com/a/78509705
score: 0
type: Comment
type: AnswerComment
has text: Global variables are universally a bad idea, for extremely well-documented reason. The function's argument should be an explicit parameter, like the OP attempted. In other words, what @Fravadona pointed out can be solved two ways, but their comment implies keeping the global variable, which is obviously the worse solution.

http://stackoverflow.com/comment/138376595
has text: You're calling `sh` with `#!/bin/sh` but then using bash-specific syntax, e.g. with `function`. Don't do that. Pick a shell, name it in the shebang, then use the syntax for that shell. In this case, get rid of the word `function` as even in bash you don't need it, and change your shebang to `#!/usr/bin/env bash`.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78489249

dialog
tags question: http://stackoverflow.com/q/78549319
tags question: http://stackoverflow.com/q/78539667
tags question: http://stackoverflow.com/q/78557294
tag name: dialog
tags question: http://stackoverflow.com/q/78519611
type: Tag
tags question: http://stackoverflow.com/q/79013914
tags question: http://stackoverflow.com/q/78948937
tags question: http://stackoverflow.com/q/79215370
tags question: http://stackoverflow.com/q/79209488
tags question: http://stackoverflow.com/q/79441406

http://stackoverflow.com/comment/138311113
type: Comment
has text: Also, if you say that `$closest_date` can hundreds of MBs large, I think you shouldn't store it in a variable. You should put it in a file, or integrate it into the pipeline if you can.
comment on: http://stackoverflow.com/q/78451797
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138426750
type: Comment
has text: What do you mean by "I added perms for Termux"? No matter what you do the app private data (this includes all the Termux commands) are not accessible from other apps. That is a core concept of Android.
score: 0
comment on: http://stackoverflow.com/q/78519993
type: QuestionComment

http://stackoverflow.com/comment/138441202
has text: Of course, you could also just shorten your if/else statement: `"$arch" == "aarch64" && echo "arm64" || echo "$arch"`. Then it would become a one-liner without the need of using if and else, but I'd strongly recommend the answer given by @nomad85
type: QuestionComment
comment on: http://stackoverflow.com/q/78522211
type: Comment
score: 0

http://stackoverflow.com/a/78576827
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78576519
has body: Following the comment i received i fixed it, here's how: I took Charles Duffy's advice and modified it. You were right that the download takes place in parts which was confirmed by the output of the script. I threw my comments out, trimmed the code and placed a sleep to the correct location where i think it reads the file names after they are closed for writing, waits (so if writing happens in parts such as downloading it can continue, resetting the cycle), then executes the second part: #!/bin/bash #Directory to be watched DIR_TO_WATCH="$HOME/Downloads/" #Directory to copy the files to DEST_DIR="$HOME/Games/battlenet/drive_c/users/hori/Documents/Warcraft III/Maps/Download/" inotifywait -m "$DIR_TO_WATCH" -e close_write | while read path action file do sleep 2 if "$file" == *.w3x ; then if [ ! -f "$DEST_DIR/$file" ]; then cp "$path$file" "$DEST_DIR" fi fi done

http://stackoverflow.com/a/78461956
answers question: http://stackoverflow.com/q/78461484
has comment: http://stackoverflow.com/comment/138325422
has comment: http://stackoverflow.com/comment/138325455
downvote count: 0
has comment: http://stackoverflow.com/comment/138326016
upvote count: 1
score: 1
type: Answer
has body: Rantings in the comments apart- keep in mind that when you do sed ... in Bash, for example, you are running an entire subprocess - an OS backed subprocess, with a lot of overhead - while in Python, a function call will just run a couple opcodes. The same goes for ls, and almost all "commands" but for a few that are built-in. There are exceptions that had been made a built-in over time as echo. People proficient in Bash will usually know how to avoid these traps, and just don't call subprocess in loops. Hence people in the comments telling you to "never use ls in a script". On the other hand a language like Python has a standard syntax will run everything in a single process, and if one needs to run something in a external process, that is quite explicit - function calls will take up to 1000x less OS resources than an external process running.

http://stackoverflow.com/a/78480805
upvote count: 6
downvote count: 0
has comment: http://stackoverflow.com/comment/138359293
answers question: http://stackoverflow.com/q/78480780
score: 6
type: Answer
has body: The easiest solution is just to quote: $ var='before {{BODY_PARAM}} after' $ body_arg='body' $ echo &quot;${var/'{{BODY_PARAM}}'/$body_arg}&quot; before body after If for some reason you're attached to the curly-braces in the replacement section, more quoting lets you keep those too: $ echo &quot;${var/'{{BODY_PARAM}}'/&quot;${body_arg}&quot;}&quot; before body after (All transcripts above from bash 5.2.15).

http://stackoverflow.com/a/78537521
type: Answer
has body: With your shown samples only, please try following awk code. awk ' match($0,/[[:space:]]+data[[:space:]]+.*$/){ value=substr($0,RSTART,RLENGTH) sub(/^[[:space:]]+/,&quot;&quot;,value) print value } ' Input_file
downvote count: 0
answers question: http://stackoverflow.com/q/78534641
has comment: http://stackoverflow.com/comment/138457956
score: 5
upvote count: 5

signature
tag name: signature
type: Tag
tags question: http://stackoverflow.com/q/78587909

http://stackoverflow.com/a/78516011
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/138419522
score: -1
has body: As @Biffen already pointed out, $1 is expanded too early. Fix for your problem: alias totalcpu="ps -A -o pcpu | tail -n+2 | awk '{sum+=\$1} END {print sum}'"
answers question: http://stackoverflow.com/q/78515934
has comment: http://stackoverflow.com/comment/138460905
type: Answer

http://stackoverflow.com/comment/138349546
has text: There's no need for the FIFO. Simply pipe the output of the first `tar` to the input of the second — optionally with `pv` (pipe viewer) inserted in between.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78475452

http://stackoverflow.com/q/78490743
has comment: http://stackoverflow.com/comment/138376860
has comment: http://stackoverflow.com/comment/138376500
answer count: 1
has comment: http://stackoverflow.com/comment/138376496
accepted answer: http://stackoverflow.com/a/78491054
has comment: http://stackoverflow.com/comment/138376762
has comment: http://stackoverflow.com/comment/138376472
has comment: http://stackoverflow.com/comment/138376646
tagged with: bash
has comment: http://stackoverflow.com/comment/138376827
tagged with: sublimetext3
type: AnsweredQuestion
has body: I have the following line for my Sublime text build system json: "shell_cmd": "osascript -e 'tell application \"Terminal\" to do script \"ssh root@1.2.3.4 \"'" It works fine, but now I should add -t 'ls -la; bash -l' after ssh command. I wanted to escape ' characters with backslash (\'), but Sublime doesn't accept it: "shell_cmd": "osascript -e 'tell application \"Terminal\" to do script \"ssh root@1.2.3.4 \'ls -la; bash -l\'\"'" I tried to replace " with ' and vice versa, but it also doesn't work with Sublime. What else can I try? Upd. here is the command, which works well from the command line: osascript -e 'tell application "Terminal" to do script " ssh root@1.2.3.4 -t \"ls -la; bash -l\" " '
has answer: http://stackoverflow.com/a/78491054
has comment: http://stackoverflow.com/comment/138376713
has comment: http://stackoverflow.com/comment/138376650
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/138376571
has comment: http://stackoverflow.com/comment/138376613
tagged with: osascript
has comment: http://stackoverflow.com/comment/138376593
has comment: http://stackoverflow.com/comment/138376279
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138376512
has comment: http://stackoverflow.com/comment/138376637
has comment: http://stackoverflow.com/comment/138376506
has title: Quoting a shell command inside an osascript command run by a shell inside a JSON file

http://stackoverflow.com/q/78514371
tagged with: bash
has comment: http://stackoverflow.com/comment/138419063
has comment: http://stackoverflow.com/comment/138416724
type: Question
has comment: http://stackoverflow.com/comment/138420387
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138416887
has comment: http://stackoverflow.com/comment/138417139
duplicate of: http://stackoverflow.com/q/229551
has comment: http://stackoverflow.com/comment/138416752
has title: Struggling with basic string comparison in bash scripting
linked to: http://stackoverflow.com/q/229551
has comment: http://stackoverflow.com/comment/138416721
has comment: http://stackoverflow.com/comment/138419559
has comment: http://stackoverflow.com/comment/138416689
score: 0
answer count: 0
has comment: http://stackoverflow.com/comment/138420637
has body: So I am starting to learn bash scripting and here is my issue, I have to compare 2 strings and figure out if one of them has more than 113450 and if so, if the var variable contains the elements of the other string. One of my 2 variables (var) is evolving at each iteration. That's pretty straight forward and I thought that I came up with a good solution but it seems like the 2 conditions are never met and nothing gets displayed on the screen, although I know that it's supposed to work. Here is my code : #!/bin/bash var="8dm7KsjU28B7v621Jls" value="ERmFRMVZ0U2paTlJYTkxDZz09Cg" for i in {1..40} do var=$(echo "$var" | base64) if [ ${#var} -gt 113450 ]; then if "$var" =~ *$value ; then echo -e "Conditions met\n" echo "$var" | tail -c 20 break fi fi done

boto3
type: Tag
tags question: http://stackoverflow.com/q/78584835
tags question: http://stackoverflow.com/q/78464573
tag name: boto3

http://stackoverflow.com/comment/138332837
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78465704
has text: Cyrus They are not portable to all scripting languages.
score: 0

http://stackoverflow.com/comment/138365545
has text: @CharlesDuffy, judging from the result, it looks to me as if `bash` isn't nesting the braces as I would like and instead interpreting the first close brace as the end of entire `${}`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78480780
score: 0

http://stackoverflow.com/comment/138509593
comment on: http://stackoverflow.com/q/78562624
has text: Why did the `t` at the end of `hb-shape "$font" t` in your original script at the start of your question become `⌘` in the script you say is working at the end of your question?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138465612
comment on: http://stackoverflow.com/a/78541741
has text: after read bash manual, `;` and `&` are metacharacter, they separate words, while `{` and `}` are keywords
score: 2
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138463880
has text: The basic problem here is that the `if` is testing the exit status of the `spinner` function, not the `git` command. As for `$!`, that gets the process ID of the most backgrounded `git` command.
comment on: http://stackoverflow.com/q/78538302
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/q/78564469
has comment: http://stackoverflow.com/comment/138506877
has answer: http://stackoverflow.com/a/78587535
downvote count: 2
tagged with: bash
has comment: http://stackoverflow.com/comment/138506794
has comment: http://stackoverflow.com/comment/138506795
has comment: http://stackoverflow.com/comment/138509717
upvote count: 1
score: -1
type: Question
has comment: http://stackoverflow.com/comment/138509723
tagged with: shell
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138509763
linked to: http://stackoverflow.com/q/673055
has comment: http://stackoverflow.com/comment/138509713
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/78566339
has answer: http://stackoverflow.com/a/78564589
has body: I am trying to run a function through multiple processes in bash (on CentOs). The function does different filtering over curl: STEP=50 function filtering() { local i="$1" curl -s -g -X GET 'https://url.com?filter='$i'_filter' } for (( i=0; i<=TOTAL; i+=STEP )); do filtering "$i" done wait It works when runs as is. However, when i run the function in 10 processes it behaves odd, bringing every time different results, mostly unreliable (according to the produced numbers in comparison to the serial filtering above). My code is: PARALLEL_PROCESSES=10 ACTIVE_PROCESSES=0 for (( i=0; i<=TOTAL; i+=STEP )); do filtering "$i" > /dev/null 2>&1 & (( ACTIVE_PROCESSES++ )) if (( ACTIVE_PROCESSES >= PARALLEL_PROCESSES )); then wait -n 2> /dev/null (( ACTIVE_PROCESSES-- )) fi done wait When I check all the printed filters everything looks fine. I think curl doesn't get something correctly. GNU parallel doesn't do my task as well. I thought debugging the own paralellisation would be easier. TOTAL is defined programmatically before the iteration starts. It stands to express the total count of the API filters so that further i split it into chunks of 50. Sometimes TOTAL can be 10K and more. The '$i'_filter' itself consists of 50 filtering elements, while this API supports up to 100. The length limit of the request is not reached, the waf and rate limit doesn't block me. This function retrieves some data of (let's say) candies. This data being parsed with jq like jq -r '.data[] | .id, .name, '"$label"' | @csv' By unreliable results I mean inconsistently different results between 2 and more closely launched individual iterations. While the serial approach always delivers the same true results. This makes me feel that in the parallelisation something chaotic being submitted to the filter. I'd very appreciate practical advices how to debug what is going on/wrong inside, and any alternative suggestion for achieving my goal.
has title: debugging multi-processing in bash

http://stackoverflow.com/q/78457170
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138317683
has comment: http://stackoverflow.com/comment/138317779
has comment: http://stackoverflow.com/comment/138317765
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138317755
has comment: http://stackoverflow.com/comment/138317606
answer count: 1
has body: I am trying to write a bash script to create a filename using some variables, I should add "-" character in some places to obtain the correct filepath. However when I use the following command, it turns me an empty space instead of - character: FILEDIR=${root_path}${year}/${month}/${day}/${filename_zero}"_"${year}"-"${month}"-"${day}"-"${filename_one} public/2024/03/18/105610_2024 03 18 12:33:42.mp4 The result that I need: public/2024/03/18/105610_2024-03-18-12:33:42.mp4 I have tried many other things like single quote, non-quote, but it doesnt work...
has title: cant put substraction character as string
tagged with: bash
tagged with: escaping
has answer: http://stackoverflow.com/a/78457368
tagged with: quoting

http://stackoverflow.com/comment/138474073
type: QuestionComment
type: Comment
has text: While not completely 'anwering my question', some of the suggestions above, like moving the commands to process into a separate `function` each, have been acknowledged and applied in my (final) solution below. Other suggestions helped regarding the appropriate application of `tee` in the examples below. Depending on the use case, one of the partways or alternative solutions may work better, or suffice. The final solution, which addresses all requirements, uses a bit of everything, plus `eval`, though. Feel free to suggest improvements.
comment on: http://stackoverflow.com/q/78519611
score: 0

http://stackoverflow.com/a/78465396
type: AcceptedAnswer
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/78464573
type: Answer
accepted answer of: http://stackoverflow.com/q/78464573
has body: This is caused by the default command execution timeout on the SSM document: The time, in seconds, for a command to complete before it is considered to have failed. The default is 3600 (1 hour). The maximum value is 172800 (48 hours). Send the executionTimeout with your parameters. Example here.

http://stackoverflow.com/a/78494827
downvote count: 0
score: 1
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138410523
answers question: http://stackoverflow.com/q/78494598
has body: Untested since I don't have and don't want to create the directory structure your script and input file would require for testing: Using GNU awk for the non-POSIX extensions of a 3rd arg to match() plus nextfile since the OP has now told us their log file is huge: #!/usr/bin/env bash while IFS= read -r file; do -f "$file" && >&2 echo mv -f -- "$file" '/home/category3/sub1/' done < <( awk ' NR == FNR { if ( match($0,/Fail at (.*) is not found/,a) ) { ARGV[ARGC++] = a[1] } else { print > "newlog.txt" } next } /^CARD=[0-9]/ { print FILENAME nextfile } ' convert.20231010.log ) If you don't have GNU awk then do this instead with any awk which will just run a bit slower if your awk doesn't support nextfile (few other awks support a 3rd arg to match() but many support nextfile and the nextfile statement will do nothing if not supported so it's harmless): #!/usr/bin/env bash while IFS= read -r file; do -f "$file" && >&2 echo mv -f -- "$file" '/home/category3/sub1/' done < <( awk ' BEGIN { beg = "Fail at " end = " is not found" begLgth = length(beg) allLgth = length(beg end) } NR == FNR { if ( match($0,beg ".*" end) ) { ARGV[ARGC++] = substr($0,RSTART+begLgth,RLENGTH-allLgth) } else { print > "newlog.txt" } next } /^CARD=[0-9]/ { print FILENAME nextfile } ' convert.20231010.log ) The -f "$file" && in the shell loop protects us from any issue if the same file name appears multiple times in the input, or /^CARD=[0-9]/ matches multiple times in 1 file and your awk doesn't support nextfile, and so we may have already moved it at that point in the shell loop. Original answer: $ cat tst.sh #!/usr/bin/env bash regexp='Fail at (.*) is not found' while IFS= read -r line; do file="" $line =~ $regexp && file="${BASH_REMATCH[1]}" if -f "$file" && ! grep -q '^CARD=[0-9]' "$file"; then >&2 echo mv -f -- "$file" '/home/category3/sub1/' else printf '%s\n' "$line" fi done < convert.20231010.log > newlog.txt Remove the >&2 echo when you're done testing and sure t…
accepted answer of: http://stackoverflow.com/q/78494598
has comment: http://stackoverflow.com/comment/138384569
has comment: http://stackoverflow.com/comment/138402379
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138411190
has comment: http://stackoverflow.com/comment/138401899

http://stackoverflow.com/q/78530810
tagged with: post
tagged with: curl
tagged with: bash
answer count: 1
has body: I get curl: (26) Failed to open/read local data from file/application when uploading (with POST) a file with -F "file=@$file", in bash.
has answer: http://stackoverflow.com/a/78530811
score: 0
type: Question
has title: POST upload: curl: (26) Failed to open/read local data from file/application
type: UnansweredQuestion
tagged with: escaping

http://stackoverflow.com/q/78491375
answer count: 2
tagged with: azure-cli
type: Question
tagged with: azure
upvote count: 1
has body: Currently when I try to update azure app config I can do this: az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 This will prompt me something like this: ---------------- Key Values Preview ---------------- Updating: - {"key": "URL", "value": "\"www.test.myapp.com\""} + {"key": "URL", "value": "\"www.test2.myapp.com\""} Do you want to continue? (y/n): y now when I update the command to have -y for my pipeline since I want it to be automated, I stop seeing the preview: az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 -y Is there a way to still show the preview with the -y flag? I feel like this is very valuable information that we need in our logging. UPDATE: I tried: az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 && yes | head -n 1 and I got the following: Unable to prompt for confirmation as no tty available. Use --yes.
tagged with: azure-app-configuration
tagged with: bash
type: UnansweredQuestion
score: 1
downvote count: 0
has answer: http://stackoverflow.com/a/78795211
favorite count: 0
has title: Azure App Config import cli command: How can I show preview when passing in -y flag
has answer: http://stackoverflow.com/a/78527266

http://stackoverflow.com/comment/138383228
type: Comment
comment on: http://stackoverflow.com/q/78494598
has text: so, i said that i'm not familiar with shell, that why i'm asking . If can not , pls exception it. Thank so much.
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138340455
type: Comment
comment on: http://stackoverflow.com/q/78470611
type: QuestionComment
has text: See `-delete` switch of `find` command!
score: 0

http://stackoverflow.com/comment/138323749
type: Comment
has text: I noticed some of the lines in your file has end-of-line spaces. That could be messing up your uniqueness checks.
score: 0
comment on: http://stackoverflow.com/q/78447882
type: QuestionComment

http://stackoverflow.com/comment/138517897
comment on: http://stackoverflow.com/q/78570217
has text: What have you tried? https://idownvotedbecau.se/noattempt/ - Show what you *did* so people can help explain *why* it didn't work, as that both helps solve your problem and provides examples for the next person.
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78586078
answer count: 1
favorite count: 0
has title: How to retrieve text from the current line at specified cursor position before and after up to specified boundary characters?
upvote count: 4
has comment: http://stackoverflow.com/comment/138546631
tagged with: bash
has comment: http://stackoverflow.com/comment/138546671
type: AnsweredQuestion
downvote count: 1
has body: Examples of boundary characters can be: "", '', (), space, ^$ (start and end of the line if any other boundary characters are not specified explicitly). Boundary characters should be easily configurable. "", '', () boundary characters should have more priority over space boundary character. If no boundary characters are found in the line, ^$ (start and end of the line) should be considered as boundary characters. Text inside boundary characters is URI (directory path, file path, http address, etc). But it is not required to check URIs on pattern correctness. Let assume that inside boundary characters can be any text. Redundant space characters should be trimmed. Below different examples with lines of text, cursor position, boundary characters and what should be extracted. Symbol | in examples shows current cursor position. It will not be present in actual lines as symbol |. Only its position number is known. But in examples I will use | character for visual clarity. And it will be visually present only if it affects the result (otherwise it can be anywhere in the line). Examples of lines with cursor positions and boundary characters, text that should be retrieved from them (after ->) and comment (after #): (line with cursor -> extracted text # comment) ~ -> ~ # cursor can be anywhere in the line, result should be the same, "~" extracted ~ -> ~ # the same but with trimmed spaces, "~" extracted ~/.local/share/applications -> ~/.local/share/applications # spaces trimmed, "~/.local/share/applications" extracted /home -> /home '~/te st' -> ~/te st # result should be the same no matter where the cursor is located |"~/te st1" '~/te st2' -> ~/te st1 # border case: cursor touches boundary character, "~/te st1" extracted "~/te st1"| '~/te st2' -> ~/te st1 # border case, same result "~/te st1" |'~/te st2' -> ~/te st2 # border case, "~/te st2" extracted "~/te st1" '|~/te st2' -> ~/te st2 "~/te st1" '~/te st2|' -> ~/te st2 "~/te st1" '~/te st2'| -> ~/te st2 # border case, "~/te …
tagged with: awk
has comment: http://stackoverflow.com/comment/138547167
has answer: http://stackoverflow.com/a/78587616
tagged with: text-processing
has comment: http://stackoverflow.com/comment/138546704
tagged with: regex
has comment: http://stackoverflow.com/comment/138546548
type: Question
accepted answer: http://stackoverflow.com/a/78587616
tagged with: text-editor
score: 3

http://stackoverflow.com/comment/138464412
type: AnswerComment
score: 0
has text: @user3049941 : macs nowadays are actually great - it's a `GUI` interface comparable to Windows (not the awkward sorta GUI that is Gnome and KDE in `Linux`), is a full blown `BSD 4.4` beneath the surface without any extra layers like Microsoft's approach to `Linux`, while being powered by a CPU that's making Intel panic scream. The most extreme test I've ever done saw `gawk w/ GMP` complete a Mersenne prime validation in slightly less than 4 mins while python3 kept going for 45mins - for ONE SINGLE number (and I already used their built in `pow( )` with 3 args instead of writing custom func.
comment on: http://stackoverflow.com/a/78539309
type: Comment

http://stackoverflow.com/comment/138506036
comment on: http://stackoverflow.com/a/78564146
type: Comment
type: AnswerComment
score: 0
has text: Or better: `for dir ... ; do find ... -type f -print0 ;done | tar -cvfz "mpe-tar/part_2.tgz" --null -T -`

http://stackoverflow.com/comment/138353339
score: 1
has text: This works as expected. Thanks a lot for your help.
comment on: http://stackoverflow.com/a/78477646
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78485572
has body: See edit below Looks like you're simply trying to see if a port is open on a host, or making sure firewall is open via telnet. At first glance it looks like your attempts may have been waiting for an open telnet connection to close. Try it with forced close on successes, as in my examples below. Here's what I tested and it works. You'll get different results for failures and successes. Here's my tests with variable contents: Success (Checking if port open via telnet): # telnet_output=$(echo close | telnet localhost 80) Connection closed by foreign host. # echo $telnet_output Escape character is '^]'. Failure (Port not open): # telnet_output=$(echo close | telnet localhost 6969) telnet: connect to address ::1: Connection refused telnet: connect to address 127.0.0.1: Connection refused # echo $telnet_output Trying 127.0.0.1... ====== EDIT, Actual answer (I hope) ====== Sorry I misread your post, seems you're actually sending a command and wanting the ACTUAL response, here's what worked for me: Success. Connect to telnet, send command, store response in variable, echo response: # telnet_output=$({ echo "GET / HTTP/1.1"; echo "Host: localhost"; echo; sleep 1; } | telnet localhost 80) Connection closed by foreign host. # echo $telnet_output HTTP/1.1 302 Found Date: Wed, 15 May 2024 20:03:01 GMT Server: Apache Location: http://localhost/xxxx/Login.do Content-Length: 213 Content-Type: text/html; charset=iso-8859-1 302 Found Found The document has moved here. Hope this helps :)
answers question: http://stackoverflow.com/q/78484949
downvote count: 0
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/comment/138517908
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78570500
score: 0
has text: This was my first thought, but you beat me to it. :)

http://stackoverflow.com/comment/138469902
score: 2
type: Comment
has text: Really, don't do this at all. As others have said -- make a systemd service. You don't need to use `pgrep` or any equivalent to it when you're doing proper process supervision, because the thing you're supervising just runs as a direct child of the supervisor. That means the supervisor is affirmatively notified when it shuts down, but can also do things like restart it, check its status, &c just by looking at its children; that's more reliable (can't incorrectly find different processes by the same name) and more efficient (doesn't need to scan the whole process tree).
comment on: http://stackoverflow.com/q/78541941
type: QuestionComment

http://stackoverflow.com/a/78559697
has comment: http://stackoverflow.com/comment/138499524
type: Answer
answers question: http://stackoverflow.com/q/78559360
has comment: http://stackoverflow.com/comment/138499376
has body: I got this working by changing my flags to single characters. Getops does not work with flags that a multi charactered. #!/bin/bash ### Pass Flags #Define the help function function help(){ echo "Options:"; echo "-r Resource Group Name" echo "-l Location of Resource Group" echo "-c Cluster Name" echo "-e Email for LetsEncrypt" echo "-d domainname for Nginx" exit 1; } #Initialize the default values for the variables. r="rg"; l="location"; c="cluster"; e="email"; d="domainname"; #Define the getopts variables options=":r:l:c:e:d:h"; #Start the getopts code while getopts ${options} opt; do case $opt in r) #Get the resourcegroupname rg=${OPTARG} ;; l) #Get the location location=${OPTARG} ;; c) #Get the cluster name cluster=${OPTARG} ;; e) #Get the email email=${OPTARG} ;; d) #Get the domain name domainname=${OPTARG} ;; h) #Execute the help function "echo here" help; ;; \?) #unrecognized option - show help echo "Invalid option." help; ;; esac done #This tells getopts to move on to the next argument. shift $((OPTIND-1)) #End getopts code #rg="jc-test29-aks-rg" #location="francecentral" #cluster="jc-aks-test29-cluster" ## Create RG echo "Creating Resource Group $rg" az group create --name $rg --location "$location" ## Create AKS Cluster echo "Creating AKS Cluster $cluster" az aks create -g $rg -n $cluster--enable-managed-identity --node-vm-size Standard_B2s --node-count 3 --load-balancer-sku Standard ## Conect to Cluster echo "Connecting to AKS Cluster" az aks get-credentials --resource-group $rg --name $cluster --overwrite-existing ## Wait for the Cluster to Come online. sleep 5m ## Add the Repos helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo add cert-manager https://charts.jetstack.io helm repo add argo https://argoproj.github.io/argo-helm ## Install nginx-ingress helm install nginx-ingress ingress-nginx/ingress-nginx \ --namespace ingress-nginx --create-namespace \ --set controller.replicaCount=2 \ --set controller.admissionWebhooks.patc…
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138498653
accepted answer of: http://stackoverflow.com/q/78559360
downvote count: 0
score: 1

http://stackoverflow.com/q/78449032
has comment: http://stackoverflow.com/comment/138303888
has comment: http://stackoverflow.com/comment/138304200
has comment: http://stackoverflow.com/comment/138304032
downvote count: 0
score: 1
tagged with: bash
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138304143
has comment: http://stackoverflow.com/comment/138303808
has comment: http://stackoverflow.com/comment/138309301
tagged with: azure-pipelines
type: Question
accepted answer: http://stackoverflow.com/a/78449576
has title: Access downloaded secure files through variables
tagged with: azure-devops
has body: I have a template for my Azure DevOps pipeline, which downloads multiple secure files. In the same template (and same job), another task that executes a bash script should access each secure file download one by one and access the secure file to do an operation. However, here I run into trouble. Say I have downloaded a secure file through task named 'downloadTask'. If I then access the secureFilePath through $(downloadTask.secureFilPath), this works great. However, in my case the task names are referenced in the for loop, like so: for taskName in $taskNames; do echo $(${taskName}.secureFilePath) When I try to run this command, I get the following error: downloadTask.secureFilePath: command not found. I'm confused about the issue that's causing this error, and am not getting much wiser. Which adjustments should I make to resolve this issue? Edit - add pipeline code: parameters: - name: credentials type: string - name: secureFileNames type: object default: [] steps: - ${{ each secureFileName in parameters.secureFileNames }}: - task: DownloadSecureFile@1 displayName: 'Download secure file: ${{ secureFileName }}' name: ${{ replace(secureFileName, '.', '_') }} inputs: secureFile: '${{ secureFileName }}' - task: AWSShellScript@1 displayName: 'someDisplayName' inputs: awsCredentials: ${{ parameters.credentials }} regionName: $(DEFAULT_REGION) scriptType: 'inline' inlineScript: | secureFileNames=&quot;${{ join(' ', parameters.secureFileNames) }}&quot; sanitizedTaskNames=${secureFileNames//./_} for taskName in $sanitizedTaskNames; do echo &quot;$(${taskName}.secureFileName)&quot; done
has comment: http://stackoverflow.com/comment/138303938
has comment: http://stackoverflow.com/comment/138303999
has answer: http://stackoverflow.com/a/78449576

http://stackoverflow.com/a/78458061
answers question: http://stackoverflow.com/q/78458050
has comment: http://stackoverflow.com/comment/138319030
type: Answer
has comment: http://stackoverflow.com/comment/138319074
has comment: http://stackoverflow.com/comment/138319066
downvote count: 0
score: 2
has comment: http://stackoverflow.com/comment/138319108
upvote count: 2
has body: Can you share the json file? You could try this. jq . foo.json > temp.json && mv temp.json foo.json This will first run jq . foo.json > temp.json. If jq succeeds, it will move temp.json to foo.json, overwriting it with the formatted JSON. If jq fails, temp.json won't be updated, and foo.json will remain unchanged. Update: if jq . foo.json > foo.json.tmp && mv foo.json.tmp foo.json; then echo "JSON formatted successfully" else echo "Failed to format JSON" rm -f foo.json.tmp fi Or you could try this, it will write the output to dev/null instead of creating a file. jq . foo.json > foo.json.tmp 2>/dev/null && mv foo.json.tmp foo.json If you want to try the try/catch function from jq I think it would go something like this. jq 'try . catch empty' foo.json > foo.json.tmp 2>/dev/null && mv foo.json.tmp foo.json I tried both "foo" and "foo with the codes above and they all change "foo" to "foo" or leave "foo alone.

http://stackoverflow.com/comment/138404347
score: 0
comment on: http://stackoverflow.com/q/78507226
has text: please update the question with a sampte set of data from the `mysql` call, making sure to include a couple lines that display your issue; also update the question with the expected results
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138381254
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78493443
score: 2
has text: Use `-q` switch in `grep` instead of redirecting to `/dev/null`.

http://stackoverflow.com/q/78499350
type: Question
has comment: http://stackoverflow.com/comment/138391717
has answer: http://stackoverflow.com/a/78499604
has body: Hello and thanks for the help. I ssh into several computers and execute a <Block-of-commands> on each. I've added a new computer that does not allow ssh. So <Block-of-commands> must be executed locally on this computer, not through ssh. ORIGINAL CODE: #!/bin/bash if [ "$HOSTNAME" = "Computer" ]; then "bash -c ' <Block-of-commands> #Block-of-commands done locally on "Computer" '" else ssh "Name@RemoteComputer" "bash -c ' <Block-of-commands> #Block-of-commands done remotely using ssh '" fi Unfortunately, the above code requires duplication the <Block-of-commands>, which complicates changes to <Block-of-commands>. (I could make <Block-of-commands> a separate file and call it, but that's just another complication. I'd like to keep all of the code in one file. Simple.) The code below eliminates the duplication. NON-DUPLICATING CODE ALTERNATIVE: #!/bin/bash STRING='' #Default to local (no ssh command) [ "$HOSTNAME" != "Computer" ] && STRING='ssh Name@RemoteComputer' #if not on "Computer", then add remote ssh login eval $STRING \ "bash -c ' <Block-of-commands> '" Unfortunately, the "eval" line fails. "eval" has issues with adding anything after the STRING and with ending the line on a QUOTE. I've tried several combinations of the "eval" line (BACK-SLASHES before QUOTES, putting "bash -c ' into the STRING, etc.), but they all fail. I'd appreciate guidance or suggestions on how to just add or subtract "ssh Name@RemoteComputer" in the command which executes <Block-of-commands>. Again, thanks for the help.
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138399167
tagged with: eval
has comment: http://stackoverflow.com/comment/138391627
score: 0
answer count: 2
has title: How to "eval" a multi-line command?
tagged with: bash
has answer: http://stackoverflow.com/a/78499377

http://stackoverflow.com/a/78533676
score: 3
type: AcceptedAnswer
upvote count: 3
answers question: http://stackoverflow.com/q/78533115
has body: $ title='#Title of group 1 \newpage' $ printf '%s\n' "$title" #Title of group 1 \newpage $ See why-is-printf-better-than-echo to learn about the problems with echo, see https://mywiki.wooledge.org/Quotes to learn when to use single vs double vs no quotes and always run your code through http://shellcheck.net until you get more familiar with shell programming.
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/78533115

http://stackoverflow.com/a/78464583
has comment: http://stackoverflow.com/comment/138332477
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138333109
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/138331517
has comment: http://stackoverflow.com/comment/138330675
has comment: http://stackoverflow.com/comment/138330603
has comment: http://stackoverflow.com/comment/138332220
has body: Neither tool has the facilities to do this straightforwardly. With POSIX sed it's hard to come up with anything better than just enumerating the replacements: sed -e ' s/foo/bar/g s/Foo/Bar/g s/fOo/bAr/g s/foO/baR/g : Some modern sed versions have nonstandard Perl conveniences like \L for case conversion, but there still is no convenient way to test the case of an input character. With Awk, at least you can generate this script from the inputs. awk -v from="foo" -v to="bar" ' BEGIN { if (length(from)!=length(to)) { print "length mismatch" >"/dev/stderr" exit(42) } n = length(from) for(i=1; i<=n; i++) { f[i] = tolower(substr(from, i, 1)) g[i] = toupper(substr(from,i, 1)) t[i] = tolower(substr(to, i, 1)) u[i] = toupper(substr(to, i, 1)) } for(i=0; i<2**n; ++i) { a = b = "" q = i k = 2**(n-1) for(j = 1; j<=n; j++) { c = (q > 0) && (q - k >= 0) a = a (c ? f[j] : g[j]) b = b (c ? t[j] : u[j]) if (c) q -= k k = int(k/2) } s[a] = b } } { for(r in s) gsub(r, s[r]) } 1' This generates a bitmap to direct the logic while generating the array of substitutions s; when the bit in the current position is 1, we select the lowercase version of the current character, otherwise uppercase. Regular Awk does not have bitwise operators, so we use regular arithmetic to figure out the value of the current bit. (GNU Awk has support for bitwise logic, but really, it wouldn't simplify this much.) The array s contains all the generated substitution pairs (s["foo"] = "bar", s["foO"] = "baR", s["fOo"] = "bAr", etc etc) and so for (r in s) loops over them all and replaces any matches it finds. The Awk solution will exit with an error if the strings are of different length. Demo: https://ideone.com/liZ3nh With Perl, I imagine this would be somewhat more straightforward; but you asked about a sed or Awk solution, so I didn't go there. Both of these solutions will replace transitively, i.e. if your replacement string matches the input string, you could get multiple substitutions, depending on how exa…
answers question: http://stackoverflow.com/q/78464004
has comment: http://stackoverflow.com/comment/138330623

http://stackoverflow.com/q/78561775
has comment: http://stackoverflow.com/comment/138523738
has comment: http://stackoverflow.com/comment/138502529
has comment: http://stackoverflow.com/comment/138526667
has comment: http://stackoverflow.com/comment/138514334
has answer: http://stackoverflow.com/a/78576845
has comment: http://stackoverflow.com/comment/138502651
has comment: http://stackoverflow.com/comment/138518942
has comment: http://stackoverflow.com/comment/138502154
has comment: http://stackoverflow.com/comment/138519033
tagged with: bash
has title: How do I loop through mgz files and convert them to nii files using a shell script and freesurfer?
type: Question
linked to: http://stackoverflow.com/q/951336
accepted answer: http://stackoverflow.com/a/78576845
has comment: http://stackoverflow.com/comment/138519051
has body: I need to automate converting mgz files into nii files using freesurfer. I have tried a number of different tactics, but for some reason my script wont loop through the files and they can't be read. It isn't a permission problem because I can do other commands on the files. I have created a shell script that prompts the user for the file path for whichever folder the files are stored in. When I run it, it says "mri_convert: missing output volume name type mri_convert -u for usage". Here is my script with the loop: #!/bin/bash #ask user for filepath - Works read -p "Enter filepath: " fp #confirm filepath - Works read -p "Continue? You said ${fp} (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 #loop through files for FILE in "${fp}/*" do #seperate file extentsion and name filepath=$fp$FILE filename_with_ext=$(basename $filepath) filename="${filename_with_ext%.*}" extension="${filename_with_ext##*.}" #concatinate filename with new extension ni_file="${filename}.nii" #convert to nii using now seperated file name concaqtinated with .nii mri_convert ${FILE} ${ni_file} done I'd like the script to ask the user for the filepath to the folder containing all the files. Then I want to loop through that folder and with each file I want to get the individual file name with the original file extension and the file name with the nii file extension. I am trying to do this by separating the file name from its original extension and then concatenating the file name with .nii. Finally I want to call mri_convert on the file by using its original name and file extensions and then the target file name with the nii extension.
has comment: http://stackoverflow.com/comment/138502499
has comment: http://stackoverflow.com/comment/138502163
has comment: http://stackoverflow.com/comment/138519060
has comment: http://stackoverflow.com/comment/138518685
has comment: http://stackoverflow.com/comment/138518666
score: 0
tagged with: bioinformatics
tagged with: shell
tagged with: linux
has comment: http://stackoverflow.com/comment/138526683
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138502170

http://stackoverflow.com/comment/138533272
score: 0
has text: my doubt is when I uncomment flag1 the else block in the loop is executed not the first if part . why is that ?
comment on: http://stackoverflow.com/q/78579093
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78578346
tagged with: unzip
accepted answer: http://stackoverflow.com/a/78578383
score: 0
has body: I am unzipping the mysql-api.jpi file with the following command: unzip mysql-api.jpi Here is the output I get: Archive: mysql-api.jpi creating: META-INF/ inflating: META-INF/MANIFEST.MF creating: WEB-INF/ creating: WEB-INF/lib/ creating: META-INF/maven/ creating: META-INF/maven/io.jenkins.plugins/ creating: META-INF/maven/io.jenkins.plugins/mysql-api/ inflating: WEB-INF/lib/mysql-connector-j-8.4.0.jar inflating: WEB-INF/lib/mysql-api.jar inflating: WEB-INF/lib/protobuf-java-3.25.1.jar inflating: WEB-INF/licenses.xml inflating: META-INF/maven/io.jenkins.plugins/mysql-api/pom.xml inflating: META-INF/maven/io.jenkins.plugins/mysql-api/pom.properties And then I need to copy one of the files to classpath: cp WEB-INF/lib/mysql-connector-j-8.4.0.jar /var/lib/jenkins/war/WEB-INF/lib Is there a way to directly unzip and copy without saving the files generated from unzipping?
has answer: http://stackoverflow.com/a/78578383
tagged with: bash
upvote count: 1
favorite count: 0
downvote count: 1
type: Question
has title: Unzipping a file without saving its contents
type: AnsweredQuestion
answer count: 1

http://stackoverflow.com/q/78485242
score: 0
has answer: http://stackoverflow.com/a/78485243
tagged with: microchip
linked to: http://stackoverflow.com/q/1311037
type: Question
linked to: http://stackoverflow.com/q/394230
linked to: http://stackoverflow.com/q/59895
has body: Our team has a mix of developers on both Windows and Linux, and a shared code base that has to be able to compile on both, in the Microchip MPLAB X IDE v6.20, for PIC32 microcontrollers in our case. I see in the project properties (right-click the project name --&gt; Properties) there is an option for adding a pre-build step, here: This could be used for auto-generating C code .h header files, for instance. How can we get a common pre-build script here to run on both Windows and Linux in the MPLAB X IDE? I'm having a lot of challenges because the bash commands available in the MPLAB X IDE are inconsistent and have missing options and commands.
linked to: http://stackoverflow.com/q/17510688
linked to: http://stackoverflow.com/q/15715825
upvote count: 1
linked to: http://stackoverflow.com/q/1976007
downvote count: 1
tagged with: git-for-windows
tagged with: bash
accepted answer: http://stackoverflow.com/a/78485243
has title: Microchip MPLAB X IDE: configure and run a shared pre-build-step Bash script that runs in both Windows and Linux as part of the build process
tagged with: mplab
answer count: 1
favorite count: 0
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/8006393
linked to: http://stackoverflow.com/q/32597209
tagged with: mplab-x
linked to: http://stackoverflow.com/q/9546324

http://stackoverflow.com/comment/138377810
has text: kzi that gives an unexpected EOF error
score: 0
comment on: http://stackoverflow.com/q/78491313
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138462814
has text: This seems promising, assuming that "project dir" is definable as the root of a git project. I'm not sure why it was downvoted. But probably you should specify in the answer that it only works if that holds true - the root of the project is a git repository.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78540325
score: 0

http://stackoverflow.com/comment/138314318
has text: Are you reporting the *full* output you get? Because if you had a trailing empty line then I would expect some additional output related to that. ("Case is incorrect...", "Exiting line read....").
comment on: http://stackoverflow.com/q/78454806
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138356084
comment on: http://stackoverflow.com/q/78479235
score: 0
type: QuestionComment
type: Comment
has text: Exactly what is the logic that should be used to determine what content goes in which of the output files, and what the ordering within those files are? (Your example has "output file 2" sorted by the header field, but output file 1 is _not_ in an obviously consistent sort order).

http://stackoverflow.com/comment/138513934
comment on: http://stackoverflow.com/q/78559080
type: Comment
score: 0
has text: In this case, I would first convert the string to an array: `IFS=, ips_arr=( $var_ips )`.
type: QuestionComment

http://stackoverflow.com/comment/138364764
type: Comment
comment on: http://stackoverflow.com/q/78484156
score: 0
has text: Why do you wrap a single element in an array, sort, then unwrap the array element again?
type: QuestionComment

http://stackoverflow.com/a/78454855
accepted answer of: http://stackoverflow.com/q/78454806
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/138314299
upvote count: 5
has comment: http://stackoverflow.com/comment/138314385
has body: The single line in the input file ends with a newline. Therefore, read tries to read the following line, too, but finds the EOF. When it tries to read the line, though, it clears all the variables it should populate. Solution: Don't use the same variable for input and result. #!/bin/bash MyList=IPlist.csv while IFS=, read -r myIP UserIn _ do case $UserIn in Tom) echo "Case is Tom and the IP address is $myIP..." UserName="Tom" echo "Username is $UserName" ;; Bill) echo "Case is Bill and the IP address is $myIP..." UserName="Bill" echo "Username is $UserName" ;; *) echo "Case is incorrect..." echo "Exiting line read...." esac done <$MyList echo "$UserName" To debug the issue, I used set -xv at the start of the script. It showed me which lines were executing and what values were assigned to variables.
answers question: http://stackoverflow.com/q/78454806
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138314160
score: 5

amazon-s3
type: Tag
tags question: http://stackoverflow.com/q/78489072
tag name: amazon-s3
tags question: http://stackoverflow.com/q/79186999
tags question: http://stackoverflow.com/q/79225717
tags question: http://stackoverflow.com/q/79292117

http://stackoverflow.com/comment/138436657
has text: Ya unfortunately I've cut out a simple component of a more complex problem. I'm trying to do something like `echo 1 2 3 4 | xargs -n2 bash -c 'parent_function $1 $2 $parent_variable' _`. So `xargs` requires an actual executable to be run, and given the need to use positional args (e.g. `$1`) I can't use double quotes.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78525458
type: QuestionComment

http://stackoverflow.com/comment/138465341
has text: The rules are listed here https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_04 under *Reserved Words* and aren't that complicated.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78541741
score: 2

http://stackoverflow.com/comment/138338891
type: Comment
comment on: http://stackoverflow.com/q/78451797
score: 0
type: QuestionComment
has text: Thank you guys! awk solution worked for me best. @jhnc if the file contains multiple values, i am all good to drop the second. But I am doing that on the stage of grepping initial logs, so what I am processing with awk doesn't require to handle duplicates.

http://stackoverflow.com/comment/138505596
comment on: http://stackoverflow.com/q/78562624
has text: @EdMorton - thanks for giving my confidence in that direction. I didn't see any file names with `:` so I wasn't worried about that. `cat -A` failed.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78484907
type: Answer
score: 0
has body: I found a solution for running commands in a docker container while running docker compose up. For this, in my existing docker-compose.yaml file, I created a service with docker image with granted privileges. Then created a script and attached it to a volume. Then added the path of script in command section. Example: custom-script-runner: image: docker privileged: true working_dir: /opt/airflow volumes: - .:/opt/airflow - /var/run/docker.sock:/var/run/docker.sock - ./setup.sh:/opt/airflow/setup.sh command: /opt/airflow/setup.sh depends_on: airflow-webserver: condition: service_healthy script.sh: docker ps -a #check your running containers docker exec -i myproject-airflow-webserver-1 bash -c "ssh -o ..." docker exec -i myproject-airflow-webserver-1 bash -c "airflow connections add ..." This link helped me to get the answer.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78479103
accepted answer of: http://stackoverflow.com/q/78479103

http://stackoverflow.com/comment/138403536
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78506003
has text: `systemctl` goes to considerable effort to track and manage everything belonging to any given service. Your best bet would probably be to move the update process into a separate, for-purpose service.
type: QuestionComment

http://stackoverflow.com/comment/138307592
comment on: http://stackoverflow.com/q/78451035
type: Comment
has text: Very strange, as I don't see anything in the script that looks like a bash-specific feature.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138338424
comment on: http://stackoverflow.com/a/78469452
score: 1
has text: `Before your script executes` Means that before your script executes the replacement _has been_ done already in the past. There is nothing to do in your script, your script never sees `$!`.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138463673
has text: Notionally, examining command name and changing behaviour is no different from checking if `--help` or `-r` was passed and changing behaviour but there are situations where [command-name may not reliably be available](http://mywiki.wooledge.org/BashFAQ/028)
comment on: http://stackoverflow.com/q/78540680
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138358272
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78480370
has text: @tjm3772 The quotes were removed in an edit 10 minutes before your comment.
score: 0

http://stackoverflow.com/q/78570634
has title: Unable to execute bash commands from GO function (FN project)
tagged with: fn
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138519021
tagged with: ubuntu
has comment: http://stackoverflow.com/comment/138521368
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138521223
answer count: 1
has answer: http://stackoverflow.com/a/78571308
favorite count: 0
upvote count: 1
tagged with: bash
downvote count: 1
has body: When I try running : cmd := exec.Command("bash", "-c", "docker ps") outp, err := cmd.Output() log.Print("outp", outp) if err != nil { log.Fatalln("Starting command failed:", err) } I am having error : exit status 127 even though docker is installed and docker ps works from terminal, and works if I run the code from a GO file (not using FN project). I think that having this code as a function using FN project causes the terminal to not find commands like docker and many others. trying the following code : cmd := exec.Command("docker", "ps") gives this error : exec: \"docker\": executable file not found in $PATH I tried a lot of other commands as well even ls doesn't work. Anyone had this problem before ? I am thinking it maybe a configuration that I need to do or path problem that needs to be set for the exec command or FN project ... (I am on Ubuntu 22.04 and everything is updated) Any help is greatly appreciated. [Edit] My FN project environment after executing the suggested code thanks to Eik is : PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=2d6affdfa0d4 FN_MEMORY=128 FN_TYPE=sync FN_FN_ID=01HZ5VWQM6NG8G00GZJ000003Q FN_APP_ID=01HZ5VT0E7NG8G00GZJ000003P FN_LISTENER=unix:/tmp/iofs/lsnr.sock FN_FORMAT=http-stream HOME=/home/fn
tagged with: terminal
tagged with: go

http://stackoverflow.com/q/78576313
has comment: http://stackoverflow.com/comment/138545516
answer count: 1
tagged with: sudo
favorite count: 0
has comment: http://stackoverflow.com/comment/138528290
has comment: http://stackoverflow.com/comment/138535018
has comment: http://stackoverflow.com/comment/138528751
has answer: http://stackoverflow.com/a/78597330
has comment: http://stackoverflow.com/comment/138528480
has comment: http://stackoverflow.com/comment/138545528
has comment: http://stackoverflow.com/comment/138535045
type: Question
tagged with: macos
has comment: http://stackoverflow.com/comment/138528623
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138948334
score: 1
has comment: http://stackoverflow.com/comment/138553230
has comment: http://stackoverflow.com/comment/138537151
has title: Invoking script using launchd on MacOS is not working
tagged with: terminal
upvote count: 1
has body: Issue I have a requirement to monitor a particular folder in Users/<user name>/Libraries/Developer/Xcode/DerivedData. I have written a script that should be run all the time in the background to monitor the folder. I seem to have a permission issue when we are trying to access anything in Users/ from a launched What I have tried? I tried to set up a launch daemon that invokes a particular script by following steps mentioned in this Apple forum discussion. Script logger 'Hello Cruel World!' The script is saved in the path - /usr/local/bin/greetings.sh launchd plist <?xml version="1.0" encoding="UTF-8"?> Label com.example.hello ProgramArguments /usr/local/bin/greetings.sh RunAtLoad <true/> The plist is saved in the path - /Library/LaunchDaemons Commands executed to load the launchd and provide permissions sudo chmod +x /usr/local/bin/greetings.sh -> To make the script executable and give root level permissions. sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.hello.plist sudo launchctl start com.example.hello On printing the logs via log show —predicate 'process == "logger"' —info | grep "Hello Cruel World", I could see the Hello Cruel World getting printed. Findings In my initial investigation, I suspect the issue might lie in the permissions that the script has. When the script is in /usr/local/bin -> ls -l /usr/local/bin/greetings.sh -rwxr-xr-x 1 root wheel <Date> /usr/local/bin/greetings.sh When the script is in /Users/<user_name>/Desktop -> /Users/<user>/Desktop/greetings.sh -rwxr-xr-x@ 1 root staff 40 <date> /Users/<user>/Desktop/greetings.sh The difference is between staff and wheel level permissions. Question Is there something that I am missing to do explicitly to grant the script the appropriate permissions to a script in location Users/<user> that performs operations like CRUD on a file? As per my understanding sudo permissions should do the job.
downvote count: 0
tagged with: bash
tagged with: xcode

http://stackoverflow.com/comment/138353145
score: 0
comment on: http://stackoverflow.com/q/78477621
has text: See Bash's [Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html)
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78454099
has title: Dynamically Accessing Bitbucket Environment Variables in Pipelines
score: 0
type: Question
tagged with: shell
type: UnansweredQuestion
answer count: 1
has body: How can I dynamically pass multiple Role ARNs defined in my Bitbucket repository environment variable to a step variable in my pipeline? I have three Role ARNs defined in my Bitbucket repository environment variable, named OIDC_ROLE_ARN_dev, OIDC_ROLE_ARN_stage, and OIDC_ROLE_ARN_master, corresponding to the branch names dev, stage, and master, respectively. I want to dynamically select the appropriate Role ARN based on the current branch and use it as a step variable. I've attempted to achieve this using Indirect expansion like OIDC_ROLE_ARN="OIDC_ROLE_ARN_${BITBUCKET_BRANCH}" and then using ${!OIDC_ROLE_ARN}. While this works fine locally, it throws a syntax error "bad substitution" in the pipeline environment. Here's my pipeline step: - step: &build-and-push-fitserver-image name: Build and Push fitServer Image to ECR oidc: true script: - OIDC_ROLE_ARN="OIDC_ROLE_ARN_${BITBUCKET_BRANCH}" - docker build -t fitserver:${BITBUCKET_BRANCH} -t fitserver:latest . - pipe: atlassian/aws-ecr-push-image:2.4.0 variables: AWS_OIDC_ROLE_ARN: ${!OIDC_ROLE_ARN} IMAGE_NAME: fitserver TAGS: "${BITBUCKET_BRANCH} latest" Could someone please suggest a way to resolve this issue without using if-else conditions?
has answer: http://stackoverflow.com/a/78458650
tagged with: bitbucket-pipelines
tagged with: bash

bucket
type: Tag
tag name: bucket
tags question: http://stackoverflow.com/q/78456415

http://stackoverflow.com/comment/138500937
score: 0
comment on: http://stackoverflow.com/a/78545843
type: Comment
type: AnswerComment
has text: Thank you so much Charles for the explanation, I'll add double quotes.

http://stackoverflow.com/a/78526999
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/78526961
downvote count: 0
has comment: http://stackoverflow.com/comment/138439182
has body: You want to be able to print something like above? You can simply use: echo "11▒" or export LANG=en_GB.UTF-8 echo -e "11▒" export LANG=en_GB.UTF-8 because as user1934428 said: Perhaps it should be added, that LANG should be set to some utf8 value, for instance en_GB.UTF-8 To ensure that the Unicode character is correctly displayed, the LANG environment variable should be set to a UTF-8 locale. -e stands for the interpretation of backslash escape sequences ▒ is the Unicode code for the character “▒”.
has comment: http://stackoverflow.com/comment/138439247
type: Answer

http://stackoverflow.com/comment/138427389
score: 0
type: QuestionComment
type: Comment
has text: @EdMorton It's not being captured and then output by another command. It's a direct pipeline.
comment on: http://stackoverflow.com/q/78520070

http://stackoverflow.com/comment/138527366
type: QuestionComment
has text: I have a Mac, but I don't use OneDrive. But if you copy the pathname and get /Users/username/CloudStorage, and `ls` tells you that the directory does not exist, there is something odd going on. Since your first step is to see the directory from a shell, this is something to research. Leave out VSC, which just unnecessarily complicates things, and do everything from `Terminal.app`. Also, I suggest that you ask this problem at [apple.se]. Add a Screenshot from your Terminal.app, which demonstrates that the `ls` command indeed produces the error message you mentioned.
type: Comment
comment on: http://stackoverflow.com/q/78575374
score: 1

http://stackoverflow.com/comment/138374169
score: 2
type: Comment
has text: Don't use `$?`, but just put the command in the `if` itself: `if helm status deployment-name; then ...`.
comment on: http://stackoverflow.com/q/78489561
type: QuestionComment

http://stackoverflow.com/comment/138484555
type: Comment
comment on: http://stackoverflow.com/q/78551049
score: 0
type: QuestionComment
has text: @Philippe with the quotes, got the same error.

http://stackoverflow.com/comment/138401534
has text: i just added the last 3 strings i probably should have checked lol.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78505435

http://stackoverflow.com/q/78544705
has comment: http://stackoverflow.com/comment/138470632
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138470908
has answer: http://stackoverflow.com/a/78544892
has comment: http://stackoverflow.com/comment/138470785
accepted answer: http://stackoverflow.com/a/78544892
has title: BASH Alignment/Print Issue: Output Misaligned in TXT File Despite Correct Terminal Display
has body: In my script A, I execute SQL queries and construct a result string and a details string: # # BUILD OUTPUT # result=" DATENBANK(EN) ============= $db_overview INSTANZ(EN) =========== $instance_overview $container_overview_ " details="" Afterwards, I call the following code to write the result to a TXT file: if [ "$print_txt" = true ]; then printf "%s" "$(txt_item "Database Overview" "$result" "$details")" >> "$TXT_FILENAME"; fi For proper formatting, the function txt_item is called: function txt_item() { local h="$1" local result="$2" local details="$3" item=" # ###################################### # $h # ###################################### $result " if [ -n "$details" ]; then _details=" # $h.DETAILS $details " item+=$_details fi echo "$item" } The problem now is that tables like $db_overview are misaligned in the TXT file and not displayed as they are in the terminal. Here is an example: printf "%s" "$(txt_item "Database Overview" "$result" "$details")" # if [ "$print_txt" = true ]; then printf "%s" "$(txt_item "Database Overview" "$result" "$details")" >> "$TXT_FILENAME"; fi Output (Terminal): # ###################################### # Database Overview # ###################################### DATENBANK(EN) ============= NAME OPEN_MODE LOG_MODE DATABASE_ROLE CREATED -------------------- --------------- -------------------- --------------- ---------- XXX READ WRITE NOARCHIVELOG PRIMARY 11.10.XXXX INSTANZ(EN) =========== IID INAME HOST_NAME STATUS PAR STATUS --- -------------------- ----------------------------------- ---------- --- ---------- 1 XXX XXXXXXXXXXXXXXXX OPEN NO ACTIVE Output (TXT-FILE) # ###################################### # Database Overview # ###################################### DATENBANK(EN) ============= NAME OPEN_MODE LOG_MODE DATABASE_ROLE CREATED -------------------- --------------- -------------------- --------------- ---------- XXX READ WRITE NOARCHIVELOG PRIMARY 11.10.2022 INSTANZ(EN) =========== IID INAME HOST_NAME STATUS PAR STATUS…
tagged with: shell
has comment: http://stackoverflow.com/comment/138470698
downvote count: 0
score: 1
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/q/78570217
has comment: http://stackoverflow.com/comment/138517578
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138575611
upvote count: 1
downvote count: 6
has body: I'm hoping to print only the last word in every line of my file as in the below example. I tried using awk 'print {$NF}'` but it doesn't give the output I like as not all lines are of the same length. My file contains lines like the below ID_1 ABC;GHI;JKKK;KLLL; ID_2 JKL;YUI; ID_3 OPKJ; ID_4 uncK;oPTY; and I wish to have output as below KLLL YUI OPKJ oPTY I would appreciate it very much if you've got any ideas on how to accomplish the above on bash
has answer: http://stackoverflow.com/a/78570500
has answer: http://stackoverflow.com/a/78570241
has answer: http://stackoverflow.com/a/78570614
has comment: http://stackoverflow.com/comment/138517439
has title: How to print last word in all lines irrespective of the length of each line?
has answer: http://stackoverflow.com/a/78570310
has answer: http://stackoverflow.com/a/78570749
has answer: http://stackoverflow.com/a/78570392
has comment: http://stackoverflow.com/comment/138517322
favorite count: 0
score: -5
answer count: 6
tagged with: awk
has comment: http://stackoverflow.com/comment/138517897
tagged with: bash
has comment: http://stackoverflow.com/comment/138517416
type: Question

http://stackoverflow.com/q/78502959
score: 0
type: Question
tagged with: linux
tagged with: ubuntu
type: UnansweredQuestion
tagged with: bash
has comment: http://stackoverflow.com/comment/138397229
has title: Can I build a portable execution environment with everything in `~/.local`?
has comment: http://stackoverflow.com/comment/138398129
has comment: http://stackoverflow.com/comment/138398534
answer count: 1
has comment: http://stackoverflow.com/comment/138398987
has body: I'm using multiple Linux servers that are running on different versions of glibc and other essential libraries. Since I do not have root access, I have to compile the packages from scratch on each machine. So I want to pack a local library environment from scratch (containing glibc) in ~/.local (i.e. --prefix=/home/&lt;xxx&gt;/.local) and completely discard system libraries. Will this solution approachable? (i.e. I can pack the ~/.local and ~/.bashrc, move to a new machine, unpack them, and use them directly.) Recently I'm reading Linux from Scratch, but actually this is not a cross-compiling task so procedure in the book may not apply. My current sequence is glibc -&gt; binutils -&gt; libstdc++ -&gt; gcc. Is the order correct? What's the correct order of building libraries?
has answer: http://stackoverflow.com/a/78533183
tagged with: gnu

http://stackoverflow.com/comment/138357143
comment on: http://stackoverflow.com/a/78475452
has text: I can't conceive of any good reason to use a manually-managed FIFO instead of a [process substitution](https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html). (Well, portability to non-bash shells, but this question is explicitly tagged bash). `<(...)` will set up your FIFO, substitute in its name, and delete it when it's done... when you're on a platform that doesn't support `/dev/fd` or equivalent to be able to avoid any need for a named pipe at all.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138491477
type: Comment
has text: Can you reproduce it if you disable your shell startup scripts (e.g. `.profile` and `.bashrc`)? Maybe something you're customizing is causing the problem.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78553947

http://stackoverflow.com/comment/138377648
score: 0
type: QuestionComment
type: Comment
has text: try this printf "%s\n" { "{" .. file then dt=$(date -d @$(cat "${DrawC}" | jq '1715864400')) | echo >> file then echo } then
comment on: http://stackoverflow.com/q/78491313

http://stackoverflow.com/q/78532589
has answer: http://stackoverflow.com/a/78532630
favorite count: 0
type: AnsweredQuestion
has body: I have a gff file, i want to extract the gene id's (column 9) and the strand (+ or -) (column 7) i want to do this in bash but I don't know how to do this. I only want to extract the line that has the feature type Gene in it (column 3). i tried this: #!/bin/bash gff_file="$1" sequence_id="$2" gene_ids=$(zcat "$gff_file" | awk -F'\t' -v seq_id="$sequence_id" '$1 == seq_id && $3 == "gene" {match($9, /ID=([^;]+)/, arr); print arr[1]$7}') if [ -z "$gene_ids" ]; then exit 0 fi sorted_gene_ids=$(echo "$gene_ids" | sort -nk2 | awk '{print $1}') echo "$sorted_gene_ids" my gff-file looks like this: chr1 v1.0 gene 289 3692 . - . ID=Oeu061231.1;tid=PAC:37727357;id=gOeu061231.1;Name=Oeu061231.1;gene_id=Oeu061231.1 chr1 v1.0 mRNA 289 3692 . - . ID=Oeu061231.1;Parent=Oeu061231.1;Name=Oeu061231.1;gene_id=Oeu061231.1 chr1 v1.0 exon 289 349 . - . ID=Oeu061231.1:exon:1;Parent=Oeu061231.1;Name=Oeu061231.1;gene_id=Oeu061231.1 chr1 v1.0 CDS 289 349 . - 1 ID=Oeu061231.1:CDS;Parent=Oeu061231.1;Name=Oeu061231.1;gene_id=Oeu061231.1 chr1 v1.0 exon 473 787 . - . ID=Oeu061231.1:exon:2;Parent=Oeu061231.1;Name=Oeu061231.1;gene_id=Oeu061231.1 chr1 v1.0 CDS 473 787 . - 1 ID=Oeu061231.1:CDS;Parent=Oeu061231.1;Name=Oeu061231.1;gene_id=Oeu061231.1 ... chr2 v1.0 gene 21189213 21190423 . + . ID=Oeu046640.1;tid=PAC:37723918;id=gOeu046640.1;Name=Oeu046640.1;gene_id=Oeu046640.1 chr2 v1.0 mRNA 21189213 21190423 . + . ID=Oeu046640.1;Parent=Oeu046640.1;Name=Oeu046640.1;gene_id=Oeu046640.1 chr2 v1.0 exon 21189213 21189336 . + . ID=Oeu046640.1:exon:1;Parent=Oeu046640.1;Name=Oeu046640.1;gene_id=Oeu046640.1 chr2 v1.0 CDS 21189213 21189336 . + 0 ID=Oeu046640.1:CDS;Parent=Oeu046640.1;Name=Oeu046640.1;gene_id=Oeu046640.1 chr2 v1.0 exon 21189890 21189977 . + . ID=Oeu046640.1:exon:2;Parent=Oeu046640.1;Name=Oeu046640.1;gene_id=Oeu046640.1 chr2 v1.0 CDS 21189890 21189977 . + 2 ID=Oeu046640.1:CDS;Parent=Oeu046640.1;Name=Oeu046640.1;gene_id=Oeu046640.1 chr2 v1.0 exon 21190084 21190150 . + . ID=Oeu046640.1:exon:3;Parent=O…
type: Question
accepted answer: http://stackoverflow.com/a/78533720
downvote count: 1
has answer: http://stackoverflow.com/a/78533720
has comment: http://stackoverflow.com/comment/138449165
has title: How can I access two columns in a gff file and combine them with bash?
possible better answer: http://stackoverflow.com/a/78532630
upvote count: 2
answer count: 2
tagged with: bash
score: 1

http://stackoverflow.com/comment/138450275
type: Comment
has text: the expected output appears to have 3 items; please update the question to include the names and contents of the files that these 3 items come from
comment on: http://stackoverflow.com/q/78533115
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138465270
comment on: http://stackoverflow.com/a/78535924
type: Comment
type: AnswerComment
has text: It's the interval expressions (few other people spotted the bug in mawk 1.x before, see [mawk mishandles {2,} in regular expressions](https://github.com/ThomasDickey/original-mawk/issues/72)). `[[:space:]]*[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]+` works on both versions.
score: 1

http://stackoverflow.com/comment/138373074
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78488507
has text: There a backslash at the start of md5? How is that possible? I suspect your file names or input have dos line endings. Check them with `hexdump` or `cat -v`.
type: QuestionComment

http://stackoverflow.com/a/78466056
has body: It seems you want a FIFO (first-in, first-out) data structure, aka queue. You can probably replace all your code with a single Perl script. A slightly-easier to read version of the code from my comment, using intermediate variables, and altered to allow resuming from a new queue: walk_queue : #!/usr/bin/perl use v5.10; use strict; use warnings; use Tie::File; my ($url_queue_file, $seen_urls_file) = @ARGV; # allow reading/writing file lines as if they are arrays tie my @url_queue, 'Tie::File', $url_queue_file or die; tie my @seen_urls, 'Tie::File', $seen_urls_file or die; # (re)load lookup table from any previous results found my %seen = map {$_=&gt;1} @seen_urls; # take url from head of queue while (my $url = shift @url_queue) { # call wget - quote any metacharacters in url my $html = qx{ wget -qO- \Q$url\E }; # extract href values that are https urls my @found_urls = ( $html =~ m{href=&quot;(https://[^&quot;#]+)&quot;}g ); # filter out irrelevant and duplicates my @new_urls = grep { m{magazine/} &amp;&amp; !$seen{$_}++ } @found_urls; # add any new urls to tail of queue push @url_queue, @new_urls; # ensure starting url is always marked as seen unshift @new_urls, $url if !$seen{$url}++; # append any new urls to result file push @seen_urls, @new_urls; # optionally output progress to screen say for @new_urls; } then: $ echo 'https://abc.xyz/start' &gt;queue $ cat /dev/null &gt;found $ ./walk_queue queue found queue should end up empty found should contain the results (also displayed on stdout) To continue from a different url, add it to queue but don't clear found, and run again: $ echo 'https://abc.xyz/another/one' &gt;&gt;queue $ ./walk_queue queue found (I haven't tested this code since I don't know the actual url format nor html contents.)
has comment: http://stackoverflow.com/comment/138333414
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138336986
has comment: http://stackoverflow.com/comment/138338684
has comment: http://stackoverflow.com/comment/138334057
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/138333252
answers question: http://stackoverflow.com/q/78462933

http://stackoverflow.com/comment/138364946
type: AnswerComment
has text: Do you have idea about the performance part, btw? `jq sort` vs bash `sort`
comment on: http://stackoverflow.com/a/78484256
score: 0
type: Comment

http://stackoverflow.com/comment/138549154
type: QuestionComment
type: Comment
has text: @CharlesDuffy : added a screenshot for the hyperlink issue. www.domail.com is expanded.
comment on: http://stackoverflow.com/q/78587549
score: 0

http://stackoverflow.com/q/78514302
has comment: http://stackoverflow.com/comment/138416756
downvote count: 0
tagged with: bash
score: 1
favorite count: 0
type: AnsweredQuestion
has title: Manipulating specific columns in a csv via Bash?
tagged with: http://stackoverflow.com/tag/csv
tagged with: arrays
type: Question
has body: I am writing a script to setup a csv file with data parsed from another .txt file. I have a few particular columns, and how this program flows, I am using these columns to grab data from the .txt. I am just unsure on how to proceed, since I want the next column to be tied to the current iteration of things Im looking at. The general code I have is like this: #!/bin/bash COLUMNS=(1 2 3) for column in "${COLUMNS[@]}"; do echo "${COLUMNS[@]}" > someCSVFile.csv parsedText=$(sed -n '/'$column-'/,/^${/^$/d; p}' someTextFile.txt) for line in "${parsedText[@]}"; do echo "${line}" >> someCSVFile.csv done done When I parse the code, The text returns in a format like: a b c For sake of example, lets assume COLUMN 1 returns "abc" (in the format above), COLUMN 2 returns "def", and so on. Ideally, I should pass to the CSV in the second for loop which should be like: 1,2,3 a,d,g b,e,h c,f,i But instead, the output will be: 1 a b c 2 d e f 3 g h i Is there a way, based on iteration of the loop, that I can move to the next column of the csv?
accepted answer: http://stackoverflow.com/a/78514500
has comment: http://stackoverflow.com/comment/138416776
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/138416688
has answer: http://stackoverflow.com/a/78514500

http://stackoverflow.com/comment/138649857
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78587616
has text: This is because in above `d` param specification `''` borders have more priority than `()`. Possible fixes from user side: `awk -f foo.awk -v d="()\"\"''" -v n=1 -v p=7 <<< "(/exp) '/act'"`, `awk -f foo.awk -v d="\"\"''()" -v n=1 -v p=6.5 <<< "(/exp) '/act'"`.

http://stackoverflow.com/q/78584835
type: UnansweredQuestion
tagged with: bash
tagged with: amazon-ec2
upvote count: 1
tagged with: boto3
downvote count: 1
has body: Currently i am trying to achive that a user sign up on my website after that Enter their AWS Access Key and Secret key. After AWS Key verification, there is a form for asking the user Select Region > Select Number of Visitors, Enter Domain Name, SSL Checkbox & done. After this i am trying to Launch EC2 Instance on selected region, and instance family is depend on the Number of visitors. and for myself, i am using BOTO3 to automate this. How can we do this for user because we need to change AWS Access & Secret keys Do we need to save keys with different profile name? One more thing, How can i add Domain name because currently my bash script is installing wordpress on the public IP, Can we also change Domain name? #!/bin/bash # Update the package index apt update # Install Apache apt install -y apache2 # Pre-configure MySQL root password and install MySQL in a non-interactive mode export DEBIAN_FRONTEND=noninteractive echo "mysql-server mysql-server/root_password password Password@" | debconf-set-selections echo "mysql-server mysql-server/root_password_again password Password@" | debconf-set-selections apt install -y mysql-server # Verify MySQL installation and set the root password if needed mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password@'; FLUSH PRIVILEGES;" || true # Install PHP and required modules apt install -y php libapache2-mod-php php-mysql php-curl php-json php-cgi # Download WordPress wget -c http://wordpress.org/latest.tar.gz # Extract WordPress tar -xzvf latest.tar.gz # Move WordPress files to the Apache root directory rsync -av wordpress/* /var/www/html/ # Remove default Apache index.html page rm /var/www/html/index.html # Set permissions chown -R www-data:www-data /var/www/html/ chmod -R 755 /var/www/html/ # Create WordPress configuration file cd /var/www/html/ cp wp-config-sample.php wp-config.php # Configure WordPress to connect to the database sed -i "s/database_name_here/wordpress_db/" wp-config.ph…
favorite count: 0
tagged with: python
has title: Save User AWS keys and setup EC2 with WordPress
score: 0
has comment: http://stackoverflow.com/comment/138548740
type: Question
answer count: 0
tagged with: amazon-web-services

http://stackoverflow.com/comment/138497343
type: Comment
comment on: http://stackoverflow.com/q/78559080
score: 0
has text: Super Biffen. Thanks
type: QuestionComment

http://stackoverflow.com/a/78575456
has comment: http://stackoverflow.com/comment/138526539
has body: Partial solution: I initially opened the file through the OneDrive I had added to finder (there was an option when logging into Onedrive to add to finder, so I just used the path(?) it created to access the contents including when I opened it in vscode). So in vscode the path at the top was /Users/username/Library/CloudStorage/the organisation's name/Desktop/scripts/mycode.py. I clicked on Library and manually chose the organisation's name (skipping the CloudStorage bit) and the rest. Then the code run fine. Leaving this here in case someone has a similar problem.
score: 0
answers question: http://stackoverflow.com/q/78575374
type: Answer

http://stackoverflow.com/comment/138337248
comment on: http://stackoverflow.com/q/78466816
has text: @F.Hauri-GiveUpGitHub Cool, thank you for the links. I shall read them all through and see what I can learn. Thank you.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78462744
has comment: http://stackoverflow.com/comment/138327142
has title: ERROR 1044 (42000) while updating mysql database
score: 0
has comment: http://stackoverflow.com/comment/138327135
type: Question
tagged with: mysql
has comment: http://stackoverflow.com/comment/138327005
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138326909
answer count: 1
has body: I'm trying to send a json file to my MySQL database from bash script. As far as I know the syntax for json file part is correct but there is a strange error that I cant understand. I run the following code: EXPORT_DIR="sunum" file_name="105069_2024-03-19_20:09:06.mp4" IFS='.' read -ra ADDR <<< ${file_name} report_filename=${ADDR[0]}".json" report_dir="${EXPORT_DIR}/${report_filename}" echo "${report_dir}" VAR=$(cat "${report_dir}") echo "${VAR}" echo "${file_name}" mysql --user="sql_vestelrecog_" --password="H76X53WN2ZaaJY84" --database="sql_vestelrecog_" \ --port="3306" --execute="UPDATE media SET rapor = "${VAR}" WHERE file_name = "${file_name}"" and get the following error: ERROR 1044 (42000): Access denied for user 'sql_vestelrecog_'@'localhost' to database 'mp4' My database name sql_vestelrecog_ and its already defined, how come the the extension of the filename (mp4) becomes the database name and I get this connection error??
has answer: http://stackoverflow.com/a/78462905
tagged with: bash

http://stackoverflow.com/comment/138371318
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78485715
has text: *how I can get the output of one program copied over to the input of another* use *pipes* `program1 | program2`. For using output of a commend as argument to another command, then answer is in mentioned duplicates.

http://stackoverflow.com/comment/138398072
score: 0
has text: Regarding `I think it's zsh` - your shebang `#!/bin/zsh` specifically calls `zsh` to execute the script. Regarding `I am not sure if there is any difference` - yes there are differences, `bash` and `zsh` are 2 completely different shells.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78503442

http://stackoverflow.com/comment/138303888
score: 0
has text: Use https://www.shellcheck.net/ and make the changes suggested. `$(...)` runs its contents in a subshell and returns the stdout. `$(${taskName}.secureFilePath)` is trying to execute it's content, but the value of `${taskName}` is `downloadTask`, and `downloadTask.secureFilePath` is apparently not something it can find in the `$PATH` as executable. what were you trying to accomplish?
comment on: http://stackoverflow.com/q/78449032
type: Comment
type: QuestionComment

http://stackoverflow.com/q/78497806
tagged with: reboot
has body: I'm going nuts over something seemingly simple. I want to run a script every minute which reboots when it finds something in a log. It simply does not run via cron. My script in /home/root/resetiferror.sh #!/bin/bash tail -fn0 /var/log/messages | while read line ; do echo "${line}" | grep -i "failed to read" >> /var/log/resetiferror if [ $? = 0 ] ; then echo "$(date) found so restart" >> /var/log/resetiferror /sbin/reboot fi done This is my crontab: 1 * * * * timeout 5s /home/root/resetiferror.sh >> /var/log/resetiferror.log 2>&1 I made it executable It DOES work with /bin/sh -c "(export PATH=/usr/bin:/bin; /home/root/resetiferror.sh </dev/null >/dev/null 2>&1)" Or is there an easier script to do a reboot when 'failed to read' found in the log?
has comment: http://stackoverflow.com/comment/138402470
tagged with: sh
has comment: http://stackoverflow.com/comment/138393186
has comment: http://stackoverflow.com/comment/138388377
answer count: 0
downvote count: 0
has comment: http://stackoverflow.com/comment/138393185
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138393189
score: 1
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138388717
has comment: http://stackoverflow.com/comment/138393861
has comment: http://stackoverflow.com/comment/138388629
has comment: http://stackoverflow.com/comment/138393340
tagged with: bash
type: Question
tagged with: cron
has title: reboot via script run by cron
has comment: http://stackoverflow.com/comment/138395364

http://stackoverflow.com/comment/138382374
score: 0
has text: Damn, you're right @RomainValeri! Yesterday, with the tiredness of the day, I didn't notice this simple detail! However, I am interested in having the return log with the missing commit, but still allowing the directories to be filtered, can you explain to me what is happening to it? What is the hidden mechanism behind it?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78491259

http://stackoverflow.com/comment/138400375
type: QuestionComment
type: Comment
has text: What do those patterns look like? Are they fixed strings?
comment on: http://stackoverflow.com/q/78504692
score: 3

http://stackoverflow.com/comment/138374353
type: QuestionComment
type: Comment
score: 0
has text: @M.NejatAydin yes, I was thinking of moving the backslash to the end of the md5 hash,
comment on: http://stackoverflow.com/q/78488507

http://stackoverflow.com/comment/138341122
comment on: http://stackoverflow.com/q/78470611
type: QuestionComment
type: Comment
score: 0
has text: You use `-mtime` instead of `-ctime`. That means, after uploading an old file it is removed immediately. And files with timestamps in the future will stay longer than 1 week.

http://stackoverflow.com/comment/138518518
has text: You can get the output code of a program using `$?`. If its a non-zero number then its an error.
type: QuestionComment
comment on: http://stackoverflow.com/q/78570866
type: Comment
score: 0

http://stackoverflow.com/comment/138521140
type: QuestionComment
comment on: http://stackoverflow.com/q/78572114
score: 2
type: Comment
has text: `cat file | cmd` is known as a "useless use of cat" (UUoC). There are multiple problems with it. Some of them are explained in [BashFAQ/119 - What's the difference between "cmd < file" and "cat file | cmd"? What is a UUOC?](https://mywiki.wooledge.org/BashFAQ/119).

http://stackoverflow.com/comment/138381236
comment on: http://stackoverflow.com/q/78491313
score: 0
type: QuestionComment
type: Comment
has text: My bad. `|=` inside a jq statement converts a field, but doesn't chose it for printing out only this field. Try this: `dt=$(cat $DrawC | jq ".[].EpochTime | strflocaltime(\"%d.%m.%Y, %H:%M\")")`. Adjust the format of the timestring to your needs.

http://stackoverflow.com/comment/138381368
has text: @James using `find` for replacing `test -e` seem disproportionate
type: QuestionComment
comment on: http://stackoverflow.com/q/78493200
type: Comment
score: 1

http://stackoverflow.com/comment/138394486
comment on: http://stackoverflow.com/a/78501166
score: 1
has text: It's worth being explicit (since this is being read by a beginner) that `expr` should generally be avoided in new code -- it's an artifact of the 1970s, from before shells had built-in math support. If one _must_ use piped values (and thus xargs), then one needs an external command and expr is reasonable, but I'm not sure that this is actually a requirement as opposed to an accident of implementation.
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78523083
upvote count: 3
has comment: http://stackoverflow.com/comment/138440499
has body: As others have mentioned, count="$(foo)" is capturing all of the stdout from foo which is why you don't see 0 on your terminal, it's inside of count along with I want to return this string. Code such as you show almost always is better written with those extra echos going to stderr than stdout as they're usually for things like printing prompts, progress indicators, debugging/tracing information, error messages, etc. which you don't want getting mixed in with the actual final output of your script. Given that, this is probably what you want: $ cat tst.sh #!/usr/bin/env bash foo() { echo 1 >&2 # print in stderr echo "I want to return this string" } main() { echo 0 >&2 # print in stderr count="$(foo)" } main "$@" which when run as this would print those values to stderr: $ ./tst.sh 0 1 and if you really wanted them to go to stdout, which I highly doubt, you could always do: $ ./tst.sh >&1 0 1 or put that redirection in your code too: $ cat tst.sh #!/usr/bin/env bash foo() { echo 1 >&2 # print in stderr echo "I want to return this string" } main() { echo 0 >&2 # print in stderr count="$(foo)" } main "$@" 2>&1 # redirect stderr to stdout $ ./tst.sh 0 1 Reading your comment made me wonder if you actually could benefit from a different type of solution than output redirection plus command substitution - a name reference variable. For example: $ cat tst.sh #!/usr/bin/env bash foo() { local -n result=$1 # "-n" lets us declare a function-local variable # "result" as being a reference to the variable # passed as the first argument when this function # is called instead of a separate object. echo 1 # print in stdout result="I want to return this string" } main() { local count # Just a regular function-local variable. echo 0 # print in stdout foo count # This will set "count" indirectly inside foo(). printf 'count="%s"\n' "$count" # print in stdout } main "$@" $ ./tst.sh 0 1 count="I want to return this string" That allows you to set a variable inside foo() that can be used by …
answers question: http://stackoverflow.com/q/78522842
has comment: http://stackoverflow.com/comment/138436114
downvote count: 0
has comment: http://stackoverflow.com/comment/138436087
has comment: http://stackoverflow.com/comment/138436003
score: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138435773
accepted answer of: http://stackoverflow.com/q/78522842
type: Answer

http://stackoverflow.com/a/78514500
accepted answer of: http://stackoverflow.com/q/78514302
type: Answer
score: 0
type: AcceptedAnswer
has body: You can do what you want in bash, but it is somewhat inflexible. The logic is a bit strained since output is line-oriented, but your logic is column-oriented. But still, bash is quite capable and can put round-pegs in square-holes. Basically you want to loop 1-3 and then index letters 0, 2, 5 (e.g. "a,d,g") for the first row, then index letters 1, 3, 6 for the second, and so on. You can create the array of letters using a simple brace expansion, e.g. letters=( {a..z} ), and then just loop over your original array for 1,2,3. Putting that altogether you can do: #!/bin/bash cols=(1 2 3) # your example letters=( {a..z} ) # fill array with a-z using brace expansion str="${cols[*]}" # convert array to string of space separated values echo "${str// /,}" # echo to stdout with commas ## loop 1-3 and output corresponding letter desired using indexes for c in "${cols[@]}"; do echo "${letters[c-1]},${letters[c+2]},${letters[c+5]}" done (note: do not use UPPERCASE variable names, those are generally reserved for bash system variables and the environment) Example Use/Output With the script in cols.sh you would get: $ bash cols.sh 1,2,3 a,d,g b,e,h c,f,i You can redirect it all to a file with bash cols.sh > somefile. Let me know if you have further questions. (edited to add commas) (2nd edit to eliminate call to sed, instead using built-in parameter expansion with substring replacement)
answers question: http://stackoverflow.com/q/78514302

http://stackoverflow.com/q/78453492
tagged with: bash
tagged with: github-actions
downvote count: 1
has title: Why GitHub Actions shell don't let me use `let` or `((++))` with a variable equal to 0?
has body: I am using a GitHub Action with steps using ubuntu-latest default shell (bash 5.11 the time of writing). However, I find inconsistencies with my local bash (5.12) when running the script and a variable is 0. Specifically, the GHA fails (exit code 1) with: let my_var=0, but not let my_var=42, ((my_var++)) when my_var is 0, but not when it is 42. What causes this? Example GHA: name: Test shell on: workflow_dispatch: jobs: test-shell: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Increment variable run: | let my_var=3 echo "::notice::my_var is $my_var" ((my_var++)) echo "::notice::my_var is now $my_var" - name: FAIL - Set variable to 0 using let if: false run: | echo "::notice::Preparing to initialize variable to 0" let my_var=0 echo "::notice::my_var is $my_var" - name: Set variable to 0 run: | echo "::notice::Preparing to initialize variable to 0" my_var=0 echo "::notice::my_var is $my_var" - name: FAIL - Increment variable from 0 using ((++)) if: false run: | my_var=0 echo "::notice::my_var is $my_var" ((my_var++)) echo "::notice::my_var is now $my_var" - name: Increment variable from 0 using += run: | my_var=0 echo "::notice::my_var is $my_var" let my_var+=1 echo "::notice::my_var is now $my_var"
type: Question
upvote count: 0
has answer: http://stackoverflow.com/a/78453566
tagged with: shell
type: UnansweredQuestion
answer count: 1
favorite count: 0
duplicate of: http://stackoverflow.com/q/22428894
linked to: http://stackoverflow.com/q/19622198
score: -1
linked to: http://stackoverflow.com/q/22428894

http://stackoverflow.com/a/78570143
has body: head -n 3 dartsapp.py | cat -e outputs: #!/usr/bin/python3^M$ ^M$ # Python-App fM-CM-&lt;r das PunktezM-CM-$hlen beim Darts^M$ and so those ^Ms at the end of each line tells us that dartsapp.py has DOS line endings, see linux-bash-shell-script-error-cannot-execute-required-file-not-found for more information on this specific error and Why does my tool output overwrite itself and how do I fix it? for more information on DOS line endings in general. Both of those questions contain various fixes for this problem, starting with running dos2unix dartsapp.py.
type: Answer
score: 9
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78570018
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78570018
upvote count: 9

git-log
tags question: http://stackoverflow.com/q/78491259
type: Tag
tag name: git-log

http://stackoverflow.com/comment/138308114
type: QuestionComment
comment on: http://stackoverflow.com/q/78450852
type: Comment
score: 0
has text: Hi @GoinOff. When I do that, it just adds + signs in front of the script lines and adds those to the output.log, too. Same error message at the end, tho: + cd /volume1/@appstore/fossil-scm/bin + fossil server --port 8080 /volume1/backup/fossil/fossil --https no such file: server

http://stackoverflow.com/q/78489249
tagged with: shell
tagged with: linux
type: UnansweredQuestion
answer count: 1
linked to: http://stackoverflow.com/q/10067266
has answer: http://stackoverflow.com/a/78489344
tagged with: bash
has comment: http://stackoverflow.com/comment/138377107
has title: Password exposure in shell script
has comment: http://stackoverflow.com/comment/138377081
has comment: http://stackoverflow.com/comment/138376595
has body: I need to understand if the below code will lead to password leak when the below function is called: #!/bin/sh function call_function() { password=$1 echo $password | sed 's/$/\\$/g' } password1=$(call_function "abcd") Will the above function return lead to any security risk? I did try using ps -ef and trying to catch the password however i was not able to see password getting caught.
score: 0
type: Question

http://stackoverflow.com/comment/138319740
type: AnswerComment
score: 1
has text: [Why is testing “$?” to see if a command succeeded or not, an anti-pattern?](https://stackoverflow.com/questions/36313216/why-is-testing-to-see-if-a-command-succeeded-or-not-an-anti-pattern) You can combine the assignment into the `if` statement; `if result=$(jq ...); then`
comment on: http://stackoverflow.com/a/78458513
type: Comment

http://stackoverflow.com/q/78477621
tagged with: variables
has comment: http://stackoverflow.com/comment/138353398
has comment: http://stackoverflow.com/comment/138353145
has comment: http://stackoverflow.com/comment/138354588
tagged with: bash
has comment: http://stackoverflow.com/comment/138356308
tagged with: var
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138353347
has answer: http://stackoverflow.com/a/78477703
has body: I would like to know what means -z ${var+x} if [ -z ${VAR+x} ]; then echo "Variable VAR is unset." else echo "VAR = ${VAR}." I would like to understand in which case I should use this command. I would like to understand in which case I should use this command.
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138353197
tagged with: linux
type: UnansweredQuestion
has title: What means -z ${var+x}?
upvote count: 1
answer count: 1
linked to: http://stackoverflow.com/q/3601515
linked to: http://stackoverflow.com/q/18096670

http://stackoverflow.com/comment/138459442
comment on: http://stackoverflow.com/a/78538423
score: 0
has text: That's a one-liner version of the workaround. How come every other command substitution (like `ls` , `df` , `getopt` , `type` , `podman`) doesn't require a redirection?
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78480370
has comment: http://stackoverflow.com/comment/138358004
has body: I have some shell functions that I use for personal development. I would like to create config files on a per-project basis so that the functions read the config file and use values from the config file, if present. This is a very basic example: path/to/project/functions.sh (works) #!/usr/bin/env bash PROJECT_KEY="abc" function project_name() { if [ -f .config ]; then . .config fi echo $PROJECT_KEY # => "def" } path/to/project/.config PROJECT_KEY="def" The above works, but I have dozens of these utility/helper functions, and I wanted to load the config via another function if it exists. path/to/project/functions.sh (does not work) #!/usr/bin/env bash function load_config() { if [ -f .config ]; then . .config elif [ -f ~/.config ]; then . ~/.config fi } function project_name() { load_config echo $PROJECT_KEY # => "abc" } I believe that the load_config() function is sourcing the config file into the load_config() function, and then when that function returns/exits, the sourced variables are gone because they are scoped to the individual function call, ie, the load_config() function. I understand my current approach isn't working, but I don't know how to avoid executing source .config all over the place. I want to put it in a single function that is called. How do I cleanly read config files in my functions without a ton of duplicate code? Update 2024-05-14 17:00 EST I got a "working" version, here's the updated code. But this still seems very clunky. function config_file() { if -f .config ; then echo .config elif -f $HOME/.config ; then echo $HOME/.config fi } function project_name() { -f $(config_file) && source $(config_file) echo $PROJECT_KEY # => outputs the value from the config file... }
tagged with: config
has comment: http://stackoverflow.com/comment/138358912
has comment: http://stackoverflow.com/comment/138360332
has comment: http://stackoverflow.com/comment/138358705
has comment: http://stackoverflow.com/comment/138358811
tagged with: function
has comment: http://stackoverflow.com/comment/138358346
has comment: http://stackoverflow.com/comment/138358718
tagged with: bash
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138358272
has comment: http://stackoverflow.com/comment/138358242
downvote count: 1
has title: Per-project and global fallback config for shell scripts
has comment: http://stackoverflow.com/comment/138358673
has comment: http://stackoverflow.com/comment/138358765
has comment: http://stackoverflow.com/comment/138358012
upvote count: 2
has comment: http://stackoverflow.com/comment/138358477
has comment: http://stackoverflow.com/comment/138358687
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138358797
has comment: http://stackoverflow.com/comment/138358171
type: UnansweredQuestion

http://stackoverflow.com/a/78465027
has comment: http://stackoverflow.com/comment/138330965
has comment: http://stackoverflow.com/comment/138348939
has comment: http://stackoverflow.com/comment/138330634
answers question: http://stackoverflow.com/q/78464749
downvote count: 0
score: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/78464749
has comment: http://stackoverflow.com/comment/138373561
has comment: http://stackoverflow.com/comment/138330627
has body: Thanks for the help guys, i ended up using the getcwd thank you for showing it to me as i didnt know it existed. This is the algorythm i used to print out the source code //Getting the file path// getcwd(cwd, sizeof(cwd)); strcat(cwd,"/test.c"); //printing the code using the cat command through the execl function// execl("/bin/cat", "cat", cwd, NULL);
has comment: http://stackoverflow.com/comment/138330650
has comment: http://stackoverflow.com/comment/138397206
type: AcceptedAnswer
upvote count: 1
has comment: http://stackoverflow.com/comment/138398941

http://stackoverflow.com/comment/138497813
type: AnswerComment
comment on: http://stackoverflow.com/a/78557282
has text: Thank you, exactly what i was looking for. Appreciate it. and the explanation.
score: 0
type: Comment

http://stackoverflow.com/comment/138436720
type: Comment
comment on: http://stackoverflow.com/q/78525043
has text: I now figured out, it just starts impressive with each iteration of the loop instead of watching the folder and only start it after an event has been caught. Since each instance of impressive takes some 100MB of RAM, the RAM quickly fills up and the machine freezes.
type: QuestionComment
score: 0

http://stackoverflow.com/a/78533368
has body: In TXR Lisp: $ txr shoreup.tl &lt; data dir1 file01 file02 file03 dir2 file04 file05 dir3 file06 dir4 file07 file08 file09 file10 Code in shoreup.tl: (flow (get-lines) (mapcar (op spl &quot; &quot;)) (partition-by first) (mapdo (lambda (part) (let ((dir (first (first part))) (files [mappend rest part])) (put-line `@dir @{files &quot; &quot;}`))))) In TXR Pattern Language: $ txr shoreup.txr data dir1 file01 file02 file03 dir2 file04 file05 dir3 file06 dir4 file07 file08 file09 file10 Code in shoreup.txr: @(repeat) @dir @file0 @ (collect :gap 0 :vars (filen)) @dir @filen @ (end) @ (do (put-line `@dir @{(cons file0 filen) &quot; &quot;}`)) @(end)
upvote count: 1
answers question: http://stackoverflow.com/q/78533122
type: Answer
score: 0
downvote count: 1

http://stackoverflow.com/q/78533115
has answer: http://stackoverflow.com/a/78533676
downvote count: 0
tagged with: bash
tagged with: cat
has comment: http://stackoverflow.com/comment/138450275
favorite count: 0
has comment: http://stackoverflow.com/comment/138450289
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78533682
has comment: http://stackoverflow.com/comment/138450908
has title: How to cat text string and file in bash in way to preserve literal \newpage in output?
tagged with: echo
upvote count: 2
answer count: 2
has body: I have multiple markdown files that I am trying to concatenate into one markdown file in bash. I can concatenate markdown files and preserve “\newpage” lines, but when trying to add a group title via a string calling echo to each group it wont preserve literal \newpage in file. I am bash beginner and learning as I go. How can I achieve this without making a file just storing group name with \newpage? Examples of a single item in single markdown file ## Item 1 of group 1 Text to item 1 of group 1. \newpage ## Item 2 of group 1 Text to item 2 of group 1. \newpage ## Item 1 of group 2 Text to item 1 of group 2. \newpage Desired output after grouping all items under one group and adding a group title “Title of group 1” with \newpage at the end # Title of group 1 \newpage ## Item 1 of group 1 Text to item 1 of group 1. \newpage ## Item 2 of group 1 Text to item 2 of group 1. \newpage # Title of group 2 \newpage ## Item 1 of group 2 Text to item 2 of group 2. \newpage I can group items into each groups markdown file by using following code (this part works and \newpage is preserved: dir_in="/path/do/input_directory/" dir_out="/path/do/output_directory/" file="group_1" for f in ${dir_in}${file}/*.md; do cat $f >> ${dir_out}${file}.md; echo >> ${dir_out}${file}.md; done How should I edit the code above so I could add a group name “# Title of group 1 \newpage” from string variable? I tried making a title into a variable and echo with content of grouped markdown file. title="#Title of group 1 \newpage" content=$(cat "${dir_out}${file}.md") result=$(echo "${title}\n\n${content}") echo "$result" > ${dir_out}${file}.md But echo interprets every \n and prints newlines out and leaves “ewpages" into file. #Title of group 1 ewpage
type: Question
has comment: http://stackoverflow.com/comment/138450278
has comment: http://stackoverflow.com/comment/138451049
accepted answer: http://stackoverflow.com/a/78533676
score: 2
possible better answer: http://stackoverflow.com/a/78533682

http://stackoverflow.com/comment/138450410
type: Comment
score: 6
type: QuestionComment
has text: You're far more likely to get a solution to your problem if you get rid of the first 2 questions in your question and only show your final sample input and expected output from your question and your attempt to solve THAT problem yourself. You can safely assume there is no existing tool to do that specific thing but it'll be easy to do with an awk script. Make sure your example contains truly representative data, e.g. if your real input can contain spaces then don't post an example without them so you get a solution that'll work for your real data.
comment on: http://stackoverflow.com/q/78533122

http://stackoverflow.com/q/78539085
linked to: http://stackoverflow.com/q/5342782
has comment: http://stackoverflow.com/comment/138461351
tagged with: http://stackoverflow.com/tag/csv
has comment: http://stackoverflow.com/comment/138462171
downvote count: 1
has comment: http://stackoverflow.com/comment/138460928
has body: I'm trying to parse a file, separated by a comma (CSV file). Imagine a list of books and their authors, the second column is the author. Since the file has millions of rows (around 133M), I cannot do this with Python or Java (I mean, I can, but it takes way too long), so I decided to use bash or zsh (which is the interpreter installed in the Mac). I need to count how many books each author has, which means, counting the occurrences of each unique value on the second column. #!/bin/zsh awk -v FS="," 'NR > 1 { author_id = $2; count[$author_id]++; } END { PROCINFO["sorted_in_place"] = 1; for (author_id, count) in count; { printf "%d, %d\n", author_id, count; } }' "~/list_of_books_per_author.csv" | sort -nrk2,2 | head -n 10 I keep getting this error: awk: syntax error at source line 7 context is for >>> (author_id, <<< awk: illegal statement at source line 7 awk: illegal statement at source line 7 I'm not really aware of what I'm doing wrong now. How do you iterate an associative array, when you want both values, key and value?
has comment: http://stackoverflow.com/comment/138460799
answer count: 2
has comment: http://stackoverflow.com/comment/138460815
has answer: http://stackoverflow.com/a/78539309
has comment: http://stackoverflow.com/comment/138464323
has comment: http://stackoverflow.com/comment/138460873
possible better answer: http://stackoverflow.com/a/78545793
tagged with: bash
has comment: http://stackoverflow.com/comment/138462623
has title: Awk: syntax for looping over associative array
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138464301
has answer: http://stackoverflow.com/a/78545793
tagged with: awk
has comment: http://stackoverflow.com/comment/138461793
tagged with: zsh
has comment: http://stackoverflow.com/comment/138461109
has comment: http://stackoverflow.com/comment/138464363
type: Question
accepted answer: http://stackoverflow.com/a/78539309
upvote count: 4
has comment: http://stackoverflow.com/comment/138461197
score: 3

http://stackoverflow.com/comment/138485395
type: Comment
type: AnswerComment
has text: As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
score: 0
comment on: http://stackoverflow.com/a/78545401

http://stackoverflow.com/a/78448182
score: 0
has comment: http://stackoverflow.com/comment/138305620
has comment: http://stackoverflow.com/comment/138305529
answers question: http://stackoverflow.com/q/78447882
type: Answer
has body: Regularly I'm facing issues with doubled entries, I have the tendency of sorting them and getting the unique values, as follows: ... | sort | uniq , where ... stands for any command, resulting in a list of entries, like cat, grep, awk ... '{print $n}', ... (I have no answer for the header line, except tail -n $(($(wc -l file1.txt | awk '{print $1}') - 1)) file1.txt). The latter stands for: Calculate the number of lines in your file. Subtract 1 of that number ($((calculation)) performs a calculation). Use tail -n for getting that number of lines of your file.

http://stackoverflow.com/comment/138325749
type: Comment
type: AnswerComment
has text: @tripleee you are right :-)
comment on: http://stackoverflow.com/a/78458513
score: 0

http://stackoverflow.com/a/78469678
upvote count: 1
answers question: http://stackoverflow.com/q/78469662
type: Answer
has comment: http://stackoverflow.com/comment/138486109
has body: The issue in your script is due to the syntax error in the if statement. The correct syntax for comparing strings in Bash requires spaces between the brackets and the condition. Additionally, you should use quotes around variables to prevent issues with spaces or special characters. #!/bin/bash api='/C/Repos/me/services/api' declare -a reposArray=($api) for repo in "${reposArray[@]}" do echo echo "updating $repo" cd "$repo" echo "fetching code" #git fetch --prune branch="$(git branch --show-current)" if [ "$branch" != "main" ]; then git switch main fi echo "merging remote into main" git merge done I've added spaces around [ and ] in the if statement, as well as quotes around the variable $branch. This should resolve the "command not found" error you were encountering.
score: 0
downvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138477142
accepted answer of: http://stackoverflow.com/q/78469662
has comment: http://stackoverflow.com/comment/138476336
has comment: http://stackoverflow.com/comment/138339257

http://stackoverflow.com/a/78490192
upvote count: 2
has body: As commented by multiple persons, you should really avoid using set -e. Anyway, if using it and wanting to also capture exit code of failed command and test it; you may do it like this: #!/usr/bin/env bash set -e rc=0 && helm status deployment-name 2> /dev/null || rc=$? if [ $rc -eq 0 ]; then echo "uninstall helm release" helm uninstall deployment-name else printf 'Return code: %d\n' "$rc" echo "helm reease doesnot exist" fi Suffixing the command call with || rc=$?, || prevents stopping script on error as the command is now part of a condition. The next part of the OR condition is used to save the exit code with rc=$? Alternatively you can integrate the call to the command and the $rc assignment directly in the condition with a command group ending with the false command to trigger the false branch of the if like this: #!/usr/bin/env bash set -e if helm status deployment-name 2> /dev/null || { rc=$?;false;}; then echo "uninstall helm release" helm uninstall deployment-name else printf 'Return code: %d\n' "$rc" echo "helm reease doesnot exist" fi
answers question: http://stackoverflow.com/q/78489561
score: 2
downvote count: 0
type: Answer

http://stackoverflow.com/comment/138403048
comment on: http://stackoverflow.com/q/78505383
type: QuestionComment
has text: When trying to write or debug a script, start with 1 command, e.g. `TZ="/Europe/Berlin" date` and debug **that** first outside of all of the other complexity of a larger script. Once that's working then think about the rest.
type: Comment
score: 1

http://stackoverflow.com/comment/138519927
score: 0
comment on: http://stackoverflow.com/q/78571808
type: QuestionComment
has text: https://stackoverflow.com/search
type: Comment

http://stackoverflow.com/comment/138589841
has text: I feel like there needs to be a way to see the diff of changes being made. It seems odd Microsoft would not offer this feature...
comment on: http://stackoverflow.com/a/78527266
type: Comment
type: AnswerComment
score: 1

http://stackoverflow.com/a/78611366
type: Answer
answers question: http://stackoverflow.com/q/78585407
downvote count: 0
score: 1
upvote count: 1
has body: i was able to build dpkg using following command dpkg-deb --build --nocheck process-mgmt-svc --nocheck Inhibits dpkg-deb --build's usual checks on the proposed contents of an archive. You can build any archive you want, no matter how broken, this way.

http://stackoverflow.com/a/78465427
score: 1
upvote count: 1
has body: With: while read url; do ... perl ... list1 > list done < list You're writing to the same file you're reading, list, don't do that. Change perl -ne 'print unless $dup{$_}++;' list1 > list done < list to perl -ne 'print unless $dup{$_}++;' list1 > outfile done < list or better: perl -ne 'print unless $dup{$_}++;' list1 done < list > outfile to avoid THAT major problem but then you also have more problems including this: wget ... >> list1 perl -ne 'print unless $dup{$_}++;' list1 which is constantly appending to list1 so perl has to re-process previous contents again on every loop iteration. You should probably be doing: wget ... > list1 perl -ne 'print unless $dup{$_}++;' list1 to repopulate list1 on every iteration instead of appending to it, instead but idk why you're even using a file there instead of just piping to perl: wget ... | perl -ne 'print unless $dup{$_}++;' Overall, this might be what you're trying to do (untested and not recommending the approach, just trying to make the OPs code function): #!/usr/bin/env bash while IFS= read -r url; do wget -q "$url" -O - | grep -o -E 'href="([^"#]+)"' | grep "magazine/" | grep "https" | sort -u | sed -r 's/.*href="([^"]+).*/\1/g' | perl -ne 'print unless $dup{$_}++;' done < list > outfile Without sample input (output from curl) and expected output (from the loop) this is all just guesswork but the above then could probably be changed to this so as to not spawn subshells repeatedly to call all of those commands inside the loop: while IFS= read -r url; do wget -q "$url" -O - done < list | grep -o -E 'href="([^"#]+)"' | grep "magazine/" | grep "https" | sort -u | sed -r 's/.*href="([^"]+).*/\1/g' | perl -ne 'print unless $dup{$_}++;' \ > outfile and I further expect that this pipeline of 6 commands: grep -o -E 'href="([^"#]+)"' | grep "magazine/" | grep "https" | sort -u | sed -r 's/.*href="([^"]+).*/\1/g' | perl -ne 'print unless $dup{$_}++;' could be replaced with a single awk (or perl) command.
type: Answer
answers question: http://stackoverflow.com/q/78462933
downvote count: 0
has comment: http://stackoverflow.com/comment/138333281

http://stackoverflow.com/comment/138483840
type: Comment
has text: Thanks, eval indeed works, but how can I get return code with eval ? $? does not work. Always get 0, however, I get an error.
comment on: http://stackoverflow.com/q/78551562
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138336524
has text: @Walter A I had considered this but I was hoping for a shell independent solution and I am having trouble finding the shell specific way of determining whether a functon exists in zsh. The `type` specification is bash specific.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78465704

http://stackoverflow.com/q/78545397
score: 0
has comment: http://stackoverflow.com/comment/138472207
has body: So far I have spawned a bash script in my expect script that logins to the remote server automatically, which works. Now within my expect script I am trying to run commands such as 'configure terminal' and 'copy startup-config ftp configuration-id 1' on the remote server that i login to. These aren't commands that Linux is familiar with which makes it tricky. Any help will do thank you. Once the expect script uses the spawn to login to the remote server how can I continue with the expect script to run the commands that I need to within the remote server.
tagged with: bash
downvote count: 1
has title: Writing an expect script to execute commands on remote server that Linux itself might not be familiar with such as 'configure terminal'
tagged with: expect
type: Question
tagged with: remote-server
has answer: http://stackoverflow.com/a/78550713
type: UnansweredQuestion
answer count: 1
has comment: http://stackoverflow.com/comment/138472201
upvote count: 1
favorite count: 0

http://stackoverflow.com/comment/138372446
score: 1
has text: use `… | uniq -dw 32` to only check the first 32 characters.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78488507

http://stackoverflow.com/comment/138393003
type: Comment
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/78500397
has text: Genius. No need for random either I see.

http://stackoverflow.com/comment/138329500
type: QuestionComment
comment on: http://stackoverflow.com/q/78464004
score: 1
type: Comment
has text: Any reason this is being downvoted? Seems like a straightforward question to me.

http://stackoverflow.com/a/78455077
answers question: http://stackoverflow.com/q/78450852
upvote count: 1
type: Answer
score: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78450852
downvote count: 0
has body: My Synology model is DS918+ and for some weird reason, Synology decided to force owners of some models, including mine, to update to v7.2 manually and not even notify them. After manually updating my NAS to DSM 7.2.1-69057 Update 5, the Scheduled Task just works. Seems it was a problem with the previous version.

http://stackoverflow.com/comment/138441050
comment on: http://stackoverflow.com/a/78525190
type: Comment
score: 0
has text: No worries, it was actually part of the solution!
type: AnswerComment

http://stackoverflow.com/a/78539309
has comment: http://stackoverflow.com/comment/138475561
type: Answer
has comment: http://stackoverflow.com/comment/138464412
answers question: http://stackoverflow.com/q/78539085
has body: Awk is completely its own language, and completely distinct from both Bash and Zsh (which between themselves are also two distinct, incompatible languages, though related). However, if you are learning to use the shell, you will probably also want to learn at least the basics of Awk (and sed), too. Your attempt to loop over an associative array uses completely the wrong syntax. You want for (author_id in count) { printf "%d, %d\n", count[author_id], author_id; } Note also how there should be no semicolon before the opening brace. I'm guessing you also meant count[author_id]++; earlier in the script. ($author_id would use the integer in author_id as the index into the fields; so if author_id is 3, you were doing count[$3]++) Depending on how complex your CSV file is, Awk may or may not be inadequate. It copes well with completely trivial CSV files, but is less ideal for complex ones with quoted literal commas and/or quoted literal newlines in the CSV data. You are probably doing something wrong if you think Awk is going to be much faster than compiled Java. Python is probably a bit slower, but none of them should be catastrophically slow when it comes to reading one line at a time and spitting out a result. (But if you mean it would take longer for you to write a quick program for this in Java, that's probably true.) As a further aside, you want ~/"list_of_books_per_author.csv"; at least in Bash, the tilde will not be expanded if it is in double quotes.
has comment: http://stackoverflow.com/comment/138473876
upvote count: 5
accepted answer of: http://stackoverflow.com/q/78539085
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138467567
has comment: http://stackoverflow.com/comment/138473900
has comment: http://stackoverflow.com/comment/138461206
has comment: http://stackoverflow.com/comment/138461133
score: 5
downvote count: 0

http://stackoverflow.com/comment/138325652
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78461484
has text: Thank you all for support! I think the code may be optimized further, but I'm glad that difference is already x2.5 not x6
type: QuestionComment

http://stackoverflow.com/comment/138327263
type: Comment
has text: I'm not sure what the question is. Does this work or not?
comment on: http://stackoverflow.com/q/78462933
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138394458
comment on: http://stackoverflow.com/a/78501116
has text: @tuqueque, use `set -x` to turn on trace logging. That said, "piping to echo" is itself a problem: you shouldn't ever pipe to echo, as echo doesn't read from stdin so it ignores anything piped into it. The only pipe in this answer is the one between `find` and `wc` -- don't add more.
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138316426
type: Comment
score: 0
has text: Did you update your gcloud CLI? Do you have the same version as your colleague?
type: QuestionComment
comment on: http://stackoverflow.com/q/78456415

http://stackoverflow.com/a/78525190
has comment: http://stackoverflow.com/comment/138441050
answers question: http://stackoverflow.com/q/78525043
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/138436661
has body: The issue is that impressive is running in the foreground blocking the loop from continuing. If you want the loop to continue directly after the launch of impressive you have start impressive in the background. You can do that by adding a & after the command: #!/bin/bash TESTPATH="/some/path/" while true; do inotifywait -m -e create,delete,moved_from -r "$TESTPATH" && echo "DEBUG: Event detected!" && pkill -f /usr/bin/impressive || true && impressive -a 10 -w "$TESTPATH*.pdf" & done
has comment: http://stackoverflow.com/comment/138439888
type: Answer

http://stackoverflow.com/comment/138427445
type: Comment
comment on: http://stackoverflow.com/q/78520070
has text: I've been shell programming for 42 years and never used `dir` so I'm not sure what it's use is. `find` has no problem with newlines in file or directory names. I use `ls` all the time but just when running it manually to see some output. If I wanted to do anything else then I'd just use whatever is best suited for whatever that something else is. Using tools that output NUL chars instead of newlines at the end of file names is useful, e.g. `printf '%s\0' * | xargs -0 foo` to call `foo` on each file in your directory. `find`, `printf`, `stat`, and `xargs` are the usual tools.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138324794
type: Comment
score: 0
has text: in the 2nd loop you have `echo "$(date +%Y-%m-%d) $line"` which is invoking an (expensive) subhell to obtain the current date; big performance hit here because that subshell is invoked for every pass thru the loop; even worse, each subshell is returning the same exact thing; you would be better off invoking that subshell *once* before the loop (storing the result in a variable) and then referencing the variable in the `echo` (better yet, add an additional `sed -e` clause to preference all lines with `$last_date` - see previous comment about rewriting 1st loop)
comment on: http://stackoverflow.com/q/78461484
type: QuestionComment

http://stackoverflow.com/comment/138434243
has text: Why do you have a shell while loop in that? It's not needed and is the cause
type: Comment
comment on: http://stackoverflow.com/q/78524211
score: 2
type: QuestionComment

http://stackoverflow.com/comment/138483290
type: QuestionComment
type: Comment
has text: The command seems to be correct. Can you post the result of `type az` ?
comment on: http://stackoverflow.com/q/78551049
score: 0

http://stackoverflow.com/comment/138358718
comment on: http://stackoverflow.com/q/78480370
type: QuestionComment
score: 0
type: Comment
has text: BTW, why do you source the config from inside a function? Sourcing the it at the top of the script is the most common approach

http://stackoverflow.com/comment/138355715
type: Comment
has text: Do this answer your question: [Bash- passing input without shell interpreting parameter expansion chars](https://stackoverflow.com/a/26331436/1765658)
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78478782

http://stackoverflow.com/q/78493200
has comment: http://stackoverflow.com/comment/138381287
tagged with: bash
duplicate of: http://stackoverflow.com/q/2937407
has comment: http://stackoverflow.com/comment/138380819
answer count: 1
has comment: http://stackoverflow.com/comment/138381368
has title: using test -e to check if any file exist in a directory
has answer: http://stackoverflow.com/a/78493443
has comment: http://stackoverflow.com/comment/138381211
score: 0
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138380678
linked to: http://stackoverflow.com/q/2937407
has body: I want to execute a particular block of code if given file exists. if ssh user@$host "test -e $file"; ... When $file is a complete file name such /tmp/test1.txt this works fine. However, if I want to check if any file exists in a directory such as $file is /tmp/*, I get bash: test: too many arguments Is it possible to use * with test -e, if yes how?

http://stackoverflow.com/comment/138416347
score: 0
comment on: http://stackoverflow.com/a/78514116
has text: thanks - I think you are correct, I went in for search and the string I'm interested in is the first line: GATTCCAGATGGAGGT GATTCCAGATGGAGGTG GGATTCCAGATGGAGGT GATTCCAGATGGAGGTGC GGATTCCAGATGGAGGTG TGGATTCCAGATGGAGGT GATTCCAGATGGAGGTGCT GGATTCCAGATGGAGGTGC TGGATTCCAGATGGAGGTG ATGGATTCCAGATGGAGGT GATTCCAGATGGAGGTGCTG GGATTCCAGATGGAGGTGCT
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138371233
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78485715
has text: @F.Hauri-GiveUpGitHub How could `printf %q $(generate)` solve the problem? I do not want to print some variable but want to pass it to another script. Or do you mean that it works if I use printf inside the generate script?
type: QuestionComment

http://stackoverflow.com/q/78520208
tagged with: git-bash
upvote count: 1
tagged with: git-for-windows
has comment: http://stackoverflow.com/comment/138427351
score: 1
tagged with: bash
linked to: http://stackoverflow.com/q/21517281
tagged with: windows
favorite count: 0
duplicate of: http://stackoverflow.com/q/21517281
answer count: 2
accepted answer: http://stackoverflow.com/a/78520260
has body: In a Bash terminal on Linux, this works fine: # define some bash func foo() { echo "foo" } # Back up your system's default PS1 prompt 1 string, which controls the prompt # output if [ -z "$PS1_BAK" ]; then PS1_BAK="$PS1" fi # Set the PS1 prompt 1 string to run the `foo` function every time the # prompt is printed PS1='$(foo)'"\n$PS1_BAK" Now, every time I press Enter, it prints foo above my command prompt, as expected. Example: foo gabriel@my_computer:~$ foo gabriel@my_computer:~$ foo gabriel@my_computer:~$ I want the same behavior on Windows in the Git Bash terminal which comes with Git for Windows. This trick is how I make my terminal automatically tell me the git branch, hash, and tag whenever I am inside a git repo. (See where I set my PS1 string via PS1= here). However, in Git Bash on Windows, the above code produces this error instead: bash: command substitution: line 1: syntax error near unexpected token `)' bash: command substitution: line 1: `foo)' Why? And more importantly: how do I make it work in Git Bash on Windows? Note that the Git Bash terminal is based on MSYS2, if that helps. Update: Replace the definition of foo above with: foo() { echo "$(pwd)" } ...to print the present working directory, and you get the same behavior still: Linux works, Git Bash does not. Git Bash has problems with command substitution in the prompt strings.
has answer: http://stackoverflow.com/a/78520332
has title: Cannot use command substitution inside Git Bash on Windows: "bash: command substitution: line 1: syntax error near unexpected token `)'"
linked to: http://stackoverflow.com/q/22709371
type: Question
possible better answer: http://stackoverflow.com/a/78520332
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78520260
downvote count: 0
tagged with: git

http://stackoverflow.com/a/78451330
answers question: http://stackoverflow.com/q/78451308
has body: You are assuming that source foo will cause foo to run without arguments. This is not the case. Here's help source: If any arguments are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters are unchanged. Since the source command has no further arguments, the positional parameters are unchanged, so $1 is still /home/usr/rob/abc.sh
type: Answer
score: 0

http://stackoverflow.com/a/78451480
has comment: http://stackoverflow.com/comment/138312502
answers question: http://stackoverflow.com/q/78451463
score: -1
upvote count: 1
has body: TLDR: interactive bash has a shell built-in echo different from /usr/bin/echo The utility which can be used to show that echo in an interactive bash command line is actually using the shell built-in echo command, rather than /usr/bin/echo. Since they behave differently regarding their interpretation of escape sequences, the output differs accordingly. $ which -a echo echo: shell built-in command /usr/bin/echo /bin/echo /usr/bin/sh is pointing to /usr/bin/dash which does not have a shell built-in for echo and uses /usr/bin/echo instead, so this explains the difference in behavior when running the script using sh over bash. $ which -a echo /usr/bin/echo /bin/echo
type: Answer
has comment: http://stackoverflow.com/comment/138925011
downvote count: 2

http://stackoverflow.com/comment/138334549
type: QuestionComment
type: Comment
has text: In case you are unfamiliar with **GNU Parallel**, the referenced command finds all the files in the current directory and below and passes as many files as possible (the `-X` option) to each invocation of `rsync` and keeps 10 `rsync` jobs running in parallel, starting a new one immediately each time any job finishes.
comment on: http://stackoverflow.com/q/78466816
score: 0

http://stackoverflow.com/comment/138544418
has text: That's a [useless use of `echo`](https://www.iki.fi/era/unix/award.html#echo); just assign `configs+=("execute_program_name" "--first" "${first_column[i]}" "--second" "${second_column[i]}" "${command[i]}")` if that's what you mean, though I'm guessing you should properly just add a single string.
comment on: http://stackoverflow.com/a/78583213
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138517961
score: 2
has text: I like alternative 2 (nice to know that you can specify a regex as a field separator!)
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78570500

http://stackoverflow.com/q/78587909
tagged with: signature
tagged with: yubikey
tagged with: cryptography
has title: Sign RS256 JWT with Yubikey PIV is incorrect
score: 0
type: Question
answer count: 0
has body: I want to sign my JWT with Yubikey PIV and want to use RS256 alg. I found yubico-piv-tool, found how to make a sign and wrote bash script. The script creates sign (I check it with openssl) correctly, but, when I am trying to convert sign to JWT sign, something happenes and it break the signature. I guess that there is a mistake in signature conversion, but can't find it. Could somebody help me? There is a script, which I wrote #!/bin/bash # step 1 - generate a new key pair on a YubiKey alg="RSA2048" sha="SHA256" yubico-piv-tool -a generate -s 9c -A ${alg} -o pub.pem # step 2 - generate data to be signed #jo iss=issuer aud=audience > payload.json now=$(date +%s | cut -b1-13) echo '{"htm": "GET","htu": "https://host/token","iat": '"${now}"'}' > payload.json echo '{"typ": "dpop+jwt", "alg": "RS256"}' > header.json # base64-encode header and payload basenc --base64url header.json | tr -d '\n=' > header.b64 basenc --base64url payload.json | tr -d '\n=' > payload.b64 echo -n . > dot cat header.b64 dot payload.b64 > datatosign # step 3 - sign using yubikey yubico-piv-tool -a verify-pin --sign -s 9c -H ${sha} -A ${alg} -i datatosign -o signature.der # step 4 - verify # verify using openssl openssl dgst -${sha} -verify pub.pem -signature signature.der datatosign # convert openssl signature #cat signature.der | openssl asn1parse -inform der | egrep -o '[A-F0-9]{64}' | xxd -r -p | basenc --base64url | tr -d '\n=' > signature.b64 cat signature.der | base64 | tr -d '\n=' | tr -- '+/' '-_' > signature.b64 # construct jwt cat datatosign dot signature.b64 > token.jwt # verify using step cat token.jwt | step crypto jwt verify --key pub.pem --iss issuer --aud audience --alg RS256 # verify using jwt.io echo "Open the following URL in your browser:" echo "https://jwt.io/#debugger-io?token=$(cat token.jwt)&publicKey=$(jq -sRr @uri pub.pem)"
tagged with: jwt
type: UnansweredQuestion
tagged with: bash

http://stackoverflow.com/a/78576845
has comment: http://stackoverflow.com/comment/138557341
score: 0
answers question: http://stackoverflow.com/q/78561775
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138538996
has comment: http://stackoverflow.com/comment/138538988
has body: Thanks for all the help. I ended up with this script and it's working beautifully! #!/bin/bash #ask user for filepath and change directory to filepath read -p "Enter filepath: " fp cd "$fp" #loop through files for file in * do #seperate file extentsion and name filepath="${fp}${file}" filename_with_ext=$(basename "$filepath") filename="${filename_with_ext%.*}" extension="${filename_with_ext##*.}" #concatinate filename with new extension ni_file="${filename}.nii" #convert to nii using now seperated file name concaqtinated with .nii mri_convert --in_type mgz --out_type nii "${file}" "${ni_file}" done
type: Answer
accepted answer of: http://stackoverflow.com/q/78561775

http://stackoverflow.com/q/78571808
has title: How do i use nohup command for execute N processess in background on a server?
has comment: http://stackoverflow.com/comment/138520482
has comment: http://stackoverflow.com/comment/138519830
has comment: http://stackoverflow.com/comment/138519927
tagged with: ssh
type: Question
has comment: http://stackoverflow.com/comment/138545508
has comment: http://stackoverflow.com/comment/138520561
tagged with: nohup
has comment: http://stackoverflow.com/comment/138525722
has comment: http://stackoverflow.com/comment/138522885
has comment: http://stackoverflow.com/comment/138520558
has comment: http://stackoverflow.com/comment/138519936
linked to: http://stackoverflow.com/q/78228111
has comment: http://stackoverflow.com/comment/138519804
score: 0
linked to: http://stackoverflow.com/q/954302
answer count: 0
tagged with: bash
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/285015
linked to: http://stackoverflow.com/q/29142
has body: I'm using the command on a server for execute in background some processess: nohup bash batch &gt; logfile.txt 2&gt;&amp;1 &lt;&amp;- &amp; but when i close my ssh session, the process batch is killed right before. Another problem that i have with nohup is: After execute batch in background, i want to start another batch process with different parameters, but everytime i start a batch with nohup as described above, the previous one get closed and the new one is started. I've tried to use: nohup source batch &gt; logfile.txt 2&gt;&amp;1 &lt;&amp;- &amp; but everytime i close the ssh session i got the batch process closed. I'm expecting to use N times the command below: nohup source batch &gt; logfile.txt 2&gt;&amp;1 &lt;&amp;- &amp; that runs N different instances of a program, configured by a conf file.

http://stackoverflow.com/q/78505426
tagged with: bash
type: UnansweredQuestion
answer count: 1
duplicate of: http://stackoverflow.com/q/25358698
has comment: http://stackoverflow.com/comment/138401431
linked to: http://stackoverflow.com/q/25358698
type: Question
score: 0
has title: extracting a value from html string in bash
has answer: http://stackoverflow.com/a/78505435
has body: I am trying to write a script, which calls an API using curl: #!/bin/bash cmd="curl ....." result=`$cmd"` echo $result Result is as follows: 201 Created Created Service: I need to extract value of 'action' and store it in a variable. What is convenient way of doing it? I guess sed can help, but not sure how to use it for parsing. PS: Its a protected env, and I cant install any utility.

http://stackoverflow.com/q/78451463
tagged with: bash
type: UnansweredQuestion
favorite count: 0
downvote count: 1
has title: Why does `echo` interpret "\n" as new line character only in interactive shells and not when executing a shell script?
score: -1
type: Question
has answer: http://stackoverflow.com/a/78451478
has comment: http://stackoverflow.com/comment/138308303
has answer: http://stackoverflow.com/a/78451480
has comment: http://stackoverflow.com/comment/138308300
has comment: http://stackoverflow.com/comment/138308527
tagged with: sh
tagged with: newline
has body: Why does echo interpret "\n" as new line character in interactive shells only and not when executing a shell script also? Running in an interactive bash shell: $ echo "hello\nworld" hello world Running as a script using bash: $ echo 'echo "hello\\nworld"' > hello_world.sh $ bash hello_world.sh hello\nworld Running as a script using sh: $ sh hello_world.sh hello world
answer count: 2
upvote count: 0
tagged with: shell
tagged with: linux

http://stackoverflow.com/a/78507282
score: 0
has body: Suggesting du command. To list content of all directories in Mb units: du -m / 2&gt;/dev/null -m produce directory size in Mb. / start inspecting from root directory (hope you know what you are doing) 2&gt;/dev/null ignore all errors related to directories access Once you have all the directories you can filter them with pipe to awk script du -m / 2&gt;/dev/null | awk '$1 &lt; 4 {print $2}' $1 &lt; 4 filter only lines where 1st field less than 4 {print $2} from filtered line print 2nd field
answers question: http://stackoverflow.com/q/78503576
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78503576
type: Answer

yubikey
type: Tag
tag name: yubikey
tags question: http://stackoverflow.com/q/78587909

http://stackoverflow.com/comment/138387642
type: QuestionComment
score: 0
has text: It's unclear how the output would be used for the buckets?
comment on: http://stackoverflow.com/q/78490432
type: Comment

http://stackoverflow.com/q/78447882
has comment: http://stackoverflow.com/comment/138323749
has answer: http://stackoverflow.com/a/78448081
score: 0
type: Question
has answer: http://stackoverflow.com/a/78449704
tagged with: shell
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78448182
answer count: 4
tagged with: bash
has body: I have csv file, which has data, Server,Department testserver,Fin Tech testserver,Fin Tech testserver,Fin Tech testserver,Fin Tech testserver,Fin Tech testserver,Fin Tech testserver,HR testserver,Fin Tech testserver,Fin Tech testserver,Fin Tech testserver,Fin Tech testserver,Fin Tech testserver,HR testserver,Fin Tech testserver,Fin Tech I need to keep all values in single field by concatenating them, but it should be unique. eg: Fin Tech/HR but I am getting result as Fin Tech/Fin Tech/Fin Tech/Fin Tech/Fin Tech/Fin Tech/HR/Fin Tech/Fin Tech/Fin Tech/Fin Tech/Fin Tech/HR/Fin Tech/Fin Tech if [ -n "$current_Department" ] || "$current_Department" == *"Department"* ; then bs_name="$current_Department/$Department" fi
has comment: http://stackoverflow.com/comment/138304779
has title: concatenate column values but must be unique
has answer: http://stackoverflow.com/a/78447927

http://stackoverflow.com/comment/138464991
has text: `if` always tests the exit status of the command between `if` and `then`. If it's a compound command (like multiple commands joined with `&`, `;`, `&&`, `||`, etc), that follows the usual rules for the exit status of a compound command, namely that the last command within the compound command's exit status is used. Backgrounded commands add another complication, since they don't return an exit status until sometime later; you need to use something like the `wait` command to want for them to finish and get their exit status.
comment on: http://stackoverflow.com/q/78538302
type: QuestionComment
score: 0
type: Comment

http://stackoverflow.com/comment/138544984
type: QuestionComment
type: Comment
has text: The error message tells you what's wrong; how did it change when you changed to correct permissions?
comment on: http://stackoverflow.com/q/78585407
score: 1

http://stackoverflow.com/a/78466548
accepted answer of: http://stackoverflow.com/q/78462933
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138335099
score: 2
answers question: http://stackoverflow.com/q/78462933
type: Answer
has body: Here is another approach using bash coproc that may be slightly easier to follow than the Perl. walk_queue2 : #!/bin/bash start_url=$1 seen_urls_file=$2 # (re)load lookup table from previous results found declare -A seen if -f $seen_urls_file ; then while IFS= read -r url; do seen["$url"]=1 done < "$seen_urls_file" fi # feed in url, get back zero or more urls from its content # then append "---" to let us track queue length coproc extract_urls { while IFS= read -r url; do wget -qO- "$url" | grep -oE 'href="https://[^"#]+"' | cut -d'"' -f2 | grep 'magazine/' echo --- done } queue_length=0 url=$start_url while if (( !seen["$url"]++ )); then (( ++queue_length )) echo "$url" >& ${extract_urls[1]} echo "$url" >> "$seen_urls_file" echo "$url" fi IFS= read -r url do while $url = --- ; do (( --queue_length == 0 )) && break 2 IFS= read -r url || break 2 done done <& ${extract_urls[0]} Use as: $ cat /dev/null >found $ ./walk_queue2 'https://abc.xyz/start' found $ ./walk_queue2 'https://abc.xyz/another/one' found Addendum: As usual, coproc is not needed: walk_queue3 (same usage as above): #!/bin/bash start_url=$1 seen_urls_file=$2 declare -a queue qpos=0 queue[qpos]=$start_url declare -A seen if -f $seen_urls_file ; then while IFS= read -r url; do seen["$url"]=1 done < "$seen_urls_file" fi while (( ${#queue[@]} > qpos )); do # for simplicity, we don't delete from queue url=${queue[qpos++]} while IFS= read -r new_url; do if (( !seen["$new_url"]++ )); then queue+=("$new_url") echo "$new_url" >> "$seen_urls_file" echo "$new_url" fi done < <( wget -qO- "$url" | grep -oE 'href="https://[^"#]+"' | cut -d'"' -f2 | grep 'magazine/' ) done Note that slowness will probably be due to throttling by the website owner who may object to their website being scraped.
upvote count: 2
downvote count: 0

http://stackoverflow.com/q/78557465
duplicate of: http://stackoverflow.com/q/6697753
linked to: http://stackoverflow.com/q/6697753
tagged with: curl
duplicate of: http://stackoverflow.com/q/40852784
has title: Why does passing bearer token to a shell script not work but embedding the value does
score: 0
type: Question
tagged with: shell
has comment: http://stackoverflow.com/comment/138494170
type: UnansweredQuestion
tagged with: command-line-arguments
has body: I have a shell script foo.sh curl -i -X GET 'https://example.com/bar' \ -H 'Authorization: Bearer abc123def456' which works fine. However if I change it to use an argument for the value of bearer token ... curl -i -X GET 'https://example.com/bar' \ -H 'Authorization: Bearer $1' and invoke it like this ... $ foo.sh abc123def456 The curl request returns as unauthorised . I have tried various ways of providing the value to foo.sh. Attempt one ... $ . ./foo.sh $(python -c "import get_token; print(get_token.get_token())") ... Attempt two ... $ python -c "import get_token; print(get_token.get_token())" > secret_temp.txt $ . ./foo.sh $(cat secret_temp.txt) ... but the result is the same.
answer count: 0
has comment: http://stackoverflow.com/comment/138494532
tagged with: bash

http://stackoverflow.com/q/78457914
tagged with: bash
has title: Difference between executing command from script vs CLI
has body: I am executing following bash script: MACHINE=`cat ~/mach` SSH_CMD="ssh -v root@$MACHINE -t 'echo foo'" echo $SSH_CMD $SSH_CMD I am getting echo foo: command not found when I execute a script containing above. However, if I a copy and paste the echo-ed SSH_CMD and manually run it from command line, I am able to print foo on the console. What's different and how can I workaround it? I was expecting both to have same behavior since they look exactly same.
answer count: 1
favorite count: 0
downvote count: 1
linked to: http://stackoverflow.com/q/12136948
has answer: http://stackoverflow.com/a/78475013
type: Question
upvote count: 0
has comment: http://stackoverflow.com/comment/138319047
has comment: http://stackoverflow.com/comment/138319035
type: UnansweredQuestion
score: -1

http://stackoverflow.com/a/78471577
answers question: http://stackoverflow.com/q/78465704
type: Answer
has body: It is in general not possible to use the same syntax for csh and bash. As for the error in your script: it is probably caused by the fact the type -t deactivate does not produce output. Proper quoting will solve that issue: if [ "$(type -t deactivate)" != "function" ] ; then
accepted answer of: http://stackoverflow.com/q/78465704
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/138343248

http://stackoverflow.com/comment/138436681
has text: Sounds like an [xyproblem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) for either "how do I run a shell command with lines of stdin as arguments?" or "how do I mix and match quoting types in a shell word?"
type: QuestionComment
comment on: http://stackoverflow.com/q/78525458
type: Comment
score: 0

http://stackoverflow.com/comment/138528596
comment on: http://stackoverflow.com/q/78576519
type: QuestionComment
has text: `close` certainly does trigger when the file is closed, but a process might re-open and re-close a file several times, depending on how it's designed. (_Your own code_ is certainly doing that: Every time you use `echo ...anything... >>wc3_mapsync.log`, it opens that file, writes one line, and then closes the file until the next echo opens it again; it would be better practice to only open the log file once instead of reopening it over and over -- if the program modifying your w3x files makes the same mistake, there you are).
type: Comment
score: 1

http://stackoverflow.com/q/78513720
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138415859
has comment: http://stackoverflow.com/comment/138415941
has comment: http://stackoverflow.com/comment/138415925
has comment: http://stackoverflow.com/comment/138415562
tagged with: grep
upvote count: 2
accepted answer: http://stackoverflow.com/a/78514116
has title: Does zgrep limit the amount of search patterns?
linked to: http://stackoverflow.com/q/78504692
tagged with: bash
has body: I have the two following commands. # 6 million lines "zgrep -oF -f /projects/lab.mis/index/temp_hg19.inx /projects/incoming/M1_R2.fastq.gz" # 6 thousand lines "zgrep -oF -f /projects/lab.mis/index/optimize_hg19.inx /projects/incoming/M1_R2.fastq.gz" The first searches through a file that has over 6 million patters while the second one only 6K. Both files should contain the fixe string: "GATTCCAGATGGAGGT" However only the second command, the one with 6K search terms, returns the match. Is there a reason for this? I do not see any error message per se so very confused.
has comment: http://stackoverflow.com/comment/138415609
answer count: 1
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78514116
has comment: http://stackoverflow.com/comment/138416288
downvote count: 2

http://stackoverflow.com/comment/138330100
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78464749
has text: Why can't you use [the `getcwd` function](https://man7.org/linux/man-pages/man2/getcwd.2.html)? Perhaps you need to take a step back, and read some tutorials and beginners material about systems-programming in Linux?

http://stackoverflow.com/comment/138475778
score: 0
type: QuestionComment
has text: `poo=$(printf '%s\n' foo bar baz)` already creates a multi-line variable; but you have to use `echo "$poo"` with double quotes around the value (not `echo $poo`) to see that this is the case. See also [When to wrap quotes around a shell variable](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable)
type: Comment
comment on: http://stackoverflow.com/q/78479842

http://stackoverflow.com/comment/138305529
type: AnswerComment
has text: `sort | uniq` = `sort -u` and `tail -n $(($(wc -l file1.txt | awk '{print $1}') - 1)) file1.txt).` = `tail -n +2`.
score: 2
comment on: http://stackoverflow.com/a/78448182
type: Comment

http://stackoverflow.com/a/78453442
has comment: http://stackoverflow.com/comment/138337872
type: Answer
has comment: http://stackoverflow.com/comment/138358411
downvote count: 1
has comment: http://stackoverflow.com/comment/138363994
score: 0
has comment: http://stackoverflow.com/comment/138355217
has body: This might have something to do with file permissions, but it's hard to say since the first process works. What I do is read the R script into a value channel, and read it in like any other script. The benefit is also you can add a check if file exists function that will throw an error before the pipeline starts, rather than half way through if the R script is missing. Also, I would just paste the download_files.sh into the script box of the process. It's what nextflow was designed for. Same with the R script, but it would be more annoying to change, so I'll leave it. process templateExample { publishDir "data_analysis_files", mode:'copy' output: path "*_gex.csv" , emit: count_files script: """ #!/bin/bash # Define the URLs of the files to download urls=( "https://ftp.ncbi.nlm.nih.gov/geo/samples/GSM3832nnn/GSM3832735/suppl/GSM3832735_wt_naive_gex.csv.gz" "https://ftp.ncbi.nlm.nih.gov/geo/samples/GSM3832nnn/GSM3832736/suppl/GSM3832736_wt_naive_adt.csv.gz" "https://ftp.ncbi.nlm.nih.gov/geo/samples/GSM3832nnn/GSM3832737/suppl/GSM3832737_wt_tumor_gex.csv.gz" "https://ftp.ncbi.nlm.nih.gov/geo/samples/GSM3832nnn/GSM3832738/suppl/GSM3832738_wt_tumor_adt.csv.gz" "https://zenodo.org/records/5511975/files/negative_cDC1_relative_signatures.csv?download=1" "https://zenodo.org/records/5511975/files/positive_cDC1_relative_signatures.csv?download=1" "https://github.com/SIgN-Bioinformatics/sgCMAP_R_Scripts/blob/main/sgCMAP_R_Scripts/sgCMAP-internal.R" "https://github.com/SIgN-Bioinformatics/sgCMAP_R_Scripts/blob/main/sgCMAP_R_Scripts/sgCMAP_score.R" ) # Download each file using wget for url in "${urls[@]}"; do wget "$url" done # Unzip each downloaded file using gunzip for file in *.gz;do gunzip "$file" done """ } process read_count_p { publishDir "results",mode:'copy' input: path count_files path read_counts_rscript output: path "result.txt" """ Rscript ${read_counts_rscript} ${count_files} """ } workflow { templateExample() read_count_p(templateExample.out.count_files, read_count…
answers question: http://stackoverflow.com/q/78450649
upvote count: 1

http://stackoverflow.com/comment/138496778
has text: The design is broken. Make the arguments to mysql an array, so that each array element corresponds to one parameter for mysql, and execute it as `output=$(mysql "{$array[@]}")`.
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78551562

http://stackoverflow.com/comment/138492087
type: QuestionComment
score: 2
type: Comment
has text: I *can* reproduce it on Gnome terminal but not Xterm. I don't think this has much to do with bash
comment on: http://stackoverflow.com/q/78553947

http://stackoverflow.com/a/78500841
type: Answer
accepted answer of: http://stackoverflow.com/q/78496979
score: 2
has comment: http://stackoverflow.com/comment/138393983
has body: You could use find command with multiple use of -exec option like that: find matt paul -name "kustomization.yaml" \ -exec echo -n "Work on '{}' file in " \; -exec pwd \; \ -exec somecommand1 {} \; \ -exec somecommand2 {} \; Alternative Use -execdir option to execute commands in the directory where file found. find matt paul -name "kustomization.yaml" \ -execdir echo -n "Work on '{}' file in: " \; -execdir pwd \; \ -execdir somecommand1 {} \; \ -execdir somecommand2 {} \; Alternative 2 Use a subscript: /some/path/my_commands.sh #! /usr/bin/env bash # cd "${1%/*}" # Necessary if you use `-exec` option instead of `-execdir` echo "Work on '$1' in '$(pwd)' dirrectory" somecommand1 "$1" somecommand1 "$1" chmod +x /some/path/my_commands.sh And use only one -execdir option: find matt paul -name "kustomization.yaml" \ -execdir /some/path/my_commands.sh {} \; This alternative is very useful if you want to make treatments with return codes from somecommand* executions: Subscript: /some/path/my_commands.sh #! /usr/bin/env bash # cd "${1%/*}" # Necessary if you use `-exec` option instead of `-execdir` # It may be important to check the return code of `cd` command before continue # if $? -ne 0 ; then # echo "ERR: ${0##*/}: Cannot change directory to '${1%/*}'" >&2 # exit 1 # fi echo "Work on '$1' file in '$(pwd)' directory" if somecommand1 "$1"; then ... else ... fi ... if somecommand2 "$1"; then ... else ... fi
type: AcceptedAnswer
upvote count: 2
answers question: http://stackoverflow.com/q/78496979
downvote count: 0
has comment: http://stackoverflow.com/comment/138399395

http://stackoverflow.com/a/78499377
score: 0
answers question: http://stackoverflow.com/q/78499350
has comment: http://stackoverflow.com/comment/138392233
has body: You can just define a variable containing your commands and pass them to bash -c you don't need to use eval at all. Only small changes on your inital script are needed for that. #!/bin/bash # Define the block of commands as a variable BLOCK_OF_COMMANDS=" echo \"Running commands\" ls -l " if [ "$HOSTNAME" = "Computer" ]; then # Execute the block of commands locally by passing the BLOCK_OF_COMMANDS variable to bash -c bash -c "$BLOCK_OF_COMMANDS" else # Do the same using SSH ssh Name@RemoteComputer "bash -c '$BLOCK_OF_COMMANDS'" fi
has comment: http://stackoverflow.com/comment/138392104
type: Answer
has comment: http://stackoverflow.com/comment/138392161

http://stackoverflow.com/q/78590486
type: Question
tagged with: alpine-linux
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78593554
has title: Can't connect to Jupyter lab of my Apache/Sedona container via localhost
has answer: http://stackoverflow.com/a/78601028
tagged with: apache-sedona
score: 0
tagged with: bash
tagged with: jupyter-lab
has body: I'm working on Fink ( an astro-physicist-big-data project). My job is to modify Apache:Sedona code in order to manage 3D data (either geometries and algorithms). I use a remote server's VM based on Alpinelinux and my CPU is Ubuntu 22.04 and I'm obviously in bash. My problem: I can't found the jupyter lab by using the usual http://127.0.0.1:8888/lab after running a docker run. What I did: I pulled Apache/Sedona docker: docker pull apache/sedona Run the command below: docker run -e DRIVER_MEM=2g -e EXECUTOR_MEM=2g -p 8888:8888 apache/sedona:latest knowing that original command (found in apache/sedona docker hub was designed for 8GB. Or, when i run this and try to access to localhost: it never works.
answer count: 2
tagged with: docker

http://stackoverflow.com/comment/138325336
has text: (also, avoid `cat foo | ...` in favor of `<foo ...` or `... <foo` -- not a big difference when `...` is `sed`, but when it's something like `tail` or `sort` or `wc -c` that can optimize when given a seekable file descriptor you can miss out on very real performance gains).
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78461484
type: Comment

http://stackoverflow.com/comment/138330296
comment on: http://stackoverflow.com/q/78464749
type: QuestionComment
type: Comment
score: 0
has text: Can you please copy-paste (as text) the *full* and *complete* assignment/exercise into your question?

docker-pull
type: Tag
tag name: docker-pull
tags question: http://stackoverflow.com/q/78529880

http://stackoverflow.com/a/78535924
type: Answer
score: 6
upvote count: 6
answers question: http://stackoverflow.com/q/78534641
downvote count: 0
has comment: http://stackoverflow.com/comment/138462638
has comment: http://stackoverflow.com/comment/138464917
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138462787
has comment: http://stackoverflow.com/comment/138460835
has comment: http://stackoverflow.com/comment/138465270
has body: The premise of the awk language is that there should only be constructs to do things that aren't easy to do with other constructs to keep the language concise and so avoid the language bloat that some other tools/languages suffer from. e.g. some people like that perl has many unique language constructs to do anything you could possible want to do while others express their opposing view of the language in cartoons like https://www.zoitz.com/comics/perl_small.png. This is just one of the many things that it'd be nice to have a function to do, but it's so easy to code whatever you actually need to do to skip a couple of fields for any specific input it'd just be cluttering up the language if a function existed to do it and if we had a function for THIS there are 100s of other functions that should also be created to do all of the other things it'd just be nice to have a function to do. Using GNU awk for \s/\S shorthand $ awk 'sub(/^\s*(\S+\s+){2}/,&quot;&quot;)' file data for row1 data for row2 data for row3 data for row4 and the same with any POSIX awk: $ awk 'sub(/^[[:space:]]*([^[:space:]]+[[:space:]]+){2}/,&quot;&quot;)' file data for row1 data for row2 data for row3 data for row4 Note that the awk output from above would retain any trailing white space, unlike a shell read loop. Both of those rely on the FS being the default blank character but are easily modified for any other FS that can be negated in a bracket expression (or opposite character class). Note that the entire approach relies on being able to negate the FS in a bracket expression so it wouldn't work if the FS was some arbitrary regexp or even a multi-char string but then neither would the shell read loop you're asking to duplicate the function of. If you do happen to have a FS you can't just negate in a bracket expression, e.g. if your fields are separated by 3 digits or 2 punctuation characters so you have something like: $ echo 'abc345def;%ghi+klm;%nop345qrs' | awk -v FS='[[:digit:]]{3}|[[:punct:…
accepted answer of: http://stackoverflow.com/q/78534641
has comment: http://stackoverflow.com/comment/138457397

http://stackoverflow.com/comment/138551606
comment on: http://stackoverflow.com/q/78588816
score: 1
type: QuestionComment
type: Comment
has text: `cmd=( npm run jest )` and then `"${cmd[@]}"` -- or `cmd() { npm run jest; };` and then `cmd` -- isn't many more characters, but either has far fewer hidden surprises.

http://stackoverflow.com/a/78525192
has comment: http://stackoverflow.com/comment/138436914
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/138436638
has comment: http://stackoverflow.com/comment/138436726
has comment: http://stackoverflow.com/comment/138436795
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78525043
has comment: http://stackoverflow.com/comment/138436880
downvote count: 0
has body: You might want to run the impressive command asynchronously. And did you know that you can group commands in curly-brackets? #!/bin/bash TESTPATH="/some/path/" while true do inotifywait -e create -e delete -e moved_from -r "$TESTPATH" && { echo "DEBUG: Event detected!" kill % impressive -a 10 -w "$TESTPATH"*.pdf & } done remark: I constrained the kill to the impressive process of the previous iteration, and moved the glob out of the double-quotes (for it to get expanded)
accepted answer of: http://stackoverflow.com/q/78525043
has comment: http://stackoverflow.com/comment/138436782
has comment: http://stackoverflow.com/comment/138436692
type: Answer

http://stackoverflow.com/comment/138357850
type: Comment
type: AnswerComment
has text: The snapshot file used with `--incremental` can't be a FIFO itself (since tar needs to be able to both inspect and modify it), so I don't see why resume capabilities would work only with explicitly managed named FIFOs and not ones created via process substitution.
comment on: http://stackoverflow.com/a/78475452
score: 0

http://stackoverflow.com/q/78582237
tagged with: bash
linked to: http://stackoverflow.com/q/12136948
answer count: 1
linked to: http://stackoverflow.com/q/13365553
duplicate of: http://stackoverflow.com/q/12136948
score: 0
tagged with: grep
type: Question
tagged with: shell
has body: I have a script that is trying to find a line in a text file. It could be completely alphanumerical, but it's also possible that it contains special characters, mostly < and > as it's sometimes xml-tags with content. Basically this is what I am trying to do: $ grep ' 20240605074212800000001' filename | less Detlef [user@servername /path] $ STRANGEBEHAVIOR="' Detlef'" [user@servername /path] $ echo $STRANGEBEHAVIOR ' Detlef' [user@servername /path] $ grep $STRANGEBEHAVIOR filename | less (END) [user@servername /path] $ grep "$STRANGEBEHAVIOR" filename | less (END) [user@servername /path] $ echo "grep $STRANGEBEHAVIOR filename | less" grep ' Detlef' filename | less I had found out that using grep the next thing works, but using zgrep it does not: [user@servername /path] $ STRANGEBEHAVIOR=" Detlef" [user@servername /path] $ echo $STRANGEBEHAVIOR Detlef [user@servername /path] $ grep "$STRANGEBEHAVIOR" filename | less Detlef For reasons I do not understand, I can't find an easy solution. If I manually type my search with single quotes, grep works the way I understand it to, it looks for this string and ignores all special characters. If I give grep the same information using a variable, grep does not find a match, probably because it is interpreting the single quotes as part of the string, but why?
type: UnansweredQuestion
has title: using grep with a variable containing xml-tags
has answer: http://stackoverflow.com/a/78582251
tagged with: parameter-passing

http://stackoverflow.com/q/78458917
answer count: 0
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/66551874
tagged with: torchserve
tagged with: bash
tagged with: pytorch
has title: CMD to start torchserve from Dockerfile won't execute and exits the container
linked to: http://stackoverflow.com/q/66551874
tagged with: dockerfile
tagged with: docker
score: 0
has body: I have created a Dockerfile for serving an AI application. FROM python:3.10-slim RUN apt-get update &amp;&amp; \ apt-get install -y default-jre ca-certificates-java &amp;&amp; \ apt-get install -y gcc libgdal-dev g++ &amp;&amp; \ apt-get clean &amp;&amp; \ update-ca-certificates -f WORKDIR /home/model-server COPY requirements.txt . ENV GDAL_VERSION 3.3.0 ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-arm64/ RUN pip install -r requirements.txt COPY model_store /home/model-server/model_store/ COPY config.properties /home/model-server/config.properties COPY deploy.sh /home/model-server/deploy.sh EXPOSE 8080 CMD torchserve --model-store model_store --start --models my_model=Unet.mar --ts-config config.properties My start command is docker run --name platerra -p 8080:8080 platerra-ai The docker image build fine but the final step in launching the application results in the container exiting and the final start command does not execute not even with an sh file that has the same command. Keeping the container running by adding tail -f /dev/null and going inside the container and running torchserve --model-store model_store --start --models my_model=Unet.mar --ts-config config.properties or bash deploy.sh works as expected and the server starts running. But why can I not achieve this from the Dockerfile. Going in manually and starting the server is not the best option for wanting to automate deployment.
type: Question

http://stackoverflow.com/a/78458513
upvote count: 1
answers question: http://stackoverflow.com/q/78458050
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/138325749
has comment: http://stackoverflow.com/comment/138319740
has body: Another way could be this (adapted after tripleee's comment): do not use sponge, but before writing to file check jq exit code: if result=$(jq . foo.json); then echo "$result" > foo.json else echo "There was an error. Exiting now." exit 1 fi
downvote count: 0

http://stackoverflow.com/comment/138382444
score: 1
has text: Yeah I've wondered too about why the commit doesn't appear in your first log. So far no idea, sorry. Let's keep on searching.
comment on: http://stackoverflow.com/q/78491259
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138550684
type: QuestionComment
comment on: http://stackoverflow.com/q/78588283
type: Comment
score: 0
has text: $ cat myfile servera serverb serverc $ tr '\n' ' ' <myfile servera serverb serverc Please help me modify the tr (or use vi or sed) to add "or" between words: servera or serverb or serverc

http://stackoverflow.com/q/78538995
has comment: http://stackoverflow.com/comment/138460408
has comment: http://stackoverflow.com/comment/138460343
tagged with: docker
type: Question
has body: I am using docker on windows. And everything works fine. I can create images and docker containers. Version of docker is: docker -v:Docker version 26.1.1, build 4cf5afa And I added in the environments variables of windows this paths: C:\Program Files\Docker\Docker\resources C:\Program Files\Docker\Docker\resources\bin But if I try to connect from a docker container to a other nework inside a docker container: root@032194c3eca0:/# docker exec dwl_backend_rachid-web-1 bash -c "ping 172.18.0.3" Then the following error pops up: bash: docker: command not found Question: how to resolve this error?
has comment: http://stackoverflow.com/comment/138460491
score: -2
accepted answer: http://stackoverflow.com/a/78539050
downvote count: 3
has answer: http://stackoverflow.com/a/78539050
has comment: http://stackoverflow.com/comment/138460324
has title: How to resolve bash: docker: command not found, inside docker container?
tagged with: bash
has comment: http://stackoverflow.com/comment/138460806
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/a/78496026
has comment: http://stackoverflow.com/comment/138385687
type: AcceptedAnswer
score: 2
accepted answer of: http://stackoverflow.com/q/78491259
upvote count: 2
has body: I wanted to share a solution to an issue I encountered while using git log with a directory filter. Initially, when running the command: 15:28:46 ~/Documents/01_repo/b2b-crm (uat) └─▶ $ git log --name-status --oneline --pretty=format:"COMMIT: %H" --diff-filter=ACDMRTUXB 814cfc685b430020192e7c0db04b2874b5790a1e..b0341db807cf7e4fa6b0dff63cf7eabca057308e -- 'force-app/main/default/' COMMIT: ff565cdef935907ec6b8995463c907375a70f9f2 M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParametersController.js COMMIT: 84ee2707977848ff7a7b693b1e2f56f4b54c678d M force-app/main/default/aura/IS_ImprimirContrato_Quadient/IS_ImprimirContrato_QuadientHelper.js I received a list of modified files that did not match what I expected. Removing the directory filter changed the output, showing more modified files. After some research and with the help of the community, especially @knittl, I discovered that the missing parameter was --full-history. This parameter is crucial for including in the log all commits that have touched the specified path, even if the change was made on a branch that was later merged. Here is the correct command that provides the expected output: 15:28:53 ~/Documents/01_repo/b2b-crm (uat) └─▶ $ git log --name-status --oneline --pretty=format:"COMMIT: %H" --full-history --diff-filter=ACDMRTUXB 814cfc685b430020192e7c0db04b2874b5790a1e..b0341db807cf7e4fa6b0dff63cf7eabca057308e -- 'force-app/main/default/' COMMIT: ff565cdef935907ec6b8995463c907375a70f9f2 M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParametersController.js COMMIT: 6e0d17558b091d00fe47304b588ec5e066c09d37 M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParameters.cmp M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParametersController.js M force-app/main/default/aura/GE_CL_SaveComponents/GE_CL_SaveComponents.cmp M force-app/main/default/aura/GE_CL_SaveComponents/GE_CL_SaveComponent…
downvote count: 0
answers question: http://stackoverflow.com/q/78491259
type: Answer

http://stackoverflow.com/comment/138415083
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78513408
score: 4
has text: Does `CONNECT_POD_RESOURCE_NAME` have a carriage return or some other unusual character in it? Try `cat -A SetEnvVariable.sh` and see what it looks like.

http://stackoverflow.com/comment/138308488
type: AnswerComment
score: 4
comment on: http://stackoverflow.com/a/78451478
has text: Different versions of `echo` (or even the same version in different modes) behave differently. Some interpret escapes by default, some don't. Some you can tell to interpret escapes with `-e`, some will print "-e" as part of their output. It's a complete nightmare; I once had a bunch of my scripts break because an OS update changed bash's default behavior. If you want consistent behavior, [use `printf` (with an appropriate format string) instead of `echo`](https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo) for anything involving escapes and/or command options.
type: Comment

http://stackoverflow.com/q/78576698
linked to: http://stackoverflow.com/q/13219634
has comment: http://stackoverflow.com/comment/138528985
type: Question
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78577063
has title: Global associative array (hash) in the older bash-4
tagged with: associative-array
has comment: http://stackoverflow.com/comment/138529492
score: 0
tagged with: global-variables
tagged with: bash
has comment: http://stackoverflow.com/comment/138529625
has body: The following script works as expected for me on FreeBSD using bash-5: function a { declare -gA Seen if [[ -v Seen[$1] ]] then echo "Saw $1 already" return fi Seen[$1]='' } a a a a a b a a a b Yielding the output of: Saw a already Saw a already Saw b already On RHEL7, however, where bash is older (4.2), the repeated argument is never recognized as already seen -- as if the Seen-array is recreated each time the function is invoked. Moving the declare-line outside of the function -- into global scope -- does not help. Is there a work-around, perhaps? Some way for a function to persist its state between invocations (within the same bash-process)?
has answer: http://stackoverflow.com/a/78577077
answer count: 2

http://stackoverflow.com/comment/138331517
comment on: http://stackoverflow.com/a/78464583
type: Comment
type: AnswerComment
score: 0
has text: The Awk script performs the substitutions in Awk, too. The array `s` contains pairs like `s["foo"] = "bar"` , `s["Foo"] = "Bar"`, `s["FOO"] = "BAR"`, etc etc. Thanks for the note about regex metacharacters; I added a paragraph at the end about that.

http://stackoverflow.com/comment/138460806
has text: Is there a specific reason not to use Docker exec from the windows cmd? Otherwise, just run ping on its own from that container
comment on: http://stackoverflow.com/q/78538995
type: QuestionComment
type: Comment
score: 1

http://stackoverflow.com/a/78582205
score: 2
answers question: http://stackoverflow.com/q/78581424
upvote count: 2
downvote count: 0
has body: Since "the command returns the list of files seen from the git root directory" wouldn't it make more sense to put your git root directory in front of each path instead of ../.. as the latter will break if you run it from any other directory? e.g. using any awk: git diff --name-only | awk -v g=$(git rev-parse --show-toplevel) '{print g "/" $0}'
type: Answer

http://stackoverflow.com/comment/138392746
type: Comment
type: AnswerComment
has text: Yeah, sorry, mobile keyboard /-:
score: 0
comment on: http://stackoverflow.com/a/78500357

http://stackoverflow.com/comment/138338417
comment on: http://stackoverflow.com/q/78469410
type: Comment
score: 0
has text: That depends on why you think you *need* `eval` here. Simply *not* using `eval`, as KamilCuk suggests in his answer, is probably all you need. You can't make up for someone incorrectly passing an argument to your script *inside* your script.
type: QuestionComment

http://stackoverflow.com/comment/138385053
type: QuestionComment
type: Comment
has text: Unfortunately no, I didn't really think about it! I just tried it and it works!! @knittl THANK YOU SO MUCH, I will now proceed to create a response post
score: 0
comment on: http://stackoverflow.com/q/78491259

http://stackoverflow.com/comment/138405060
type: Comment
has text: Did you by any chance use `jpackage` to build this application, and from a very recent JDK 17/21 or 22 (not first release, but .0.1 update)?
comment on: http://stackoverflow.com/q/78506003
type: QuestionComment
score: 0

http://stackoverflow.com/a/78457368
upvote count: 1
has comment: http://stackoverflow.com/comment/138321392
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/78457170
has comment: http://stackoverflow.com/comment/138320805
has body: You are using the quotes incorrectly. Instead of surrounding each individual symbol with quotes, surround the entire value in quotes. #!/bin/bash root_path="example" year="2024" month="May" day="9" filename_zero="filename_0" filename_one="filename_1" FILEDIR="${root_path}${year}/${month}/${day}/${filename_zero}_${year}-${month}-${day}-${filename_one}" echo "${FILEDIR}" Which prints the following example2024/May/9/filename_0_2024-May-9-filename_1

http://stackoverflow.com/q/78479103
has answer: http://stackoverflow.com/a/78484907
tagged with: bash
has body: I have a docker-compose.yaml for local airflow setup. It would setup all airflow services. In the service container airflow-webserver, I want to run a few commands which could be a ssh command or a airflow connections add ... command. The airflow-webserver service from docker-compose.yaml is given below: airflow-webserver: ... command: webserver ports: - 8080:8080 healthcheck: test: ["CMD", "curl", "--fail", "http://localhost:8080/health"] interval: 10s timeout: 10s retries: 5 restart: always depends_on: ... airflow-init: condition: service_completed_successfully The commands I want to run in this container is: airflow connections add conn1 --conn-type 'mysql' --conn-login 'user' ... ssh -o StrictHostKeyChecking=no -4 -N -L ... I tried to utilize the command section command: webserver and used commnd: webserver && bash -c "... but I got following message: airflow-webserver-1 | airflow command error: argument GROUP_OR_COMMAND: invalid choice: 'webserver &&' (choose from 'celery', 'cheat-sheet', 'config', 'connections', 'dag-processor', 'dags', 'db', 'info', 'jobs', 'kerberos', 'kubernetes', 'plugins', 'pools', 'providers', 'roles', 'rotate-fernet-key', 'scheduler', 'standalone', 'sync-perm', 'tasks', 'triggerer', 'users', 'variables', 'version', 'webserver'), see help above. Next option I tried is adding entrypoint as: command: webserver entrypoint: | bash -c "airflow connections add ... ... but this option repeatedly gives me following error: airflow-webserver-1 | Traceback (most recent call last): airflow-webserver-1 | File "/home/airflow/.local/bin/airflow", line 5, in <module> airflow-webserver-1 | from airflow.__main__ import main airflow-webserver-1 | ModuleNotFoundError: No module named 'airflow' Even the basic entrypoint: bash -c "echo ..." command gets executed repeatedly. Since above options did not worked. I have been running following command manually after running docker compose up. docker-compose exec -T airflow-webserver bash -c " airflow connections a…
has comment: http://stackoverflow.com/comment/138356599
type: AnsweredQuestion
tagged with: docker-compose
has comment: http://stackoverflow.com/comment/138367479
tagged with: airflow
has title: run a command in docker container during docker compose up
tagged with: docker
score: 0
type: Question
accepted answer: http://stackoverflow.com/a/78484907
answer count: 1
has comment: http://stackoverflow.com/comment/138369741

http://stackoverflow.com/q/78461484
has comment: http://stackoverflow.com/comment/138325070
linked to: http://stackoverflow.com/q/65538947
accepted answer: http://stackoverflow.com/a/78461955
has comment: http://stackoverflow.com/comment/138325315
has comment: http://stackoverflow.com/comment/138325267
has comment: http://stackoverflow.com/comment/138325682
upvote count: 1
tagged with: performance
has comment: http://stackoverflow.com/comment/138324937
has comment: http://stackoverflow.com/comment/138324794
has title: Is Bash slow or am I doing something wrong?
has comment: http://stackoverflow.com/comment/138324600
score: 0
has comment: http://stackoverflow.com/comment/138327693
has comment: http://stackoverflow.com/comment/138327698
has comment: http://stackoverflow.com/comment/138325450
tagged with: shell
has comment: http://stackoverflow.com/comment/138325317
has comment: http://stackoverflow.com/comment/138325350
has comment: http://stackoverflow.com/comment/138324729
favorite count: 0
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/78461956
tagged with: python
has comment: http://stackoverflow.com/comment/138330012
downvote count: 1
has comment: http://stackoverflow.com/comment/138324619
has comment: http://stackoverflow.com/comment/138324747
has comment: http://stackoverflow.com/comment/138327673
has comment: http://stackoverflow.com/comment/138325652
has comment: http://stackoverflow.com/comment/138324822
answer count: 2
has comment: http://stackoverflow.com/comment/138324833
has comment: http://stackoverflow.com/comment/138325257
tagged with: bash
has answer: http://stackoverflow.com/a/78461956
type: Question
has comment: http://stackoverflow.com/comment/138325336
has answer: http://stackoverflow.com/a/78461955
has comment: http://stackoverflow.com/comment/138324810
has body: Recently I've had a need in going through the logs in my Minecraft Server. I needed to unpack several gzipped log files and collapse them into one huge log. And then I'd use grep to seek for useful info (however that's how I decided to do that). So I've decided to write a bash script: dir="/home/minecraft/spigot-1.20.2/logs" logs=$(ls $dir) start=$SECONDS sum="" for log in $logs do s=$SECONDS log_date=$(echo $log | cut -b 1-10) unzipped_log="$(zcat -f $dir/$log | sed -e "s/\[Async Chat Thread - #[0-9]\+\/INFO]: //" -e "s/^/$log_date /g")"$'\n' while read -r line do echo "$line" done <<< "$unzipped_log" echo The file $log $(du -h $dir/$log) processed in $(($SECONDS - $s)) done s=$SECONDS last="$(cat $dir/latest.log | sed -e "s/\[Async Chat Thread - #[0-9]\+\/INFO]: //")"$'\n' date_today=$(date +%Y-%m-%d) while read -r line do echo "$date_today $line" done <<< "$last" echo The file latest.log processed in $(($SECONDS - $s)) echo Script worked in $(($SECONDS-$start)) seconds After launching source sum_logs.sh | tac > all_logs.txt the timing was 60 seconds. I then rewrote the code in Python: import os, gzip, time, re from datetime import datetime dir = "/home/minecraft/spigot-1.20.2/logs" start = time.time() time.sleep(1) logs = os.listdir(dir) for log in logs: log_path = os.path.join(dir, log) log_date = log[:10] try: with gzip.open(log_path, 'rt') as f: for line in f.readlines(): line = re.sub(r'\[Async Chat Thread - #\d+\/INFO]: ', '', line) print(log_date, line.replace('\n', '')) except: with open(log_path, 'r') as f: for line in f.readlines(): line = re.sub(r'\[Async Chat Thread - #\d+\/INFO]: ', '', line) print(log_date, line.replace('\n', '')) elapsed = round(time.time() - start) print(f'Script worked in {elapsed} seconds') The timing is 9 seconds. I understand that bash is slower than Python. But I had no idea that the difference is 6x. Is bash really so slow or is there a way to speed up my code? Edit. dir="/home/minecraft/spigot-1.20.2/logs" start=$SECONDS sum…
has comment: http://stackoverflow.com/comment/138330095
has comment: http://stackoverflow.com/comment/138325659

http://stackoverflow.com/q/78491259
has answer: http://stackoverflow.com/a/78496026
favorite count: 0
has comment: http://stackoverflow.com/comment/138382039
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/78496026
has comment: http://stackoverflow.com/comment/138383463
tagged with: zsh
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/138382444
score: 1
answer count: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/138382374
has title: Inconsistent git log results when filtering by directory
tagged with: bash
tagged with: git
has comment: http://stackoverflow.com/comment/138385053
tagged with: git-log
has body: I’m encountering an odd behavior with git log when filtering by a specific directory. Here’s the command I’m using: 18:05:04 ~/Documents/01_repo/b2b-crm (uat) └─▶ $ git log --name-status --oneline --pretty=format:"COMMIT: %H" --diff-filter=ACDMRTUXB 814cfc685b430020192e7c0db04b2874b5790a1e..b0341db807cf7e4fa6b0dff63cf7eabca057308e -- 'force-app/main/default/' COMMIT: ff565cdef935907ec6b8995463c907375a70f9f2 M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParametersController.js COMMIT: 84ee2707977848ff7a7b693b1e2f56f4b54c678d M force-app/main/default/aura/IS_ImprimirContrato_Quadient/IS_ImprimirContrato_QuadientHelper.js However, when I run the command again, with the directory filter removed, I get a different list of modified files: 18:05:12 ~/Documents/01_repo/b2b-crm (uat) └─▶ $ git log --name-status --oneline --pretty=format:"COMMIT: %H" --diff-filter=ACDMRTUXB 814cfc685b430020192e7c0db04b2874b5790a1e..b0341db807cf7e4fa6b0dff63cf7eabca057308e COMMIT: ff565cdef935907ec6b8995463c907375a70f9f2 M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParametersController.js COMMIT: 6e0d17558b091d00fe47304b588ec5e066c09d37 M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParameters.cmp M force-app/main/default/aura/GE_CL_ConfigurationParameters/GE_CL_ConfigurationParametersController.js M force-app/main/default/aura/GE_CL_SaveComponents/GE_CL_SaveComponents.cmp M force-app/main/default/aura/GE_CL_SaveComponents/GE_CL_SaveComponentsController.js M force-app/main/default/aura/GE_CL_SelectedComponent/GE_CL_SelectedComponent.cmp M force-app/main/default/aura/GE_CL_SelectedComponent/GE_CL_SelectedComponentController.js M force-app/main/default/classes/GE_CL_ComponentList_Controller.cls M force-app/main/default/classes/GE_CL_ComponentList_Controller_Test.cls M force-app/main/default/classes/RD3_ContractGenerator.cls M force-app/main/default/classes/RD3_ContractGenerator_Test.cls COMMIT: 84e…

http://stackoverflow.com/comment/138376506
has text: @CharlesDuffy there is no way to exit the single quoted context since the whole command should be passed to `osascript`
type: Comment
comment on: http://stackoverflow.com/q/78490743
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138424329
type: Comment
has text: it's rhel 9.4 , i find solution, we should add this line in yml config :
comment on: http://stackoverflow.com/q/78517962
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138328645
comment on: http://stackoverflow.com/q/78462933
score: 0
type: QuestionComment
has text: @jhnc when reuse the above command from the "stop" link, I can manually feed the missing url link, then is it possible for it to follow the existing 'direction' and only get the "previous issue" link, but not the ones already in the list? i.e. /yyyy/mm/dd in the previous links always older than the current link
type: Comment

http://stackoverflow.com/q/78475004
tagged with: slurm
has comment: http://stackoverflow.com/comment/138348724
answer count: 2
has comment: http://stackoverflow.com/comment/138348675
score: 0
has answer: http://stackoverflow.com/a/78477646
type: Question
has comment: http://stackoverflow.com/comment/138348620
has answer: http://stackoverflow.com/a/78475194
accepted answer: http://stackoverflow.com/a/78477646
has comment: http://stackoverflow.com/comment/138348804
possible better answer: http://stackoverflow.com/a/78475194
tagged with: python
has title: Export `stdout` and `stderr` of a single-line bash command to text file while using python module followed by `-m` syntax
tagged with: python-3.x
tagged with: bash
has body: I would like to export the stdout and stderr of a bash command to the same text file. The bash command is a single-line command that calls python3 followed by the name of the module and function, followed by three arguments (each using --). The bash command is running on an HPC as part of a slurm job. python3 -m module.function --Arg1 Val1 --Arg2 Val2 --Arg3 Val3 I tried the following but it failed. It assumes that 2&gt; or &gt; are extra information to the last argument. python3 -m module.function --Arg1 Val1 --Arg2 Val2 --Arg3 Val3 2&gt; Output.txt python3 -m module.function --Arg1 Val1 --Arg2 Val2 --Arg3 Val3 &gt; Output.txt How to be able to export the output to a file without making large changes to the syntax (I need to keep using a single line command for calling the function from the module). Thanks
linked to: http://stackoverflow.com/q/876239
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138348722
downvote count: 1
type: AnsweredQuestion

http://stackoverflow.com/comment/138307457
score: 0
comment on: http://stackoverflow.com/q/78450852
type: QuestionComment
has text: Try adding `set -x` just after `#!/bin/bash` for debugging output in `start_fossil.sh` and see if it points you in the right direction.
type: Comment

http://stackoverflow.com/comment/138319047
type: Comment
has text: As for why it looks ok when you `echo` it, that's highly misleading. Compare the output of `echo ssh -v root@$MACHINE -t 'echo foo'` with `echo $SSH_CMD` and you'll see that with the actual command string there the single-quotes don't get printed. That's because they're parsed as shell syntax, applied, and removed. With the variable, they're printed, which means they were *not* parsed as shell syntax, applied, or removed. In other words, the fact that it looks right is actually a sign that something has gone wrong.
comment on: http://stackoverflow.com/q/78457914
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138423249
has text: No I am not behind a proxy and I've only seen this happen in that particular website I can't seem to replicate it on other websites which makes it more strange. At this point I'm wondering if it's a problem of that site
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78515364
score: 0

http://stackoverflow.com/comment/138521223
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78570634
has text: Will do that, thank you for the suggestion.
score: 0

http://stackoverflow.com/q/78533122
type: Question
has body: I want to transform this: dir1 file01 dir1 file02 dir1 file03 dir2 file04 dir2 file05 dir3 file06 dir4 file07 dir4 file08 dir4 file09 dir4 file10 Into the following: dir1 file01 file02 file03 dir2 file04 file05 dir3 file06 dir4 file07 file08 file09 file10 I do this sort of thing often enough that I would be surprised if there's not already a command in linux that does this - I just don't know what it is or how to search for this. What would you call this? I would call it coalesce, but maybe that's just me. Anyway, I can assume that the first column is already sorted, but if it were not - it would be OK if coalesce was dumb about processing the input. I.E. $ cat <<EOF | coalesce a 1 a 2 b 3 a 4 EOF a 1 2 b 3 a 4 Ideally, this command would also optionally indent the coalesced values on a separate line. cat <<EOF | coalesce --level-indent 2 a 1 a 2 a 3 b 4 b 5 b 6 EOF a 1 2 3 b 4 5 6 I suppose it would also be neat if it supported multiple levels of keys, too. cat <<EOF | coalesce --level-indent 2 a b 1 a b 2 a b 3 a c 4 a c 5 d b 6 d b 7 d b 8 d c 1 EOF a b 1 2 3 c 4 5 d b 6 7 8 c 1 I'm thinking that each line of tokens could be treated as a combination of "levels" to coalesce (at the front of the line) and "tokens" to group together. Finally, it would be useful if the line of tokens could be considered "all levels", or "non-grouping". When combined with a maximum number of levels to coalesce, it would produce something like the following. cat <<EOF | coalesce --level-indent 2 --non-grouping --levels 3 2024-05-25 01:23:45 INFO: Something happened 2024-05-25 01:23:46 INFO: Something happened 2024-05-25 01:23:46 WARN: Something strange happened 2024-05-25 01:23:46 DEBUG: Something typical happened EOF 2024-05-25 01:23:45 INFO: Something happened 01:23:46 INFO: Something happened WARN: Something strange happened DEBUG: Something typical happened I could probably write something using awk that retains the seen levels from previous lines and collects matching tokens to be…
tagged with: shell
linked to: http://stackoverflow.com/q/11710552
tagged with: linux
upvote count: 2
has comment: http://stackoverflow.com/comment/138450410
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78533761
answer count: 3
tagged with: posix
has comment: http://stackoverflow.com/comment/138450360
has comment: http://stackoverflow.com/comment/138450379
score: -4
tagged with: bash
favorite count: 0
has comment: http://stackoverflow.com/comment/138459000
has answer: http://stackoverflow.com/a/78533368
tagged with: awk
downvote count: 6
has comment: http://stackoverflow.com/comment/138452821
has title: linux command to coalesce repeated entries in output
has answer: http://stackoverflow.com/a/78533850

http://stackoverflow.com/a/78539255
downvote count: 0
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/78534641
has body: You don't need gawk and the 4-argument variant of split( ) just to get the seps. Using the same example as above : echo 'abc345def;%ghi+klm;%nop345qrs' | mawk 'BEGIN { __ = (_ = "[0-9]") (_)_ "|" (_ = "[[:punct:]]")_ _ = "\3&\5" ___ = "[\3\5]+" } gsub(__, _) + gsub(___, "\f")_' abc 345 def ;% ghi+klm ;% nop 345 qrs The odd-numbered "steps" are the fields[] you can get from any split(), while the even numbered ones in between are the seps[] Change it to a single gsub(__, "\11 \14| &\12")_' and it should be even more obvious abc | 345 def | ;% ghi+klm | ;% nop | 345 qrs This would, by and large, emulate gawk's FPAT and patsplit() functionalities. Using this filtering criteria instead : __ = "[A-Za-z]+([[:punct:]][A-Za-z]+)*", the roles of fields[] and seps[] have just been swapped. | abc 345 | def ;% | ghi+klm ;% | nop 345 | qrs This approach should work on all awk variants.

http://stackoverflow.com/comment/138338491
has text: That makes sense, appreciate the help!
score: 0
comment on: http://stackoverflow.com/a/78469452
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138358004
has text: Variables aren't local to the function unless you use the `local` command to declare them.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78480370

http://stackoverflow.com/comment/138472207
has text: E.g. it's very common to write Expect scripts to control Cisco routers (which is what this sounds like).
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78545397

http://stackoverflow.com/comment/138415601
has text: To read the filenames into an array with all characters preserved exactly use `readarray -d '' files_in_change < <(git diff HEAD~1 --name-only -z)`. To loop through the array use `for filename in "${files_in_change[@]}"; do ...`.
score: 2
comment on: http://stackoverflow.com/q/78513595
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138330634
comment on: http://stackoverflow.com/a/78465027
type: Comment
type: AnswerComment
score: 0
has text: Separately, are you quite sure this is what your assignment meant you to do? Writing a quine is a common exercise, but referring to your source file at runtime is generally considered cheating.

http://stackoverflow.com/comment/138416752
score: 2
comment on: http://stackoverflow.com/q/78514371
type: QuestionComment
type: Comment
has text: To understand what the script is doing, put `set -x` at the beginning so you see all the commands as they're executed, with variables expanded.

http://stackoverflow.com/comment/138426222
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78519611
has text: You need `$(eval "$cmd0")`

http://stackoverflow.com/comment/138504116
score: 1
comment on: http://stackoverflow.com/q/78562624
has text: Adjustment to @user1934428's recommendation: use `hexdump -C <<<"$font"` since there's a bug in old versions of bash if variables in a here-string aren't double-quoted... and macOS ships with an old version of bash.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138549187
comment on: http://stackoverflow.com/q/78587549
has text: Including a side-by-side between those headers and the headers representing an email attachment that the same client displays the way you want would be even better.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78562360
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78566440
possible better answer: http://stackoverflow.com/a/78564192
has comment: http://stackoverflow.com/comment/138506064
answer count: 2
has comment: http://stackoverflow.com/comment/138503039
score: 0
type: Question
tagged with: shell
has body: I have a list of commands which I dynamically read in my script, each command is stored in a line. Some lines contain commands like the following line="env_var=\"xxx\" myexe -flag1 -flag2" I'm trying to run all lines (including these) from my script. Then for each line I do cmd=($line) "${cmd[@]}" However this fails with env_var="xxx": command not found I suspect the issue is that in my array declaration the part env_var="xxx" is seen as 1 single word, and somehow I need to put syntatic equals and quotes, but I can't seem to do it. Any help is greatly appreciated. Thanks! p.s. I tried eval $line and that works but would like to avoid that.
has comment: http://stackoverflow.com/comment/138507279
has answer: http://stackoverflow.com/a/78564192
accepted answer: http://stackoverflow.com/a/78566440
has title: Setting environment variable from command stored in array
tagged with: linux
tagged with: bash

http://stackoverflow.com/comment/138411190
comment on: http://stackoverflow.com/a/78494827
type: Comment
type: AnswerComment
has text: You should have said in your question that your input file was huge and so execution speed was a big factor. I added a new script that'll be orders of magnitude faster than the original one.
score: 0

http://stackoverflow.com/comment/138330174
comment on: http://stackoverflow.com/q/78464749
has text: When the program starts the `argv[0]` string contains the path to the executable. But that may be completely different to the location of the source file. However, if it is guaranteed to be the same, you can use that information to locate the source.
type: QuestionComment
type: Comment
score: 2

http://stackoverflow.com/comment/138522866
type: QuestionComment
comment on: http://stackoverflow.com/q/78572797
type: Comment
has text: Either nothing happens or the process terminates when the terminal exits. Please verify which is which. Maybe you can ask for user input before exiting the terminal to see.
score: 0

http://stackoverflow.com/a/78483864
has comment: http://stackoverflow.com/comment/138364454
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138364111
accepted answer of: http://stackoverflow.com/q/78483806
type: Answer
has comment: http://stackoverflow.com/comment/138364402
answers question: http://stackoverflow.com/q/78483806
score: 0
has body: Sounds like you want something like: while read -r token name; do curl 'https://localhost:8289/v1/certificatesigningrequest' \ --header 'Content-Type: application/json' \ -H "Authorization: Bearer $token" \ --data '{ "input": '"$name"', }' -k -s done < <(nats sub demo.1 --queue demo -r | jq -j '.token," ",.name,"\n"' ) See towards the bottom of https://mywiki.wooledge.org/BashFAQ/001#Input_source_selection for why I'm using process substitution above instead of a pipe to loop on the output of nats | jq.
has comment: http://stackoverflow.com/comment/138364099

http://stackoverflow.com/comment/138367369
type: AnswerComment
comment on: http://stackoverflow.com/a/78485450
has text: This was the piece of information I was missing! Great catch and explanation.
score: 0
type: Comment

http://stackoverflow.com/comment/138550373
score: 1
comment on: http://stackoverflow.com/a/78587616
type: Comment
type: AnswerComment
has text: Will this be easy to fix inside `awk` script? Or it will be better to do in preprocessing and postprocessing? Spaces can be trimmed before processing the line (but in this case cursor position is better to correct if it gets beyond the line length after trimming).

http://stackoverflow.com/a/78489498
has body: Use jq's --raw-output (or -r) flag to decode JSON strings into raw text (essentially resolving escaped characters and removing the double quotes). Without it, the Bash variable storing each result would still contain the encoded output. (Yet, manually copying that into a command on the terminal may accidentally still work because the shell would consume those quotes when reading the command.) while read -r source do aws s3 cp &quot;${source}&quot; . done &lt; &lt;(jq -r '.[]' sources.lst)
downvote count: 0
score: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/78489072
answers question: http://stackoverflow.com/q/78489072
type: AcceptedAnswer
upvote count: 1

http://stackoverflow.com/q/78503576
answer count: 3
favorite count: 0
tagged with: directory
has answer: http://stackoverflow.com/a/78507282
type: Question
has comment: http://stackoverflow.com/comment/138398405
upvote count: 0
tagged with: linux
accepted answer: http://stackoverflow.com/a/78507282
tagged with: bash
has answer: http://stackoverflow.com/a/78510938
downvote count: 1
has body: I want to display all directories that are smaller than 4MB using find command. Already tried find / type d -size -4000000c(same with a dot instead of/`) but both combinations display files too. What kind of switch should I put here to search only for directories? Maybe there is another command for this purpose? how it looks
tagged with: find
score: -1
has answer: http://stackoverflow.com/a/78503612
type: AnsweredQuestion
has title: Search for all directories that are smaller than 4MB
possible better answer: http://stackoverflow.com/a/78503612

http://stackoverflow.com/comment/138432157
type: AnswerComment
comment on: http://stackoverflow.com/a/78520178
score: 0
has text: Those don't do the job, @LéaGris, if in `/home` there is a regular file among the first three entries. The question asks for the third *subdirectory*.
type: Comment

http://stackoverflow.com/q/78456512
score: 1
tagged with: export-to-csv
upvote count: 1
answer count: 1
tagged with: jq
favorite count: 0
has title: Using jq to parse multilevel json
tagged with: bash
has answer: http://stackoverflow.com/a/78456552
type: AnsweredQuestion
has body: I'm trying to parse a JSON file that look like this: [ { "date":"date1", "results": [ { "field1":"string11", "field2":"string12", "field3":"string13", }, { "field1":"string21", "field2":"string22", "field3":"string23", } ] }, { "date":"date2", "results": [ { "field1":"string11", "field2":"string12", "field3":"string13", }, { "field1":"string21", "field2":"string22", "field3":"string23", } ] } ] and I would like an output like this: 08/05/2024,string11,string12,string13 08/05/2024,string21,string22,string23 09/05/2024,string11,string12,string13 09/05/2024,string21,string22,string23 I tried: jq -Mr '.. | objects | select(has("field1")) | [.field1, .field2, .field3,] | @csv' file.json and got: string11,string12,string13 string21,string22,string23 string11,string12,string13 string21,string22,string23 and tried: jq -r '.[] | [.date, .results[].field1, .results[].field2, .results[].field3] | @csv' file.json and got only the first line: date1,string11,string12,string13 date2,string11,string12,string13 and I would like to have: date1,string11,string12,string13 date1,string21,string22,string23 date2,string11,string12,string13 date2,string21,string22,string23
tagged with: http://stackoverflow.com/tag/json
accepted answer: http://stackoverflow.com/a/78456552
type: Question
downvote count: 0

http://stackoverflow.com/comment/138416688
type: QuestionComment
has text: `parsedText` is NOT an array. `parsedText = ` is not valid bash (NO `' '` spaces around `'='` sign allowed). Before posting here (or now and edit questions with results) paste your script into [ShellCheck](https://www.shellcheck.net/) and fix warning/errors (wonderful tool). That's to start. Then you likely can do this all in a single call to `awk`. Show your actual input rather than `COLUMNS=(1 2 3)` (which I take as a quick example) and explain the logic that takes `1 2 3` and converts that into a heading of `"1,1,1"` with lines that follows `"a,a,a", "b,b,b", etc..`
comment on: http://stackoverflow.com/q/78514302
type: Comment
score: 1

http://stackoverflow.com/q/78553947
has comment: http://stackoverflow.com/comment/138491477
tagged with: subshell
linked to: http://stackoverflow.com/q/56616921
has comment: http://stackoverflow.com/comment/138488145
type: Question
tagged with: command-line-interface
tagged with: shell
downvote count: 0
tagged with: pipe
has comment: http://stackoverflow.com/comment/138487961
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78574398
score: 1
answer count: 1
has comment: http://stackoverflow.com/comment/138487738
upvote count: 1
has title: Why is command listing delaying the control release of a subshell?
favorite count: 0
has comment: http://stackoverflow.com/comment/138489270
has body: In Bash, running the following: ( sleep 50 &gt; /dev/null 2&gt;&amp;1 &amp;) &amp;&amp; exit 0 exits before my human eye can even notice. But if I list commands within the group ( sleep 50 &amp;&amp; sleep 50 &gt; /dev/null 2&gt;&amp;1 &amp;) &amp;&amp; exit 0 it will pause for like 2 seconds displaying exit It does the same if I switch &amp;&amp; for || or ; or any kind of listing or if I wrap the parenthesis grouping for { command1 ; command2 ; } The only things that seem to get that blazing speed again are: using ( bash -c 'sleep 50 &amp;&amp; sleep 50' &gt; /dev/null 2&gt;&amp;1 &amp;) &amp;&amp; exit 0 putting all this in a script #!/usr/bin/env bash sleep 50 || sleep 50 ( ./wrapperScript.sh &gt; /dev/null 2&gt;&amp;1 &amp;) &amp;&amp; exit 0 And I can't understand why it does so. My assumptions were that a subshell ( c1 || c2 &amp;&amp; c3 ;; c4 ) would be equivalent (enough) to putting all this in a script but it's not (at all). There seem to be a forking optimization when a group is not a compound but I don't know why it would display the exiting message for longer. I could use a wrapping script (probably will for the time being) but this is itching my mind, i GOT to know why there's this (negligible yet annoying) delay. (I feel like I'm missing something pretty obvious.)
has comment: http://stackoverflow.com/comment/138491461
has comment: http://stackoverflow.com/comment/138487765
has comment: http://stackoverflow.com/comment/138492087
tagged with: bash
has comment: http://stackoverflow.com/comment/138489256

http://stackoverflow.com/comment/138549235
type: Comment
score: 0
has text: How does `example.com` become `domail.com` ? Is this the same email from your code?
comment on: http://stackoverflow.com/q/78587549
type: QuestionComment

http://stackoverflow.com/comment/138427356
type: Comment
score: 0
has text: man pages and documentation for open_ssl will tell you everything you need to know.
type: QuestionComment
comment on: http://stackoverflow.com/q/78469768

http://stackoverflow.com/comment/138389546
type: Comment
score: 1
has text: It'd be easier to do this from within ./rec_desc1
comment on: http://stackoverflow.com/q/78498490
type: QuestionComment

newline
tag name: newline
type: Tag
tags question: http://stackoverflow.com/q/78451463

http://stackoverflow.com/comment/138573970
has text: Yes, this seems very reasonable because handling of spaces, start of line and end of line need to be handled separately from handling explicit border chars. Let's try this approach, it must cover pattern validity check that URI should not start and end with spaces.
score: 1
comment on: http://stackoverflow.com/a/78587616
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138427363
score: 0
comment on: http://stackoverflow.com/q/78520070
type: QuestionComment
has text: "Don't parse the output of `ls`" is one of the oldest, most well known FAQs in shell programming. See https://mywiki.wooledge.org/ParsingLs.
type: Comment

http://stackoverflow.com/comment/138355264
type: Comment
has text: if you use `argparse`, you could define the `--password` argument as a flag with `parser.add_argument("--password", action="store_true")` and then call `getpass.getpass()` in your script if the `--password` flag is given
comment on: http://stackoverflow.com/q/78478782
type: QuestionComment
score: 0

http://stackoverflow.com/q/78504692
has comment: http://stackoverflow.com/comment/138400375
answer count: 2
linked to: http://stackoverflow.com/q/65621325
type: Question
upvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138403287
has answer: http://stackoverflow.com/a/78506651
has comment: http://stackoverflow.com/comment/138415429
has title: for zgrep how do I limit per pattern and not the entire match?
has comment: http://stackoverflow.com/comment/138415620
downvote count: 1
has answer: http://stackoverflow.com/a/78505020
score: -1
tagged with: grep
tagged with: bash
has body: I have a file that has about 1000 patterns to match. For each pattern I want to limit for each pattern however when I use the -m option it will find the first 10 and stop. Is there a way to do this in an equivalent or speedier way? zgrep -o -m10 -f /projects/test.indx /projects/incoming/SRR80527_2.gz;
favorite count: 0

http://stackoverflow.com/q/78456415
has answer: http://stackoverflow.com/a/78456538
has comment: http://stackoverflow.com/comment/138316661
tagged with: bash
has body: I want to automate the process of creating a Google Cloud bucket. For this, I have written a script that should do it. It should make a bucket to store media in from a dotnet appliation. Without the bucket, the script works and deploys. Only if I put the bucket section in the script, it won't work anymore. The deploy script: create_bucket() { gcloud storage buckets create $BUCKET_NAME \ --project "$PROJECT_ID" \ --location "$ZONE" \ --versioning \ --logging \ --transfer-protocol=HTTPS \ --service-account=$SERVICE_ACCOUNT # Update environment variable file set_env_var "ASPNETCORE_STORAGE_BUCKET" "$BUCKET_NAME" } The config file: BUCKET_NAME="phygital-bucket" However, I always get an error that there is a problem with the parameters. It's strange because a colleague of mine can run this script without any problems. the error: ERROR: (gcloud.storage.buckets.create) unrecognized arguments: --versioning (did you mean '--verbosity'?) --logging (did you mean '--location'?) --transfer-protocol=HTTPS --service-account=phygital-service-account@phygital-222256.iam.gserviceaccount.com (did you mean '--impersonate-service-account' I tried many other things but nothing really helped. The deploy file is pretty big, because it deploys an entire dotnet application. So The way I set up the service account should be correct. I appreciate your help!!
has title: Create gc bucket with bash script
tagged with: bucket
score: 0
type: Question
type: UnansweredQuestion
tagged with: google-cloud-platform
tagged with: google-compute-engine
has comment: http://stackoverflow.com/comment/138316426
answer count: 1

http://stackoverflow.com/a/78557282
answers question: http://stackoverflow.com/q/78556921
has comment: http://stackoverflow.com/comment/138500537
type: Answer
has comment: http://stackoverflow.com/comment/138500692
has body: Here is some code that works: #!/bin/bash read -a data # read data into array while getopts ":1234567:" opt "${data[@]/#/-}" # prepend '-' to each do case "$opt" in 1) echo "you selected option 1" ;; 2) echo "you selected option 2" ;; 3) echo "you selected option 3" ;; 4) echo "you selected option 4" ;; 5) echo "you selected option 5" ;; # \?) echo "unknown Option -$OPTARG" ; exit ;; # :) echo "missing required parameter for Option -$OPTARG" ; exit 1 ;; esac done shift $(($OPTIND -1)) echo "Your value testing $opt" The major problem with your implementation is that getopts wants arguments. These are things that begin with a dash. So, -s or -1 are arguments, whereas 1 is not. I modified the read command to read into an array, which allows me to use array substitution to prepend a - to each argument in the array before feeding the values to getopts. I also used unique variable names to reduce any possible confusion. Also print is going to send a file to a printer - use echo or printf to put text on the screen.
score: 1
has comment: http://stackoverflow.com/comment/138497813
upvote count: 1
has comment: http://stackoverflow.com/comment/138501241
has comment: http://stackoverflow.com/comment/138500678
downvote count: 0

http://stackoverflow.com/q/78559360
has comment: http://stackoverflow.com/comment/138497969
score: -1
upvote count: 0
tagged with: bash
answer count: 1
favorite count: 0
downvote count: 1
type: AnsweredQuestion
tagged with: sh
has answer: http://stackoverflow.com/a/78559697
has body: For some reason, my flags are not being passed through. I'm using the unix getopts function, Where I am going wrong? #!/bin/bash ### Pass Flags #Define the help function function help(){ echo "Options:"; echo "-rg Resource Group Name" echo "-loc Location of Resource Group" echo "-clus Cluster Name" echo "-e Email for LetsEncrypt" echo "-hos Hostname for Nginx" exit 1; } #Initialize the default values for the variables. rg="rg"; loc="location"; clus="cluster"; e="email"; hos="hostname"; #Define the getopts variables options="rg:loc:clus:e:hos:h"; #Start the getopts code while getopts $options opt; do case $opt in rg) #Get the username rg=$OPTARG ;; loc) #Get the password location=$OPTARG ;; clus) #Get the repository name cluster=$OPTARG ;; e) #Get the service name email=$OPTARG ;; hos) #Get the branch name hostname=$OPTARG ;; h) #Execute the help function "echo here" help; ;; \?) #unrecognized option - show help echo "Invalid option." help; ;; esac done #This tells getopts to move on to the next argument. shift $((OPTIND-1)) #End getopts code #rg="jc-test29-aks-rg" #location="francecentral" #cluster="jc-aks-test29-cluster" ## Create RG echo "Creating Resource Group $rg" az group create --name $rg --location $location ## Create AKS Cluster echo "Creating AKS Cluster $cluster" az aks create -g $rg -n $cluster --enable-managed-identity --node-vm-size Standard_B2s --node-count 3 --load-balancer-sku Standard ## Conect to Cluster echo "Connecting to AKS Cluster" az aks get-credentials --resource-group $rg --name $cluster --overwrite-existing ## Wait for the Cluster to Come online. sleep 5m ## Add the Repos helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo add cert-manager https://charts.jetstack.io helm repo add argo https://argoproj.github.io/argo-helm ## Install nginx-ingress helm install nginx-ingress ingress-nginx/ingress-nginx \ --namespace ingress-nginx --create-namespace \ --set controller.replicaCount=2 \ --set controller.admissionWeb…
type: Question
tagged with: getopts
accepted answer: http://stackoverflow.com/a/78559697
has title: Bash Flags are not passing through
has comment: http://stackoverflow.com/comment/138499869

http://stackoverflow.com/comment/138331376
type: Comment
comment on: http://stackoverflow.com/a/78464547
type: AnswerComment
score: 0
has text: Nice! I didn't know about spellcheck.net and I love it! Thanks. `grep -o ` : found it here https://man7.org/linux/man-pages/man1/grep.1.html and didn't think anything bad about it. In fact I chose `grep -o .` explicily for its effect of splitting the string `d` character-by-character into elements of the array `D`. Something other array creators explicitly prevent. And as the arrays' elements are explicitly individual characters, I dropped the double-quotes around the array-calls. I agree, that shell is not meant to be a text-editor, but IMHO my code is the least complex. ;)

http://stackoverflow.com/comment/138561497
type: QuestionComment
type: Comment
has text: @Saboteur, ...but even then, [`eval` is bad practice](https://mywiki.wooledge.org/BashFAQ/048) (as real-use cases generally involve parameterized data rather than constant strings), so guiding people to the BashFAQ #50 solutions is very deliberate. If folks want to run expansions at evaluation time, a function lets them do that more safely.
score: 0
comment on: http://stackoverflow.com/q/78588816

http://stackoverflow.com/comment/138550340
score: 1
has text: Almost all tests passed! Found non serious problems in border cases. `awk -f foo.awk -v d="\"\"''() " -v n=1 -v p=1 <<< " '/etc' "` returns nothing, expecting /etc. `awk -f foo.awk -v d="\"\"''() " -v n=1 -v p=9 <<< " '/etc' "` returns '/etc', expecting /etc like for 3-8 positions. Interestingly that position 50 (beyond line length) returns '/etc' (`awk -f foo.awk -v d="\"\"''() " -v n=1 -v p=50 <<< " '/etc' "`).
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78587616

http://stackoverflow.com/a/78570749
type: Answer
has body: In sed - $: sed -E 's/.*[ ;]([^ ;]+)[; ]*$/\1/' file KLLL YUI OPKJ oPTY In case a bare bash solution helps - $: while IFS=&quot;$IFS;&quot; read -ra f; do echo &quot;${f[-1]}&quot;; done &lt; file KLLL YUI OPKJ oPTY $: while read -r line;do line=${line%;}; echo ${line##*[ ;]}; done &lt; file KLLL YUI OPKJ oPTY $: pat=$'([^ ;]+)[; ]+$'; while read -r line; do $line =~ $pat &amp;&amp; echo ${BASH_REMATCH[1]}; done &lt; file KLLL YUI OPKJ oPTY Your problem is just that the semicolon at the end of the line is delimiting an extra field, but one of your lines only has one field after the ID column - you have to count both the whitespace after the first column and the semicolons as delimiters, and take the next to last if you are splitting into fields, or just manually account for it with string processing.
score: 0
answers question: http://stackoverflow.com/q/78570217

http://stackoverflow.com/q/78562624
has comment: http://stackoverflow.com/comment/138509567
has comment: http://stackoverflow.com/comment/138505594
has comment: http://stackoverflow.com/comment/138509489
type: Question
has comment: http://stackoverflow.com/comment/138509616
has body: I have a script that where I'm trying to check to see if a given font has a given character in it. hb-shape (from harfbuzz) is able to do this in the shell: $ hb-shape "/System/Library/Fonts/Supplemental/Courier New.ttf" t [t=0+1229] But when I to do it in the script I get: hb-shape: /System/Library/Fonts/Supplemental/Courier New.ttf : Failed reading file Try `hb-shape --help' for more information. Here is my script: #!/opt/homebrew/Cellar/bash/5.2.26/bin/bash mapfile -t fonts < <(fc-list : file | head -4 | tr -d ':' | awk '{$1=$1};1') for font in "${fonts[@]}"; do hb-shape "$font" t done Why won't hb-shape handle the variable as an input? I have tried: hb-shape "$font" t hb-shape "${font}" t hb-shape '"'$font'"' t Thank you! Details System: Mac OS 14.1.2 ZSH (my terminal): zsh 5.9 (x86_64-apple-darwin23.0) Bash (my script): 5.2.26 fc-list (part of fontconfig package): fontconfig version 2.15.0 hb-shape (HarfBuzz) 8.4.0 Details re: fc-list $ fc-list | head -4 fc-list | head -4 /System/Library/Fonts/SFCompact.ttf: .SF Compact:style=Thin /System/Library/Fonts/Apple Color Emoji.ttc: .Apple Color Emoji UI:style=Regular /System/Library/Fonts/Supplemental/Verdana Bold.ttf: Verdana:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia /System/Library/Fonts/SFNSMonoItalic.ttf: .SF NS Mono:style=Medium Italic $ fc-list : file | head -4 fc-list : file | head -4 /System/Library/Fonts/Supplemental/Courier New.ttf: /System/Library/Fonts/Apple Braille Pinpoint 6 Dot.ttf: /System/Library/Fonts/KohinoorTelugu.ttc: /System/Library/Fonts/ヒラギノ角ゴシック W2.ttc: $ fc-list : file | head -4 | tr -d ':' | awk '{$1=$1};1' fc-list : file | head -4 | tr -d ':' | awk '{$1=$1};1' /System/Library/Fonts/Supplemental/Courier New.ttf /System/Library/Fonts/Apple Braille Pinpoint 6 Dot.ttf /System/Library/Fonts/KohinoorTelugu.ttc /System/Library/Fonts/ヒラギノ角ゴシック W2.ttc My attempt with the last two commands (t…
has comment: http://stackoverflow.com/comment/138504116
has title: Why won't hb-shape read files when passed a variable?
has comment: http://stackoverflow.com/comment/138505600
has comment: http://stackoverflow.com/comment/138505154
has comment: http://stackoverflow.com/comment/138505611
has comment: http://stackoverflow.com/comment/138505137
has comment: http://stackoverflow.com/comment/138509666
has comment: http://stackoverflow.com/comment/138505545
score: 0
has comment: http://stackoverflow.com/comment/138505569
has comment: http://stackoverflow.com/comment/138504047
has comment: http://stackoverflow.com/comment/138505593
answer count: 0
has comment: http://stackoverflow.com/comment/138508867
has comment: http://stackoverflow.com/comment/138509647
tagged with: bash
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138505514
has comment: http://stackoverflow.com/comment/138509553
has comment: http://stackoverflow.com/comment/138509593
tagged with: harfbuzz
has comment: http://stackoverflow.com/comment/138505596
linked to: http://stackoverflow.com/q/19345872

http://stackoverflow.com/comment/138430837
has text: take a look at my [mquote (magic quote)](https://github.com/clarkwang/magic-aliases) which can help deal with this kind of quoting work.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78515934
type: Comment

http://stackoverflow.com/comment/138354950
has text: Because *variable expansion* is done **before** executing line. At time `$A` is empty. Search for *variable expansion* in bash's man page!
score: 0
comment on: http://stackoverflow.com/q/78478726
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138402784
comment on: http://stackoverflow.com/a/78505348
has text: So? I do not understand. Most probably it is getting "stuck" because there is nothing to read from the pipe. Should there be? Why / why not? Also, comments are very bad to paste code. See https://unix.stackexchange.com/a/155570/209955 for help with debugging bash scripts.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78539121
downvote count: 0
has comment: http://stackoverflow.com/comment/138466050
score: 3
has body: you mean like this ? awk '($!_=_)^_' FS=data OFS=data data for row1 data for row2 data for row3 data for row4
upvote count: 3
has comment: http://stackoverflow.com/comment/138464225
has comment: http://stackoverflow.com/comment/138615333
has comment: http://stackoverflow.com/comment/138464198
type: Answer
answers question: http://stackoverflow.com/q/78534641
has comment: http://stackoverflow.com/comment/138461530

http://stackoverflow.com/comment/138427327
type: Comment
comment on: http://stackoverflow.com/a/78520260
type: AnswerComment
has text: @thatotherguy, quote removed.
score: 0

http://stackoverflow.com/comment/138425083
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78518396
has text: what does your OpenAPI document look like? do you have a PUT with /foo/bar defined? any other path parameters?

http://stackoverflow.com/q/78489072
has body: I have a file of s3 paths, sources.lst. Contents: [ "s3://bucket-name/path/to/file0.tif", "s3://bucket-name/path/to/file1.tif", ] I am attempting to iterate over these s3 paths & download the files. I am trying to using jq and a bash while loop. My download.sh: #!/bin/bash set -o errexit while read -r source do echo "Attempting to execute:" echo "aws s3 cp "${source}" ." aws s3 cp "${source}" . done < <(cat sources.lst | jq '.[]') Executing bash download.sh gives me: Attempting to execute: aws s3 cp "s3://bucket-name/path/to/file0.tif" . usage: aws s3 cp <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri> Error: Invalid argument type Which is strange, since if I copy the line causing the error, ie aws s3 cp "s3://bucket-name/path/to/file0.tif" . and execute it in the terminal I run bash download.sh, the download succeeds. How do I download the files specified in sources.lst using bash? I am using Mac, bash --version: GNU bash, version 5.2.26(1)-release (aarch64-apple-darwin22.6.0), aws --version: aws-cli/2.13.1 Python/3.11.4 Darwin/23.4.0 exe/x86_64 prompt/off
tagged with: amazon-s3
tagged with: bash
type: AnsweredQuestion
has title: How to avoid "Invalid argument type" error when executing a seemingly valid AWS CLI command created using jq and bash?
has comment: http://stackoverflow.com/comment/138373945
score: 0
has answer: http://stackoverflow.com/a/78489498
type: Question
tagged with: amazon-web-services
tagged with: aws-cli
accepted answer: http://stackoverflow.com/a/78489498
answer count: 1
tagged with: jq

http://stackoverflow.com/comment/138578279
comment on: http://stackoverflow.com/a/78587616
type: Comment
has text: *you are using is the equivalent of that of gvim in insert mode (not in normal mode)?* Right. *Is it always the case or do you also sometimes want to consider the cursor as being on top of a character?* For my use case with `Kate` editor the position is used always in between chars. But I think it would be better to make algorithm more flexible (if it not overcomplicate it). May be some next researcher will be interested in `over cursor` position behavior. *(foo)|(bar), which of the 2 do you want to select?* Let it be up to algorithm. For example, `foo` if algorithm goes from left to right.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138348722
type: Comment
has text: Sounds like slurm isn't running the command through the shell, so everything is treated literally.
comment on: http://stackoverflow.com/q/78475004
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138509489
has text: @RyanJM I said "`cat -A` **or similar** so we can see white space in the fc-list : file output"(emphasis added here). If the version of `cat` on your system doesn't have `-A` then try `cat -te` or `od -c` or something else to make the spaces show up.
comment on: http://stackoverflow.com/q/78562624
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138538537
type: Comment
score: 1
has text: So `if [ "$3" = 'I' ] && [ $# -ne 3 ]`
type: QuestionComment
comment on: http://stackoverflow.com/q/78581887

http://stackoverflow.com/comment/138459000
type: Comment
has text: AFIK, there is no command around which would do this right out of the box. So I suggest that you write it yourself, using your language of choice.
comment on: http://stackoverflow.com/q/78533122
score: 0
type: QuestionComment

http://stackoverflow.com/a/78520178
has comment: http://stackoverflow.com/comment/138434796
answers question: http://stackoverflow.com/q/78520070
downvote count: 0
has body: How to print name of (for example) third subdirectory of /home directory in Bash? It depends on the order with respect to which you define "third". It also depends on what exactly you want to print -- a full path, a basename, something else? If you're satisfied with the order that a glob pattern produces, and if it's the basename you want to print, then I would do this: ( dirs=(/home/*/); basename "${dirs[2]}" ) That collects the names matching glob pattern /home/*/ in an array, then prints the basename of the third element. It does this in a subshell to avoid conflict with any other variable named dirs, and to avoid leaving its definition of dirs in the host shell environment. The output will in many cases be the same as that of the command suggested in the question, but it will be correct (relative to the specifications above) in some potential cases that the suggested one would get wrong. In particular, if one of the first three directory names contains a newline or space or tab. The above is also simpler, and IMO clearer, than the alternative suggested in the question.
has comment: http://stackoverflow.com/comment/138434903
has comment: http://stackoverflow.com/comment/138427088
type: Answer
has comment: http://stackoverflow.com/comment/138432157
has comment: http://stackoverflow.com/comment/138427048
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/138430478

http://stackoverflow.com/comment/138551273
has text: thanks @CharlesDuffy, the problem was related to the IFS. To simplify, I have an array of repos I am looping over. For each, i have a comma-separated list of commands I want to run (had to change IFS for the comma). Restoring the IFS before running the command worked.
score: 0
comment on: http://stackoverflow.com/q/78588816
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138394497
has text: BTW, I'm not sure you really need to use `find` or `wc` at all. For example, `shopt -s nullglob; frames=( input_frames/*.webp ); frame_count=${#frames[@]}` will store the number of matching names in `frame_count` without invoking either tool, and after you've done that, `$(( frame_count * 4 ))` will expand to the desired multiplier.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78501061

http://stackoverflow.com/comment/138509553
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78562624
has text: Based on what you've now posted, this isn't your current problem but if your file names contained any `:`s or white space other than single blank chars then `| tr -d ':'` would remove the `:`s and then awk '{$1=$1};1'` would change all that white space to individual blanks thereby changing/corrupting your file name so definitely don't do either of those. `"$(printf '%s' "$font")"` is identical to just `"$font"`. Don't do `printf "'$font'"` as it'll fail when `$font` contains any printf formatting char line `%s`, always do `printf '%s' "$font"` instead IF you need that (which you don't).

http://stackoverflow.com/a/78572772
accepted answer of: http://stackoverflow.com/q/78572680
has body: Use space and = as input field separator: unset $(awk -F '[ =]' '/^export .*=/{print $2}' env)
type: Answer
answers question: http://stackoverflow.com/q/78572680
score: 0
type: AcceptedAnswer

http://stackoverflow.com/comment/138436782
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78525192
has text: The difference is that now `impressive` only runs when `inotifywait` terminates **successfully**. Before, `impressive` was always launched after `inotifywait` termination. Not sure what the reason is for `inotifywait` to fail; what did it capture?
type: Comment

http://stackoverflow.com/comment/138333281
type: AnswerComment
comment on: http://stackoverflow.com/a/78465427
has text: Great! this is really something I need to feed myself:) falling into this bash rabbit hole recently...in my sample code, when I run wget line followed by perl line, and get the new url link, I manually copy it to $url and repeat the process, and I can get the url links I expect, but don't know how to pass the new url the "bash way" :) this helps a lot!
score: 1
type: Comment

http://stackoverflow.com/comment/138373945
score: 0
type: QuestionComment
type: Comment
has text: Thanks, this worked. Would you like to add this as an answer?
comment on: http://stackoverflow.com/q/78489072

http://stackoverflow.com/comment/138353963
comment on: http://stackoverflow.com/q/78477998
score: 0
type: Comment
has text: How about using tqdm's `--delim` option to introduce an artificial delimiter that is printed within the loop (e.g. using `printf '\0'`), and then cleaned up afterwards (e.g. `tr -d '\0'`)
type: QuestionComment

http://stackoverflow.com/a/78485243
type: AcceptedAnswer
has body: After much effort, I figured it out. One very functional and customizable way to do it is to use a common .sh bash script which will run on both Linux and Windows. This bash script can then do whatever pre-build steps you want. It could call other executables, other bash scripts, Python scripts, or just do the work directly. Why this approach? This approach supports the following 6 build scenarios: Windows users building in the MPLAB X IDE by clicking the build button. Linux users building in the MPLAB X IDE by clicking the build button. Windows users building from the command-line in Git Bash via a custom build.sh script. Linux users building from the Bash command-line via the same exact build.sh script as the Windows users. Automated Bitbucket Pipeline CI/CD builds running on a self-hosted Windows runner, calling the same build.sh script as above from inside Windows PowerShell. Automated Bitbucket Pipeline CI/CD builds running on a self-hosted Linux runner, calling the same build.sh script as above from inside Bash. This approach does all that. It also has these added benefits: Handles any OS. Has full, flexible access to Bash. Can be extended to support new build systems, such as Cmake. Gracefully handles all boards (project1, project2, and project3). Gracefully handles all build targets for each board (regular, trace, etc.). The build.sh script should be placed into a git submodule (sub repo) within the main project repo. This way, you can share the same build.sh script across multiple projects. A basic layout of it would be this: build.sh: #!/usr/bin/env bash # Fail if any command fails set -eu # Force Bitbucket Pipelines to fail if this script fails and exits. set -o pipefail build_my_project1() { git_rm_ignored_files cd path/to/project.X # generate makefiles using the MPLAB X IDE's makefile generator prjMakefilesGenerator . # clean time "$make" -f "nbproject/Makefile-${BUILD_TARGET}.mk" SUBPROJECTS="" \ .clean-conf # build with all cores available # - Note th…
score: 0
answers question: http://stackoverflow.com/q/78485242
upvote count: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/78485242
downvote count: 1

http://stackoverflow.com/comment/138518666
has text: @Saboteur, that's not correct: `-o` isn't supported at all in bash/ksh `[[ ]]` (the correct alternative is `[[ ... || ... ]]`), and it's marked obsolescent for `[ ]` (where the preferred alternative to `[ ... -o ... ]` is `[ ... ] || [ ... ]`).
comment on: http://stackoverflow.com/q/78561775
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138392373
has text: https://stackoverflow.com/questions/28844492/bash-how-to-hash-value-of-a-string https://stackoverflow.com/questions/1602378/how-to-calculate-a-hash-for-a-string-url-in-bash-for-wget-caching what resaerch did you do? Check your script with shellcheck. Do not name your variables uppercase - a variable naemd `$RANDOM` is used by bash for random number generation. No need to run a shell inside a shell - `var=$(bash -c "sript")` is just `var=$(script)`.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78500271

http://stackoverflow.com/comment/138528623
comment on: http://stackoverflow.com/q/78576313
score: 0
has text: Did you update your plist file to have the right location in the ProgramArguments String? You did change it from usr/local/bin ?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138327005
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78462744
has text: Thank you, yes I added #!/bin/bash right now and updated the suggestions but its only about the double quotes around VAR variable and doesn't really change anything..

http://stackoverflow.com/comment/138385911
type: Comment
comment on: http://stackoverflow.com/q/78495016
has text: What should happen for line which is present in only one file, but more than once?
score: 0
type: QuestionComment

http://stackoverflow.com/a/78544892
has comment: http://stackoverflow.com/comment/138486707
score: 0
has body: The output was identical. The issue was caused by the editor being used. See @Barmar. Problem closed.
answers question: http://stackoverflow.com/q/78544705
type: Answer
accepted answer of: http://stackoverflow.com/q/78544705
type: AcceptedAnswer

http://stackoverflow.com/a/78501138
accepted answer of: http://stackoverflow.com/q/78481642
type: AcceptedAnswer
score: 0
type: Answer
has body: You can import multiple layers into docker using docker image load if you organize the layers (and metadata about the layers) in a directory following the Docker Image Specification v1.x.x. The Specification Released in January 2015, the Docker Image Specification v1.0.0 defines exactly what you want: how to arrange the different layer tarballs on-disk so that they can be fed into docker to import it as one image. The spec provides an example tree of the files: For example, here's what the full archive of library/busybox is (displayed in tree format): . ├── 5785b62b697b99a5af6cd5d0aabc804d5748abbb6d3d07da5d1d3795f2dcc83e │ ├── VERSION │ ├── json │ └── layer.tar ├── a7b8b41220991bfc754d7ad445ad27b7f272ab8b4a2c175b9512b97471d02a8a │ ├── VERSION │ ├── json │ └── layer.tar ├── a936027c5ca8bf8f517923169a233e391cbb38469a75de8383b5228dc2d26ceb │ ├── VERSION │ ├── json │ └── layer.tar ├── f60c56784b832dd990022afc120b8136ab3da9528094752ae13fe63a2d28dc8c │ ├── VERSION │ ├── json │ └── layer.tar └── repositories There are one or more directories named with the ID for each layer in a full image. Each of these directories contains 3 files: * `VERSION` - The schema version of the `json` file * `json` - The JSON metadata for an image layer * `layer.tar` - The Tar archive of the filesystem changeset for an image layer. The content of the VERSION files is simply the semantic version of the JSON metadata schema: 1.0 And the repositories file is another JSON file which describes names/tags: { "busybox":{ "latest":"5785b62b697b99a5af6cd5d0aabc804d5748abbb6d3d07da5d1d3795f2dcc83e" } } Every key in this object is the name of a repository, and maps to a collection of tag suffixes. Each tag maps to the ID of the image represented by that tag. The code In your case, for the nextcloud:stable image, you can create these files with the following steps. Layer Download First, let's download the layers. But we'll put each layer in its own directory, and put each of these directories in a director…
answers question: http://stackoverflow.com/q/78481642

http://stackoverflow.com/a/78534684
type: Answer
answers question: http://stackoverflow.com/q/78534641
has body: If the data is separated by 1 or more spaces, you can remove the first 1 or 2 columns with sub, where the column is a single word consisting of non whitespace characters. As your example shell script will also remove the word if there is just a single word, you can use an optional part for the second word. awk '{ sub(/^[[:space:]]*[^[:space:]]+([[:space:]]+[^[:space:]]+)?[[:space:]]*/, &quot;&quot;); }1' file The pattern matches: ^ Start of string [[:space:]]*[^[:space:]]+ Match optional spaces and 1+ non whitespace chars ([[:space:]]+[^[:space:]]+)? Optionally match 1+ non whitspace chars followed by 1+ spaces [[:space:]]* Match trailing spaces Input 1.1 1.2 data for row1 2.1 2.2 data for row2 test ? ? data for row3 \ * data for row4 Output data for row1 data for row2 data for row3 data for row4
score: 4
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/78583629
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138550640
upvote count: 3
has body: Assumptions: the input string --command yes this is bad --other-command needs to be passed to execute_program_name in the following format: --command 'yes this is bad' --other-command the 3rd column consists of long form options (ie, options always start with --) if the 3rd column is populated the first string will always be a long form option (ie, string will always have the format --option) the contents of mycsv.csv only need to be parsed for this one for loop; net result: we'll only need a single array (args[]); (see 2nd half of answer for an approach that allows for a single parse and multiple re-use) We'll make some changes to OP's inputs to demonstrate handling options with and without arguments: $ cat mycsv.csv love,hate,--command yes this is bad --other-command fox,duck,--command yes this is bad --other-command single_string turtle,rabbit sweet,sour,--new-command --newer-command A simple script to list input parameters: $ cat execute_program_name #!/bin/bash echo "### $0 $@" cnt=0 for arg in "$@" do ((cnt++)) echo "arg #${cnt} : ${arg}" done One bash approach $ cat parse_n_run #!/bin/bash while IFS=, read -r c1 c2 c3 do printf "\n########### %s : %s : %s\n\n" "${c1}" "${c2}" "${c3}" args=( "--first" "${c1}" "--second" "${c2}" ) # store first 2 sets of options in array while read -r option string do [[ -z "${option}" ]] && continue # skip first line (blank) args+=( "${option}" ) # add "--option" to array [[ -n "${string}" ]] && args+=( "${string}" ) # if there's an argument then add to the array done <<< "${c3//--/$'\n'&}" # split c3 into lines by placing a "\n" before each "--" typeset -p args # display contents of array echo "" execute_program_name "${args[@]}" done < mycsv.csv Taking for a test drive: $ parse_n_run ########### love : hate : --command yes this is bad --other-command declare -a args=([0]="--first" [1]="love" [2]="--second" [3]="hate" [4]="--command" [5]="yes this is bad" [6]="--other-command") ### ./execute_program_name --first love --second…
downvote count: 0
answers question: http://stackoverflow.com/q/78583045
type: Answer
accepted answer of: http://stackoverflow.com/q/78583045
score: 3

http://stackoverflow.com/a/78448885
has comment: http://stackoverflow.com/comment/138303568
score: 0
has comment: http://stackoverflow.com/comment/138304356
type: Answer
has body: To add a new element to an array, you need to parenthesise the right hand side. romList+=("($(echo "$line\n"))") Without it, it's interpreted as string concatenation and it operates on the first element of the array. But if there's a file foo.txt, it already gets into the array in the first assignment (romList=(*)), why do you need (foo.txt\n) in the array, as well?
has comment: http://stackoverflow.com/comment/138303738
answers question: http://stackoverflow.com/q/78448804
accepted answer of: http://stackoverflow.com/q/78448804
type: AcceptedAnswer

http://stackoverflow.com/q/78500271
favorite count: 0
downvote count: 1
type: AnsweredQuestion
upvote count: 2
answer count: 2
type: Question
linked to: http://stackoverflow.com/q/1602378
has answer: http://stackoverflow.com/a/78500397
has answer: http://stackoverflow.com/a/78500357
possible better answer: http://stackoverflow.com/a/78500357
accepted answer: http://stackoverflow.com/a/78500397
has comment: http://stackoverflow.com/comment/138392373
has body: I am attempting to create a tunnel into a private network. I want to create a random but consistent localhost port based on the internal domain name I am trying to tunnel into between 9000-9999. That way I can have multiple tunnels open all on different ports but its the same port per domain name each time. Here is a little bash that I'm struggling with: FQDN=example.internal.net PORT=$(bash -c "RANDOM=$FQDN; echo \$(( 9000 + \$RANDOM % 1000 ))") kubectl port-forward --namespace default service/example $PORT:433 The problem I'm having is that $RANDOM appears to require the seed to be a number rather than a string. Therefore regardless of the value of $FQDN the port is always the same. Therefore what I'd like to do is to convert the string into a number using some kind of a consistent hashing algorithm. FQDN=example.internal.net SEED=$( ??? ) PORT=$(bash -c "RANDOM=$SEED; echo \$(( 9000 + \$RANDOM % 1000 ))") kubectl port-forward --namespace default service/example $PORT:433 Does anyone know a good way to do FQDN -> SEED in the above example?
has title: How can I hash a string into a number in bash?
tagged with: bash
score: 1
linked to: http://stackoverflow.com/q/28844492

http://stackoverflow.com/comment/138362141
has text: The proper process is to edit your original question so that it can be reopened. Now that you have skirted that, perhaps it's best to delete [the original](https://stackoverflow.com/questions/78473648/how-to-loop-in-bash-if-to-be-processed-data-is-more-than-365-days-and-we-only-ne) (though keep in mind that *repeatedly* deleting your questions can also carry a penalty)
type: Comment
comment on: http://stackoverflow.com/q/78479842
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138427323
comment on: http://stackoverflow.com/a/78520332
type: Comment
type: AnswerComment
has text: The way you put `\n` seems to cause problem. I used `ANSI-C Quoting` with `\n` inside it.
score: 1

http://stackoverflow.com/a/78593554
score: 0
has body: JupyterLab localhost 8888 is not designed to be accessed from remote server, by default. You will need to do extra config for JupyterLab. You might need to build the docker image yourself. See: https://medium.com/@mlquest0/set-up-remote-jupyter-lab-notebook-server-for-remote-browser-access-2cef464f203e
answers question: http://stackoverflow.com/q/78590486
type: Answer

http://stackoverflow.com/comment/138427486
comment on: http://stackoverflow.com/a/78520332
type: Comment
type: AnswerComment
score: 0
has text: I see in the default `PS1` variable in Git Bash on Windows, they use the backtick-style command substitution instead. I've updated [my answer](https://stackoverflow.com/a/78520260/4561887) with this information.

http://stackoverflow.com/comment/138376279
type: Comment
comment on: http://stackoverflow.com/q/78490743
type: QuestionComment
score: 0
has text: try `"ssh root@1.2.3.4\" \"cd ..\"'"`

http://stackoverflow.com/comment/138477142
score: 0
comment on: http://stackoverflow.com/a/78469678
has text: No I don't use GPT.
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78545401
upvote count: 1
downvote count: 0
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/138485395
answers question: http://stackoverflow.com/q/78545346
has body: Hy, I think this code will help you: import datetime workstations = { "workstation1": "2023-05-01", "workstation2": "2023-04-01", "workstation3": "2023-03-15", # add more [workstation_name lastupdate] } THRESHOLD_DAYS = 45 current_date = datetime.datetime.now().date() def parse_date(date_str): """Parse a date string into a datetime.date object.""" return datetime.datetime.strptime(date_str, "%Y-%m-%d").date() def is_up_to_date(update_date, threshold_days): """Check if the given update date is within the threshold days from the current date.""" delta_days = (current_date - update_date).days return delta_days <= threshold_days parsed_workstations = {ws: parse_date(date_str) for ws, date_str in workstations.items()} outdated_workstations = [ws for ws, update_date in parsed_workstations.items() if not is_up_to_date(update_date, THRESHOLD_DAYS)] for workstation in outdated_workstations: print(f"{workstation} is not up to date. Last update was on {workstations[workstation]}.") print("\nWorkstation Status:") for workstation, update_date in parsed_workstations.items(): status = "Up to date" if is_up_to_date(update_date, THRESHOLD_DAYS) else "Outdated" print(f"{workstation}: {status} (Last update: {update_date})") I use this code on my own vps and it's fine, except that my workstations are taken from the dynamic db

http://stackoverflow.com/q/78545346
tagged with: bash
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/138473637
downvote count: 2
tagged with: rhel
type: Question
has body: I am writing a script that provides me dates with update times. I am trying to figure out how I can have the script let me know when something is past a certain time frame. For example if i have 100 workstations that have update date of May 1st but three of them have an update date of April 1st, i want it to be able to tell me that these 3 workstations are not up to date. It would be ideal if this script can somehow tell me when something hasn't been updated in 45 days or if there is an update date past 45 days. I have tried seeing if i could somehow use if else statements for this.
type: UnansweredQuestion
score: -2
has answer: http://stackoverflow.com/a/78545401
has title: How can i set alerts through bash based on dates?
upvote count: 0
tagged with: linux

http://stackoverflow.com/comment/138391717
type: Comment
has text: Don't use `eval` if you don't *thoroughly* understand it. When you do thoroughly understand it, you will use it rarely, if ever, because you will know that it is dangerous, and that it is almost never the right tool for any job that should actually be done.
comment on: http://stackoverflow.com/q/78499350
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138460401
comment on: http://stackoverflow.com/a/78539050
has text: I doubt that this is what the OP is asking about. They appear to want to be able to connect to the `docker` daemon on the host system.
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138431739
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78522842
type: QuestionComment
has text: @JoachimSauer if I `echo "$count"` at the end of `main()`, then I got "0\n1\nI want to return this string". So `count` captures all lines printed in "foo()".

http://stackoverflow.com/a/78564146
has comment: http://stackoverflow.com/comment/138506005
has body: You can modify your code like this: path3="A/B/C" length=5 # Adjust the length as needed if [ "$length" -ne 0 ]; then # Collect the files into a temporary list file_list=$(mktemp) for dir in $(find "$path3" -type d); do find "$dir" -maxdepth 1 -type f | tail -n "$length" >> "$file_list" done # Create the tar file using the collected list of files tar cvfz "mpe-tar/part_2.tgz" -T "$file_list" # Remove the temporary list rm "$file_list" fi
has comment: http://stackoverflow.com/comment/138506098
score: 0
has comment: http://stackoverflow.com/comment/138506088
has comment: http://stackoverflow.com/comment/138506138
has comment: http://stackoverflow.com/comment/138506036
has comment: http://stackoverflow.com/comment/138506065
type: Answer
has comment: http://stackoverflow.com/comment/138506016
has comment: http://stackoverflow.com/comment/138506072
has comment: http://stackoverflow.com/comment/138506009
has comment: http://stackoverflow.com/comment/138509837
has comment: http://stackoverflow.com/comment/138505993
answers question: http://stackoverflow.com/q/78564127

http://stackoverflow.com/q/78587549
has comment: http://stackoverflow.com/comment/138548859
has comment: http://stackoverflow.com/comment/138549023
has comment: http://stackoverflow.com/comment/138549341
has comment: http://stackoverflow.com/comment/138549026
has comment: http://stackoverflow.com/comment/138549154
has comment: http://stackoverflow.com/comment/138549847
score: 0
tagged with: shell
has comment: http://stackoverflow.com/comment/138549433
tagged with: bash
has comment: http://stackoverflow.com/comment/138549165
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138550160
answer count: 1
has comment: http://stackoverflow.com/comment/138549235
has comment: http://stackoverflow.com/comment/138549095
has answer: http://stackoverflow.com/a/78588212
has comment: http://stackoverflow.com/comment/138549050
has comment: http://stackoverflow.com/comment/138549714
has comment: http://stackoverflow.com/comment/138549272
has comment: http://stackoverflow.com/comment/138556594
tagged with: sendmail
type: Question
tagged with: mailx
has comment: http://stackoverflow.com/comment/138549187
has title: how do i avoid expanding the hyperlink in email body using shell script
has body: I am required to send an email using shell script. The body of the email consists of a hyperlink. The email should also have an pdf attachment. I have tried using mailx and sendmail. Facing the following issue. With mailx, EMAIL_TO_USERS=/tmp/test.email touch $EMAIL_TO_USERS pdf_to_attach=sample.pdf echo " Hello " > $EMAIL_TO_USERS echo " This is test url www.domain.com " >> $EMAIL_TO_USERS cat $EMAIL_TO_USERS | mailx -a $pdf_to_attach -r sender@email.com -s "Subject" pooja@email.com rm $EMAIL_TO_USERS This works fine with the attachment but the hyperlink gets expanded in the email that i receive. When i use www.domail.com : Hence i tried with sendmail With sendmail, ATTACH="sample.pdf" ( echo "To: pooja@email.com" echo "Subject: hello" echo "Content-Type: text/html" echo echo " Hello " echo " www.example.com " echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'; echo "Content-Transfer-Encoding: base64"; echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'; echo base64 sample.pdf ) | /usr/sbin/sendmail -t This works great with the hyperlink but i cant find the attachment. The attachment is converted to some random text in the email body. I cant use mutt because its not available in the server i work on. Please help!
has comment: http://stackoverflow.com/comment/138548923
has comment: http://stackoverflow.com/comment/138549058

http://stackoverflow.com/a/78501430
downvote count: 0
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/138398172
has body: Thanks to @Barmar I checked at the -n and -i options once again and reached to the conclusion on why the target file was empty except for the appended text. The -i option redirects sed's pattern space output to the file in a direct fashion without exceptions basically, plus -n which suppresses its automatic output. This solution consists of writing the last line of the file (it could be anything as signal) to standard output after the text is appended to the file as well as excluding the -n option. Executing sed with sudo (if not root) is also necessary because sed requires root permissions for w (writing) to /dev/stdout. appended_string=$(sudo -S <<< "$PASSWORD" sed -i -e "0,/^$MAGIC_STRING/!b; //!b ; //a $DNS_REGISTRY" -e '$w /dev/stdout' $file) Both -e options are necessary because the a command escapes all subsequent characters in the script thus making impossible to write further commands, so separating the main script into 2 solves this. On the other hand, there is another more reliable, neater approach to ensure whether a file was changed by sed or not, which consists of saving to a variable the old file's version, executing sed and then comparing the current file's contents with those of the variable using diff command: local old_file="$(cat $file)" sudo -S <<< "$PASSWORD" sed -i -e "0,/^$MAGIC_STRING/!b; //a $DNS_REGISTRY" $file if diff <(echo -n "$old_file") $file; then echo Failed to add registry to \"$file\" else echo 'Success!'; fi echo -n spares the newline at the end of the output and the <() wrapping around it makes possible to refer to the variable's as a file.
score: 1
answers question: http://stackoverflow.com/q/78501102

http://stackoverflow.com/a/78506651
answers question: http://stackoverflow.com/q/78504692
score: 1
has body: Updated answer given the OPs recent comment that their "patterns" are actually literal strings (untested): zgrep -F -o -f /projects/test.indx /projects/incoming/SRR80527_2.gz | awk 'cnt[$0]++ < 10' or this might be more efficient if you get many more than 10 matches for every string: zgrep -o -f /projects/test.indx /projects/incoming/SRR80527_2.gz | awk -v m=10 ' NR == FNR { cnt[$0] ++numStrs next } $0 in cnt { print if ( ++cnt[$0] == m ) { delete cnt[$0] if ( --numStrs == 0 ) { exit } } } ' /projects/test.indx - Original answer when the question appeared to be about regexps: zgrep for all of the regexps but then pipe the output to awk to count the matches for each of them and exit when awk has counted 10 for each regexp which will send a SIGPIPE back to zgrep to stop it running too, e.g. untested: zgrep -o -f /projects/test.indx /projects/incoming/SRR80527_2.gz | awk -v m=10 ' NR == FNR { gsub(/\\/,"\\\\") # double the backslashes for dynamic regexp use cnt["^(" $0 ")$"] # add anchors so we only match the whole line ++numRes next } { matched = 0 for ( re in cnt ) { if ( $0 ~ re ) { matched = 1 if ( ++cnt[re] == m ) { delete cnt[re] if ( --numRes == 0 ) { exit } } } } } matched # only print the input line if it matched any re remaining in cnt[] ' /projects/test.indx - We zgrep first for efficiency so we don't need to execute the relatively very slow awk loop for every line of the gzipped file, just for the lines that contain a match, and so awk gets the exact matching strings that zgrep found so we can avoid best we can any issues related to our awk script and zgrep doing multi-regexp matching differently. We need to double any backslashes in the res for awk since awk will be using them in a dynamic regexp (which gets parsed twice) context at $0 ~ re while zgrep will be using them in a literal regexp (which only gets parsed once) context, see https://www.gnu.org/software/gawk/manual/gawk.html#Computed-Regexps. Since zgrep -o will output the full string that matches …
downvote count: 0
upvote count: 1
type: Answer

http://stackoverflow.com/q/78477819
has answer: http://stackoverflow.com/a/78482379
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138356725
tagged with: pipeline
answer count: 1
tagged with: bash-completion
has title: set the group variable in azure devops pipeline using bash script
has comment: http://stackoverflow.com/comment/138362065
tagged with: bash
tagged with: azure-pipelines
has comment: http://stackoverflow.com/comment/138354332
has body: #!/bin/bash # Read Docker Compose file compose_file="docker-compose.yml" images=($(grep -E '^ *image:' $compose_file | awk '{print $2}' | cut -d ':' -f 1)) # Initialize group variable all_variables=() for image in "${images[@]}"; do # Store image name in pipeline variable variable_name="image_${image//[^a-zA-Z0-9_]/_}" # Set individual variable # echo "Setting pipeline variable for $variable_name: $image" echo "##vso[task.setvariable variable=$variable_name]$image" # Concatenate variable assignment to group variable with newline group _variable+="$variable_name: $image"$'\n' done echo "$all_variables" # Set group variable in Azure Pipelines # echo "Setting group variable in Azure Pipelines" echo -e "##vso[task.setvariable variable=allVariables;isOutput=true]$all_variables" echo "allVariables:$allVariables" but the (all variables)group variable are not set in the pipeline so please give me any suggestion what ever i am do is right the process is right like this thing is possible i am expecting like this variables: allvariables: | image_postgres: postgres image_mongo: mongo image_quay_io_keycloak_keycloak: quay.io/keycloak/keycloak image_discovery_server: discovery-server image_api_gateway: api-gateway image_auth_service: auth-service but this variable is dynamically
tagged with: azure-pipelines-yaml
score: 0
type: Question

http://stackoverflow.com/a/78481134
has body: awk -F'|' ' NR>FNR { exit } NR==1 { n=ARGC-2 if (n<1) { print "not enough output files"; exit } for (i=2; i<ARGC; i++) print >ARGV[i] next } { print >ARGV[ $3 in seen ? seen[$3] : ( seen[$3]=(++i%n)+2 ) ] } ' inputfile outputfile1 outputfile2 Pass the input file and one or more output filenames as arguments in ARGV. (Output files will have indices 2, 3, ..., ARGC-1.) NR>FNR - no longer reading input file, so finished NR==1 - save number of output files as n for later use (abort if n < 1) then write header to every output file on every following input line: if $3 has already been seen, select its associated output file (i.e. ARGV[seen[$3]]) else, use modular arithmetic on a counter to associate $3 with index of "next" output file, and select that print the line to the selected file The parentheses around the assignment to seen[$3] avoids misparsing by the busybox version of awk. Works for any (small) positive number of output files (if there are too many, awk will run out of filehandles). For your sample input, this code will split as: outputfile1 : Header|Name|date A|123|MR b|124|MR de|126|YR xe|128|NR c|125|CR de|126|CR outputfile2 : Header|Name|date c|125|ER de|126|ER fr|127|ER xe|128|ER c|125|XR fr|127|ZR A|123|BR b|124|BR fr|127|DR xe|128|DR A|123|ER b|124|ER With 3 output files, it gives: Header|Name|date c|125|ER de|126|ER fr|127|ER xe|128|ER de|126|YR A|123|BR b|124|BR A|123|ER b|124|ER Header|Name|date A|123|MR b|124|MR fr|127|ZR c|125|CR de|126|CR Header|Name|date c|125|XR xe|128|NR fr|127|DR xe|128|DR
answers question: http://stackoverflow.com/q/78479235
has comment: http://stackoverflow.com/comment/138360474
downvote count: 0
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/a/78505149
type: Answer
score: 0
has body: From the docs: Use kubectl exec to execute commands directly. kubectl exec -it pod-name -- /bin/bash -c "command(s)" The for loop is not a command, try to use this: [...] -- /bin/bash -c "for i in {0..5}; do curl http://127.0.0.1:8080/health; done" or [...] -- sh -c "for i in {0..5}; do curl http://127.0.0.1:8080/health; done"
answers question: http://stackoverflow.com/q/78505054

http://stackoverflow.com/comment/138470632
comment on: http://stackoverflow.com/q/78544705
type: Comment
has text: Replace TAB characters by a fix amount of spaces.
score: 1
type: QuestionComment

http://stackoverflow.com/q/78572680
tagged with: terminal
has comment: http://stackoverflow.com/comment/138521399
tagged with: command-line
has comment: http://stackoverflow.com/comment/138521386
tagged with: command-line-interface
has body: I have a .env file that contains information, to include environment variables. For example: # comment <mini script> export NAME="John Doe" export LOCATION="US" export TZ_LOCAL="NY" When ran, I am able to have these environment variables; however, when done, a script runs to unset the environment variables. This is the snippet that does such: unset $(grep 'export' env | awk 'BEGIN { FS = "=" }; { print $1 }' | awk 'BEGIN { FS = " " }; { print $2 }') This seems a bit much. Is there a simpler way to get the variable name after export and stop at the equal sign? This snippet works, but seems like there should be a much simpler way than my snippet with multiple pipes.
has comment: http://stackoverflow.com/comment/138547395
answer count: 1
has comment: http://stackoverflow.com/comment/138521423
has comment: http://stackoverflow.com/comment/138521564
score: 0
tagged with: scripting
accepted answer: http://stackoverflow.com/a/78572772
tagged with: bash
has title: Extract Variable Name for Unset Script
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78572772

http://stackoverflow.com/comment/138358705
has text: Using `declare` could become an issue (or a feature) when you source the file from a function; those "declared" variables would then become local variables of the function.
type: QuestionComment
comment on: http://stackoverflow.com/q/78480370
type: Comment
score: 0

http://stackoverflow.com/q/78478782
type: AnsweredQuestion
duplicate of: http://stackoverflow.com/q/26330359
tagged with: python
tagged with: command-line
has body: I have a python script I'm running that I don't have the ability to change. Here's how I tried running it: python my_script.py --username &lt;username&gt; --password - Just to see if python would allow me to use the - to read from stdin somehow, but it didn't, the script just assumed the password I wanted was &quot;-&quot; of course. Can I force the input to --password to be read from stdin somehow?
score: 0
type: Question
has comment: http://stackoverflow.com/comment/138355715
has title: Is there a way to force a command's argument to read from stdin instead of straight from the command line?
has comment: http://stackoverflow.com/comment/138355264
accepted answer: http://stackoverflow.com/a/78479044
answer count: 1
has comment: http://stackoverflow.com/comment/138355137
tagged with: bash
linked to: http://stackoverflow.com/q/26330359
has comment: http://stackoverflow.com/comment/138355013
has answer: http://stackoverflow.com/a/78479044
has comment: http://stackoverflow.com/comment/138355677

http://stackoverflow.com/q/78549319
has comment: http://stackoverflow.com/comment/138479503
tagged with: eval
tagged with: hardening
type: Question
has comment: http://stackoverflow.com/comment/138481580
tagged with: dialog
has comment: http://stackoverflow.com/comment/138650014
has comment: http://stackoverflow.com/comment/138649970
score: 0
answer count: 0
tagged with: bash
has body: I've tried to make a function, which accepts a command whose result is piped into a progress dialog, while preserving the exit status return value and also being able to capture the command's result into a var, from stdout. Due to vars not being properly evaluated in command substitutions after their expansion, as in $("${command[@]}"), so far, I couldn't manage to realize the following functionality without eval, though. Many state, that eval is 'evil' and completely avoidable. While this may be true for many cases, others say, that its usage is safe, as long as no 'untrusted user input' is involved and that there are other, non-obvious implicit evaluations performed by shells, which may be equally dangerous. How can I alter the following function in a way, that avoids eval and other evaluating techniques, that could pose a problem in its scope, or can the code be properly hardened and used like that? The function's evaluated 'input', may come in the form of explicitly crafted command strings, as expanded var or as var name reference to these command strings. In this case, that would comprise of git and dialog commands and a worktree name from a var inside the git command. The command input could involve sth. like ls ,find, grep or cat. So there shouldn't be any direct user input involved, other than a dynamic 'worktreeName' var, which might either be extracted from a git worktree list or from a previous input dialog. I presume, the dynamic worktree name could only be potentially problematic here in the latter case; would the var expansion with single-quoting via ${worktreeName@Q} (which should happen before eval) sufficient, or are there additional sanitizing measures required? Also, is the double-quoting in the form eval "${diaCom[@]@E} >/dev/tty" sufficient, does wrapping it inside a process substitution {...} and @E escaping improve the security, or would there be other measures required, to harden the expression? # Evaluates a command to process and a dialog c…
type: UnansweredQuestion
has title: How to replace or improve eval
has comment: http://stackoverflow.com/comment/138632341

text-processing
type: Tag
tag name: text-processing
tags question: http://stackoverflow.com/q/78586078
tags question: http://stackoverflow.com/q/78668918
tags question: http://stackoverflow.com/q/78613091
tags question: http://stackoverflow.com/q/79392369
tags question: http://stackoverflow.com/q/79522023

http://stackoverflow.com/q/78588816
has comment: http://stackoverflow.com/comment/138551164
has comment: http://stackoverflow.com/comment/138561490
has comment: http://stackoverflow.com/comment/138561497
has comment: http://stackoverflow.com/comment/138551159
has comment: http://stackoverflow.com/comment/138552080
has comment: http://stackoverflow.com/comment/138551585
has comment: http://stackoverflow.com/comment/138551183
linked to: http://stackoverflow.com/q/49949556
has comment: http://stackoverflow.com/comment/138551606
has comment: http://stackoverflow.com/comment/138551273
score: 0
has title: Command not found when command stored in variable
type: Question
has comment: http://stackoverflow.com/comment/138556519
answer count: 0
has comment: http://stackoverflow.com/comment/138552061
has comment: http://stackoverflow.com/comment/138561514
duplicate of: http://stackoverflow.com/q/49949556
has body: I'm trying to run an npm script from inside a bash script. It works when I enter the command directly like this: echo "$(npm run jest)" But when I store the command in a variable like this, it says test-build.sh: line 115: npm run jest: command not found: str="npm run jest" echo "$($str)" # this way fails echo "$(${str})" # this other way fails, too What am I doing wrong? TIA.
type: UnansweredQuestion
tagged with: bash

http://stackoverflow.com/comment/138358745
type: Comment
score: 1
comment on: http://stackoverflow.com/q/78480751
has text: Why did you run `git init` in both places? When in this process did you add files and commits to the remote?
type: QuestionComment

http://stackoverflow.com/comment/138426853
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78520070
has text: It will also include symbolic links that point to directories. Is that OK?

http://stackoverflow.com/q/78566886
tagged with: date
has comment: http://stackoverflow.com/comment/138511330
type: Question
has body: Just when I thought I understood Bash $(date) formatting. This simple script just returns 12:00 AM tried printf too, same. What am I missing? The file $D5 is just a reference to an JSON element Date-Time. These lines represent the values respectfully srx=$(cat "${D5}" | jq '.Data[0].sr') #srx=$(date -d "$(cat '${D5}' | jq -r '.Data[0].sr')" "+%s") echo $srx Returns "Fri May 31 08:30:00 PM CDT 2024" #1717340100 I pass this to: srt=$(date -d "($srx)" +"%I:%M %p") #srt=printf "$srx" %s "%(%I-%M)T/n" echo $srt Always returns: 12:00 AM
has title: Bash Date only Returning Midnight
upvote count: 1
has comment: http://stackoverflow.com/comment/138510789
score: -1
downvote count: 2
has answer: http://stackoverflow.com/a/78566934
tagged with: bash
has comment: http://stackoverflow.com/comment/138511135
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/78566934
type: AnsweredQuestion

http://stackoverflow.com/q/78511517
downvote count: 1
has comment: http://stackoverflow.com/comment/138414082
has comment: http://stackoverflow.com/comment/138411653
has comment: http://stackoverflow.com/comment/138412824
upvote count: 2
tagged with: sh
type: Question
has comment: http://stackoverflow.com/comment/138411841
tagged with: text
type: UnansweredQuestion
score: 1
has title: How to keep last few numbers of lines or last few numbers of bytes from each file of folder recursively and save with same name keeping hierarchy
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78512304
has body: I have logs folder under which there can be nested sub folders. I want to operate on each file recursively and keep last few bytes (tail -c) or last few lines (tail -n) based on configuration and delete existing and keep the updated file with the same name. I want to operate for every file recursively and maintaining hierarchal structure. Update: eval "find $TEMP_FOLDER -type f| while read f;do tail -c "${my_array[0]}" $f > ${f}.tmp && mv ${f}.tmp ${f};done" I have used above. Its working fine.
tagged with: linux
tagged with: bash

http://stackoverflow.com/comment/138340718
comment on: http://stackoverflow.com/a/78460489
score: 0
has text: Yes, but the Rscript invocation does not look up the script name in `PATH`.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138338579
type: Comment
comment on: http://stackoverflow.com/q/78469410
has text: See [Why should eval be avoided in Bash, and what should I use instead?](https://stackoverflow.com/q/17529220/4154375) and [BashFAQ/048 (Eval command and security issues)](https://mywiki.wooledge.org/BashFAQ/048).
score: 0
type: QuestionComment

http://stackoverflow.com/q/78519993
type: Question
has comment: http://stackoverflow.com/comment/138426750
tagged with: java
has body: I need to launch script in termux in java (i want to make apk compiler). Here is build_script.sh file: #!/data/data/com.termux/files/usr/bin/sh # Додайте PATH export PATH=$PATH:/data/data/com.termux/files/usr/bin echo "=== Starting script ===" pkg update -y pkg upgrade -y pkg install -y openjdk-17 dx ecj aapt apksigner termux-api echo "=== Packages installed ===" # Параметри APP_NAME=$1 PACKAGE_NAME=$2 MAIN_ACTIVITY=$3 SOURCE_DIR=$4 BUILD_DIR=$5 OUTPUT_DIR=$6 MANIFEST_FILE="AndroidManifest.xml" MAIN_ACTIVITY_CODE=" package $PACKAGE_NAME; import android.app.Activity; import android.os.Bundle; public class $MAIN_ACTIVITY extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Тут можна додати ваш код } } " echo "=== Parameters set ===" MANIFEST_CONTENT=" <action android:name=\"android.intent.action.MAIN\" /> <category android:name=\"android.intent.category.LAUNCHER\" /> " # Створення необхідних директорій mkdir -p $SOURCE_DIR/$PACKAGE_NAME mkdir -p $BUILD_DIR mkdir -p $OUTPUT_DIR mkdir -p res/mipmap echo "=== Directories created ===" # Створення основного Java файлу echo "$MAIN_ACTIVITY_CODE" > $SOURCE_DIR/$PACKAGE_NAME/$MAIN_ACTIVITY.java # Створення AndroidManifest.xml echo "$MANIFEST_CONTENT" > $MANIFEST_FILE # Створення placeholder іконок touch res/mipmap/ic_launcher.png touch res/mipmap/ic_launcher_round.png echo "=== Files created ===" # Перевірка наявності файлів echo "=== Checking files ===" ls -R $SOURCE_DIR ls -R res cat $MANIFEST_FILE # Компіляція Java-коду find $SOURCE_DIR -name "*.java" > sources.txt ecj -d $BUILD_DIR @sources.txt if [ $? -ne 0 ];то echo "Помилка компіляції Java файлів" then exit 1 fi # Перетворення класів в DEX файл dx --dex --output=$BUILD_DIR/classes.dex $BUILD_DIR if [ $? -ne 0 ];то echo "Помилка перетворення класів в DEX файл" then exit 1 fi # Створення APK файлу aapt package -f -m -F $OUTPUT_DIR/$APP_NAME.unsigned.apk -M $MANIFEST_FILE -S res -I $PREFIX/share/aapt/andr…
upvote count: 1
tagged with: termux
answer count: 0
has comment: http://stackoverflow.com/comment/138428266
has comment: http://stackoverflow.com/comment/138429418
tagged with: bash
type: UnansweredQuestion
score: 1
favorite count: 0
has title: how to run termux command in another app?
tagged with: android
downvote count: 0

http://stackoverflow.com/a/78457682
has body: You can use the uri module to fetch the remote URL, instead of calling out to curl; you can use the json_query filter to parse the data; and you can use the sort and last filters to get the value you want. Finally, you use the set_fact module to store the value in a variable: - name: get latest version hosts: localhost gather_facts: false tasks: - name: get latest version uri: url: https://download.checkmk.com/stable_downloads.json register: version - set_fact: chkmk_version: "" - debug: msg: "Latest checkmk version: {{ chkmk_version }}"
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78457521
type: Answer
answers question: http://stackoverflow.com/q/78457521
score: 4
upvote count: 4
type: AcceptedAnswer

http://stackoverflow.com/a/78475452
downvote count: 2
has comment: http://stackoverflow.com/comment/138355875
has comment: http://stackoverflow.com/comment/138357197
upvote count: 0
answers question: http://stackoverflow.com/q/78466816
has comment: http://stackoverflow.com/comment/138363760
has comment: http://stackoverflow.com/comment/138356036
score: -2
has comment: http://stackoverflow.com/comment/138356002
has comment: http://stackoverflow.com/comment/138357143
has comment: http://stackoverflow.com/comment/138359459
type: Answer
has comment: http://stackoverflow.com/comment/138357850
has comment: http://stackoverflow.com/comment/138355858
has comment: http://stackoverflow.com/comment/138355871
has body: Just use a pipe. Same difference, without potential argument errors. #!/bin/bash mkfifo my_fifo tar cvf - --sort=name --ignore-failed-read -C /pathto/source . | pv > my_fifo & tar xvf my_fifo --keep-newer-files -C /pathto/destination --remove-files -j exit 0 This achieves the same parallel extraction as the original command. It can also be one line: mkfifo my_fifo; tar cvf - --sort=name --ignore-failed-read -C /pathto/source . | pv > my_fifo & tar xvf my_fifo --keep-newer-files -C /pathto/destination --remove-files -j Regular Pipes vs. Named Pipes Regular pipes: Send data via anonymous communications channel, known as a "cut buffer", providing a simple way to connect the output & input of two processes. Named pipes: Being an actual file, they allow attachments (processes, file descriptors), by providing persistence in the file system. mkfifo (man-page excerpt): "A FIFO special file is similar to a pipe, except that it is created in a different way. Instead of being an anonymous communications channel, a FIFO special file is entered into the filesystem by calling mkfifo(). Once you have created a FIFO special file in this way, any process can open it for reading or writing, in the same way as an ordinary file." Using a named pipe is not mandatory, but... a FIFO (in context of the above tar command) provides the ability for parallel processing or asynchronous execution. If you have a large archive containing numerous files, by writing the data to a pipe, multiple instances of the tar command can read from the FIFO, simultaneously, leveraging multi-core CPU's. If you want to start extraction before the archiving is done, a pipe enables asynchronous execution. You can start writing to the FIFO and immediately start the extraction process. Extraction can begin while you're still archiving. A FIFO will act as a buffer between the archiving and extraction. If archiving produces data faster than the extraction process can handle, the FIFO stores the data, allowing it to cat…
has comment: http://stackoverflow.com/comment/138357999
has comment: http://stackoverflow.com/comment/138349546
has comment: http://stackoverflow.com/comment/138355948

http://stackoverflow.com/comment/138367387
comment on: http://stackoverflow.com/q/78480751
type: Comment
score: 0
type: QuestionComment
has text: `git init` and commits on remote are fine, but if you do that then you don't need to replicate `git init` on local - `git clone` will initialize the local repo, associate it with the remote, and pull the latest changes. Also, `git fetch` updates Git's index of commits but does not update local files to reflect the latest state; `git pull` will fetch and then update local files.

http://stackoverflow.com/comment/138493480
score: 1
has text: `read -ra opts` will put each option into a separate element in an *array* named `opts`, so `for o in "${opts[@]}"; do case $o in` ... is probably more what you want than `getopts`.
comment on: http://stackoverflow.com/q/78556921
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78990397
score: 0
type: Answer
answers question: http://stackoverflow.com/q/78462747
has body: I would check it in the following way (although I am not really understanding the part with the flag completely and I am not using CFT): #!/usr/bin/env bash echo "Checking for secret in AWS SecretsManager ...." describe_output=$(aws secretsmanager describe-secret --secret-id "$1" --output text 2>&1) describe_exit_code=$? if "$describe_exit_code" -ne 0 ; then # secret does not yet exist export isResourceAlreadyExistsFlag=0 else # secret already exists export isResourceAlreadyExistsFlag=1 fi Hope that points you in the right direction.

http://stackoverflow.com/comment/138530811
score: 1
has text: @MikhailT., [BashFAQ/112 (What are the advantages and disadvantages of using set -u (or set -o nounset)?)](https://mywiki.wooledge.org/BashFAQ/112) may be of use or interest.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78577077

http://stackoverflow.com/a/78451478
score: 0
answers question: http://stackoverflow.com/q/78451463
has comment: http://stackoverflow.com/comment/138308488
type: Answer
has body: By default, the external echo command does not interpret the escape character and prints its arguments verbatim. The -e argument tells it to interpret the sequences that start with \ as special characters. For speed optimisation, some shells provide internal implementations of echo and these implementations may support different arguments and may have different default values for them. It is also possible that the initialisation script of sh (which is probably also executed by bash) defines a function or an alias named echo that delegates the work to the external or builtin echo with the extra argument -e.

http://stackoverflow.com/comment/138329104
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78464004
has text: @Thefourthbird Its normal search and replace but it should preserve case. So it does not need to have the same length, and it can be part of a larger word

http://stackoverflow.com/a/78513077
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78513030
downvote count: 0
score: 5
has body: One possibility is that this Bash script is being generated by some program, and there are some conditions under which the : would have been a real command instead. It may be simpler for that program to always emit COMMAND &amp;&amp; ... at this point in its output, with the command being : when there's nothing to do there, than for the program to emit the COMMAND &amp;&amp; part only when needed. (In other words, this may just be a weird artifact of the logic that happened to generate the command.) Edited to add: Another possibility — also specific to generated code — is that the generating program is building a dynamic list of commands that need to be run in the form COMMAND1 &amp;&amp; COMMAND2 &amp;&amp; COMMAND3. It can be convenient, in that case, for it to start with : and then add each command by appending &amp;&amp; COMMAND, rather than having to keep track of whether a given command is the first.
answers question: http://stackoverflow.com/q/78513030
upvote count: 5
type: Answer

http://stackoverflow.com/a/78581553
has body: You can use sed to modify the file names: ls -ltrd $(git diff --name-only | sed 's=^=../../=') (Note that I used $(...) instead of back quotes, as they nest cleanly). This only works if the file names don't contain spaces.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78581424
has comment: http://stackoverflow.com/comment/138537822
accepted answer of: http://stackoverflow.com/q/78581424
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/comment/138463734
comment on: http://stackoverflow.com/q/78539667
has text: Why not use the simple `output=$(git worktree remove -- "mytestbranch" 2>&1); dialog --colors --no-collapse --programbox 20 120 <<<"$output"` ?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78522842
has title: Calling a function stops printing anything to stdout when using `echo`
has comment: http://stackoverflow.com/comment/138431752
has comment: http://stackoverflow.com/comment/138431739
has comment: http://stackoverflow.com/comment/138436032
has comment: http://stackoverflow.com/comment/138431686
type: Question
has answer: http://stackoverflow.com/a/78523083
has comment: http://stackoverflow.com/comment/138431691
possible better answer: http://stackoverflow.com/a/78522891
score: 1
has comment: http://stackoverflow.com/comment/138431876
answer count: 3
has body: I am running a bash script, and it is strange that after a line of calling function, echo in the called function does not print anything. $ cat test.sh #!/bin/bash foo() { echo 1 # not print in stdout echo "I want to return this string" } main() { echo 0 # print in stdout count="$(foo)" } main "$@" $ ./test.sh 0 How do I get called functions to echo to stdout?
has comment: http://stackoverflow.com/comment/138431979
has answer: http://stackoverflow.com/a/78522958
has answer: http://stackoverflow.com/a/78522891
downvote count: 0
tagged with: bash
upvote count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138435794
accepted answer: http://stackoverflow.com/a/78523083

http://stackoverflow.com/comment/138358242
type: QuestionComment
type: Comment
has text: Check the script with [shellcheck](https://shellcheck.net/) and address any findings. `. "~/.config"` looks suspicious because tilde expansion does not occur within quotes.
score: 1
comment on: http://stackoverflow.com/q/78480370

http://stackoverflow.com/comment/138588883
type: AnswerComment
comment on: http://stackoverflow.com/a/78587616
score: 0
type: Comment
has text: Interesting idea with decimal specification for in between positions. With new version all discussed tests passed! Thanks!

http://stackoverflow.com/comment/138518080
comment on: http://stackoverflow.com/q/78570866
type: Comment
score: 1
has text: You could track the progress of the scripts by logging what they are doing to a logfile. Why have you named the scripts `.sh` btw? It looks like they are python scripts.
type: QuestionComment

http://stackoverflow.com/q/78494598
answer count: 1
tagged with: unix
has answer: http://stackoverflow.com/a/78494827
has body: i have log file with contents inside. i.e file name is convert.20231010.log. The content inside file as below 2024-05-17 00:14:02.447 Success ABCXYZ15 on hard disk 2024-05-17 00:14:02.447 Fail at /home/category1/sub1/ABCXYZ01 00054 is not found 2024-05-17 00:14:02.447 Success ABCXYZ16 00030 on hard disk 2024-05-17 00:14:02.447 Fail at /home/category1/sub2/ABCXYZ02 is not found 2024-05-17 00:14:02.447 Success ABCXYZ17 000110 on hard disk I want to check file and do some work on that. a) find line in log with condition "Fail" and "is not found", get path and file name. grep -E 'Fail.*is not found' convert.20231010.log found 2 line with right condition 2024-05-17 00:14:02.447 Fail at /home/category1/sub1/ABCXYZ01 00054 is not found 2024-05-17 00:14:02.447 Fail at /home/category1/sub2/ABCXYZ02 is not found b) pickup file from path and check file content the path and file name will pickup from category2 based on founding at step a /home/category2/sub1/ABCXYZ01 00054 /home/category2/sub2/ABCXYZ02 c) move file if content is good Based on step b, read content file "ABCXYZ01 00054" and "ABCXYZ02" . If content is good , move file to category3. The content checking inside file is "CARD", if really have value, then file is good. If "CARD" is blank or empty, don't move that file. ID=ABCXYZ01 00054 NAME=JOIN DEPT=ACC CARD=1234 LOC=NY ID=ABCXYZ02 NAME=CINDY DEPT=LOG CARD=6789 LOC=LA mv -f '/home/category2/sub1/ABCXYZ01 00054' '/home/category3/sub1/' mv -f '/home/category2/sub2/ABCXYZ02' '/home/category3/sub2/' d) remove line in log file this one will remove 2 line in log file at step a sed -i '/Fail.*is not found/d' convert.20231010.log How can i do with bash shell in linux and write new log from step from a to d ? I'm not familiar with shell, appreciate for your help. #!/bin/bash MYSELF=$0 MYNAME=`echo $0 | gawk '{print substr($0, match($0, /[^\/]+$/))}'` MYNAME_NOEXT=`echo "$MYNAME" | gawk '{print gensub(/\.[^\.]*$/, "", "g")}'` MYPATH=`echo $0 | gawk '{print substr($0, 1, match…
tagged with: sh
has title: How can extract data single line from file and other process in each that line?
score: 0
accepted answer: http://stackoverflow.com/a/78494827
type: Question
tagged with: shell
tagged with: linux
has comment: http://stackoverflow.com/comment/138384505
has comment: http://stackoverflow.com/comment/138383150
upvote count: 1
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138383228
tagged with: bash
linked to: http://stackoverflow.com/q/673055
type: AnsweredQuestion

http://stackoverflow.com/comment/138415234
comment on: http://stackoverflow.com/q/78513408
type: Comment
has text: @tjm3772 Got it, the "SetEnvVariable" which was provided to me was not having linux compatible EOL character (probably built in windows I guess). I have corrected it and it is working now. Can you please put your comment properly in answer section so i can accept it as an answer.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138340653
comment on: http://stackoverflow.com/a/78460489
type: Comment
type: AnswerComment
score: 0
has text: nextflow will automatically add `bin` in the pipeline directory to `PATH` https://www.nextflow.io/docs/latest/sharing.html#using-bundled-executables-in-the-workflow

http://stackoverflow.com/comment/138372237
type: QuestionComment
comment on: http://stackoverflow.com/q/78484949
type: Comment
score: 0
has text: `telnet` is designed for interactivity. Use `nc`, `ncat`, `netcat` or any other tool of this family. If you need a dialog, then `socat` is my recommendation.

http://stackoverflow.com/comment/138399167
has text: You can use `ssh localhost ...` and not worry about the distinction between local and remote hosts.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78499350

http://stackoverflow.com/comment/138367606
comment on: http://stackoverflow.com/q/78480751
score: 0
type: QuestionComment
has text: My local directory contains files before I promote it to a git repository. Running `git clone` requires my local directory to be empty. I need to pull from an unrelated remote when my local contains files already.
type: Comment

http://stackoverflow.com/comment/138465694
comment on: http://stackoverflow.com/q/78541941
has text: Please paste your script at [shellcheck.net](http://www.shellcheck.net/) and try to implement the recommendations made there.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138427044
has text: @david751 Do you know how `xargs` works in general? If so, what makes this particularly confusing?
comment on: http://stackoverflow.com/q/78520070
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/a/78519493
score: 3
type: AcceptedAnswer
upvote count: 3
has body: i made my own dockerfile for the same reasone (not an update for years). Maybe there are some error, i admit that i don't make docker image every day (sorry). If it can help you, it seams to work. FROM ubuntu:22.04 RUN apt-get update && apt-get upgrade && apt-get install -y sudo gzip zip git RUN git clone https://github.com/pdf2htmlEX/pdf2htmlEX.git WORKDIR ./pdf2htmlEX ENV UNATTENDED="-y" RUN buildScripts/getBuildToolsApt RUN buildScripts/buildInstallLocallyApt #ENTRYPOINT ["pdf2htmlEX"]
answers question: http://stackoverflow.com/q/78518786
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78518786
type: Answer
has comment: http://stackoverflow.com/comment/138430205

http://stackoverflow.com/comment/138550015
comment on: http://stackoverflow.com/q/78588126
has text: please update the question with some metadata ... how many files are you talking about? how big (# of lines, MBytes) can these files get? how often do you need to run this operation (ie, is this a one-time operation or do you need to run this on an hourly, daily, weekly basis)? if you're talking about a large volume of changes (either in terms of number of changes or number of times this operation needs to be performed) then you'll likely want a solution that favors performance over brevity (of coding)
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78539716
answers question: http://stackoverflow.com/q/78539667
upvote count: 2
has comment: http://stackoverflow.com/comment/138461755
has comment: http://stackoverflow.com/comment/138477570
downvote count: 0
has body: Use process substitutions like so: var=$({ git ... 2&gt;&amp;1 | tee &gt;(cat &gt;&amp;3) | dialog ... &gt;/dev/tty;} 3&gt;&amp;1)
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/138475223
accepted answer of: http://stackoverflow.com/q/78539667
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138461776

http://stackoverflow.com/comment/138411653
has text: What did you try, where did you get stuck, how did it fail, and do you have a question? See [ask] then [edit] your question to provide all the missing information that'd allow us to help you (don't reply in a comment).
score: 2
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78511517

http://stackoverflow.com/comment/138427430
score: 0
has text: @EdMorton That's a chance I'm willing to take, I guess. I've encountered a file name containing a \n twice in 23 years. Which leads me to ask... How are you going to parse any directory listing, at all, without using ls, dir or find?
comment on: http://stackoverflow.com/q/78520070
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78573858
has body: 'Error parsing reference: "aaaaaaaaaa.azurecr.io/alpine:x.xx.x\r" is not a valid repository/tag: invalid reference format'. If you are running the script in windows, you will get that error caused carriage return characters (\r) which are causing errors in a Unix environment. To resolve the issue, install dos2unix on windows by using below commands. wsl --install sudo apt-get update sudo apt-get install dos2unix ACR.text image1/hello-world:v1 image1/mcr.microsoft.com/windows/servercore:v1 ACR.sh #!/bin/bash # Source ACR details ACR_S="venkataccr.azurecr.io" ACR_U="venkataccr" ACR_P="12233333" # Destination ACR details D_ACR_S="destinationacr1.azurecr.io" D_ACR_U="destinationacr1" D_ACR_P="1233444444" docker login $ACR_S -u $ACR_U -p $ACR_P docker login $D_ACR_S -u $D_ACR_U -p $D_ACR_P images_file=/root/ACr/ACR.text while IFS= read -r image; do if ! -z "$image" ; then echo "Processing image: $image" docker pull "$ACR_S/$image" docker tag "$ACR_S/$image" "$D_ACR_S/$image" docker push "$D_ACR_S/$image" fi done < "$images_file" Output: Reference: How to install Linux on Windows with WSL
answers question: http://stackoverflow.com/q/78529880
type: Answer
score: 0

http://stackoverflow.com/comment/138549058
score: 0
type: QuestionComment
has text: ...huh? Attachments aren't hyperlinks (not natively; a client may display them that way, but that's the client's doing, not a part of the message itself). This might be a place where a screenshot would help to clarify.
comment on: http://stackoverflow.com/q/78587549
type: Comment

http://stackoverflow.com/comment/138496639
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78558798
score: 0
has text: @PrashantKumarJha: That's because of *variable and path expansions*. Read about expansions in `man bash`. Also, I doubt the "recursively" part.

http://stackoverflow.com/comment/138338368
comment on: http://stackoverflow.com/q/78469410
type: QuestionComment
type: Comment
has text: Why are you using `eval` at all?
score: 1

http://stackoverflow.com/comment/138363760
has text: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/257691/discussion-between-jaycravens-and-charles-duffy).
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78475452

http://stackoverflow.com/comment/138427048
type: AnswerComment
comment on: http://stackoverflow.com/a/78520178
has text: What if there are fewer than 3 subdirectories?
score: 0
type: Comment

http://stackoverflow.com/comment/138319035
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78457914
score: 0
has text: Don't put commands in variables, it causes a variety of problems. Functions are for commands, variables are for data. Once you put something in a variable, it's treated as data, not as shell syntax, so in this case those single-quotes aren't actually being treated as syntactic quotes, they're just part of the data. See ["Why does shell ignore quoting characters in arguments passed to it through variables?"](https://stackoverflow.com/questions/12136948) and [BashFAQ #50: "I'm trying to put a command in a variable, but the complex cases always fail!"](http://mywiki.wooledge.org/BashFAQ/050).

http://stackoverflow.com/q/78590066
accepted answer: http://stackoverflow.com/a/78809414
has body: I need to download an artefact from TC using a bash command (it should work in Ubuntu 22.04.3 deb based server). TeamCity authentication mode is SSO only via MS account and 2FA authentication. Is it possible somehow to wget my TC builds? I tried wget --user my_username --ask-password -v --load-cookies 2sso.cookie --save-cookies auth2.cookie --keep-session-cookies https://teamcity***.iso but got Resolving teamcity***.com (teamcity***.com)... 1.2.3.4 Connecting to teamcity***.com (teamcity***.com)|1.2.3.4|:443... connected. HTTP request sent, awaiting response... 401 Username/Password Authentication Failed. In this command, user is my MS account.
score: 0
has title: Download file from TeamCity with SSO using bash
has comment: http://stackoverflow.com/comment/138554292
tagged with: bash
tagged with: single-sign-on
answer count: 1
has comment: http://stackoverflow.com/comment/138554326
has comment: http://stackoverflow.com/comment/138554242
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78809414
tagged with: wget

http://stackoverflow.com/comment/138369049
comment on: http://stackoverflow.com/q/78484949
score: 1
type: QuestionComment
has text: Aside: If you really need the behavior of `-e` in `echo -e "$message"`, use `printf '%b\n' "$message"` instead to avoid surprises. [Even if your shell is 100% certain to be bash](https://unix.stackexchange.com/a/65819/3113), `echo -e` can sometimes print `-e` on output instead of changing behavior in handling escape sequences; in more strictly POSIX-compliant shells, it'll do that 100% of the time.
type: Comment

http://stackoverflow.com/comment/138377529
score: 0
type: QuestionComment
type: Comment
has text: If I knew the syntax for jq to add quotes, that be helpful. kzi suggestion looked promising but gives an unexpected EOF.
comment on: http://stackoverflow.com/q/78491313

http://stackoverflow.com/a/78501404
type: Answer
answers question: http://stackoverflow.com/q/78500956
has body: Create an entrypoint script entrypoint.sh and reference it in your docker-compose.yml. This approach is cleaner and separates your logic from the docker-compose.yml, making it easier to maintain and debug. #!/bin/sh max=20 min=10 trap exit TERM while :; do echo test sleep $(($RANDOM % ($max - $min + 1) + $min)) done Make sure to make this script executable: chmod +x entrypoint.sh Reference the script in your docker-compose.yml version: "3.9" services: lool: image: image_name entrypoint: ["/bin/sh", "-c", "/path/to/entrypoint.sh"]
score: 3
type: AcceptedAnswer
upvote count: 3
accepted answer of: http://stackoverflow.com/q/78500956
downvote count: 0

http://stackoverflow.com/comment/138506088
comment on: http://stackoverflow.com/a/78564146
type: Comment
type: AnswerComment
score: 0
has text: But `find` don't sort his ouptut, so `find | tail` will **arbitrary** list only `$length` files. I don't understand what you're trying to do, but this seem not reliable.

http://stackoverflow.com/comment/138509110
has text: Aside from the fact that you never assign a value to `i`, you don't seem to feed anything into the stdin of `xargs`. Also, I would expect that `[$length != 0 ]` gives you an error message.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78564127

http://stackoverflow.com/comment/138554292
comment on: http://stackoverflow.com/q/78590066
type: Comment
has text: `https://teamcity***.iso` is the full path including an ISO name (file name) I want to download, `teamcity***.com` is the hostname
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138524104
type: Comment
score: 0
has text: What exactly do you mean by _session login_?
comment on: http://stackoverflow.com/q/78572797
type: QuestionComment

http://stackoverflow.com/comment/138506795
type: Comment
comment on: http://stackoverflow.com/q/78564469
has text: please use a [repro].
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138444437
type: QuestionComment
score: 0
has text: Sorry, `<<` should be just `<`, as shown in the linked question.
type: Comment
comment on: http://stackoverflow.com/q/78529571

http://stackoverflow.com/comment/138332295
comment on: http://stackoverflow.com/q/78465704
score: 0
type: QuestionComment
type: Comment
has text: Gordon Davisson Because the underlying system should be able to run in any environment. This script is actually a front end to the Python virtual environment activation support which is expected to run almost anywhere.

http://stackoverflow.com/comment/138432085
comment on: http://stackoverflow.com/a/78522891
has text: @chepner: Reformulated, thanks. I also moved the redirection closer to the calling line so it's clear it doesn't influence the definition of the function.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78533761
answers question: http://stackoverflow.com/q/78533122
type: Answer
score: -1
has comment: http://stackoverflow.com/comment/138452830
downvote count: 2
has body: in bash we do not have internal libraries, instead we have a lot of powerfull console tools to do anything you want. Try to use popular text-processing tools. Here is example in awk: cat myfile.txt|awk 'BEGIN{n=""}{if (dir!=$1) {printf n$1" "$2 , n="\n"} else printf " "$2;dir=$1}END{printf n}'
upvote count: 1
has comment: http://stackoverflow.com/comment/138462275

http://stackoverflow.com/comment/138424659
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78515364
score: 0
has text: LinkedIn has an API, they discourage web scraping like this (it may even be against their TOS).

http://stackoverflow.com/comment/138401376
type: AnswerComment
has text: I can't follow the GNU grep source but I can't help but feel that it ought to be constructing a single automaton out of all the patterns passed in - so matching against all in parallel. Getting awk to test them serially seems unlikely to gain anything even if one aborts early.
comment on: http://stackoverflow.com/a/78505020
score: 1
type: Comment

http://stackoverflow.com/comment/138427540
has text: @EdMorton `for f in *; do echo "$f"; done` The site says that's `# Good!` Okay, I'll play along... How do I make that show only/no directories?
type: Comment
comment on: http://stackoverflow.com/q/78520070
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138427637
type: Comment
has text: Agreed, but that's not what this site is for. This site is for asking a question about a real, specific problem you've encountered and getting an answer to that question so it solves that problem. There are forums out there for general technical discussions, comp.unix.shell on Usenet, for example, is often used that way. Maybe google groups has some way of doing that too, idk. Good luck.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78520070

http://stackoverflow.com/comment/138476336
comment on: http://stackoverflow.com/a/78469678
type: Comment
score: 0
type: AnswerComment
has text: Did you create this answer with [ChatGPT](https://meta.stackoverflow.com/questions/421831/temporary-policy-generative-ai-e-g-chatgpt-is-banned?cb=1)?

http://stackoverflow.com/comment/138487738
type: Comment
comment on: http://stackoverflow.com/q/78553947
type: QuestionComment
has text: Which distribution of Linux are you using ? Are you running under WSL ? git-bash ?
score: 0

http://stackoverflow.com/comment/138394044
score: 1
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78501116
has text: `let` is an artifact of shells from the 1980s. Modern POSIX-compliant arithmetic syntax -- which still works in ksh88 and its spiritual successors such as bash and zsh, but _additionally_ is supported in ash, dash, and other POSIX sh implementations -- uses `$(( ))` instead.

http://stackoverflow.com/q/78479235
tagged with: bash
has comment: http://stackoverflow.com/comment/138356228
has comment: http://stackoverflow.com/comment/138356851
has comment: http://stackoverflow.com/comment/138356093
has comment: http://stackoverflow.com/comment/138355883
has comment: http://stackoverflow.com/comment/138356581
type: Question
has comment: http://stackoverflow.com/comment/138356094
has comment: http://stackoverflow.com/comment/138355888
has title: Split the data of the particular column from the file using unix command
has comment: http://stackoverflow.com/comment/138355896
has body: We have requirement here to split file based on colum 3 on 3rd column we have 9 unique values based on this we need split into 2 files one contain 4 another file contain remaining 5 (its based on no of unique values in 3 column if we have 20 unique values we will split into 10 &amp; 10 ) and header should be added on both files We will count the no of unique values with this cmd awk -F'|' '{print $3}' inputfile.txt | uniq after counting how to put into 2 files half of the count should in one file, remaining in another file Please advise a script/cmd to that Input file Header|Name|date c|125|ER de|126|ER fr|127|ER xe|128|ER A|123|MR b|124|MR c|125|XR de|126|YR fr|127|ZR xe|128|NR A|123|BR b|124|BR c|125|CR de|126|CR fr|127|DR xe|128|DR A|123|ER b|124|ER Output file 1 Header |Name | date c|125|ER de|126|ER fr|127|ER xe|128|ER A|123|ER b|124|ER A|123|MR b|124|MR c|125|XR de|126|YR fr|127|ZR output file 2 Header|Name|date xe|128|NR A|123|BR b|124|BR c|125|CR de|126|CR fr|127|DR xe|128|DR
type: UnansweredQuestion
answer count: 1
tagged with: unix
has answer: http://stackoverflow.com/a/78481134
has comment: http://stackoverflow.com/comment/138356080
score: 0
has comment: http://stackoverflow.com/comment/138357188
has comment: http://stackoverflow.com/comment/138356084
tagged with: shell
tagged with: linux

http://stackoverflow.com/comment/138419346
comment on: http://stackoverflow.com/q/78515934
has text: `alias` is for commands. Bind entire pipelines to functions.
type: QuestionComment
type: Comment
score: 2

http://stackoverflow.com/comment/138377496
has text: Adding quotes won't make something a valid numeric literal. A numeric literal should just contain digits, without any quotes around it.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78491313

http://stackoverflow.com/q/78484156
upvote count: 0
has comment: http://stackoverflow.com/comment/138364863
tagged with: bash
tagged with: jq
favorite count: 0
has answer: http://stackoverflow.com/a/78484245
has answer: http://stackoverflow.com/a/78484256
downvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138364763
score: -1
has body: I am querying ElasticSearch and sorting the documents locally in Bash with jq, as sorting in ES is too slow for me. The original purpose is to create a CSV file. But I find the sorting does not work properly, it seems sort step does nothing. As I am launching cURL requests, I thought the wrong order is due to content is chunked so I save some results into a local test.json file and tried again, but it still does not work. test.json: { "took": 680, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "max_score": 1.0, "hits": [ { "_index": "my-index", "_type": "_doc", "_id": "111111113584925", "_score": 1.0, "fields": { "field2": [ "FOO" ], "field1": [ "111111113584925" ] } }, { "_index": "my-index", "_type": "_doc", "_id": "111111121254059", "_score": 1.0, "fields": { "field2": [ "FOO" ], "field1": [ "111111121254059" ] } } ] } } (There are many more records - edited for brevity.) Command that I use: jq '.hits.hits[].fields | [.field1[0] + "," + .field2[0]] | sort | .[0]' -r test.json The result: 111111113584925,FOO 111111121254059,FOO 111111116879444,FOO etc. Why? Should I rely on jq sorting? Am I using it correctly? I mean I want to do string comparison by alphabetical order, and field1 all have unique values, so it will never be a tie and start to compare values of field2(it also could have various values but I only want to sort by field1) Should I use Bash sort -k 1 instead? Which is faster when it comes to 100K rows?
possible better answer: http://stackoverflow.com/a/78484245
answer count: 2
accepted answer: http://stackoverflow.com/a/78484256
has comment: http://stackoverflow.com/comment/138364853
tagged with: sorting
type: Question
has title: Sorting user-defined array with strings gives wrong order, even when file content is fully available on disk
has comment: http://stackoverflow.com/comment/138364764
has comment: http://stackoverflow.com/comment/138364753
has comment: http://stackoverflow.com/comment/138364973
has comment: http://stackoverflow.com/comment/138364781

http://stackoverflow.com/a/78577077
type: Answer
has comment: http://stackoverflow.com/comment/138530811
has body: Another take - a() { declare -gA Seen if [[ -n "${Seen[$1]}" ]] then echo "Saw $1 already" else Seen[$1]=1 fi } This isn't any better than Ed's but I had already typed and tested. :) We begin most of our scripts with set -u here. – Mikhail T. Excellent! I generally do the same. Also, easy to accommodate. I still recommend Ed's, but to address your concern: $: set -u $: declare -gA Seen $: a() { > if [[ -n "${Seen[$1]:-}" ]] # set -u safe > then echo "Saw $1 already" > else Seen[$1]=1 > fi > } $: a a $: a a Saw a already
downvote count: 0
answers question: http://stackoverflow.com/q/78576698
has comment: http://stackoverflow.com/comment/138529630
score: 1
upvote count: 1

http://stackoverflow.com/comment/138469021
type: AnswerComment
comment on: http://stackoverflow.com/a/78541741
has text: @yuanjianpeng : I think "they separate statements" would be more accurate. Of course a statement separator is also a word separator, since a word can not span statement boundaries.
score: 0
type: Comment

http://stackoverflow.com/a/78582259
has body: Just use a simple case statement. eg: #!/usr/bin/bash usage() { cat <<- EOF usage: $(basename $0) [-h] test_case_a test_value_a action [date_test_value_a] The 'action' may be one of I (insert) or U (update). If action is U, the date_test_value_a is required. If action is I, date_test_value_a must not be specified. EOF } die() { echo "$* (-h for usage)"; exit 1; } >&2 case $1 in -h|--help|-?) usage; exit 0;; esac case $3 in I) test $# = 3 || die "Insert requires exactly 3 arguments";; U) test $# = 4 || die "Update requires exactly 4 arguments";; '') die "No action given";; *) die "Invalid action";; esac Note that all error messages need to go to stderr (hence the >&2 redirect on the die function). Also, don't propagate usage spew. Emit an error message that succinctly describes the problem, and only write a usage statement when specifically requested by the user. Although it is an unfortunately common practice over the past few decades, it is lazy programming. Writing good error messages is hard. Just printing the entire usage statement and forcing the user to figure out exactly what is wrong is a lazy way of avoiding having to write good error messages. Also note that the <<- style heredoc only works properly if you indent your script properly (eg, with hard tabs, not with spaces).
score: 0
answers question: http://stackoverflow.com/q/78581887
type: Answer

http://stackoverflow.com/comment/138409326
comment on: http://stackoverflow.com/a/78509705
type: Comment
type: AnswerComment
score: 0
has text: With your method you don't need `myfunction "$input"`, just calling `myfunction` is enough

http://stackoverflow.com/comment/138520561
score: 0
type: QuestionComment
type: Comment
has text: Also see the [comment by Charles Duffy](https://stackoverflow.com/questions/78228111/run-jobs-sequentially-in-the-background-in-bash#comment137914699_78228111) on [Run Jobs Sequentially, in the Background, in Bash](https://stackoverflow.com/q/78228111/4154375).
comment on: http://stackoverflow.com/q/78571808

http://stackoverflow.com/comment/138365620
has text: @WesternGun The standalone sort utility is gonna be faster for big inputs.
score: 1
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78484256

http://stackoverflow.com/comment/138320805
comment on: http://stackoverflow.com/a/78457368
type: Comment
score: 0
type: AnswerComment
has text: Thank you for the quick answer it works! My fault was not to use single quotes when defining FILEDIR= variable and I was doing echo $FILEDIR instead of echo "${FILEDIR}"

http://stackoverflow.com/comment/138499152
type: Comment
has text: @Barmar, the extra `}` is just a copy paste error, because I have the `load_dialog` function in a region defined above, which wasn't copied.
score: 0
comment on: http://stackoverflow.com/q/78557294
type: QuestionComment

http://stackoverflow.com/comment/138507279
type: QuestionComment
score: 2
has text: If you could reliably parse `line` into an array, you wouldn't need arrays in the first place.
type: Comment
comment on: http://stackoverflow.com/q/78562360

http://stackoverflow.com/q/78456881
has comment: http://stackoverflow.com/comment/138317270
has body: I check a file that have names with wildcards. I need to compare a variable with these names. To do that. I do: while read -r LineExc; do if [[ "${job}" == ${LineExc} ]]; then echo "found" excepcion=yes else echo "not found" fi done < exceptions.cfg The exceptions have: car* house So if job variable with value house, it goes to not found, but it should go to found. Any help please?
has comment: http://stackoverflow.com/comment/138317124
has comment: http://stackoverflow.com/comment/138317261
has comment: http://stackoverflow.com/comment/138317081
tagged with: bash
type: Question
has title: while searching a string doesn't work as expected
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138317253
has comment: http://stackoverflow.com/comment/138317626
tagged with: while-loop
has comment: http://stackoverflow.com/comment/138317245
has comment: http://stackoverflow.com/comment/138317167
duplicate of: http://stackoverflow.com/q/42913798
score: 0
has comment: http://stackoverflow.com/comment/138317068
answer count: 0
linked to: http://stackoverflow.com/q/42913798
has comment: http://stackoverflow.com/comment/138317240

http://stackoverflow.com/q/78540680
has comment: http://stackoverflow.com/comment/138463599
tagged with: bash
has title: Shutdown symlinked to systemctl in an unexpected way, how is it achieved?
downvote count: 1
has body: I'm looking in /usr/sbin/shutdown and seeing $ ll /usr/sbin lrwxrwxrwx 1 root root 14 Apr 8 20:51 shutdown -&gt; /bin/systemctl* I'm used to symlinks being the exact same command as their link, however when I run the --help commands for shutdown and systemctl they're different. How is this type of symlinking achieved? I'm familiar with how to do it with a wrapper script but then the actual symlink wouldn't be needed as the linked command is called from within the wrapper script. nick ~ : shutdown --help shutdown [OPTIONS...] [TIME] [WALL...] Shut down the system. Options: --help Show this help -H --halt Halt the machine -P --poweroff Power-off the machine -r --reboot Reboot the machine -h Equivalent to --poweroff, overridden by --halt -k Don't halt/power-off/reboot, just send warnings --no-wall Don't send wall message before halt/power-off/reboot -c Cancel a pending shutdown See the shutdown(8) man page for details. nick ~ : systemctl --help systemctl [OPTIONS...] COMMAND ... Query or send control commands to the system manager. Unit Commands: list-units [PATTERN...] List units currently in memory list-sockets [PATTERN...] List socket units currently in memory, ordered by address list-timers [PATTERN...] List timer units currently in memory, ordered by next elapse .....more
score: 0
type: Question
tagged with: linux
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138463673
answer count: 1
upvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78540727
tagged with: systemd

http://stackoverflow.com/comment/138649970
comment on: http://stackoverflow.com/q/78549319
type: QuestionComment
score: 0
type: Comment
has text: @EdMorton thanks for your feedback. I'm going with Barmar's statement suggesting eval's safe in my own function's context. Other from that I'll probably have to resort to dedicated command instructions inside the caller functions, evading the parsing method `getDialogCmdResultAndExitStatus()` in general.

http://stackoverflow.com/a/78574398
answers question: http://stackoverflow.com/q/78553947
has comment: http://stackoverflow.com/comment/138533251
type: Answer
has body: A single pipeline means that both commands are executed at once. Double pipeline means execute the second command if the first fails. Double ampersand means only execute the second command if the first is successful. And the semicolon executes both commands, one before the other no matter the exit status of the previous one, as if they were in 2 separate lines on a script. On the first line you posted ###( sleep 50 > /dev/null 2>&1 &) && exit 0 ###, you are setting the sleep command in background by setting the last ampersand before the closing parentheses (you execute things in background like "command &") so the script doesnt wait for it to finish. If you remove it, it will do the full sleep.
score: 0

http://stackoverflow.com/comment/138431994
score: 0
comment on: http://stackoverflow.com/a/78522891
type: Comment
type: AnswerComment
has text: I would be precise and say that it writes to file descriptor 3, no matter what standard output is when `foo` is *called*.

google-drive-api
type: Tag
tag name: google-drive-api
tags question: http://stackoverflow.com/q/78470611
tags question: http://stackoverflow.com/q/78653040

http://stackoverflow.com/comment/138473637
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78545346
has text: If you provide the output that contains the update times of the 100 workstations then someone will surely be able to help you
score: 0

http://stackoverflow.com/q/78500956
accepted answer: http://stackoverflow.com/a/78501404
has answer: http://stackoverflow.com/a/78501005
answer count: 2
score: -1
type: Question
possible better answer: http://stackoverflow.com/a/78501005
has answer: http://stackoverflow.com/a/78501404
upvote count: 0
has title: variable is not set error in docker-compose using bash variables
has body: In my docker-compose I have a command like this: version: "3.9" ... command: "/bin/sh -c 'max=20; min=10; trap exit TERM; while :; do echo test; sleep $(($RANDOM%($max-$min+1)+$min)); done" ... It prints test with intervals between 10 and 20 seconds. In my terminal this works just fine. In docker-compose it has issues: WARN[0000] The "RANDOM" variable is not set. Defaulting to a blank string. WARN[0000] The "max" variable is not set. Defaulting to a blank string. WARN[0000] The "min" variable is not set. Defaulting to a blank string. WARN[0000] The "min" variable is not set. Defaulting to a blank string. WARN[0000] /..../dist/docker-compose.yml: `version` is obsolete 1 error(s) decoding: * error decoding 'services[tool].command': invalid command line string It seems to have issues with these bash variables. Is there a way to fix this?
favorite count: 0
downvote count: 1
tagged with: bash
type: AnsweredQuestion
tagged with: docker-compose

quoting
tag name: quoting
tags question: http://stackoverflow.com/q/78457170
type: Tag
tags question: http://stackoverflow.com/q/78663739

http://stackoverflow.com/comment/138358687
comment on: http://stackoverflow.com/q/78480370
type: Comment
score: 0
has text: @Fravadona It is just set in the main script file itself as `PROJECT_KEY="value"` and then in the `.config` files it is overwritten the same way with a new value. I'm not partial to that approach, it's just the only way I knew how to set and overwrite values in shell script. Any sort of key/value approach is fine with me.
type: QuestionComment

http://stackoverflow.com/comment/138436986
type: QuestionComment
type: Comment
has text: @CharlesDuffy Ok let me put it this way. I don't mind concatenating onto the users input string (which is expected to come in with single quotes), using double quotes. But I'm not sure how to do that for the entire shell variable & function scope.
comment on: http://stackoverflow.com/q/78525458
score: 0

docker-tag
tags question: http://stackoverflow.com/q/78529880
tag name: docker-tag
type: Tag

http://stackoverflow.com/q/78450852
has comment: http://stackoverflow.com/comment/138307457
tagged with: scheduled-tasks
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138313392
has answer: http://stackoverflow.com/a/78455077
has body: I'm trying to run a simple bash script using Scheduled Tasks on a Synology NAS. It fails interpreting an argument as a file. OS: DSM 7.1.1-42962 Update 6 The 'user-defined script' in Scheduled Tasks: /bin/bash /volume1/backup/fossil/start_fossil.sh start_fossil.sh: #!/bin/bash cd /volume1/@appstore/fossil-scm/bin fossil server --port 8080 /volume1/backup/fossil/fossil --https Output: no such file: server I don't understand why the argument server is interpreted as a file. If I run the script with ./start_fossil.sh or bash start_fossil.sh it just works. It also works if I run the command directly in my shell. I tried several options with different quotes around the command or the arguments to no avail. Any advice?
accepted answer: http://stackoverflow.com/a/78455077
score: 0
has comment: http://stackoverflow.com/comment/138313885
has title: Synology Scheduled Task fails running simple command with 'no such file'
tagged with: synology
has comment: http://stackoverflow.com/comment/138313632
answer count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138308114

http://stackoverflow.com/comment/138340467
comment on: http://stackoverflow.com/q/78470611
score: 0
type: QuestionComment
type: Comment
has text: I often use `cd $path || exit ; find . -type f -mtime +7 -print -delete`...

http://stackoverflow.com/q/78564127
has comment: http://stackoverflow.com/comment/138509110
has comment: http://stackoverflow.com/comment/138507602
type: Question
upvote count: 0
tagged with: shell
has body: I want to iterate through all the folders present in path3 and then get length number of files inside each of them at depth of 1 and make a single tar from them, I am trying something like this: path3=A/B/C if [$length != 0 ];then for dir in $(find "$path3" -type d) do find $dir -maxdepth 1 -type f | tail -$length done xargs tar cvfz mpe-tar/$i/part_2.tgz fi But tar is not getting created , how to pass the output from for loop to xargs and get the tar? I am expecting single tar file containing length number of files at depth 1 from each folders in path3.
type: UnansweredQuestion
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78564146
has title: Creating tar file from the output file names from for loop in shell script
score: -1
tagged with: bash
downvote count: 1

http://stackoverflow.com/a/78455278
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/138338865
type: Answer
answers question: http://stackoverflow.com/q/78451797
accepted answer of: http://stackoverflow.com/q/78451797
has body: You only posted 1 line of sample input and no expected output so we're all just guessing at what you might need but here's a GNU awk script (for arrays of arrays) and the output it produces from the input you provided in case this is what you're trying to do: $ awk ' /Closest Day/ { pairs[$NF][$(NF-2)] } END { for (nr in pairs) printf "%d - %d emails\n", nr, length(pairs[nr]) } ' file 1 - 1 emails See why-is-using-a-shell-loop-to-process-text-considered-bad-practice for why your shell script is so slow, an equivalent awk script will be orders of magnitude faster.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/78564589
upvote count: 2
downvote count: 0
type: Answer
score: 2
answers question: http://stackoverflow.com/q/78564469
has body: For debugging, try to replace external calls to something you control. I don't know what the "unreliable" results are, can you reproduce them with #!/bin/bash STEP=50 TOTAL=2000 filtering() { local j="$1" sleeptime="0.$((RANDOM%10))" sleep $sleeptime printf "Filter %s\n" $j #l -s -g -X GET 'https://url.com?filter='$i'_filter' } PARALLEL_PROCESSES=30 ACTIVE_PROCESSES=0 for (( i=0; i<=TOTAL; i+=STEP )); do filtering "$i" & # > /dev/null 2>&1 & (( ACTIVE_PROCESSES++ )) if (( ACTIVE_PROCESSES >= PARALLEL_PROCESSES )); then wait -n 2> /dev/null (( ACTIVE_PROCESSES-- )) fi done When it does reproduce your problem, you can change the script to a minimal complexity. Changing the steps to 1 and TOTAL to 10 might help. Things you might notice is the number of steps in different in non-parallel and the parallel approach (TOTAL % STEP versus ACTIVE_PROCESSES) and a 'random' order in the output of the parallel case. When it does not reproduce your problem, the curl (or remote site) is giving the problem. Next to curl -v you might try to change in something without a get or another website. You might find that the site (or your firewall or network) shows a problem when it has many parallel requests.

http://stackoverflow.com/comment/138553230
type: Comment
has text: I am afraid, we cannot do anything about it. We are trying to monitor the log files captured by Xcode[https://en.wikipedia.org/wiki/Xcode] which is by default stored in `Users/<user_name>/Library/Developer/Xcode/DerivedData`.
comment on: http://stackoverflow.com/q/78576313
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138377559
has text: Please post a [mre] and the complete error message.
comment on: http://stackoverflow.com/q/78491313
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138332220
type: Comment
type: AnswerComment
has text: I'm not sure what you're trying to tell me when you say "The Awk script performs the substitutions in Awk, too" sorry.
score: 0
comment on: http://stackoverflow.com/a/78464583

http://stackoverflow.com/comment/138344858
type: Comment
score: 7
comment on: http://stackoverflow.com/q/78473026
has text: @0stone0, that's not required for `:`. Almost certainly the OP is trying to operate on a vfat or HFS filesystem, and both of those disallow `:` in names.
type: QuestionComment

http://stackoverflow.com/q/78535384
has comment: http://stackoverflow.com/comment/138457361
has comment: http://stackoverflow.com/comment/138458314
answer count: 0
downvote count: 0
has comment: http://stackoverflow.com/comment/138461231
score: 1
upvote count: 1
favorite count: 0
has title: Is Bash 3.2's PIPESTATUS + PROMPT_COMMAND broken?
tagged with: bash
type: Question
has comment: http://stackoverflow.com/comment/138456016
has comment: http://stackoverflow.com/comment/138455547
has body: I've been trying to expand my old Bash(3.2+) prompt that checks $? and reports bright red error blocks to also include "${PIPESTATUS[@]}" ... But from what I've been able to tell with the simplest reproductions below, PIPESTATUS is always just ( 0 ) in 3.2 prompts and afterwards (3.2.57 is the last Bash Apple will ever ship, so I'm trying to keep supporting that version) Back in ~2.05 days Chet said As for PIPESTATUS, I will change things so that it won't change as the result of executing $PROMPT_COMMAND. The end result should be that neither $PROMPT_COMMAND nor prompt string expansion change $? or $PIPESTATUS. ...BUT PIPESTATUS always seems to be wrong in PROMPT_COMMAND in bash 3.2 Reproduction / Testing Bash 3.2 vs 5.2 prompt-x.sh -- Three sample prompts ( https://pastebin.com/xfhvWgq0 ) _p_simple _p_return _p_pipe Full log with Bash 3.2 https://pastebin.com/erJNhNZ0 Full log with Bash 5.2 https://pastebin.com/DbviAfts _p_simple () { unset PROMPT_COMMAND PS1='${BASH_VERSINFO[0]}: \$ ' } # Save $? _p_return_prompt_command () { save_rtn=$? : other commands return $save_rtn } _p_return () { PROMPT_COMMAND=_p_return_prompt_command PS1='${BASH_VERSINFO[0]}: $save_rtn \$ ' } # Save ${PIPESTATUS[@]}, then derive $? _p_pipe_prompt_command () { save_pipe=( "${PIPESTATUS[@]}" ) save_rtn=${save_pipe[ $(( ${#save_pipe[@]} - 1)) ]} : other commands return $save_rtn } _p_pipe () { PROMPT_COMMAND=_p_pipe_prompt_command PS1='${BASH_VERSINFO[0]}: $save_rtn (${save_pipe[*]}) \$ ' } printf '_p_simple\n or: _p_return\n or: _p_pipe\n' _p_simple Of course 5.2 does the right thing, but 3.2 with _p_return: can only report AND preserve $? (not PIPESTATUS) 3: 0 $ false 3: 1 $ echo "$?" "${PIPESTATUS[@]}" 1 0 3: 0 $ echo a | cat | grep x 3: 1 $ echo "$?" "${PIPESTATUS[@]}" 1 0 3: 0 $ echo a | cat | grep x ; echo "$?" "${PIPESTATUS[@]}" 1 0 Similarly, 3.2 with _p_pipe: works for $? but still not PIPESTATUS
type: UnansweredQuestion
tagged with: command-prompt

http://stackoverflow.com/q/78588126
has answer: http://stackoverflow.com/a/78588226
has answer: http://stackoverflow.com/a/78588159
upvote count: 1
answer count: 3
has body: My goal is to insert id=“#” near every found “match” string when parsing a file. Instead of # must be an incrementing number. There are plenty of files that need to be parsed. I’ve tried: counter=0 find -type f -name "*.html" | xargs sed -i “s/match/id=$((++counter)) match/g” But counter is always 1. (In addition, it would be good to set counter to 0 at the beginning of the new file, but most important is just to make it incremented). UPDATED: I understood that provided info was not enough. It might be hundreds of files, each of them - an html document. The line of one file may look like this: 1.6.2 The match I'm looking for is "background-color:#FFC1C1". There also might be hundreds of those matches per ONE file. An expected result is: 1.6.2 /* more html here */ Version4 /* more html here */ 2.0.92 /* more html here */ But what I have now is: 1.6.2 /* more html here */ Version4 /* more html here */ 2.0.92 /* more html here */
has comment: http://stackoverflow.com/comment/138549986
linked to: http://stackoverflow.com/q/5942360
possible better answer: http://stackoverflow.com/a/78588159
has comment: http://stackoverflow.com/comment/138550061
score: 0
has comment: http://stackoverflow.com/comment/138550015
has comment: http://stackoverflow.com/comment/138550166
favorite count: 0
type: AnsweredQuestion
downvote count: 1
has answer: http://stackoverflow.com/a/78590267
tagged with: sed
has title: How to insert an autoincremented variable when replacing content in file
tagged with: bash
type: Question
accepted answer: http://stackoverflow.com/a/78590267

http://stackoverflow.com/a/78795211
downvote count: 0
answers question: http://stackoverflow.com/q/78491375
has body: I have figured a way to resolve this, at least for myself. The pipeline step results in an error if the LAST command to be executed has no "--yes". You can resolve this by adding the actual commit ("--yes") as a second command. - task: AzureCLI@2 displayName: 'Import Configurations' inputs: azureSubscription: '...' scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: | az appconfig kv import -s file --path my_file.json --format json -n ... az appconfig kv import -s file --path my_file.json --format json -n ... **--yes** This also works if you ONLY want previews, just make the second line import an empty file without a --yes. This will result in an extra output line: ---------------- Key Values Preview ---------------- WARNING: Target configuration already contains all configuration settings in source. No changes will be made.
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/a/78571308
type: Answer
answers question: http://stackoverflow.com/q/78570634
has comment: http://stackoverflow.com/comment/138519450
has body: Do you mean Fn Project? I would assume your function is running inside a docker container, which contains no docker binary. Why you can't execute ls is not clear to me. Could you add your environment to your question? package main import ( "fmt" "os" ) func main() { for _, value := range os.Environ() { fmt.Println(value) } } Edit: Your $PATH looks reasonable, what is the output of package main import ( "fmt" "log" "os/exec" ) func main() { cmd := exec.Command("ls", "/") out, err := cmd.CombinedOutput() if err != nil { log.Fatalln(err) } fmt.Println(string(out)) } ?
score: 0
has comment: http://stackoverflow.com/comment/138521220
has comment: http://stackoverflow.com/comment/138519851

http://stackoverflow.com/q/78462747
type: UnansweredQuestion
answer count: 1
has title: What is the better way to perform resource already exist in AWS secret manager
tagged with: aws-secrets-manager
has answer: http://stackoverflow.com/a/78990397
tagged with: bash
tagged with: aws-cloudformation
has comment: http://stackoverflow.com/comment/138332730
tagged with: aws-cli
has body: I am trying to create the secret in secret manager using CFT, but there is no direct way in CFT to check If the secret already exist and then If it doesn't exists then create the secret. (Basically resource already exists check is not there in CFT) so I need to write the custom condition like below. "Conditions": { "CreateProdResources": { "Fn::Equals": [ { "Ref": "isResourceAlreadyExistsFlag" }, "false" ] } }, "Resources": { "DatabaseCredentials": { "Type": "AWS::SecretsManager::Secret", "Properties": { "SecretString": "XXXXXX" .. } } To check whether the secret is already created, I need to use the aws cli command in 'bash' to check whether the secret already exists and pass this flag - 'isResourceAlreadyExistsFlag' to the CFT to create the new secret / not. I did the research to check any existing aws cli command to check the 'secret already exists' but not able to find any in their documentation. Could some one help in finding the aws cli command / any wrapper code to check the secret already exists please. Thanks in advance. Thanks, Harry
has comment: http://stackoverflow.com/comment/138328906
score: 0
type: Question
tagged with: amazon-web-services

http://stackoverflow.com/a/78493443
answers question: http://stackoverflow.com/q/78493200
type: Answer
has body: To determine if the folder "/tmp" has anything in it, you may use find and grep together: DIR='/tmp' if ssh user@host "find $DIR -mindepth 1 -maxdepth 1 | grep . > /dev/null"; then echo "File found in $DIR of host." else echo "No file found in $DIR of host." fi This command fill find the immediate level in the folder to see if there is any file or folder in it. If you're only concerning files, then: DIR='/tmp' if ssh user@host "find $DIR -mindepth 1 -maxdepth 1 -type f | grep . > /dev/null"; then echo "File found in $DIR of host." else echo "No file found in $DIR of host." fi
has comment: http://stackoverflow.com/comment/138381304
score: -1
downvote count: 1
has comment: http://stackoverflow.com/comment/138381254
upvote count: 0

http://stackoverflow.com/comment/138527594
type: Comment
has text: https://idownvotedbecau.se/noattempt/
score: 1
comment on: http://stackoverflow.com/q/78574995
type: QuestionComment

http://stackoverflow.com/comment/138303568
has text: Thanks! Adding the extra parenthesis solved the problem. Removing "\n" from the loop and the "*" from the initial variable cleaned up the array - "/n" just added /n as plain text in the end of each value after adding the parenthesis and the * resulted in the array having two copies of the array inside itself for some reason.
comment on: http://stackoverflow.com/a/78448885
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/138411727
has text: It is interesting you have a solution. Your problem has the indicators being a [duplicate](https://stackoverflow.com/questions/77937092/restarting-a-java-program-does-not-work-with-the-new-jdk-21-02-13#comment137399820_77937092) of the annoying bug [JDK-8325203](https://bugs.openjdk.org/browse/JDK-8325203)- though your case is first time I've seen non-Windows report. Once a jpackage app closes after launching the update installer, the installer is killed possibly before it has chance to run, and unfortunately this bug was backported to all of the current JDKs 17/21/22.
type: Comment
comment on: http://stackoverflow.com/q/78506003
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138499524
has text: @JohnBollinger : Thanks for clarification. You are right of course.
score: 0
comment on: http://stackoverflow.com/a/78559697
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78499604
score: 2
upvote count: 2
type: Answer
has body: The command passed to ssh has to be double-quoted. Do not do it yourself. Instead, let bash do it. I propose first make a function of what you what to execute: worktodo() { <Block-of-commands> } You can use shellcheck to check correctness of your commands. Then you can execute the function just locallyl. Or alternatively, you can serialize the function to a string with declare -f work and use printf "%q" to quote it properly for sourcing for the remote shell, and then execute it.. if [ "$HOSTNAME" = "Computer" ]; then worktodo else ssh "Name@RemoteComputer" "$(printf "%q " bash -c "$(declare -f worktodo); worktodo")" fi Do not store commands to execute as variables like STRING='ssh Name@RemoteComputer'. To store commands, use functions. You can make it a function. if [ "$HOSTNAME" = "Computer" ]; then execfunc() { "$@"; } else execfunc() { ssh "Name@RemoteComputer" "$(printf "%q " bash -c "$(declare -f "$1"); $1")" } fi execfunc work
has comment: http://stackoverflow.com/comment/138391700
answers question: http://stackoverflow.com/q/78499350
downvote count: 0

http://stackoverflow.com/comment/138401518
type: AnswerComment
has text: also behaviour of: `echo abcde | grep -o -e a -e ab -e bc -e cd` is not entirely intuitive if patterns are searched serially, but makes more sense if searched in parallel
score: 0
comment on: http://stackoverflow.com/a/78505020
type: Comment

http://stackoverflow.com/comment/138511135
has text: Your text snippets aren't complete code (what is `"+%s")` on it's own line supposed to be?), you didn't provide sample input we could copy/paste to test with, and it's very difficult to figure out what it was you meant to write and what you wanted us to get from reading those text blocks. Are you trying to store the command `cat "${D5}" | jq '.Data[0].sr'` in a variable but you used `"($srx)"` instead of `"$(srx)"` to execute it? If so - don't do that, see https://mywiki.wooledge.org/BashFAQ/050. Please provide a [mcve] wo we can help you do whatever it is you're trying to do.
score: 2
comment on: http://stackoverflow.com/q/78566886
type: QuestionComment
type: Comment

http://stackoverflow.com/a/78574374
score: 2
answers question: http://stackoverflow.com/q/78573688
upvote count: 2
accepted answer of: http://stackoverflow.com/q/78573688
type: Answer
has body: You should back up the original descriptors (stdout and stderr) at the very beginning, and then restore them before the exec redirection. #!/bin/bash -e # backup stdout/stderr in file descriptor 3 and 4 resp. exec 3&gt;&amp;1 4&gt;&amp;2 function redirectOutputToLogFile() { local -r logFile=&quot;${1}&quot; mkdir -p &quot;$(dirname &quot;${logFile}&quot;)&quot; exec 1&gt;&amp;3 2&gt;&amp;4 # restore orig state of stdout/stderr exec &gt; &gt;(tee -a &quot;${logFile}&quot;) 2&gt;&amp;1 }
downvote count: 0
type: AcceptedAnswer

http://stackoverflow.com/q/78582686
downvote count: 0
score: 1
upvote count: 1
answer count: 1
linked to: http://stackoverflow.com/q/46407770
favorite count: 0
has body: I'm trying to use curl in Bash to fetch data from a web page using this script. #!/bin/bash # Define variables for URL and browser sGCitta="fucecchio" sGTypo="sale-houses" sGDomain="real-estate" url="https://www.$sGDomain.it/$sGTypo/$sGCitta" # Get HTML content of the page html_content=$(curl -s -L "$url") # Use html-xml-utils to extract announcements announcements=$(echo "$html_content" | hxselect 'li.nd-list__item.in-searchLayoutListItem') # Connect to SQLite database db_file="immo.db" # Initialize arrays for prices, links, descriptions, sizes, and auction prices=() links=() descriptions=() sizes=() auctions=() # Loop through the announcements while IFS= read -r announcement; do # Extract price price=$(echo "$announcement" | hxselect 'div.in-listingCardPrice span' -c | grep -oP '(?<=€ )[0-9,.]+') # Extract link link=$(echo "$announcement" | hxselect 'a.in-listingCardTitle' -s '\n' | grep -o 'href="[^"]*"' | sed 's/^href="//' | sed 's/"$//') # Extract description description=$(echo "$announcement" | hxselect 'a.in-listingCardTitle' -s '\n' | grep -oP '(?<=title=")[^"]+') # Extract size size=$(echo "$announcement" | hxselect 'div.in-listingCardFeatureList__item:nth-of-type(2) span' -c | grep -oP '[0-9]+') # Check if the description contains the word "auction" if "$description" =~ "auction" ; then auction=1 else auction=0 fi # Add data to the arrays prices+=("$price") links+=("$link") descriptions+=("$description") sizes+=("$size") auctions+=("$auction") done <<< "$announcements" # Print the sizes of the arrays echo "Size of the prices array: ${#prices[@]}" echo "Size of the links array: ${#links[@]}" echo "Size of the descriptions array: ${#descriptions[@]}" echo "Size of the sizes array: ${#sizes[@]}" echo "Size of the auctions array: ${#auctions[@]}" # Insert data into the SQLite database for ((i = 0; i < ${#prices[@]}; i++)); do sqlite3 "$db_file" "INSERT INTO $sGDomain (price, link, description, size, auction) VALUES ('${prices[i]}', '${links[i]}', '${descr…
has title: Using hxselect Command in Bash: How to Store Output in Arrays?
has answer: http://stackoverflow.com/a/78583954
has comment: http://stackoverflow.com/comment/138546266
tagged with: bash
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138539881
has comment: http://stackoverflow.com/comment/138541228
has comment: http://stackoverflow.com/comment/138540946
has comment: http://stackoverflow.com/comment/138540009

http://stackoverflow.com/a/78458900
answers question: http://stackoverflow.com/q/78457521
type: Answer
score: 2
has body: Get all attributes version chkmk_ver_all: "" gives chkmk_ver_all: - 2.2.0p26 - 2.1.0p43 - 2.0.0p39 - 1.6.0p30 - 2.3.0p1 Use the filter community.general.version_sort and sort the versions chkmk_ver_srt: "" gives chkmk_ver_srt: - 1.6.0p30 - 2.0.0p39 - 2.1.0p43 - 2.2.0p26 - 2.3.0p1 Then, get the last version chkmk_version: "" gives chkmk_version: 2.3.0p1 But, in the question, you "want to get the highest value of a child key". Then, get all keys chkmk_key_all: "{{ version.json.checkmk.keys() }}" gives chkmk_key_all: - 2.2.0 - 2.1.0 - 2.0.0 - 1.6.0 - 2.3.0 sort the versions chkmk_key_srt: "" gives chkmk_key_srt: - 1.6.0 - 2.0.0 - 2.1.0 - 2.2.0 - 2.3.0 and get the last version chkmk_version: "" gives chkmk_version: 2.3.0
upvote count: 2
downvote count: 0

http://stackoverflow.com/a/78484256
answers question: http://stackoverflow.com/q/78484156
score: 2
has comment: http://stackoverflow.com/comment/138365620
upvote count: 2
has body: You're looking for something like this: .hits.hits | map(.fields | .field1[0] + &quot;,&quot; + .field2[0]) | sort[] Online demo
has comment: http://stackoverflow.com/comment/138378461
type: Answer
has comment: http://stackoverflow.com/comment/138364946
accepted answer of: http://stackoverflow.com/q/78484156
downvote count: 0
has comment: http://stackoverflow.com/comment/138365102
has comment: http://stackoverflow.com/comment/138364923
type: AcceptedAnswer

http://stackoverflow.com/comment/138340760
score: 0
comment on: http://stackoverflow.com/a/78460489
has text: Yeah, hence my suggestion to fix the shebang; I see your point though, with `Rscript scriptname.R`adding the file to `bin` will not solve the issue
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138437137
score: 0
type: QuestionComment
type: Comment
has text: @CharlesDuffy Actually thanks I adapted part of your idea for the solution. In particular `bash -c "$(declare -f)"'cmd'` worked for exporting the functions and the variables I got exported with @Barmar 's answer.
comment on: http://stackoverflow.com/q/78525458

http://stackoverflow.com/a/78545793
has comment: http://stackoverflow.com/comment/138473940
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138474032
type: Answer
score: 2
has body: You got an answer to the question you asked about your awk error but in regards to "what I'm doing wrong now", it sounds to me like you're interested in speed of execution and so I wouldn't do all that work in awk and then pipe it to sort, I'd sort first and then pipe it to awk if necessary. Consider this alternative approach: $ cat file foo,Clive Barker bar,Danielle Steele etc,Clive Barker $ cut -d, -f2 file | sort | uniq -c 2 Clive Barker 1 Danielle Steele If you want the output rows ordered by count then pipe the above to sort -n or sort -nr as you like: $ cut -d, -f2 file | sort | uniq -c | sort -n 1 Danielle Steele 2 Clive Barker $ cut -d, -f2 file | sort | uniq -c | sort -nr 2 Clive Barker 1 Danielle Steele If you want the output columns in a different order, pipe the above to either of these (after piping to sort -n or sort -nr if you like): $ cut -d, -f2 file | sort | uniq -c | sed 's/ *\([0-9]*\) \(.*\)/\2, \1/' Clive Barker, 2 Danielle Steele, 1 $ cut -d, -f2 file | sort | uniq -c | awk -v OFS=', ' '{n=$1; sub(/ +[0-9]+ /,""); print $0, n}' Clive Barker, 2 Danielle Steele, 1 I doubt if you really want | sort -nrk2,2 from your script, btw, as that'd sort by the author's second name. You probably meant | sort -t, -nrk2,2.
answers question: http://stackoverflow.com/q/78539085
has comment: http://stackoverflow.com/comment/138473918

http://stackoverflow.com/comment/138348939
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78465027
has text: You can use `__FILE__` macro to find the file even if you are executing it from a different directory

http://stackoverflow.com/a/78525480
has comment: http://stackoverflow.com/comment/138436806
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/138436899
answers question: http://stackoverflow.com/q/78525458
upvote count: 3
has comment: http://stackoverflow.com/comment/138437170
downvote count: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138436835
has body: You can use this answer in a subshell (export $(compgen -v); bash -c 'cmd')
accepted answer of: http://stackoverflow.com/q/78525458
has comment: http://stackoverflow.com/comment/138437149

http://stackoverflow.com/comment/138526366
has text: Try putting the complete path name in double quotes.
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78575374

http://stackoverflow.com/a/78469452
has comment: http://stackoverflow.com/comment/138338407
answers question: http://stackoverflow.com/q/78469410
accepted answer of: http://stackoverflow.com/q/78469410
type: AcceptedAnswer
has body: You are calling your script with: ./mgba.sh "WarioWare, Inc. - Mega Microgame$!.gba" Before your script executes, "$!" is replaced by the last background pid. If you want to preserve the literal value of a string, you have to escape it upon writing. ./mgba.sh "WarioWare, Inc. - Mega Microgame\$!.gba" or ./mgba.sh 'WarioWare, Inc. - Mega Microgame$!.gba' Your script is really simple - it should just pass properly quoted expansion of arguments and call the exe. Nothing to do in your script. Just: "${exe}" "$@" Check your scripts with shellcheck. Debug your scripts with set -x, also interactive shell.
score: 2
has comment: http://stackoverflow.com/comment/138338491
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/138338424
type: Answer

http://stackoverflow.com/comment/138401385
type: AnswerComment
has text: I think your code may give incorrect output if two patterns overlap. More obvious if you use `match` instead of `~` and output `substr` (cf. `grep -o`). eg. match `abcdef` against `a` and `ab`
score: 0
comment on: http://stackoverflow.com/a/78505020
type: Comment

http://stackoverflow.com/q/78518299
type: UnansweredQuestion
score: 1
has title: oasdiff --err-ignore flag doesn't ignore
has body: Anyone has any idea on how to create this ignore file? the docs aren't clear and it basically says to just write the endpoint in it. so after running oasdiff breaking my output is something like error [api-deprecated-sunset-parse] at packages/server/src/generated/swagger.json in API PUT /foo/bar api sunset date '' can't be parsed for deprecated API: 'sunset extension not found' therefore I create a file with the endpoint named ignore.md (md is what the doc says people usually use) e.g. PUT /foo/bar however running breaking --err-ignore ignore.md base revision is still giving me the output with the error.
tagged with: command-line-interface
downvote count: 0
tagged with: bash
has answer: http://stackoverflow.com/a/78518396
upvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/78518718
tagged with: swagger
tagged with: openapi
answer count: 2
type: Question
tagged with: javascript

http://stackoverflow.com/comment/138506877
score: 1
type: QuestionComment
has text: define *`bringing every time different results, mostly unreliable`*; provide examples of what's 'different' and 'unreliable'; what are you expecting? what are you generating? update the question with these additional details (do not provide these additional details in comments)
type: Comment
comment on: http://stackoverflow.com/q/78564469

http://stackoverflow.com/comment/138437336
has text: (See https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/basedefs/V1_chap08.html for the relevant naming convention declaring names with at least one lowercase character "reserved for application use" -- yes, that's the POSIX environment variable spec, but it applies to even non-exported variables since setting a variable with a name that overlaps with a preexisting environment variable overwrites the latter).
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78525458

http://stackoverflow.com/a/78587616
has comment: http://stackoverflow.com/comment/138649853
answers question: http://stackoverflow.com/q/78586078
has comment: http://stackoverflow.com/comment/138551827
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138649857
has body: You could try awk (tested with GNU awk). Search delimiters to the left and right of integer position $ cat foo.awk #!/usr/bin/env awk function lastindex(s, c, r) { r = index(s, c) if(r != 0) return r + lastindex(substr(s, r + 1), c) return 0 } NR == n { h = substr($0, 1, p - 1); c = substr($0, p, 1); t = substr($0, p + 1) for(i = 1; i < length(d); i += 2) { c0 = substr(d, i, 1); c1 = substr(d, i + 1, 1) i0 = lastindex(h, c0); i1 = index(t, c1) if(i0 && (c == c1)) { # opening in head, closing at position s = substr(h, i0 + 1) exit } if((c == c0) && i1) { # opening at position, closing in tail s = substr(t, 1, i1 - 1) exit } if(i0 && i1) { # opening in head, closing in tail s = substr(h, i0 + 1) c substr(t, 1, i1 - 1) exit } } s = $0; exit } END { sub(/^[[:space:]]*/, "", s) sub(/[[:space:]]*$/, "", s) print s } And then, if your file is file, the line of interest is line 15 (counting from 1 for the first line), the position is 72 (counted from 1 for the first character) your delimiter pairs, in decreasing order of precedence, are "", '', () and (2 spaces): $ awk -f foo.awk -v d="\"\"''() " -v n=15 -v p=72 file Or, if you want to pass the text line directly (but you'll have to properly escape quotes, if needed): $ awk -f foo.awk -v d="\"\"''() " -v n=1 -v p=5 <<< "'~/te st'" Explanations: The script uses 3 variables passed on the command line: d is the string of opening/closing characters in decreasing order of precedence; example for pairs "", '', ()and (2 spaces): -v d="\"\"''() ". n is the line number (starting from 1). p is the position in line (starting from 1). The lastindex custom function returns the index of the last occurrence of character c in string s or 0 if there is none. The index built-in function does the same with the first occurrence. The script processes only line number n (condition NR == n). We splits the line in 3 parts: head (h) from character 1 to character p-1, character at position p (c), and tail (t) from character p+1 to the end. Then, for…
has comment: http://stackoverflow.com/comment/138550340
has comment: http://stackoverflow.com/comment/138550373
has comment: http://stackoverflow.com/comment/138578324
upvote count: 2
has comment: http://stackoverflow.com/comment/138559231
type: Answer
has comment: http://stackoverflow.com/comment/138577314
has comment: http://stackoverflow.com/comment/138588883
score: 2
accepted answer of: http://stackoverflow.com/q/78586078
has comment: http://stackoverflow.com/comment/138557265
has comment: http://stackoverflow.com/comment/138578279
has comment: http://stackoverflow.com/comment/138573970
downvote count: 0

http://stackoverflow.com/comment/138403287
type: QuestionComment
type: Comment
has text: Don't just use the word `pattern` when asking for help with pattern matching. That's like going to a car showroom and only telling the salesman you want a "vehicle" instead of car, truck, motorbike, whatever. You need to say if you want to do regexp or string, full or partial, etc. pattern matching or you're likely to get a solution that;s less efficient and/or less robust than it could be. See [how-do-i-find-the-text-that-matches-a-pattern](https://stackoverflow.com/questions/65621325/how-do-i-find-the-text-that-matches-a-pattern).
comment on: http://stackoverflow.com/q/78504692
score: 0

http://stackoverflow.com/comment/138420387
has text: Hi @user1934428 I disagree. `a =~ *a ` exits with 2 exit code (for me on bash5.2.26). Exit code 2 means error. It is not interpreted as literal asterisk: `'*a' =~ *a ` also exits with 2 exit code. It is a valid syntax, but then when parsing the regex, it fails, and makes `[[` always exit with 2 exit code.
comment on: http://stackoverflow.com/q/78514371
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138537151
type: QuestionComment
has text: You should definitely leave `/usr/bin` alone; this is reserved for OS-installed utilities. You can put your own binaries in `/usr/local/bin` and required data files in `/usr/share/lib` or etc.
type: Comment
comment on: http://stackoverflow.com/q/78576313
score: 0

http://stackoverflow.com/q/78587160
accepted answer: http://stackoverflow.com/a/78587183
score: 0
type: Question
duplicate of: http://stackoverflow.com/q/64082460
tagged with: environment-variables
answer count: 1
has body: I'd like to call kubectl run that allows to specify environment values with the syntax: --env=nameOfVar=valueOfVar. I have this construct: env=() for v in var1 var2 var2; do env+="--env=$v=${!v}" done kubectl run mycontainer "${env[@]}" In this way, I can pass the value of existing variables to kubectl. It works ok, except when the value of a var contains spaces. How can I delimiter arguments correctly to kubectl? I've tried other variations like: env= for v in var1 var2 var2; do env="$env --env=$v=${!v}" done kubectl run mycontainer "$env" Suposing var1 has the value value 1 and so on, I'd like this result: kubectl run mycontainer "--env=var1=value 1" "--env=var2=value 2" "--env=var3=value 3" instead of this: kubectl run mycontainer --env=var1=value 1 --env=var2=value 2 --env=var3=value 3
has title: How to expand variables with spaces in bash
tagged with: bash
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/64082460
has answer: http://stackoverflow.com/a/78587183

http://stackoverflow.com/comment/138519804
score: 2
type: QuestionComment
comment on: http://stackoverflow.com/q/78571808
type: Comment
has text: You may want to consider using `screen` as an alternative. It's been my go-to for remote server administration for years since it will stay running, as well as everything in it, through SSH sessions and whatnot.

http://stackoverflow.com/comment/138398987
type: Comment
score: 0
has text: Why not just a docker image?
comment on: http://stackoverflow.com/q/78502959
type: QuestionComment

http://stackoverflow.com/comment/138437170
type: AnswerComment
comment on: http://stackoverflow.com/a/78525480
score: 0
has text: Feel free to post that as an answer and accept it in place of mine.
type: Comment

http://stackoverflow.com/a/78465150
has body: Alternate possibility: pass the file path of your source code to the program as argument. #include <stdio.h> #include <unistd.h> int main( int argc, char ** argv ) { // No argument? No go! if (argc != 2) return 1; // Run cat for the argument file execl( "/bin/cat", "/bin/cat", argv[1], (char*)NULL ); // If we get here then execl() failed return 1; } Now you can compile your program and run it as: $ gcc -Wall -Wextra -Werror -pedantic-errors -O3 a.c $ ./a.out a.c #include <stdio.h> #include <unistd.h> int main( int argc, char ** argv ) { // No argument? No go! if (argc != 2) return 1; // Run cat for the argument file execl( "/bin/cat", "/bin/cat", argv[1], (char*)NULL ); // If we get here then execl() failed return 1; } $
answers question: http://stackoverflow.com/q/78464749
type: Answer
score: 0

http://stackoverflow.com/comment/138472918
has text: Note that `array=( $(subcommand) )` is an antipattern -- [BashPitfalls #50](https://mywiki.wooledge.org/BashPitfalls#hosts.3D.28_.24.28aws_.2BICY.29_.29) goes into more detail. For items where there's one item per line (where bash 4.0 or later is in use), `readaray -t array < <(subcommand)` is preferred; for compatibility with bash 3.2, one instead ends up with a [BashFAQ #1](https://mywiki.wooledge.org/BashFAQ/001) loop appending (`array=(); while IFS= read -r item; do array+=( "$item" ); done < <(subcommand)`)
comment on: http://stackoverflow.com/a/78545843
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78527266
answers question: http://stackoverflow.com/q/78491375
has comment: http://stackoverflow.com/comment/138589841
downvote count: 0
score: 1
upvote count: 1
type: Answer
has body: Is there a way to still show the preview with the -y flag? I feel like this is very valuable information that we need in our logging. No, it is not possible to show the preview when using the -y flag with the az appconfig kv import command. The purpose of the -y flag is to bypass the confirmation prompt and automate the import process. If you need to check the URL before updating it, you can use the az appconfig kv list command. It will list the URL. Command and output: venkatesan@Azure:~$ az appconfig kv list -n sampleconfig --label test --query "[?key=='value'].value" -o tsv "\"www.test1.myapp.com\"" Now, after verifying the URL, you can use the az appconfig kv import command to update the URL. Command and output: az appconfig kv import -n sampleconfig --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 -y Portal: Reference: az appconfig kv | Microsoft Learn

http://stackoverflow.com/comment/138429418
has text: I would recommend to you reading the documentation what those Termux permissions allow you to do, e.g. [RUN_COMMAND](https://github.com/termux/termux-app/wiki/RUN_COMMAND-Intent). They work totally different as you expect: you have to create an Intent to execute a command.
comment on: http://stackoverflow.com/q/78519993
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138393861
comment on: http://stackoverflow.com/q/78497806
type: QuestionComment
type: Comment
has text: That suggests something is awry with your `$PATH`. What if you use the full path to `timeout`?
score: 0

http://stackoverflow.com/a/78587183
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/78587160
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/138548319
has body: Use the correct syntax. env=() for v in var1 var2 var2; do env+=(&quot;--env=$v=${!v}&quot;) done kubectl run mycontainer &quot;${env[@]}&quot;
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/78587160

http://stackoverflow.com/q/78534641
has answer: http://stackoverflow.com/a/78537521
type: Question
has title: AWK equivalent to `read -r _ _ remainder`
has comment: http://stackoverflow.com/comment/138454038
downvote count: 1
has answer: http://stackoverflow.com/a/78539255
accepted answer: http://stackoverflow.com/a/78535924
has body: Let's say that you have a file which contains N whitespace-delimited columns and an additional column which has spaces in it that you want to keep. Example with N = 2: 1.1 1.2 data for row1 2.1 2.2 data for row2 ? ? data for row3 \ * data for row4 I would like to output: data for row1 data for row2 data for row3 data for row4 In the shell you can do it easily with: while read -r _ _ data do printf "%s\n" "$data" done < data.txt But with awk it's kind of difficult. Is there a method in awk for splitting only the first N columns?
has answer: http://stackoverflow.com/a/78535045
has answer: http://stackoverflow.com/a/78539121
upvote count: 9
has comment: http://stackoverflow.com/comment/138455134
tagged with: bash
linked to: http://stackoverflow.com/q/78539701
has answer: http://stackoverflow.com/a/78535924
has comment: http://stackoverflow.com/comment/138463236
favorite count: 0
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/78537521
answer count: 6
tagged with: awk
has answer: http://stackoverflow.com/a/78534684
has comment: http://stackoverflow.com/comment/138455057
score: 8
has comment: http://stackoverflow.com/comment/138462667

http://stackoverflow.com/comment/138342284
has text: You never need grep when you're using awk. `foo | grep | awk` is an anti-pattern.
type: Comment
comment on: http://stackoverflow.com/q/78451797
type: QuestionComment
score: 1

http://stackoverflow.com/a/78539050
has comment: http://stackoverflow.com/comment/138460401
answers question: http://stackoverflow.com/q/78538995
type: AcceptedAnswer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/78538995
has comment: http://stackoverflow.com/comment/138460467
score: 1
downvote count: 0
has body: You have to install the docker CLI inside your image. Here is my solution to the same problem (that can customize on your needs): FROM &lt;YOUR_DEBIAN_BASED_IMAGE&gt; RUN apt update -y RUN apt install -y curl RUN curl https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz | tar xvz -C /tmp/ &amp;&amp; mv /tmp/docker/docker /usr/bin/docker # Customize here your container... Then in order to connect to the docker outside your container you have to remember to create your container by: docker run -v /var/run/docker.sock:/var/run/docker.sock &lt;YOUR_IMAGE&gt; At this link https://devopscube.com/run-docker-in-docker/ you can find some more useful explanations.
type: Answer

http://stackoverflow.com/comment/138308503
has text: Right. `$@` contains the positional arguments, which doesn't incluide `$0`.
score: 0
comment on: http://stackoverflow.com/a/78451344
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/138496559
type: QuestionComment
comment on: http://stackoverflow.com/q/78558739
type: Comment
has text: Don't store commands in variables (the `command="ls ...` part). Variables are for storing data, functions are for storing commands. Either use a function, or don't store it at all, just execute it normally, like `length="$(ls ...`. See [BashFAQ #50: "I'm trying to put a command in a variable, but the complex cases always fail!"](http://mywiki.wooledge.org/BashFAQ/050) and many many previous questions from people who tried this and ran into trouble.
score: 1

http://stackoverflow.com/a/78484245
downvote count: 0
has body: To sort by .fields.field1[0] use sort_by(.fields.field1[0]). But as you want to output the same values used as criteria, reduce beforehand using map, and just use sort on the result array: jq -r '.hits.hits | map(.fields.field1[0]) | sort[]' file.json Demo Note that this performs string sorting as all first items of the .field1 arrays are actually strings (despite containing digits only, 11 would be sorted before 2). If you want numeric sorting (in the sense that two is smaller than eleven), convert the items into numbers first using tonumber. In this case, you could also drop the -r flag as JSON numbers don't have special encoding. jq -r '.hits.hits | map(.fields.field1[0] | tonumber) | sort[]' file.json Demo As the sample data only has digit-only string items of equal lengths, both approaches yield the same output: 111111113034864 111111113034877 111111113034894 111111113046053 111111113046124 : I want a CSV file with both field1 and field2 separated by , With output items differing from the sorting criteria, I'd revert to using sort_by(.fields.field1[0]) as it gives you more freedom to mix and match, and have @csv construct the output, which also takes care of escaping special characters: .hits.hits | sort_by(.fields.field1[0])[].fields | [.field1[0], .field2[0]] | @csv "111111113034864","FOO" "111111113034877","FOO" "111111113034894","FOO" "111111113046053","FOO" "111111113046124","FOO" Demo
has comment: http://stackoverflow.com/comment/138378480
score: 2
type: Answer
answers question: http://stackoverflow.com/q/78484156
has comment: http://stackoverflow.com/comment/138364914
upvote count: 2

http://stackoverflow.com/comment/138499612
has text: Learn to use https://shellcheck.net and post only "corrrected code" with a notice (shellcheck approved or similar). AND "it's not working" is a bad description of your problem. Always post exact text of error messages. Glad you got a solution below. Good luck.
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/78556921
type: Comment

azure-app-configuration
type: Tag
tag name: azure-app-configuration
tags question: http://stackoverflow.com/q/78491375

http://stackoverflow.com/comment/138517945
has text: When you have a file named `dartsapp.py` which contains a first line starting with `#!` (known as a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix))) like `#!/usr/bin/python3` you can call it as just `./dartsapp.py` as the OP was doing because the Unix kernel will use that shebang to call `/usr/bin/python3` to interpret the rest of the file, the same as if you had manually typed `python3 ./dartsapp.py`.
comment on: http://stackoverflow.com/a/78570291
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/a/78578383
answers question: http://stackoverflow.com/q/78578346
type: Answer
accepted answer of: http://stackoverflow.com/q/78578346
type: AcceptedAnswer
has body: Yes. Use the -p option to pipe the output to stdout. Then you can: unzip -p mysql-api.jpi WEB-INF/lib/mysql-connector-j-8.4.0.jar &gt; /var/lib/jenkins/war/WEB-INF/lib/mysql-connector-j-8.4.0.jar That would be useful if you want to pipe the extracted data through some other processing. Since you are simply copying the file, which is in fact saving it, a more direct approach would be to specify the directory to extract to: unzip -d /var/lib/jenkins/war/ mysql-api.jpi WEB-INF/lib/mysql-connector-j-8.4.0.jar
score: 4
upvote count: 4
downvote count: 0

sshpass
tags question: http://stackoverflow.com/q/78469768
tag name: sshpass
type: Tag

http://stackoverflow.com/comment/138377610
type: Comment
has text: jq requires double quotes around the value. Why it doesn't have a date object/function baffles me.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/78491313

http://stackoverflow.com/comment/138327283
score: 0
has text: You should be able to combine all the greps: `grep -o -E 'href="https:[^"#]+magazine/[^"#]+"'`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78462933

http://stackoverflow.com/a/78538423
type: Answer
has body: Change: echo &quot;[Status] $(killall --wait example)&quot; into: echo &quot;[Status] $(killall --wait example 2&gt;&amp;1)&quot; Explanation: killall prints out on standard error instead of standard output.
score: 1
has comment: http://stackoverflow.com/comment/138459442
answers question: http://stackoverflow.com/q/78538377
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/138459459
has comment: http://stackoverflow.com/comment/138459877
accepted answer of: http://stackoverflow.com/q/78538377
downvote count: 0
has comment: http://stackoverflow.com/comment/138459542

http://stackoverflow.com/comment/138312764
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78451797
has text: you've stated you have multiple files ... do you need to sum up the emails on a per-file basis? or do you need to sum up the emails across all files?
score: 0

http://stackoverflow.com/comment/138377286
type: Comment
has text: Can't you use JQ to format it to your liking?
comment on: http://stackoverflow.com/q/78491313
score: 0
type: QuestionComment

http://stackoverflow.com/q/78557294
upvote count: 2
tagged with: arrays
type: Question
tagged with: ifs
has title: How to parse an array, that uses space delimiter, and has spaces in the values?
tagged with: dialog
has comment: http://stackoverflow.com/comment/138493883
has comment: http://stackoverflow.com/comment/138493844
score: 2
has body: I'm using Dialog, in bash, to create a simple multiple choice question. My options all include spaces in the values. When the Dialog is constructed, it appears to be building the array with a space delimiter. My options are as such: TITLE="Setup Script..." VER="0.2Β" { # Default Dialog Values. # └──These can be overwritten if need be. DIALOG_TOGGLE="OFF" # Used for dialog multiple choice. DIALOG_HEIGHT=15 # Sets the height. DIALOG_WIDTH=78 # Sets the width. DIALOG_CHOICES=4 # Sets the number of choices. DIALOG_OK_LABEL="Submit" # Sets the OK button label. DIALOG_CANCEL_LABEL="Cancel" # Sets the Cancel button label. DIALOG_EXTRA_BUTTON=true # Enable/Disable the extra button. DIALOG_EXTRA_LABEL="Select All" # Sets the "EXTRA" button label. DIALOG_BACKTITLE=$TITLE" v:"$VER # Sets the background title. DIALOG_TITLE="Example Title..." # Sets the dialog title. DIALOG_DESCRIPTION="\n\ Welcome to the $TITLE\n\n\ Example Description" declare -a DIALOG_OPTIONS=( "Example Item 1" "This is an example option" $DIALOG_TOGGLE "Example Item 2" "This is an example option" $DIALOG_TOGGLE "Example Item 3" "This is an example option" $DIALOG_TOGGLE ) } My Dialog is then constructed as such: load_dialog() { # Check whether or not to display the extra button if [ "$DIALOG_EXTRA_BUTTON" = true ] ; then EB_TOGGLE='--extra-button' else EB_TOGGLE='' fi # Dialog Framework cmd=(dialog --colors --clear --keep-tite --backtitle "$DIALOG_BACKTITLE" --title "$DIALOG_TITLE" --ok-label "$DIALOG_OK_LABEL" --cancel-label "$DIALOG_CANCEL_LABEL" $EB_TOGGLE --extra-label "$DIALOG_EXTRA_LABEL" --checklist "${DIALOG_DESCRIPTION//$'\t'/}" "$DIALOG_HEIGHT" "$DIALOG_WIDTH" "$DIALOG_CHOICES" ) # Build Dialog CHOICES="$("${cmd[@]}" "${DIALOG_OPTIONS[@]}" 2>&1 1>/dev/tty)" # Detect the exit status of the Dialog (what button was pressed) exitStatus=$? # Backup existing IFS SAVEIFS=$IFS # Set new IFS IFS=$'\n' # Determine what choices were selected if [ -z "${CHOICES}" ]; then echo "No option was selected..." echo …
has comment: http://stackoverflow.com/comment/138499152
downvote count: 0
tagged with: bash
accepted answer: http://stackoverflow.com/a/78557547
answer count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138493872
has answer: http://stackoverflow.com/a/78557547

http://stackoverflow.com/q/78558314
has body: I installed zsh but decided to remove it but got this error on my terminal &lt;3&gt;WSL (412) ERROR: CreateProcessEntryCommon:505: execvpe /usr/bin/zsh failed 2 &lt;3&gt;WSL (412) ERROR: CreateProcessEntryCommon:508: Create process not expected to return [process exited with code 1 (0x00000001)] You can now close this terminal with Ctrl+D, or press Enter to restart. I tried to acces wsl with bash using wsl -e /bin/bash and tried to remove zsh sudo apt remove zsh sudo apt purge zsh i hoped it would uninstall zsh, and the purge command will remove any configuration files associated with zsh.
has answer: http://stackoverflow.com/a/78558351
tagged with: zsh
type: Question
type: UnansweredQuestion
tagged with: windows-subsystem-for-linux
score: 0
tagged with: bash
has title: How to fix wsl error [process exited with code 1 (0x00000001)]
answer count: 1

http://stackoverflow.com/comment/138421913
score: 0
has text: @DuncG thanks. this is very interesting, but a little bit different. The problem in my case was the default configuration of the service which kills all child processes.
comment on: http://stackoverflow.com/q/78506003
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138401431
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/78505426
has text: Don't store the command in a variable. Don't forget to quote the argument to `echo`. Try https://shellcheck.net/ for basic diagnostics.
score: 2

http://stackoverflow.com/comment/138415859
comment on: http://stackoverflow.com/q/78513720
has text: I tried with 6,000,000 patterns and it worked as expected. Did you verify that both files contain the pattern you said they should?
score: 0
type: QuestionComment
type: Comment

bioinformatics
tags question: http://stackoverflow.com/q/78561775
type: Tag
tag name: bioinformatics
tags question: http://stackoverflow.com/q/78620851
tags question: http://stackoverflow.com/q/78975695
tags question: http://stackoverflow.com/q/78974679
tags question: http://stackoverflow.com/q/79232636
tags question: http://stackoverflow.com/q/79216406
tags question: http://stackoverflow.com/q/79429771

http://stackoverflow.com/comment/138513028
type: Comment
type: AnswerComment
score: 0
has text: @CharlesDuffy, yes but that was not my problem mate, even when I pass the second option, if I did not use single quotes at run.sh then it would remove all the double quotes from it, the trick was using single quotes at run.sh too, but yes this both ways of declaring the var at .env are the same you are right in that
comment on: http://stackoverflow.com/a/78568050

http://stackoverflow.com/comment/138421292
comment on: http://stackoverflow.com/a/78516302
type: Comment
type: AnswerComment
has text: Thanks, it worked. I thought aliases are meant for a executing a single command and functions for executing a block of commands.
score: 0

http://stackoverflow.com/q/78505054
tagged with: kubectl
score: 0
has answer: http://stackoverflow.com/a/78505149
tagged with: bash
has title: For loop within kubectl exec
answer count: 1
has body: I want to understand how we could run a for loop or complex commands inside kubectl exec. Currently I'm running the following and getting an error. kubectl exec -it my-statefulset-0 -n my-namespace -- for i in {0..5}; do curl http://my-statefulset-$i.svc:8080/health; done -bash: syntax error near unexpected token `do'
duplicate of: http://stackoverflow.com/q/37586811
linked to: http://stackoverflow.com/q/37586811
tagged with: for-loop
type: Question
type: UnansweredQuestion

compare
tags question: http://stackoverflow.com/q/78465704
tag name: compare
type: Tag
tags question: http://stackoverflow.com/q/79094427

http://stackoverflow.com/comment/138509616
type: Comment
has text: Based on the output of `fc-list : file | head -4` you show, replacing `| tr -d ':' | awk '{$1=$1};1'` with `sed 's/:$//'` would make your script more robust and efficient but there's no indication in your question of any problem with your files names and no problem with your original shell script that'd cause it to fail using those file names. My best guess at this point is that the script in your question is not the script you're actually running that's producing the error message in your question. Add `set -x` to the top of your script, run it again, then post THAT output.
score: 0
comment on: http://stackoverflow.com/q/78562624
type: QuestionComment

http://stackoverflow.com/comment/138398137
has text: The code in my comment will do what I think you want in bash and maybe also in zsh. The default bash on MacOS is an extremely old one (Apple avoiding licensing issues) so install a newer version if you're going to switch to bash. Bash is a more commonly used shell and more people would be able to help you. The only real zsh expert I know, [Stéphane Chazelas](https://unix.stackexchange.com/questions/776511/parse-txt-file-on-basis-of-occurrence-of-a-tag-in-linux#:~:text=at%2013%3A39-,St%C3%A9phane%20Chazelas,-549k92), participates in questions over on StackExchange FWIW.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78503442
score: 0

http://stackoverflow.com/comment/138497309
has text: @biffen you are very close. its working but it dont work if number of ip gets change to 1 or 3 or more. It should be generic
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78559080

http://stackoverflow.com/a/78566440
upvote count: 1
has body: It's not clear why you're trying to avoid eval as what you're trying to do is what eval exists to do but you should do eval "$line", i.e. quoted, not eval $line unquoted for all the usual reasons you don't remove quotes unless you need to (see https://mywiki.wooledge.org/Quotes). See https://mywiki.wooledge.org/BashFAQ/048 for best practices when using eval and see https://mywiki.wooledge.org/BashFAQ/050 for more information about storing commands in variables and note it says: In bash, the only ways to generate, manipulate, or store code more complex than a simple command at runtime involve storing the code's plain text in a variable, file, stream, or function, and then using eval or sh to evaluate the stored code i.e. that using eval is 1 of only 2 ways (the other being to run a shell on it) to do what you're trying to do robustly. The negative to using eval (or calling a shell to execute the code in your variable) is that it executes what you tell it to and so if you tell it to execute bad code then bad things will happen, but that's the same problem as telling the shell to execute a script, the only difference being that code stored in a variable is often created dynamically, possibly including input from a user or some other source outside of your control, while that's extremely rare for code stored in a script. So as long as the commands in your input file are completely under your control, you treat then with the same rigor as any script you write, and you just want a way to execute them as if you had created a script for each - then eval is your friend. Using a command with flags (date) as in the OPs sample input and adding a mix of single and double quotes plus a globbing char (*), potential variable expansion ($bar), command expansion ($(date)), and a complex command in a sample input file to really test that only the correct expansions, etc. happen in the script: $ cat file TZ=EST date -d 'yesterday' TZ=UTC date -d 'yesterday' env_var='$(date)' awk '{prin…
type: Answer
accepted answer of: http://stackoverflow.com/q/78562360
score: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/78562360
downvote count: 0

http://stackoverflow.com/comment/138374581
has text: @Fravadona The last `sed` command will place the backslash at the beginning of the line again. This won't conflict with anything, because, if the filename contains a backslash then the md5sum line always starts with a backslash.
type: Comment
comment on: http://stackoverflow.com/q/78488507
score: 1
type: QuestionComment

http://stackoverflow.com/comment/138308527
score: 3
comment on: http://stackoverflow.com/q/78451463
has text: Please read [why-is-printf-better-than-echo](https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo)
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78480780
has answer: http://stackoverflow.com/a/78480805
score: 0
has title: How to search and replace bash variable with braces?
type: Question
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138364159
has comment: http://stackoverflow.com/comment/138366019
has body: I have the following: var='before {{BODY_PARAM}} after' body_arg='body' Using ${var/{{BODY_PARAM}}/${body_arg} emits before }} after}/body. How do I use bash variable search and replace syntax to replace {{BODY_PARAM}} with body?
has comment: http://stackoverflow.com/comment/138365683
has answer: http://stackoverflow.com/a/78480782
answer count: 2
has comment: http://stackoverflow.com/comment/138368470
has comment: http://stackoverflow.com/comment/138365660
tagged with: bash
has comment: http://stackoverflow.com/comment/138365545
has comment: http://stackoverflow.com/comment/138365779
has comment: http://stackoverflow.com/comment/138365571

http://stackoverflow.com/comment/138394085
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78501116
has text: I'm showing my age :)
type: Comment

http://stackoverflow.com/q/78562095
has comment: http://stackoverflow.com/comment/138503444
has body: Consider the following script, which I simplified from this question. #!/bin/bash A=( foo bar "a b c" 42 ) B=("${A[@]:1}") # slice to the end of the array echo "${B[@]}" This works fine, but if I try to use similar syntax for the argument array $@ I get a syntax error: #!/bin/bash echo "$@" B=("${$@:1}") # slice to the end of the array Executing: ./play x y z ./play: line 4: ${$@:1}: bad substitution Is there a different magic syntax for slicing the argument array?
score: 1
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138502642
accepted answer: http://stackoverflow.com/a/78562117
has comment: http://stackoverflow.com/comment/138502575
downvote count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/138503024
has answer: http://stackoverflow.com/a/78562117
type: Question
tagged with: arrays
linked to: http://stackoverflow.com/q/1335815
has title: Is it possible to slice the argument array in Bash?
has comment: http://stackoverflow.com/comment/138502610
tagged with: arguments

http://stackoverflow.com/comment/138415620
score: 0
comment on: http://stackoverflow.com/q/78504692
type: QuestionComment
has text: Had we known they were literal strings instead of regexps you'd have got quite different answers.
type: Comment

http://stackoverflow.com/q/78464573
downvote count: 0
score: 1
tagged with: bash
type: Question
tagged with: amazon-ec2
tagged with: boto3
accepted answer: http://stackoverflow.com/a/78465396
has answer: http://stackoverflow.com/a/78465396
tagged with: amazon-web-services
has comment: http://stackoverflow.com/comment/138334490
has title: AWS Boto3 EC2 client send_command process shuts down
upvote count: 1
answer count: 1
favorite count: 0
type: AnsweredQuestion
tagged with: python
has body: I am using send_command() function to run local python script on about 100 ec2 instances for long periods(days). ssm_client = boto3.client('ssm', region_name = 'eu-west-1') commands_to_execute = """cd /home/ubuntu set -x exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>logv5.out 2>&1 python3 myscript.py""" command_lines_to_execute = commands_to_execute.split('\n') ssm_client.send_command(InstanceIds=[instance_id], DocumentName="AWS-RunShellScript", Parameters={'commands': commands_to_execute}) I am also logging the console output via the part below: set -x exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>logv5.out 2>&1 Logging part works as intended. However after about an hour, Python process in each EC2 instance simply dies with no output. I thought perhaps some kind of virtual bash session dies which causes the python process that was launched by it to die. So, I tried launching screen first before executing other commands, but this did not help either. What am I missing here? Why does my Python process die without any output?

http://stackoverflow.com/comment/138410435
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78509705
has text: On the other hand, having a global variable outside the function which controls its behavior sort of ruins the whole point of putting the logic in a function.
score: 2

http://stackoverflow.com/comment/138493883
has text: You need quotes around: `${CHOICES[@]}`. It should be `"${CHOICES[@]}"`. Otherwise the spaces in the values will be treated as word delimiters.
score: 1
comment on: http://stackoverflow.com/q/78557294
type: QuestionComment
type: Comment

http://stackoverflow.com/q/78530614
tagged with: bash
has comment: http://stackoverflow.com/comment/138456089
has body: I am using Eclipse 2022-12 on Windows 10. I installed GitBash for Windows. I installed the Bash Editor from the Marketplace. When I run a file.sh, an external console window will flicker briefly but the script will fail. I am able to run the script directly in a Git Bash terminal. Here is a screenshot of Windows &lt; Preferences &lt; Bash Editor Launch. The following images Show result cmd and Test Terminal, where the Test Terminal is the external console window and lingers for a few seconds (enough to get the image). eclipse bashed launch configuration bashed external terminal I expected that when I did a right-click Run as bash on a file.sh, it would execute that bash script and write the output file the script produces.
has title: Terminal failures installing Eclipse Bash Editor Windows 10
has comment: http://stackoverflow.com/comment/138456561
score: 0
type: Question
answer count: 0
has comment: http://stackoverflow.com/comment/138456533
type: UnansweredQuestion
tagged with: eclipse
has comment: http://stackoverflow.com/comment/138457896
has comment: http://stackoverflow.com/comment/138448070
has comment: http://stackoverflow.com/comment/138455895
has comment: http://stackoverflow.com/comment/138456543

http://stackoverflow.com/comment/138416721
comment on: http://stackoverflow.com/q/78514371
type: Comment
type: QuestionComment
has text: `if [ ${#var} -gt 113450 ]; then if [ "$var" = "$value" ]` So how can var have more characters than 113450 and yet then still be equal to `value` which is only `ERmFRMVZ0U2paTlJYTkxDZz09Cg`, which is way way shorter than 113450 characters?
score: 0

http://stackoverflow.com/comment/138336048
comment on: http://stackoverflow.com/q/78465704
type: Comment
has text: When you want the script sourced, perhaps use a wrapper that sources the right native script. Perhaps with aid of a variable set in your shell dependent login script. This will introduce maintaining different scripts, but this is better than a multi-language script that nobody can maintain.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138529809
score: 0
has text: Quibble: Not actually a bash command. `shell=True` uses sh, not bash. (Even if your operating system installs sh as a link to bash -- which isn't the case on many popular operating systems such as Debian, Ubuntu, or Alpine -- bash disables some of its features when started under the sh name).
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78576344

http://stackoverflow.com/comment/138327673
type: Comment
has text: @markp-fuso It wasn't obvious for me, that variables would be such a performance killer :0. Thanks!
comment on: http://stackoverflow.com/q/78461484
score: 0
type: QuestionComment

http://stackoverflow.com/comment/138317081
score: 0
has text: Also, you may want to match the entire string with `^"${LineExc}"$`. And by using `"${LineExc}"` within double quotes, you ensure that any special characters in `LineExc` are treated literally and not as part of the pattern matching syntax.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78456881

http://stackoverflow.com/comment/138327264
score: 0
type: Comment
has text: If it doesn't work, what is the expected output and what are you getting instead?
comment on: http://stackoverflow.com/q/78462933
type: QuestionComment

http://stackoverflow.com/comment/138536536
score: 0
comment on: http://stackoverflow.com/q/78579093
has text: @Saboteur that depends on what "correctly" means to the OP. Maybe it's combinations of flags that should cause something to happen or maybe they really do want a loop setting/clearing flags and doing different things, etc. So far all the OP has told us about their code is "it's giving different result than expected" but they didn't tell us what's expected, nor in what way it's behaving unexpectedly so we're all just guessing at this point.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138303808
comment on: http://stackoverflow.com/q/78449032
has text: Could you please share your pipeline code or at least the most relevant parts?
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138456016
comment on: http://stackoverflow.com/q/78535384
type: QuestionComment
score: 0
has text: I don't have Mac but 3.2.57 built on Ubuntu 22.04 from original GNU source behaves as apparently desired, not as shown above
type: Comment

http://stackoverflow.com/a/78489844
type: AcceptedAnswer
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/78488507
type: Answer
upvote count: 2
has body: If your uniq supports -D and -w options: find . -type f -exec md5sum {} + | sed 's/^\\\(.*\)/\1\\/' | sort -k1,1 | uniq -w32 -D | sed 's/\(.*\)\\$/\\\1/' The sed commands are to rectify the md5sum lines that begin with a backslash character. In some versions of md5sum, lines begin with a backslash if the filename contains a newline or backslash character (and those characters are escaped with backslashes in the filenames; \n and \\). The -w 32 option of uniq is to compare only 32 characters at the beginning of the lines, and the -D option prints all duplicated lines (in the first 32 characters). These options are GNU extensions.
answers question: http://stackoverflow.com/q/78488507

http://stackoverflow.com/q/78538302
tagged with: bash
downvote count: 2
has title: Problem while implementing a function in a conditional bash command using background operator (&)
has comment: http://stackoverflow.com/comment/138463880
tagged with: unix
upvote count: 1
score: -1
has body: I'm working on a Bash script where I need to show a spinner animation function while checking if a specified Git remote exists. The script snippet for checking the Git remote is as follows: read remote_to_pull_from if ! git remote show $remote_to_pull_from &>/dev/null; then echo "Remote '$remote_to_pull_from' does not exist, exiting..." return 1 fi This snippet works correctly and checks if the remote exists. Now, I want to add a spinner function to show an animation while the git remote show command is running. The spinner function, credited to this post, is as follows: spinner() { local PROC="$1" local str="${2:-'Running...'}" local delay="0.1" tput civis # hide cursor printf "\033[1;34m" while [ -d /proc/$PROC ]; do printf '\033[s\033[u[ / ] %s\033[u' "$str"; sleep "$delay" printf '\033[s\033[u[ — ] %s\033[u' "$str"; sleep "$delay" printf '\033[s\033[u[ \ ] %s\033[u' "$str"; sleep "$delay" printf '\033[s\033[u[ | ] %s\033[u' "$str"; sleep "$delay" done tput cnorm # restore cursor return 0 } I attempted to integrate the spinner with my conditional check using the approach mentioned in the Stack Overflow post, where the spinner animation is run in the background using a background operator (&). Here is the code I used to get it running while my condition is being checked: read remote_to_pull_from if ! git remote show $remote_to_pull_from &>/dev/null & spinner $!; then echo "Remote '$remote_to_pull_from' does not exist, exiting..." return 1 fi The spinner spins, but the condition fails, and the script echoes the error message, while without the spinner, the condition works correctly. I'm expecting the spinner function to run while the git remote show command is executing, and if the remote doesn't exist, the script should echo the error message and exit. How can I correctly use this spinner function with my conditional check, I think I'm missing a logical step here and breaking the condition when mixing it with that function? How can I handle this? Additionally, can…
tagged with: function
type: Question
linked to: http://stackoverflow.com/q/47234947
has comment: http://stackoverflow.com/comment/138464684
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78538431
answer count: 1
favorite count: 0
tagged with: conditional-statements
tagged with: if-statement
has comment: http://stackoverflow.com/comment/138464991

http://stackoverflow.com/comment/138483536
type: QuestionComment
type: Comment
has text: Redirections also aren't processed in the expansion of a variable. You need to use `eval "$v_command"`
comment on: http://stackoverflow.com/q/78551562
score: 0

http://stackoverflow.com/comment/138384569
has text: Another (possibly extremely inconvenient) method for testing is to add `-i` to the invocation of `mv`.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78494827

http://stackoverflow.com/comment/138401899
type: Comment
has text: Hi @Ed Morton, what's this line ```$line =~ $regexp && file="${BASH_REMATCH[1]}"```
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78494827

http://stackoverflow.com/comment/138397229
type: Comment
score: 0
comment on: http://stackoverflow.com/q/78502959
has text: What you are describing is very much like how Nix operates. (*Everything* is stored under `/nix/store`, instead of `~/.local`, and symlinks and `PATH` manipulation are used to make things accessible.)
type: QuestionComment

http://stackoverflow.com/comment/138364753
score: 3
type: QuestionComment
comment on: http://stackoverflow.com/q/78484156
type: Comment
has text: If you look at your intermediate results, you'll see that after your first step, you have separate objects, and no longer an array as the top-level element. The sort then applies to each element separately. The answers you received make sure you actually have an array before sorting.

http://stackoverflow.com/q/78501061
score: 0
has comment: http://stackoverflow.com/comment/138396288
type: Question
accepted answer: http://stackoverflow.com/a/78501166
upvote count: 1
has body: I want to check the number of files inside a folder and I want the result to, for example, be multiplied by 4. I tried something like: cd path/to/my/folder && find . -maxdepth 1 -type f | wc -l | expr {} * 4 But it doesn't work. It works until: cd path/to/my/folder && find . -maxdepth 1 -type f | wc -l But when I add something like "expr {} * 4", I get an error... I also tried other alternatives to "expr" but no luck so far. BTW, I also want the result to be "pipeable" to another program, like ffmpeg, something like: cd path/to/my/folder && find . -maxdepth 1 -type f | wc -l | expr {} * 4 | ffmpeg -i {} out.mp4 The above is a silly example to simplify what I'm trying to do... For those curious, I'm using https://github.com/nihui/rife-ncnn-vulkan to quadruple the frames/framerate of a video, so I need to check the number of files (images) inside a folder, automatically multiply the number by 4 and put the result in the "-n" parameter of rife-ncnn-vulkan... So a more realistic command would be something like: ffmpeg -i "video.mkv" -r 12 -c:v libwebp -lossless 1 -y input_frames/frame_%06d.webp && cd input_frames && find . -maxdepth 1 -type f | wc -l | expr {} * 4 | rife-ncnn-vulkan -i input_frames -o output_frames -f %08d.webp -x -v -n {} (notice the "{}" at the very end, where I want to place the result of the math operation).
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/78501166
tagged with: bash
has answer: http://stackoverflow.com/a/78501116
has comment: http://stackoverflow.com/comment/138394497
type: AnsweredQuestion
downvote count: 1
possible better answer: http://stackoverflow.com/a/78501116
has title: How can I do a math operation to the result of "wc -l"?
has answer: http://stackoverflow.com/a/78501375

http://stackoverflow.com/comment/138520262
has text: The redirection provides a real, seekable handle. The pipe provides a FIFO that can only be read once, front-to-back with no ability to rewind, fast forward, check its size in constant time, or do any of the other nifty things one can do with a real file handle.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78572114
score: 5

http://stackoverflow.com/q/78572114
tagged with: linux
has answer: http://stackoverflow.com/a/78572634
has comment: http://stackoverflow.com/comment/138521038
has comment: http://stackoverflow.com/comment/138521263
has answer: http://stackoverflow.com/a/78574904
tagged with: bash
has comment: http://stackoverflow.com/comment/138520997
has body: I am working with the Orca quantum chemistry software on Linux. It doesn't accept input through stdin, but does accept input through a file. I want to generate these input files on-the-fly using a bash script and pipe them in, so I wrote a script called orca_stdin.sh: (note that fd0 is a symbolic link to /dev/fd0 since Orca tries to write output files in the same directory as the input files) #!/bin/bash set -e cd $(dirname $0) cd workdir orca fd0 rm fd0_* fd0.* And I tested it with: ./orca_stdin.sh &lt; test.inp ... where test.inp is a valid input file. However, oddly, when I run: cat test.inp | ./orca_stdin.sh The program hangs. This is a problem since I want to have another script generate the input file, so I can only use a pipe. This would be the wrong place to ask about Orca, of course, and there are plenty of workarounds to this issue, one of which I have adopted without problem. However, this issue raises a question: How are a redirect in and a cat to a pipe functionally any different for the recipient of the pipe?
has comment: http://stackoverflow.com/comment/138520283
has comment: http://stackoverflow.com/comment/138520347
has title: Bash pipe vs redirect?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78572595
has comment: http://stackoverflow.com/comment/138520355
has comment: http://stackoverflow.com/comment/138526624
has comment: http://stackoverflow.com/comment/138520262
has comment: http://stackoverflow.com/comment/138521140
answer count: 3
possible better answer: http://stackoverflow.com/a/78574904
accepted answer: http://stackoverflow.com/a/78572595
has comment: http://stackoverflow.com/comment/138526655
score: 0
has comment: http://stackoverflow.com/comment/138520352
type: Question

http://stackoverflow.com/comment/138546671
comment on: http://stackoverflow.com/q/78586078
type: Comment
type: QuestionComment
score: 0
has text: @RenaudPacalet Let in this case just `cc` be returned. Here I must probably to clarify use cases for this question. It is for `Kate` text editor to be able to open links like `Notepad++` or `Vim` editors do but in much more flexible way. Imagine there is a text file that have lines with URIs as described in examples for this question. User put cursor over some URI, press hotkey and this URI is extracted and opened by corresponding program (by web browser for http links and by file manager for directories). In Linux `xdg-open` is used for this.

http://stackoverflow.com/comment/138383463
type: QuestionComment
comment on: http://stackoverflow.com/q/78491259
has text: Have you tried with `--full-history` already?
type: Comment
score: 1

telnet
type: Tag
tag name: telnet
tags question: http://stackoverflow.com/q/78484949

http://stackoverflow.com/a/78477703
has body: -z checks for "emptiness" ${...} is parameter expansion ${VAR+x} evaluates this expression to x, if VAR is set and not empty. So if VAR is set and not empty, your expression evaluates to false (so this code runs : echo "VAR = ${VAR}."), otherwise it evaluates to true (so this code runs: echo "Variable VAR is unset.") It's one way to check if VAR is set and not empty.
score: 2
answers question: http://stackoverflow.com/q/78477621
type: Answer
has comment: http://stackoverflow.com/comment/138353203
upvote count: 2
downvote count: 0

http://stackoverflow.com/a/78516302
downvote count: 0
has body: Forget aliases. They are remnants from the past (to allow unmaintained old stuffs to still work); when shells did not have functions. Aliases are full of quoting and escaping traps. Always prefer functions. Functions declarations can be put in ~/.bashrc or whatever interactive shell session initialization and replace all those clunky aliases. This is all you need instead of an alias : totalcpu(){ ps -Ao pcpu|awk '{s+=$1}END{print s}';}
type: Answer
has comment: http://stackoverflow.com/comment/138421292
answers question: http://stackoverflow.com/q/78515934
score: 4
upvote count: 4

http://stackoverflow.com/q/78478726
tagged with: bash
accepted answer: http://stackoverflow.com/a/78478727
has body: EDIT: The point of this question is to make it possible to Google this. While the flagged duplicate question has the same answer, it's in some sense not the same question, because that question is specifically about using env. In bash, why does A=1 echo $A produce a blank line instead of 1 as expected?
answer count: 1
favorite count: 0
duplicate of: http://stackoverflow.com/q/13998075
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/138354950
has title: Why can't I set a variable and then echo it right away in bash
has comment: http://stackoverflow.com/comment/138385028
type: Question
downvote count: 3
has answer: http://stackoverflow.com/a/78478727
tagged with: variable-expansion
linked to: http://stackoverflow.com/q/13998075
score: -3
upvote count: 0

http://stackoverflow.com/comment/138499869
has text: If a user requests a help message, it seems reasonable that it is not an error if one is provided, so `exit 1` is not appropriate. If the user makes an error, it is appropriate to give a succinct error message and not appropriate to give a full usage statement. Only give a usage message in response to a request, and `exit 0`.
score: 2
comment on: http://stackoverflow.com/q/78559360
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/138355137
type: QuestionComment
comment on: http://stackoverflow.com/q/78478782
score: 0
type: Comment
has text: Use `xargs my_script.py --username <username> --password` so `xargs` will read from STDIN and pass the value as argument.

http://stackoverflow.com/a/78491054
type: AcceptedAnswer
upvote count: 3
has body: Don't try to figure out quoting by hand when it can be at all avoided: instead, let tools do the work for you. For example, let's say you have a working shell command: ssh 1.2.3.4 'cd .. && bash -l' If you want to create a shell string containing that command, first put it in an array, then ask the shell to quote it: cmdArr=( ssh 1.2.3.4 'cd .. && bash -l' ) cmdStr="${cmdArr[*]@Q}" In bash 5.x or later, this will store something like 'ssh' '1.2.3.4' 'cd .. && bash -l' in your string. The next step would typically be to figure out how to escape the contents of cmdStr to be safely substituted into osascript source code without risk of injection vulnerabilities -- but we can sidestep this entirely by passing cmdStr out-of-band from the osascript source code, on the command line argument vector (argv). osascript source that looks on the argv for the text of a shell command to run might look like the following: osascript -- - "$cmdStr" <<'EOF' on run(argv) return tell application "Terminal" to do script item 1 of argv end EOF ...but we want a string containing a shell command that runs that osascript code (with the shell string created by our previous escaping operation passed to it), right? Well, one way to assemble one might be: # generate a shell string containing the command we want to run cmdArr=( ssh 1.2.3.4 'cd .. && bash -l' ) cmdStr="${cmdArr[*]@Q}" # text of osascript code that runs its first argument in terminal osascript=$(cat <<'EOF' on run(argv) tell application "Terminal" to do script item 1 of argv end EOF ) # one array per simple command; pass script on stdin to osascript # ...and command on argv of osascript interpreter write_script_arr=( printf '%s\n' "$osascript" ) run_script_arr=( osascript -- - "$cmdStr" ) # finally, assemble those pieces together full_cmd_str="${write_script_arr[*]@Q} | ${run_script_arr[*]@Q}" Okay! Now we just need to make that into JSON. Fortunately, that's something jq will do for you automatically: jq -R '{"shell_cmd": .}' <<<"…
answers question: http://stackoverflow.com/q/78490743
score: 3
type: Answer
has comment: http://stackoverflow.com/comment/138376998
accepted answer of: http://stackoverflow.com/q/78490743
downvote count: 0

http://stackoverflow.com/comment/138541655
type: Comment
comment on: http://stackoverflow.com/q/78583045
score: 1
has text: Add the expected output (commands)
type: QuestionComment

http://stackoverflow.com/q/78573688
answer count: 1
accepted answer: http://stackoverflow.com/a/78574374
tagged with: sh
score: 0
type: Question
tagged with: shell
tagged with: tee
has title: multiple call of exec > >(tee -a "${logFile}") 2>&1 with different log files
has body: Look like if I call exec > >(tee -a "${logFile}") 2>&1 multiple times in the same script with different log files, the first log files will get appended multiple times. Is there a way to reset exec call before calling exec > >(tee -a "${logFile}") 2>&1 ? $ cat sample.bash #!/bin/bash -e function redirectOutputToLogFile() { local -r logFile="${1}" mkdir -p "$(dirname "${logFile}")" exec > >(tee -a "${logFile}") 2>&1 } function main() { redirectOutputToLogFile 'test1.log' echo 'hello 1' redirectOutputToLogFile 'test2.log' echo 'hello 2' redirectOutputToLogFile 'test3.log' echo 'hello 3' } main "${@}" $ ./sample.bash hello 1 hello 2 hello 3 $ cat test1.log hello 1 hello 2 hello 3 $ cat test2.log hello 2 hello 3 $ cat test3.log hello 3
tagged with: bash
has answer: http://stackoverflow.com/a/78574374
type: AnsweredQuestion
tagged with: exec

http://stackoverflow.com/a/78505020
has comment: http://stackoverflow.com/comment/138401518
upvote count: 1
has body: Here is a simple Awk script to collect all the search phrases into an array, and limit how many matches for each array element you print. zcat /projects/incoming/SRR80527_2.gz | awk -v limit=3 'NR==FNR { w[++n] = $0; h[n] = 0; next } { p=1 for(i=1; i<=n; ++i) { if((h[i] < limit) && ($0 ~ w[i])) { h[i]++; if (p) print; p=0 } } }' /projects/test.indx - Demo (with a lower limit, just to make it easier to grasp): https://ideone.com/TcxPYT In very brief, the array w contains the search phrases, and the parallel array h contains the number of hits we have printed for each. In other words, h[42] indicates how many hits we have printed for w[42]. The NR==FNR and other basic Awk idioms should be familiar; if not, spending an hour on learning basic Awk will be time well spent. The variable p keeps track of whether the current line should be printed, so that we only print once, even if the line matches multiple patterns in w. In case it isn't obvious, this looks for partial matches anywhere in a line. In other words, if your search phrases include "sick" then it will find matches in "sickle" or "sickly" or "physicking". Another thing to note is that it will print a line if it matches at least one pattern for which the limit has not been reached yet. If a line matches multiple patterns, it will increase the count for each of them.
answers question: http://stackoverflow.com/q/78504692
type: Answer
has comment: http://stackoverflow.com/comment/138401389
has comment: http://stackoverflow.com/comment/138401376
has comment: http://stackoverflow.com/comment/138401385
downvote count: 0
score: 1

http://stackoverflow.com/comment/138519060
comment on: http://stackoverflow.com/q/78561775
type: QuestionComment
score: 0
type: Comment
has text: @Saboteur, ...and as for `[[`, the documentation you linked makes no assertions that it supports `-o`. See the syntax error shown in https://ideone.com/YcB23I demonstrating that, in fact/practice, it does not.

http://stackoverflow.com/comment/138354931
comment on: http://stackoverflow.com/a/78478727
has text: or `A=1 bash -c 'echo $A'`
score: 1
type: Comment
type: AnswerComment

http://stackoverflow.com/a/78489605
type: Answer
score: 0
answers question: http://stackoverflow.com/q/78488507
has body: I don't see the use of that +-sign at the end of your find. I tried this on my computer and it worked: find . -type f -exec md5sum {} \; | sort -k1,1 | uniq -d Good luck
downvote count: 1
has comment: http://stackoverflow.com/comment/138374648
has comment: http://stackoverflow.com/comment/138374682
has comment: http://stackoverflow.com/comment/138374669
upvote count: 1

http://stackoverflow.com/comment/138372862
type: QuestionComment
type: Comment
has text: @KamilCuk Sorry, I didn't research it outside of SO. The method in your first link is the same as what I came up here, but there's that backslash that appears at the start of the md5 of some files; I need to handle it somehow. BTW, external utilities are a no-go as I won't be cross-compiling them for the NAS.
score: 0
comment on: http://stackoverflow.com/q/78488507

http://stackoverflow.com/comment/138357999
score: 0
type: Comment
type: AnswerComment
has text: @CharlesDuffy As t[he page you linked](https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html) states, "*Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files.*" It's literally the same mechanism.
comment on: http://stackoverflow.com/a/78475452

http://stackoverflow.com/q/78513595
type: Question
has comment: http://stackoverflow.com/comment/138415740
has comment: http://stackoverflow.com/comment/138433576
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/78524124
upvote count: 3
has comment: http://stackoverflow.com/comment/138415601
score: 2
has answer: http://stackoverflow.com/a/78514018
tagged with: bash
tagged with: git
favorite count: 0
downvote count: 1
tagged with: awk
has comment: http://stackoverflow.com/comment/138416068
answer count: 2
has title: how to capture filename along with space in bash when operating with git diff
has body: Team, my use case is we don't want any user to push a file that has leading/trailing space in it. as it blocks windows local users I have this code but seems like files_in_change=$(git diff HEAD~1 --name-only) itself is stripping off the space which I don't want to happen. is there a way I can capture the filename as it is with space? when i am running the below script, I am never getting a failure though there exists a file in change that has space before/after. #!/bin/sh # For windows local users, check if each file in change has leading and trailing whitespace # Fetch all affected files in change files_in_change=$(git diff HEAD~1 --name-only) # Trim leading and trailing whitespace trimmed_filename="${filename#"${filename%%[![:space:]]*}"}" trimmed_filename="${trimmed_filename%"${trimmed_filename##*[![:space:]]}"}" # Check if the original filename is different from the trimmed filename if [ "$filename" != "$trimmed_filename" ]; then echo "Filename '$filename' has leading and/or trailing whitespace." # Block the change from merge as it blocks windows users local tests. exitcode=1 else exitcode=0 fi exit $exitcode

http://stackoverflow.com/comment/138485198
comment on: http://stackoverflow.com/q/78551987
has text: script in cronjob may run as different user, in different folder with different privileges - it may need to write some message in log file to see which code is executed and which has problem. I'm not sure if `cronjob` has access to display. it may need to run with option `--headless` or with `Xvfb`. Python has even module for `Xvfb` to run it from script.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/138325350
type: QuestionComment
comment on: http://stackoverflow.com/q/78461484
type: Comment
score: 1
has text: (and make a habit of running your code through http://shellcheck.net/ -- nothing it'll find that's obviously performance-centric, but plenty of little correctness optimizations available).

http://stackoverflow.com/comment/138313435
comment on: http://stackoverflow.com/q/78454731
has text: I don't know `virt-xml`, and its docs are a bit opaque to me. However, I note that because the shell does quote processing, and nothing in `a=b` is special to the shell when that appears after the command name, the quotes in the command are insignificant. The given command is equivalent to `cat ./xml | virt-xml --edit --xml ./tag1/tag2=a=b > output.xml`.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/q/78560562
duplicate of: http://stackoverflow.com/q/4321456
tagged with: fastq
score: 1
upvote count: 1
has title: BASH Find Exec Custom Function
answer count: 1
linked to: http://stackoverflow.com/q/4321456
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78560669
downvote count: 0
tagged with: bash
type: Question
accepted answer: http://stackoverflow.com/a/78560669
has body: I defined the following BASH function to count the number of reads in fastq: fastq_countGzReads() { zcat "$1" | echo $((`wc -l`/4)) ; } Now I want to apply this function to a number of gz files found with find. find . -iname "*gz" -exec sh fastq_countGzReads {} \; Error: sh cannot open fastq_countGzReads How to apply a BASH function on a selection of gz files in a directory ?

http://stackoverflow.com/comment/138518175
score: 0
comment on: http://stackoverflow.com/q/78570866
type: Comment
has text: I see. Well, catch the exception and log it.
type: QuestionComment

http://stackoverflow.com/comment/138364914
comment on: http://stackoverflow.com/a/78484245
score: 0
type: Comment
type: AnswerComment
has text: Thanks, I think map is the way. Sorry I have to accept the other one, as I want a CSV file with both `field1` and `field2` separated by `,`; but thanks anyway

http://stackoverflow.com/q/78507226
has comment: http://stackoverflow.com/comment/138410685
duplicate of: http://stackoverflow.com/q/66480618
has comment: http://stackoverflow.com/comment/138404347
has comment: http://stackoverflow.com/comment/138404430
has comment: http://stackoverflow.com/comment/138404438
has comment: http://stackoverflow.com/comment/138404370
score: 0
has title: Bash MySQL Looping through results
has body: I'm trying to read MySQL results via a loop. I have this working but I have a small issue. The code I'm using is while IFS=$'\t' read fieldA fieldB fieldC fieldD; do echo "$fieldA $fieldB $fieldC $fieldD" done < <(mysql -N -u $mysql --password=$pass database -h $host -e "SELECT BLAB BLABBLAB BLABBLAB BLAB") If one of the fields is empty then the variable is populated with the value from the next field. eg: if fieldC is empty echo $feildC will show the results from fieldD if fieldB and fieldC are empty echo $feildB will show the results from fieldD How do I account for the empty fields ? I was hoping the variable would return null or blank. Thanks UPDATE This is working using : while IFS=$'|' read fieldA fieldB fieldC fieldD; do echo "$fieldA $fieldB $fieldC $fieldD" done < <(mysql -N -u $mysql --password=$pass database -h $host -e "SELECT BLAB BLABBLAB BLABBLAB BLAB" | tr '\t' '|' )
type: Question
tagged with: mysql
has comment: http://stackoverflow.com/comment/138404465
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/138404752
answer count: 0
tagged with: ifs
tagged with: bash
linked to: http://stackoverflow.com/q/66480618

http://stackoverflow.com/q/78569226
answer count: 1
has title: connect_to localhost error while testing remote SSH connection with netcat from bash script
has body: I'm writing a bash script that needs to maintain a SSH connection (SSH tunnel) to a remote host alive. I am checking whether connection on the remote IP exists with netcat -z, and if it doesn't, then I start it, and the loop goes on. This is my script: #!/bin/bash RIP="A.B.C.D" RPORT=8000 CHK_CONN="nc -z $RIP $RPORT" while true do $CHK_CONN alive=$? if [ $alive -ne 0 ]; then echo "No SSH tunnel to $RIP:$RPORT. Starting..." ssh -N -R $RIP:$RPORT:127.0.0.1:8000 <usr>@$RIP -i '/path/to/key' -o 'BatchMode yes' -o 'ServerAliveInterval 120' -T & else echo "SSH tunnel to $RIP:$RPORT is up." fi sleep 60 #sleep 1 minute done echo "exiting." exit 0 The issue that I am facing is the output that I am getting from the script, and that is this: connect_to 127.0.0.1 port 8000: failed. At the same time I get the message that the SSH tunnel is up. I wonder why is this, and does it mean that my script is not working as intended? Am I doing something wrong? This is running on Debian (Raspbian). My second question is how can I test whether the tunnel is working as expected? I understand that the connection can be in different states, and it seems to me that connection can be established, but tunnel not open(sort of connection hangs)? Does nc -z test the connection through the tunnel itself, and can it do that? Thanks!
has comment: http://stackoverflow.com/comment/138522819
tagged with: ssh
tagged with: bash
linked to: http://stackoverflow.com/q/673055
type: Question
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/21612980
has answer: http://stackoverflow.com/a/78569893
score: 0
tagged with: ssh-tunnel
has comment: http://stackoverflow.com/comment/138516417
tagged with: netcat

http://stackoverflow.com/comment/138520352
type: QuestionComment
type: Comment
score: 0
has text: @somebody0 - Building off my last comment, since pipes and files are treated differently, I think you could still workaround your issue by writing the configuration to a temporary file and reading it within a one-liner. `write_configuration.sh > test.inp && ./orca_stdin.sh < test.inp`
comment on: http://stackoverflow.com/q/78572114

http://stackoverflow.com/comment/138521220
has text: Thank you for the answer, after executing that code I got the environment variables and added them to the question as you suggested.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/78571308
score: 0

http://stackoverflow.com/comment/138513017
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/78568050
has text: `dynamicOptionsJson='{"bigqueryTable": "table", "dummyOption": "hehexd"}'` and `dynamicOptionsJson="{\"bigqueryTable\": \"table\", \"dummyOption\": \"hehexd\"}"` store **exactly** the same value in the `dynamicOptionsJson` variable. Which is to say -- using single quotes is indeed correct and appropriate, but the syntax the question shows for that particular assignment is equally correct to the one in this answer.

http://stackoverflow.com/q/78469768
has comment: http://stackoverflow.com/comment/138339311
score: 0
has comment: http://stackoverflow.com/comment/138339507
answer count: 0
tagged with: openssl
tagged with: bash
upvote count: 1
favorite count: 0
downvote count: 1
has comment: http://stackoverflow.com/comment/138427356
has comment: http://stackoverflow.com/comment/138339455
has comment: http://stackoverflow.com/comment/138339178
has comment: http://stackoverflow.com/comment/138349212
tagged with: sshpass
has body: This line of code works in Linux, but doesn't in OSX. What am I missing? pwd=$(echo "$password_file" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass "pass:$salt_password") On Linux, it outputs the decrypted text. On OSX, it just gives openssl usage info, but no error, and no decrypted text. OpenSSl versions: On OSX: LibreSSL 2.6.5, on Linux: OpenSSL 3.0.11. Here's the code in full context: #!/bin/bash SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # password_file="$SCRIPT_DIR/test_passfile_2.ssl" password_file="U2FsdGVkX18RH4KXM5Ldz0Q2ny8RQegoaDPObu50Y6k=" salt_password="salt password" # Decrypt password file or encrypted passwrod string if provided if [ -n "$password_file" ]; then if [ -f "$password_file" ]; then echo "Decrypting password file using salt password..." pwd=$(cat "$password_file" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass "pass:$salt_password") else echo "Decrypting password string using salt password..." pwd=$(echo "$password_file" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass "pass:$salt_password") fi esc() { printf "%s" "$1" | sed -e "s/'//g" } # utilize the function so that we don't need to quote pwd. password=$(esc "${pwd}") unset pwd if [ $? -ne 0 ]; then echo "Error: Failed to decrypt password." exit 1 fi echo "Password decrypted successfully." fi echo $password # Should output 'test' Here's the OSX terminal output: usage: enc -ciphername [-AadePp] [-base64] [-bufsize number] [-debug] [-in file] [-iv IV] [-K key] [-k password] [-kfile file] [-md digest] [-none] [-nopad] [-nosalt] [-out file] [-pass arg] [-S salt] [-salt] -A Process base64 data on one line (requires -a) -a Perform base64 encoding/decoding (alias -base64) -bufsize size Specify the buffer size to use for I/O -d Decrypt the input data -debug Print debugging information -e Encrypt the input data (default) -in file Input file to read from (default stdin) -iv I…
type: Question
tagged with: macos
has title: Openssl command works in Linux but not OSX?
type: UnansweredQuestion

character
type: Tag
tags question: http://stackoverflow.com/q/78526961
tag name: character
tags question: http://stackoverflow.com/q/79315347

http://stackoverflow.com/comment/138538996
comment on: http://stackoverflow.com/a/78576845
type: Comment
type: AnswerComment
score: 0
has text: More seriously, there are some bugs in this code due to lack of quoting -- filenames with spaces will misbehave because of the unquoted expansions. Use `"$FILE"` or `"${FILE}"`, not `$FILE` or `${FILE}`; `cd "$fp"` instead of `cd $fp`, etc. (And consider sticking with lower-case names for your own variables -- that prevents you from overwriting a name with special meaning by mistake; it's more than one person who's run `for PATH in` and then been surprised because `ls` or `awk` is no longer in a location listed in their PATH).

http://stackoverflow.com/a/78518396
answers question: http://stackoverflow.com/q/78518299
has comment: http://stackoverflow.com/comment/138425083
has body: You can try this #cli command oasdiff breaking &lt;api1&gt; &lt;api2&gt; --err-ignore ignore.md The ignore file must be relative to where you run the command unless you add the proper path # ignore.md PUT /foo/bar this api is deprecated
score: 0
has comment: http://stackoverflow.com/comment/138424027
type: Answer

http://stackoverflow.com/comment/138450360
type: Comment
has text: Regarding "this command would also..." and "Finally, it would be useful if..." - please just ask 1 question per question to make each question standalone and easy for someone with a similar question to find an answer to that question in future. If you have additional questions after getting an answer to your first question then ask them in separate followup questions.
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/78533122

wget
tags question: http://stackoverflow.com/q/78451035
tags question: http://stackoverflow.com/q/78590066
tag name: wget
type: Tag
tags question: http://stackoverflow.com/q/78627719
tags question: http://stackoverflow.com/q/79544368

http://stackoverflow.com/comment/138365571
comment on: http://stackoverflow.com/q/78480780
type: QuestionComment
type: Comment
score: 0
has text: @EdMorton, what I'm doing is implementing the decorator pattern. When I posted this question, I had wanted to use Gherkin syntax but once I started down that path, I realized it would really mess up syntax highlighting and formatting (so I've stuck with using guillemets instead of braces).

http://stackoverflow.com/comment/138499376
comment on: http://stackoverflow.com/a/78559697
type: Comment
type: AnswerComment
has text: That's exactly backward, @user1934428. POSIX-conforming `getopts` absolutely does work with option clustering. Indeed, the problem was that `getopts` was interpreting the OP's attempt at long options as option clusters. On the other hand, `getopts` does not necessarily work with GNU-style long options, which are not addressed by POSIX. Perhaps you are mixing that up with GNU's similarly-named command `getopt`, but (when used correctly) that understands *both* clustering and (GNU-style) long options. I don't know any standard command that handles the OP's original long option style.
score: 3

http://stackoverflow.com/comment/138411780
score: 1
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/78506003
has text: Another [similar one](https://stackoverflow.com/questions/78281758/jpackaged-app-start-msi-installer-and-then-system-exit#comment138008809_78281758)

http://stackoverflow.com/comment/138326994
type: QuestionComment
comment on: http://stackoverflow.com/q/78458050
type: Comment
has text: In `jq ... | sponge > foo.json` the shell starts `jq` and `sponge` simultaneously. If it didn't then `sponge` wouldn't be running while `jq` is producing output. So, are you asking how to stop `sponge` when `jq` stops (I'd expect that to happen by default) or how to make `sponge` wait until `jq` has stopped (you don't know if `jq` will fail or not before it completes running) before `sponge` starts to write to `foo.json` (if so, don't use a pipe) or something else?
score: 0

http://stackoverflow.com/comment/138377767
type: QuestionComment
has text: Try this printf "%s\n" "{date: " >> file then dt=$(date -d @$(cat "${DrawC}" | jq '17158644file00')) | echo >> file then echo "}" >> then dt=$(date -d @$(cat "${file}" | jq '.[].date | .' echo "$dt"
type: Comment
comment on: http://stackoverflow.com/q/78491313
score: 0

http://stackoverflow.com/q/78535188
tagged with: bash
type: Question
linked to: http://stackoverflow.com/q/67979342
has title: Docker on Windows: OCI runtime create failed: unable to start container process: "bash": no such file or directory
has body: I'm trying to run a Docker container on my Windows machine to execute some reformatting commands using poetry, isort, and black. Here is the relevant part of my Makefile: .PHONY: reformat reformat: docker run --rm \ --name container-name \ -v $(shell pwd)/src:/opt/datahub-consumer/src \ -v $(shell pwd)/tests:/opt/datahub-consumer/tests \ $(CONTAINER_NAME) /bin/bash -c "poetry run isort . && poetry run black . --exclude venv" However, when I run the make reformat command, I get the following error: docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "C:/Program Files/Git/usr/bin/bash": stat C:/Program Files/Git/usr/bin/bash: no such file or directory: unknown. It looks like Docker is trying to use a Windows path for bash, but this should be executed inside the Linux container. How can I modify my setup to ensure that the command is run correctly inside the container? What I Have Tried: Verified that bash is accessible from Git Bash by running which bash, which outputs: /usr/bin/bash Tested using sh instead of bash in the Docker command, but it still results in errors. Checked Docker Desktop settings to ensure WSL integration is enabled.
tagged with: sh
tagged with: docker
score: 0
answer count: 0
type: UnansweredQuestion
tagged with: git-bash
tagged with: windows-subsystem-for-linux
duplicate of: http://stackoverflow.com/q/67979342

http://stackoverflow.com/comment/138319571
score: 1
has text: Clear demo, much appreciated! Using the defaullt directory (`$(Agent.TempDirectory)`) to which secure files are downloaded solves the issue for me, as I am no longer dependent on getting the secure file path through `.secureFilePath`.
comment on: http://stackoverflow.com/a/78449576
type: Comment
type: AnswerComment

http://stackoverflow.com/q/78570018
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/79512024
has answer: http://stackoverflow.com/a/78570143
tagged with: pyinstaller
has answer: http://stackoverflow.com/a/78570291
type: Question
answer count: 4
upvote count: 9
possible better answer: http://stackoverflow.com/a/78570291
has body: I am having multiple problems with making my pythonscript dartsapp.py executable for my pi. At first i tried to use chmod +x dartsapp.py and ./dartsapp.py but i got the error: -bash: ./dartsapp.py: cannot execute: required file not found I also added the dir to PATH but still no luck. Afterwards i tried to use pyinstaller but when i try to call pyinstaller --version i get the same -bash: pyinstaller: command not found even though my PATH looks like this: maxdu@LEDpi:~/0306 $ echo $PATH /home/maxdu/0306:/home/maxdu/0306/dartsapp.py:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games What am i missing / doing wrong here? Update: ls -l /usr/bin/python3 gives me lrwxrwxrwx 1 root root 10 Apr 9 2023 /usr/bin/python3 -&gt; python3.11 and head -n 3 dartsapp.py | cat -e gives me #!/usr/bin/python3^M$ ^M$ # Python-App fM-CM-&lt;r das PunktezM-CM-$hlen beim Darts^M$ and type python3 gives me python3 is hashed (/usr/bin/python3)
favorite count: 0
tagged with: python
has answer: http://stackoverflow.com/a/79293898
score: 9
has title: -bash: cannot execute: required file not found
accepted answer: http://stackoverflow.com/a/78570143
downvote count: 0
tagged with: bash
linked to: http://stackoverflow.com/q/45772525

http://stackoverflow.com/comment/138327267
type: Comment
comment on: http://stackoverflow.com/q/78462933
has text: The `perl` command just seems to be removing duplicates. Didn't you already do that with `sort -u`?
score: 0
type: QuestionComment

http://stackoverflow.com/a/78583213
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/138550579
upvote count: 3
has comment: http://stackoverflow.com/comment/138547641
downvote count: 0
answers question: http://stackoverflow.com/q/78583045
has comment: http://stackoverflow.com/comment/138544418
has body: I think I ended up finding a solution... It is not pretty because it uses eval, which can be a source of problems on itself The solution lies on opening a new array with the correct commands on each line first: configs=() for i in "${!first_column[@]}"; do echo "${first_column[i]}" echo "${second_column[i]}" echo "${command[i]}" configs+=( $(echo "execute_program_name --first "${first_column[i]}" --second "${second_column[i]}" "${command[i]}"") ) done Then run: for i in "${configs[@]}"; do eval $i done I'm not sure if one line of your input does not run properly, if the next will. But it has worked on my example

http://stackoverflow.com/comment/138511330
score: 0
type: Comment
comment on: http://stackoverflow.com/q/78566886
has text: We don't know what's in your D5 file so we can't test this ourselves.
type: QuestionComment

http://stackoverflow.com/a/78527839
type: Answer
score: 2
answers question: http://stackoverflow.com/q/78522211
upvote count: 2
downvote count: 0
has body: You could use bash variable substitution as well: arch=$(uname -m) echo ${arch/aarch64/arm64}

http://stackoverflow.com/comment/138466934
type: QuestionComment
has text: The minimal fix is `#!` instead of `!#` and `if [ "$status" = "true" ]` though as suggested in a previous comment, `if pgrep -f minecraft` is much better. Tangentially see also [Why is testing `$?` to see if a command succeeded or not, an anti-pattern?](https://stackoverflow.com/questions/36313216/why-is-testing-to-see-if-a-command-succeeded-or-not-an-anti-pattern)
type: Comment
comment on: http://stackoverflow.com/q/78541941
score: 1

http://stackoverflow.com/a/78464908
has comment: http://stackoverflow.com/comment/138330597
score: -1
answers question: http://stackoverflow.com/q/78464749
upvote count: 0
has comment: http://stackoverflow.com/comment/138330450
downvote count: 1
type: Answer
has body: It depends on how you compile your program. If you use gcc, you probably get your binary file next to your source code. Instead of executing pwd, you should use getcwd function (as pointed out by @Some programmer dude). Don't forget to run your program in directory with source code. #include <stdlib.h> #include <string.h> #include <unistd.h> #include <linux/limits.h> #define YOUR_FILE "test.c" int main() { char cwd[PATH_MAX]; getcwd(cwd, sizeof(cwd)); char* destination; int chars = strlen(cwd) + strlen(YOUR_FILE); chars += 3; destination = malloc(sizeof(char)*chars); memcpy(destination, cwd, sizeof(char)*chars); strcat(destination, "/"); strcat(destination, YOUR_FILE); execl("/bin/cat", "/bin/cat", destination, NULL); free(destination); return 0; }

http://stackoverflow.com/a/78501116
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/138394458
has body: This works in bash and zsh: cd path/to/my/folder let count="$(find . -type f -maxdepth 1 | wc -l) * 4" rife-ncnn-vulkan ... -n $count The let command allows the shell to do arithmetic. Update Thank you to Charles Duffy for the suggestion. Here is a rewrite of the calculation: count="$(( $(find . -type f -maxdepth 1 | wc -l) * 4 ))"
has comment: http://stackoverflow.com/comment/138394044
downvote count: 0
has comment: http://stackoverflow.com/comment/138394386
type: Answer
has comment: http://stackoverflow.com/comment/138394468
answers question: http://stackoverflow.com/q/78501061
has comment: http://stackoverflow.com/comment/138394390
has comment: http://stackoverflow.com/comment/138394085

http://stackoverflow.com/a/78509705
has comment: http://stackoverflow.com/comment/138418318
upvote count: 2
has comment: http://stackoverflow.com/comment/138412865
has body: You should be capturing the $1 right away and then use the function call to send the input to the "$1" in the function. #!/bin/bash input="$1" myfunction() { local package_status=$(ssh secondnode "dpkg-query -W -f='${Status}' $input 2>/dev/null") if $package_status == "install ok installed" ; then echo "Installed." exit 0 fi } myfunction echo "Not found." exit 1 Use: ./script.sh entry
has comment: http://stackoverflow.com/comment/138418664
has comment: http://stackoverflow.com/comment/138410435
answers question: http://stackoverflow.com/q/78508971
score: 1
has comment: http://stackoverflow.com/comment/138409326
downvote count: 1
type: Answer

http://stackoverflow.com/comment/138414366
type: Comment
has text: `: && /usr/bin/g++ ... ` essentially means "do nothing, and if that succeeds (which it always will), then execute the g++ command".
comment on: http://stackoverflow.com/q/78513030
type: QuestionComment
score: 0

http://stackoverflow.com/comment/138325450
type: QuestionComment
type: Comment
score: 0
has text: `ls $dir` is going to pick up `latest.log` so you'll end up processing `latest.log` twice, yes? is that what you want?
comment on: http://stackoverflow.com/q/78461484

http://stackoverflow.com/comment/138461776
score: 0
comment on: http://stackoverflow.com/a/78539716
type: Comment
has text: @fozzybear Yep, that's correct
type: AnswerComment