I have the following commands. Wherever the .user.log file is present, we need to print the parent directories (i.e hht and wee1.) How can this be done? Answer Am I missing something here. Surely all this regex and/or looping is not necessary, a one-liner will do the job. Also “for foo in $()” solutions will fail when there are spaces
Tag: shell
Adding newline characters to unix shell variables
I have a variable in a shell script in which I’d like to format the data. The variable stores new data during every iteration of a loop. Each time the new data is stored, I’d like to insert a new line character. Here is how I’m trying to store the data into the variable. VARIABLE=”$VARIABLE ‘n’ SomeData” Unfortunately, the output
How to change a word in a file with linux shell script
I have a text file which have lots of lines I have a line in it which is: MyCar on how can I turn my car off? Answer You could use sed:
Linux Shell: VLC programming
Is there a way to manipulate VLC with a Linux shell script without the script waiting for VLC to close. This code keeps running VLC until the file is completed, and then evidently it is to late to pause the file. Answer You need to use dbus interface of VLC. Now, you can use the mpris interface of VLC. It’s
bash scripting: how to get item name on a radiolist using dialog
I need to make a radiolist in bash script using dialog interface, for example if I have the following list: I need when the user chooses an option and presses “ok”, my script could read the item’s name and not the item’s number. It is possible? Thanks! Answer You can put your expected results in an array:
Open All files named generator.yml in all subdirectories of current directory in gedit
I’m no expert at shell scripting so I just want a quick answer. I tried something like but It just doesn’t work because it’s just a stupid guess. So what’s the correct way? UPDATE: answers by Jaypal Singh , kev and Sorin were very helpful but kev’s answer covers more cases so I’m marking that correct. Answer Or
split for words separated with semicolon
I have some string like 1;2;3;4;5 I want to be able to iterate over this string taking each word one by one. For the first iteration to take 1 the next to take 2 and the last 5. I want to have something like this but I do not know how to fill the myvar Answer
capture network traffic on two different ports simultaneously
I wish to capture tcpdump traffic on two different ports simultaneouly . I tried this .. Althoug it worked but problem is first it will wait for traffic on port 21 and when interrupted then it will wait for port 22. Also another problem is it will not capture the traffic on port 22 untill traffic on port 21 will
Why doesn’t “sort file1 > file1” work?
When I am trying to sort a file and save the sorted output in itself, like this the contents of the file1 is getting erased altogether, whereas when i am trying to do the same with ‘tee’ command like this it works fine [ed: “works fine” only for small files with lucky timing, will cause lost data on large ones
What are the alternative(s) to applescript in Linux? How are they different?
I’m preparing to switch to Linux. I want to learn more about what Linux users do to solve problems that OSX users solve with Applescript. More specifically: What are they called? How are they different? Answer I am assuming you’re using applescript for basic system automation. There are a wide variety of languages available, but none as closely/uniformly integrated with