- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Shell script: Brace expansion
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 07:21 PM
тАО07-11-2006 07:21 PM
The following two brace expansion working differently. Can someone explain how this works?
# echo {file1,file2}\ :{\ A," B",' C'}
file1 : A file1 : B file1 : C file2 : A file2 : B file2 : C
# echo {file1,file2} :{\ A," B",' C'}
file1 file2 : A : B : C
TIA.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 01:43 AM
тАО07-12-2006 01:43 AM
Re: Shell script: Brace expansion
file1 : A file1 : B file1 : C file2 : A file2 : B file2 : C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 03:16 PM
тАО07-12-2006 03:16 PM
Re: Shell script: Brace expansion
Under which shell you tried?
# echo $SHELL
/bin/bash
# echo {file1,file2} :{\ A," B",' C'}
file1 file2 : A : B : C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 05:38 PM
тАО07-12-2006 05:38 PM
Re: Shell script: Brace expansion
/bin/bash
> echo {file1,file2}\ :{\ A," B",' C'}
file1 : A file1 : B file1 : C file2 : A file2 : B file2 : C
>echo {file1,file2}\ :{\ A," B",' C'}
file1 : A file1 : B file1 : C file2 : A file2 : B file2 : C
No differences?
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 06:01 PM
тАО07-12-2006 06:01 PM
Re: Shell script: Brace expansion
Use BASH shell on rhel4.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 06:05 PM
тАО07-12-2006 06:05 PM
Solution>echo {file1,file2}\ :{\ A," B",' C'}
file1 : A file1 : B file1 : C file2 : A file2 : B file2 : C
>echo {file1,file2} :{\ A," B",' C'}
file1 file2 : A : B : C
Difference in commands: the back-slash to escape the space before the colon.
Man page:
A correctly-formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma. Any incorrectly formed brace expansion is left unchanged.
I don't think that helps.
If you escape the space with a backslash, the space is part of the string. If you do not escape the space, it is a separator and there is nothing to expand in the two separate brace lists...
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 10:54 PM
тАО07-12-2006 10:54 PM
Re: Shell script: Brace expansion
echo {file1,file2}" : "{\ A," B",' C'}
file1 : A file1 : B file1 : C file2 : A file2 : B file2 : C
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 04:39 PM
тАО07-19-2006 04:39 PM
Re: Shell script: Brace expansion
# echo {file1,file2}:{\ A," B",' C'}
You should get the result below:
file1: A file1: B file1: C file2: A file2: B file2: C
Because of additional space in between of } and : , that why get the problem look like below:
file1 file2 : A : B : C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 05:00 PM
тАО07-19-2006 05:00 PM