I am writing a bash script that deletes all the files whose paths are given in delete.txt. delete.txt is thousands of lines long, each line has a path that is structured like this: Where there is a space in the name of the first directory. Currently, my bash script reads each line of delete.txt, saves it to$line and deletes it.
Tag: shell
How to get next param in linux shell command params?
I’m writing a shell script of this command: For ‘-w’ options, I want to process ‘/test.pcap’ into ‘$PWD/test.pcap’, so I write script like this: As we see, I want to get ‘/test.pcap’ by ‘$OPTARG’, but is none. So my question is how to get ‘test.pcap’ in my script? When I use ‘getopts’ like this: When I run sh ovs-dump -w
how can i cut one line on two on a cat /ect/passwd?
I’m trying to write a command that shows all odd lines of /etc/passwd: I’ve tried: but it didn’t work Is there a different way to obtain the result? Answer The step syntax is a GNU extension. sed ‘n;d’ should be the portable version of your sed invocation.
Show all sourced files in ZSH
I want to see which files got sourced while starting the Z-shell. Does it even keep track and if yes is there a way to list all the files? Answer You could do a at the beginning of the very first file which gets sourced. See man zshoptions.
Unexpected behaviour of double quotes in bash script
I’ve created a variable which looks like this: If I print it to the terminal, using echo $firstAndLastLines, I get the following output: root bin daemon adm lp Privilege-separated SSH Account used by the trousers package to sandbox the tcsd daemon Norbert Fogarasi But, if I use echo “$firstAndLastLines”, I get the following, separated by new lines: I wondered, why
Collect and sum statistics of `strace` commands?
I know that I can runstrace -c ls to collect system call statistics on the ls executable. However, I want to run the command strace -c {some executable here} mulitiple times over different executables, merge the individual results, and then write to a single file. I want to merge the ‘syscall’ and the ‘calls’ columns. So for example, if ls
sudo doesn’t work, but root user works [closed]
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
Bash ‘swallowing’ sub-shell children process when executing a single command
Bumped into an unexpected bash/sh behavior and I wonder someone can explain the rationale behind it, and provide a solution to the question below. In an interactive bash shell session, I execute: $ bash -c ‘sleep 10 && echo’ With ps on Linux it looks like this: _ -bash _ bash -c sleep 10 && echo _ sleep 10 The
Copying files from multiple directories into a single destination directory
There are multiple directories which contain a file with the same name: Now I want to extract them to another directory, direct_new and with a different file name such as: How can I do this? BTW, if I want to put part of the name in original directory into the file name such as: What can I do? Answer This
space issue between Month and date in linux
In my linux system date is having two space between month and date(ex:Jun 4) .so i used date command(ex:date +’%b %_d %H’) and stored the value in variable that time i am getting only one space between month and date(ex:Jun 4), so please help me to get the actual system format while using variable. Answer date is outputting the string