expansion

Bash substring expansion on array

会有一股神秘感。 提交于 2019-12-06 09:23:59
I have a set of files with a given suffix. For instance, I have a set of pdf files with suffix .pdf . I would like to obtain the names of the files without the suffix using substring expansion. For a single file I can use: file="test.pdf" echo ${file:0 -4} To do this operation for all files, I now tried: files=( $(ls *.pdf) ) ff=( "${files[@]:0: -4}" ) echo ${ff[@]} I now get an error saying that substring expression < 0 .. ( I would like to avoid using a for loop ) Use parameter expansions to remove the .pdf part like so: shopt -s nullglob files=( *.pdf ) echo "${files[@]%.pdf}" The shopt -s

jQuery Accordion expand all div

泪湿孤枕 提交于 2019-12-06 02:29:10
问题 Is it possible to expand all components when page is load or when an event occurs? Thanks!! 回答1: Simply use this $('#accordion .ui-accordion-content').show(); 回答2: No, if you are referring to accordion as your tag states. From jQuery. NOTE: If you want multiple sections open at once, don't use an accordion http://docs.jquery.com/UI/API/1.8/Accordion 回答3: I would recommend this plugin Multi-open Accordion // this will make the second tab by default opened (index starts from 0) $('

android play movie inside expansion file

*爱你&永不变心* 提交于 2019-12-05 21:13:27
问题 My app is trying to deliver lots of contents to users, so the app's size is much greater than 50mb. There is no way we could reduce or remove some of the content, so we decided to go with the expansion approach. I am trying to follow this tutorial: Android APK Expansion Files, and have been successful up to putting the expansion file into my device for testing. I could get the input stream of any video file inside the expansion. But when I try to setVideoUri for the videoView, it starts

Avoid expansion of * in bash builtin function let

扶醉桌前 提交于 2019-12-05 12:05:49
I have a problem with a bash script. I have to use the operator * to multiplicate. Instead the script bugs me with expansion and using as operator the name of the script itself. I tried with single quotes but it doesn't work :( Here's the code #!/bin/bash -x # Bash script that calculates an arithmetic expression # NO PRECEDENCE FOR OPERATORS # Operators: + - * if [ "$#" -lt "3" ] then echo "Usage: ./calcola.scr <num> <op> <num> ..." exit 1 fi result=0 op=+ j=0 for i in "$@" do if [ "$j" -eq "0" ] then # first try #result=$(( $result $op $i )) # second try let "result$op=$i" j=1 else op=$i j=0

Four Dollar signs in Makefile

感情迁移 提交于 2019-12-05 09:47:16
问题 I am reading the document of GNU Make. Here is an example %.d: %.c @set -e; rm -f $@; \ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ sed ’s,\($*\)\.o[ :]*,\1.o $@ : ,g’ < $@.$$$$ > $@; \ rm -f $@.$$$$ I tried this on a C++ program, and got the list of files init3d.d init3d.d.18449 input.d input.d.18444 main.d main.d.18439 Here is what I found but don't understand in the same document If you have enabled secondary expansion and you want a literal dollar sign in the prerequisites list, you must

Is there any difference between $@ and “$@”? [duplicate]

若如初见. 提交于 2019-12-05 04:58:50
This question already has answers here : Accessing bash command line args $@ vs $* (5 answers) Closed 3 years ago . Is there any difference between $@ and "$@" ? I understand there may be differences for non special characters, but what about the @ sign with input arguments? fedorqui Yes! $ cat a.sh echo "$@" echo $@ Let's run it: $ ./a.sh 2 "3 4" 5 2 3 4 5 # output for "$@" 2 3 4 5 # output for $@ -> spaces are lost! As you can see, using $@ makes the parameters to "lose" some content when used as a parameter. See -for example- I just assigned a variable, but echo $variable shows something

Why zsh tries to expand * and bash does not?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 17:48:04
问题 I just encountered the following error with zsh when trying to use logcat. Namely, when typing: adb logcat *:D I get the following error in zsh zsh: no matches found: *:D I have to escape the * like : adb logcat \*:D While using bash, I do not get the following error. Why would it be like this? 回答1: zsh warns you by default if you use a glob with no matches. Bash, on the other hand, passes the unexpanded glob to the app, which is a potential problem if you don't know for certain what will

jQuery Accordion expand all div

一世执手 提交于 2019-12-04 08:28:59
Is it possible to expand all components when page is load or when an event occurs? Thanks!! Simply use this $('#accordion .ui-accordion-content').show(); No, if you are referring to accordion as your tag states. From jQuery. NOTE: If you want multiple sections open at once, don't use an accordion http://docs.jquery.com/UI/API/1.8/Accordion I would recommend this plugin Multi-open Accordion // this will make the second tab by default opened (index starts from 0) $('#multiAccordion').multiAccordion({active: 1 }); // [ OR ] // supports multiple tabs to be opened by default $('#multiAccordion')

Algorithm for bit expansion/duplication?

社会主义新天地 提交于 2019-12-04 06:57:30
Is there an efficient (fast) algorithm that will perform bit expansion/duplication? For example, expand each bit in an 8bit value by 3 (creating a 24bit value): 1101 0101 => 11111100 01110001 11000111 The brute force method that has been proposed is to create a lookup table. In the future, the expansion value may need to be variable. That is, in the above example we are expanding by 3 but may need to expand by some other value(s). This would require multiple lookup tables that I'd like to avoid if possible. There is a chance to make it quicker than lookup table if arithmetic calculations are

How to prevent filename expansion in for loop in bash

人走茶凉 提交于 2019-12-04 03:46:25
问题 In a for loop like this, for i in `cat *.input`; do echo "$i" done if one of the input file contains entries like *a , it will, and give the filenames ending in 'a'. Is there a simple way of preventing this filename expansion? Because of use of multiple files, globbing ( set -o noglob ) is not a good option. I should also be able to filter the output of cat to escape special characters, but for i in `cat *.input | sed 's/*/\\*'` ... still causes *a to expand, while for i in `cat *.input | sed