The tag has no wiki summary.

learn more… | top users | synonyms

4
votes
2answers
61 views

Brace compression

I love brace expansion (e.g. rm file.{0..5}). I find it a lot easier to read than the expanded version. Is there a quick and easy way of doing the opposite? For example given the input ...
2
votes
1answer
34 views

Can I use variables inside {} expansion without `eval`?

Can I use variables inside {} expansion without appealing to eval? If so, how? This doesn't work: $ touch 1.foo 1.bar $ ls 1.{foo,bar} 1.bar 1.foo $ extensions=foo,bar $ ls 1.{$extensions} ls: ...
3
votes
3answers
67 views

'Binding' Bash Curly Braces

In Bash, echo a{b,c}d{e,f} prints abde abdf acde acdf The output I'd like to see is abde acdf In other words, given N parameters, I'd like Bash to use the ith parameter within ...
1
vote
3answers
230 views

Reversing the value key pairs of array using sed or pattern replacement or brace expansion?

#!/bin/bash arr=(a b c d) declare -A brr for i in ${!arr[@]} do brr[${arr[$i]}]=$i done echo ${brr[@]} #0 1 2 3 Is there any way to reverse the values and key pairs ...
1
vote
3answers
92 views

Why brace expansion not supported?

Do I have to do any configuration to start brace expansion? When I run mkdir {1..10}, it just creates a dir naming {1..10}.
7
votes
2answers
235 views

Possible to use brace (permutation) and array expansion simultaneously?

Bash's {} brace expansion syntax allows for creating easy permutations # echo {b,c,d}{a,e,i,o,u} ba be bi bo bu ca ce ci co cu da de di do du However it's not clear to me if/how it's possible to ...
1
vote
2answers
144 views

How to do multiple brace expansions without combinatorial explosion?

I often use brace expansion on the command line, because it's handy. Example {foo,bar} expands to: foo bar Multiple brace expansion also expand, e.g.: {foo,bar}Q{foo,bar} would expand to: ...
2
votes
1answer
86 views

cp : short way of copying

I don't remember exactly but there was either cp or mv command which I was able to do something like this with: cp file{.cpp, .cpp.org} Which would copy file.cpp and make a copy named file.cpp.org. ...
1
vote
2answers
54 views

Renaming a file to a shorter name easily using something like brace expansion

So I know about using braces when backing up a file to making this sweet and easy like so: cp -v original.xml{,.backup} But if I wanted to restore the original I would have to do this cp -v ...
3
votes
2answers
91 views

Bash expansion of ${@} as command

I have a parent script while read cmd do nohup ./script ${cmd[@]} &>> log & done < ~/list that executes this child script while true do eval "${CMD[@]}" #${CMD[@]} ...
1
vote
1answer
170 views

Quoting curly braces in the shell [duplicate]

I found examples of different quoting for curly braces for find, but I could not find an explanation. The possible choices are: 1. {} 2. '{}' 3. "{}" And they all seem to work fine. Is ...
3
votes
2answers
779 views

How could I make multiple symbolic links for multiple directories, conveniently

lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v122 -> /home/files/video122 lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v123 -> /home/files/video123 lrwxrwxrwx 1 deploy users 20 1월 23 ...
2
votes
4answers
3k views

How to create a sequence with leading zeroes using brace expansion

When I use the following, I get a result as expected: $ echo {8..10} 8 9 10 How can I use this brace expansion in an easy way, to get the following output? $ echo {8..10} 08 09 10 I now that ...
3
votes
1answer
627 views

mkdir multiple directories with a subdirectory name having space in it

I want to make multiple directories in one go. The problem is that one of the sub directories have a name with a space in it. The directory structure i want to make is as follows. project /level ...
2
votes
2answers
81 views

Expand less-than sign when using multios and brace expand

With zsh multios set (setopt multios) it's possible to do things like: < in1 < in2 > out and: < in > out1 > out2 which is very convenient. I want to combine this feature with ...
5
votes
2answers
208 views

Why arguments in braces do not expand in this case?

For example, I want to put some file names inside braces for expansion like this: $ ls blue_texture blue_waves green_light $ ls -m | tr -d ' \n' blue_texture,blue_waves,green_light $ echo ...
1
vote
2answers
490 views

Auto-expansion problem with array elements containing an '*' (asterisk)

I'm trying to write me a find script that should later be able to read a list of directories to be excluded from an external file. Whilst I can accomplish that part myself, it's the annoying array ...
2
votes
1answer
147 views

Change completion behaviour with brace expansion in zsh

I have got used to using tab-autocompleting inside braces without expanding in zsh. This was possible, while I used zsh with a basic grml-config. Since I migrated to oh-my-zsh, I can't reproduce this ...
3
votes
2answers
724 views

Short way to scp using the same dir/file in origin and target

I am frequently updating files from a development enviroment to a production one in different servers so the paths are the same in both hosts and it becomes kind of a repetitive procedure to update a ...
1
vote
3answers
395 views

Accessing bash [internal] brace expansion iteration number/variable

Question: Is it possible to access which number of a bash iteration is currently being processed? Psuedo-Command mv {1..5}.something.{1..5} $x1.$x2.something Note: This is a logical ...
7
votes
3answers
4k views

bash: Use a variable to store stderr|stdout redirection

Is there any way to redirect stdout and stderr via variable like adding command options in script? For example I have a script: #!/bin/bash -x TEST=">/dev/null 2>&1" OPT='-p -v' mkdir $OPT ...
1
vote
2answers
220 views

brace expansion other commands besides mkdir?

Found this nifty lifehacking gem to create multiple directories: http://unix.stackexchange.com/a/640/7768 I was wondering if there are other commands support brace expansion?
7
votes
2answers
1k views

Using curly brackets (braces) to create folder structure with `mkdir -p`

As man mkdir states -p, --parents no error if existing, make parent directories as needed When I ran this command mkdir -p work/{F1,F2,F3}/{temp1,temp2} It creates a folder ...
2
votes
1answer
129 views

How can I control bash's brace expansion to do the right thing (which zsh does automatically)?

In zsh, I get the expected result from both of these brace expansions: $ touch file-{001..100} $ touch file-{1..100} The first one gives me files named file-001, file-002, etc., all the way to ...
7
votes
2answers
384 views

How can I use $var in a shell brace expansion of a sequence?

I want to use $var in a shell brace expansion with a range, in bash. Simply putting {$var1..$var2} doesn't work, so I went "lateral"... The following works, but it's a bit kludgey. # remove the ...