Tag Info

Hot answers tagged

4

The best guess so far seems to be that you are asking: The command ret="$(ls "my dir")" is a pretty terrible example of a command that contains four double-quote (") marks.  One might naïvely expect that the second quote would match the first one, and the fourth would match the third, like this: ret="$(ls "my dir")" ↑-----↑ ...


3

tmux display-message -p -F "#{pane_current_path}" -t0


3

Put the mysql jobs in the background: #!/bin/bash num=$(wc -l < ip.txt) while read ip; do mysql --login-path=login -h $ip "database" < "query.sql" & num=$((num-1)) done < ip.txt wait echo "Script 1 Finished!!" The wait causes the script to wait until all background jobs have completed. This is a pretty simple-minded way of doing ...


2

Try make -p: it shows you all rules that make knows about, at the end of parsing (which means after running all functions including $(shell), $(wildcard) and $(patsubst)). Beware, it will be very long, because it includes all the prebuilt implicit rules too, so you'll probably want to do make -p | less and then search through it.


2

This function should looks like: callSINGULAR() { /opt/local/bin/Singular -b "$1" } Because the parameter is first, provided to function


2

You need to go directly into that directory: cat /home/me/mydir/* > /home/me/finalData.txt


1

You can use this: (find directory -type f | xargs -i cat {} ) > TOTAL Looks for all files in directory and puts all content in TOTAL.


1

#!/bin/bash DIRS="dir1 dir2 dir3" echo -n "Date (YYYYMMDD): " read YMD echo -n "Log name (unique number): " read UQM for D in $DIRS ; do LOG="/$D/usr/home/var/log/logfile-$YMD/$UQM.log" test -f "$LOG" && echo "Located file @ $LOG" done


1

This bash function will block until the given file appears or a given timeout is reached. The exit status will be 0 if the file exists; if it doesn't, the exit status will reflect how many seconds the function has waited. wait_file() { local file="$1"; shift local wait_seconds="${1:-10}"; shift # 10 seconds as default timeout until test ...


1

If you just want to replace <author type=''><\/author> with <author type='Local'><\/author>, you can use that sed command: sed "/<fiction type='a'>/,/<\/fiction>/ s/<author type=''><\/author>/<author type='Local'><\/author>/g;" file But, when you dealing with xml, I recommend an xml parser/editor ...


1

You might like the option to accept many formats and convert them to standard form; the date command can help: $ day=$(unset day; until date -d "${day:-XXX}" '+%Y%m%d' 2>/dev/null do read -p "Which day? " day done) Which day? Which day? weds Which day? friday $ echo $day 20150508


1

This method treats input as a string then parses and tests it for proper formatting. In this form, I have it also checking if the fields in the date are correct, but you can remove those conditionals if you don't need them. #!/bin/bash echo -n "Enter the date as YYYYMMDD >" read date if [ ${#date} -eq 8 ]; then year=${date:0:4} month=${date:4:2} ...



Only top voted, non community-wiki answers of a minimum length are eligible