通过变量在外壳中带有空格的打开目录

我在变量New folder中有目录i的名称。我知道此目录存在于当前路径中,但是当我的shell脚本尝试使用cd \"$i\"打开该目录时,我收到一条消息:No such file or directory: "New folder"。但是,如果我直接输入名称cd "New folder"-可以。为什么它不能与变量一起使用?

谢谢

zzlxf85 回答:通过变量在外壳中带有空格的打开目录

我找到了解决方案。当import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Table extends Applet { private Label msg; TextField number; public void init() { setLayout(new FlowLayout()); Label heading = new Label("Multiplication Table"); number = new TextField(10); Button button = new Button(" Press "); msg = new Label(""); add(heading); add(number); add(button); add(msg); button.addActionListener(new ButtonListener()); } private class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { String str=" "; int n = Integer.parseInt(number.getText()); if(n%2==0 && n>=11 && n<=90) { for(int i=1;i<=10;i++){ str = str+ n*i+" "; } } else { str = "Try Again! Number must be even and between 11-90"; } msg.setText(str); } } public static void main(String[] args) { } } i="New folder"

时,
本文链接:https://www.f2er.com/2583624.html

大家都在问