I am trying to create an alias that should turn into the following command: It’s straightforward to just do on bash, but on zsh, the command turns into I can’t get the ” or the to escape. Answer It looks like you’re treating the first and last double-quotes as ‘surrounding’ quotes for the entire expression, but that’s not how
Tag: shell
How to replace ‘>> $log_file 2>&1’ from all files
In my files commands are like : File1.sh: File2.sh File3.sh I am looking for a command to remove the line where defined variable ‘log_file’ from all the files AND remove only ‘>> $log_file 2>&1’ part from all the files Output in files: File1.sh: echo -e “n Output is n” File2.sh File3.sh I tried multiple ways with sed but nothing worked,
What is the command to remove files in Linux from a particular directory which are owned by a particular user?
Let’s say we have a directory path /home/username. How can we delete all the files only from this path which are owned/created by the user dev-user? When I am trying but it’s giving an error and it’s removing files from other directories as well. Answer Use the user flag to specify files owner by a specific user and use -delete
Problem while loop to compare current date to date in a file
I want to compare current date to date present in file [every 30 seconds and in background] I don’t know if I have to do an infinite loop or a while read line loop … So, every match of current date with a date of a file, I print the current line matched in xmessage. ( I add a date
What would be a good algorithm for patching binary files on Linux?
I am trying to reduce data transfer to my embedded Linux device by creating patches for almost similar binaries. I have memory constraints on my device and hence heavy algorithms like bsdiff and bspatch are unaffordable on my target for binary sizes of around 36-60 MB. I would like to know the commands that have the best algorithms for diffing and
Recursively delete all but the one newest file throughout all directories
My system depends on only having one file (PDF, DOCX) per subdirectory. There are thousands and thousands of subdirectories. Due to a permission error, in some of them, I have ended up with more than one file. In these instances, I only want to keep the one most recently modified file. I was able to export a list of directories
Can someone help me to translate this line of code for bash shell?
I have been struggling to understand this line of code, could someone helpe me ? for what I understood the od means will convert the outout for octal format, -An I think it means input base which is no address but why ? and the -N is the length if someone could help to translate this while sintax I would
How to have Bash set -x only apply to the very next command without creating child processes and without calling set +x
This is limited to Bash only, and the answer needs to work on all Bash versions without exception. I do this now: and it does what I expect: The op1 is not transcribed, the op2 is transcribed, and then op3 is not. And this has the feature that if “code wedging” occurs whereby op2 has a lot of lines of
Change another word on condition of a word in the same row in command line?
I got a html file which is as follows(delete some unuseful words). What I want is to edit it without going into the file (sed command for example). I had a dict which is Following the dict, the html file should be Before the replacement it is l1, l3 and l4. After it is l1, l2 and l3. I know
Can we store “cd ..” path in a variable in bash file?
I am new to the bash my use case is to store the one previous directory in to a variable. Example: How can we add /local/ to any variable like $PREV? Answer You can use parameter expansion on $PWD which contains the current path: Or, use an external tool like readlink with command substitution: