How can I trim white space from a variable in awk?
You’re printing the result of the gsub, but gsub does an in-place modify of $2 instead of returning a modified copy. Call gsub, then print: awk -F\, ‘{gsub(/[ \t]+$/, “”, $2); print $2 “:”}’
You’re printing the result of the gsub, but gsub does an in-place modify of $2 instead of returning a modified copy. Call gsub, then print: awk -F\, ‘{gsub(/[ \t]+$/, “”, $2); print $2 “:”}’
You shouldn’t use ls like that and a for loop is not appropriate either. Also, the destination directory should be outside the source directory. mkdir /path/to/destination find . -type f -exec iconv -f iso-8859-1 -t utf-8 “{}” -o /path/to/destination/”{}” \; No need for a loop. The -type f option includes files and excludes directories. Edit: … Read more
shell-file-name is the variable that controls which shell Emacs uses when it wants to run a shell command. explicit-shell-file-name is the variable that controls which shell M-x shell starts up. Ken’s answer changes both of those, which you may or may not want. You can also have a function that starts a different shell by … Read more
Use the -O binary output format: objcopy -O binary –only-section=.text foobar.elf foobar.text Just verified with avr-objcopy and an AVR ELF image’s .text section. Note that if, as Tim points out below, your section doesn’t have the ALLOC flag, you may have to add –set-section-flags .text=alloc to be able to extract it.
For simple input, like two prompts and two corresponding fixed responses, you could also use a “here document”, the syntax of which looks like this: test.sh <<! y pasword ! The << prefixes a pattern, in this case ‘!’. Everything up to a line beginning with that pattern is interpreted as standard input. This approach … Read more
Another very handy way to do this is with gnu parallel, which is well worth installing if you don’t already have it; this is invaluable if the tasks don’t necessarily take the same amount of time. seq 1000 | parallel -j 8 –workdir $PWD ./myrun {} will launch ./myrun 1, ./myrun 2, etc, making sure … Read more
You can either use: “texta’textb” (APOSTROPHE inside QUOTATION MARKs) or ‘texta’\”textb’ (APOSTROPHE text APOSTROPHE, then REVERSE SOLIDUS, APOSTROPHE, then APOSTROPHE more text APOSTROPHE) I used unicode character names. REVERSE SOLIDUS is more commonly known as backslash. In the latter case, you close your apostrophe, then shell-quote your apostrophe with a backslash, then open another apostrophe … Read more
You will need to double-escape the $ character within the shell command: HEADER = $(shell for file in `find . -name *.h`;do echo $$file; done) The problem here is that make will try to expand $f as a variable, and since it doesn’t find anything, it simply replaces it with “”. That leaves your shell … Read more
This is what I use: var escapeShell = function(cmd) { return ‘”‘+cmd.replace(/([“‘$`\\])/g,’\\$1’)+'”‘; };
Git bash is already a batch file with content similar to this : C:\WINNT\system32\cmd.exe /c “”C:\Git\bin\sh.exe” –login -i” If you want run (and leave running) a shell script in the context of the shell, specify it at the command line. The trick is that when the script file name is interpreted, it uses the Windows … Read more