I want to create soft links (ln -s) to folder2 of all the files that contain *foo* in its name, and can be found in some or all the subdirectories of folder1. I’ve tried it with for, find, and find -exec ln, and a combination of them, but all I get is a broken link named *foo* or a link
Tag: command-line
Bash script to transfer all files from current directory to specific directory based on name
I have these files: 100-1.jpg 100-2.jpg 200-1.jpg 200-2.jpg I want these to be transferred to specific folder based on filename 100/100-1.jpg 100/100-2.jpg 200/200-1.jpg 200/200-2.jpg How do I do this? What I have tried so far how do I know I cut the string before the dash e.g 200-1 to 200 and store in a variable? so I can do it
get all aliases in linux shell
How to list all aliases defined in a shell. Like the command below to list all files/folders in a directory I have defined some alias in ~/.bashrc i want to list all that command Answer Are you wondering if you have a UNIX alias already set for a specific command? You can find it easily by issuing this on the
Shell param doesn’t pass with command
I use the following code to execute shell command, the issue is that when I put it as parameter which I should get from user it doesn’t work but If I put it hard-coded it works. Working Not working In the not working version which I do cat to param I see the value printed OK, what could I miss
Bash: Want to move certain amount of files, that contains spaces to a different directory
So I’m quite new with bash and Stack Overflow in general, so forgive me if I may be missing something. I’ve been trying to create a script that moves a certain amount of files (ex: 3 files), that may contain spaces (like “hello world.txt”), to another directory. I’ve tried a few different ways to get the files with spaces, but
no such file or directory after redirection – simple command line program
Im programming a shell. This is a small piece of it that handles redirects. I only included the snippet that is causing the error. This portion of the program is supposed to take a command/argument line and execute the line accordingly. The wc < junk > junk2 is an example of a command line input and for some reason when
Send request to CMake server from the Linux command line
I would like to play around with the CMake server mode from the Linux command line. The documentation tells me to start CMake like the following: But for me it works only this way: I tried to send a request to the server, but I get only the hello response: How can I send requests to the CMake server? Answer
Quote a filename containing quotes and given as variable in Bash
Let’s say I have a directory path in variable DIR and I want to list this directory. If I care only about spaces in the path, then I could do What should I write if I want to support also single and double quotes and other weird stuff in the directory path? Example: Answer Quotes are not just for spaces
Invoke a Bash Script and End , Instead of Restarting again
I am running a Bash Script via Cron Job on my server and i need to invoke and end it self. Script : I need it to not reset on its own i will call the script thru cron when ever I want. Thanks Answer When you call it with cron, cron must take care of the looping. Remove the
How to get Linux command location in C?
I am using execv in C, but it demands to get the path of the command to get it executed, For example: To execute ls I must have char* command = “/bin/ls”; To execute gedit I must have char* command = “/usr/bin/gedit”; My question is how to get the string “/bin” or “/usr/bin” in C ? Answer You can get