Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I'm trying to enter input without typing anything I'm trying to put the input in the command.
I've seen people try this:
printf 'argument\n' | command
Or
command <<< "argument\n"
I don't know if what I'm doing is command specific but neither of these work for what I'm trying to do.
I'm trying to zip a file with a password:
zip -r -e test.zip test_zip/
-e is for password input (this isn't the part I was talking). I set the password to test1234.
When I unzip the file I try things like this:
printf 'test1234\n' | unzip test.zip
But it still asks for password input.
Any suggestions?
If you are using the Linux command line, try using echo.
echo 'test1234' | unzip test.zip
Use the -P argument
unzip -P <password> <zipfile>
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
Improve this question
ln -s $(ls ../*.txt)
When I do the command above it replay with an error message saying : "ln: target '../foo.txt' is not a directory".
foo.txt is the first file that ls command has found in the parent dir.
I am trying to make symbolic links for all the files in the parent directory which ends with ".txt".
Can you please explain why my command did not work ?
You forgot the directory name to put all the links into. If you want them put into the current directory, use ..
There's also no need to use ls, and you'll get the wrong results if any of the filenames contain whitespace or wildcard characters, because those will be processed in the $(...) output. Just use the wildcard directly.
ln -s ../*.txt .
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
Running a grep command on my file gives me the following output:
15-5-65
52-5-93
51-4-82
21-0-86
54-6-09
63-2-68
26-7-85
24-9-46
16-7-59
81-5-42
31-7-63
54-0-84
69-8-80
74-1-27
19-9-86
41-8-74
13-2-03
21-3-61
56-7-60
81-9-47
I want to use each of these as a partial input to another grep command, such as grep '02729-AS-27' maps/projects.dat | grep '...-...' circuit_(pipe input).dat How do I properly format this command?
If this isn't clear, the files I want to search are called for example circuit_81-5-42.dat with numbers corresponding to the output of the first grep command above.
I hope this is what you want:
while IFS= read -r line; do
grep "...-..." "circuit_${line}.dat"
done < <(grep "02729-AS-27" "maps/projects.dat")
Or:
grep "02729-AS-27" "maps/projects.dat" | xargs -i grep "...-..." "circuit_""{}"".dat"
Please replace the pattern ...-... with the appropriate one.
Hope this helps.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
So I have an assignment in linux terminal asking me to create a file in the home directory and to make the file display all the commands of the bash shell which is found in the /bin directory.
I already tried to use the echo command to display the commands to the file but it is not working:
echo $ls /bin > File1
I expect that the file contains all the commands of the bash shell, but when I type the line above in the linux terminal, the content of the file is just the word "/bin".
Is there any other way to use to meet the expected result?
Here you don't need the echo command, as ls already prints to standard output, which can then be piped to the file. The command you want is:
ls /bin > File1
A good way to go about this is by checking that "ls /bin" by itself will print to standard output the contents of /bin, and once you see the expected output, run it again with the "> File1" to then output to File1.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I want to rename all files in selected directory using rename command or move command from :
_02_mp3_cbr_320.m4a?anghakamitoken=sc245ae5a454547.5
_02_mp3_fsgsfsdfsfdfdsfcbr_320.m4a?anghakamitoken=sc245.ae5a
to
1.m4a
2.m4a
If those files always have a sheme like this:
_02_mp3_ * _320.m4a?anghakamitoken= *
You can do it like that:
#!/bin/bash
COUNT=0
for f in ./"_02_mp3_"*"_320.m4a?anghakamitoken="*; do
mv $f "$((++COUNT)).m4a"
done
This will result in
1.m4a
2.m4a
Assuming the initial files are in the same directory as the bash script.
Try this with GNU Parallel. it basically uses GNU Parallel's job number ({#}) as the number for renaming:
parallel --dry-run -k mv {} {#}.m4a ::: *m4a*
Sample Output
mv _02_mp3_cbr_320.m4a\?anghakamitoken\=sc245ae5a454547.5 1.m4a
mv _02_mp3_fsgsfsdfsfdfdsfcbr_320.m4a\?anghakamitoken\=sc245.ae5a 2.m4a
If the commands look correct, remove the --dry-run part and run it again. The -k keeps the output in order. The {} refers to the current file.
Make a backup before using any commands you are unfamiliar with...
To rename any file in Linux using mv (move) command:
mv (cfr. "man mv")
In this case, you need to enter the following lines on the command line:
$mv _02_mp3_cbr_320.m4a?anghakamitoken=sc245ae5a454547.5 1.m4a
$mv _02_mp3_fsgsfsdfsfdfdsfcbr_320.m4a?anghakamitoken=sc245.ae5a 1.m4a
It is important that you refer to the manual when you know the command you must use, to understand how to use it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have a dir /var/real-dir
I've created a soft link to it like this
ln -s /var/realdir /var/virtual-dir
Having that my working directory is /var/virtual-dir, I'm searching for a way to cd to real-dir with as less typing as possible.
You can use cd -P .
Note that this only updates the PWD and OLDPWD environment variables; the kernel-level current directory remains unchanged.
Alternatively, you can use the -P option with the initial cd like cd -P /var/virtual-dir.
You can:
cd "$(readlink -f .)"
If this is too much typing, you can create a helper function in your .bashrc, like this:
function cdlink() {
cd "$(readlink -f .)"
}
source ~/.bashrc or start a new shell and can simply type:
cdlink