Skip to content
Advertisement

Tag: shell

Find files and print only their parent directories

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

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

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

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

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

Advertisement