2

The expansion of bash did not work

 2 years ago
source link: https://www.codesd.com/item/the-expansion-of-bash-did-not-work.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

The expansion of bash did not work

advertisements

i have a simple problem with bash's brace expansion:

#!/bin/bash
PICS="{x1,x2,x3}.jpg {y1,y2}.png"
for i in $PICS
do
  echo $i
done

but the result is:
{x1,x2,x3}.jpg
{y1,y2}.png
But i want the result is: x1.jpg x2.jpg x3.jpg y1.png y2.png
what should i do ?


The straightforward way is

#!/bin/bash  

for i in {x1,x2,x3}.jpg {y1,y2}.png; do
  echo $i
done

Related Articles

The validation of jQuery did not work?

I have a very typical example of jQuery validation form but it doesn't seem to work. Here is my code: <html> <head> <meta charset="utf-8"> <title>Makes "field" required and 13 or larger.</title> <link r

The quotes in the variable Shell Bash do not work, why?

#!/bin/sh LOG='log --pretty=format:"%h - %an, %ar : %s"' git $LOG I expect this to output an actual git log in the specified format. However, all I get is a fatal argument error. I have also tried the options below, and they also do not work: LO

The extract from Bash does not work in makefile

I have one version file verfile which contains below version string V1.1.2 And in Makefile I intend to read this version string, So I wrote Makefile as follows, filepath := $(PWD) versionfile := $(filepath)/verfile all: cat $(versionfile) version=$(s

The rs.next () loop did not work in retrieving data from the Oracle database

Dbconn.java import com.OracleCon; public class Dbconn{ public static void main(String[] args){ try{ OracleCon oraclecon = new OracleCon(); oraclecon.callmethod(); }catch(Exception e){ System.out.println("Ex e"+e); } } } OracleCon.java package co

The Android location service did not work in the background

I am working on a Location-App which should begin to track some statistic data based on longitude and latitude when the user presses a Button. All this stuff works very well but when it comes to lock the screen or put the app in the background the se

Very basic, the HTML5 Canvas code did not work. Is it me or my browser?

I am trying to learn to use HTML5 Canvas for a project, and just started using an online tutorial (a beautifully written one actually, here is the link: http://diveintohtml5.info/canvas.html). However as soon as I started to replicate it, it is not w

the selected jquery plugin did not work in wamp

at first i ran this code on php file and run it on localhost using WampServer. the pagination didn't work so i tried to convert it to html file ("sample.html"). the code here as follows. <script type="text/javascript" src="js/j

The list with onItemClickListener did not work

OnItemClickListner is not working any one help me ,I want click list item each item goes to next activity java class public class Tab1 extends Fragment { private ListAdapter mAdapter; private ArrayList<String> listCountry; private ArrayList<Integ

Simple if the statement in bash does not work

I am learning a little bit of bash in Linux and I just can't understand why this doesn't work. It is a simple IF statement and a read command to keep the window opened. What happens is that when I execute the .sh file the terminal's window opens for

The simple DELETE statement did not work

I have a table MRU, that has 3 columns. (VALUE varchar(255); TYPE varchar(20); DT_ADD datetime) This is a table simply storing an entry and recording the date time it was recorded. What I wanted to do is: delete the oldest entry whenever I add a new

The select sqldatasource command did not work

I have a problem doing search in asp.net, when I try to run the code in sqlserver or using query buider it works fine. But when I run the program in browser, the gridview didn't even show up. Help plz. protected void btnsearchadvance_Click(object sen

The node reminder js did not work with the definition function

This is simnple findOne() method code with node and mongo var MongoClient = require('mongodb').MongoClient; MongoClient.connect('mongodb://localhost:27017/blog', function(err, db) { if(err) throw err; var users = db.collection("users"); var quer

The tar.gz compression did not work for the GIF file

I'm trying to make a program to compress file to .tar.gz: Here is the code: import java.io.*; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.GZIPOutputStream; import org.apache.commons.compress.archivers.tar.Tar

The validation of the entry in javascript did not work

why this simple javascript code didn't run properly http://codepen.io/anon/pen/wBXKQY html <form id="scoreForm" name="scoreForm" onsubmit="validateForm();"> <label for="score">Score:</label> <in

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK