shell's questions - Chinese 1answer

7.659 shell questions.

My problem definition is : 1.Write a Bourn shell script dTOe which takes as an input any number between 0 and 999 and prints the English value for this number. I am struggling with above problem. ...

How do I use the output of a command as a parameter in another command? My specific example is that I want to get the PID of a process using pgrep and pass it to the -p option of lsof. I've tried ...

I want to create a bash script that would connect to a server and run jupyter notebook on that server. How do I run jupyter notebook command while I am connected to the server using bash script? I ...

How can I append the string :/etc/simmmerin/bin/ into a file filename using echo command onto an existing row. Can't get it working. echo ":/etc/simmerin/bin/" >> filename It just appends in ...

Make `rm` move to trash

7 answers, 20.437 views shell rm
Is there a Linux script / application which, instead of deleting files, moves them to a special “trash” location? I’d like this as a replacement for rm (maybe even aliasing the latter; there are pros ...

I have a script (let’s call it scriptC) that uses getopt to parse short and long options and works fine. This script is being called like this: scriptA runs scriptB which calls scriptC with the ...

From vi, if you issue the command :sp, the screen splits into two "views", allowing you to edit more than one file from the same terminal. Along those same lines, is there a way to have multiple ...

Why do I need to run "df -h" whith sudo to show my lvm partition mounted that I just added? When I run the command with sudo I get this result : /dev/mapper/centos00-root 4,9G 1,4G 3,6G ...

How to check what shell I am using in a terminal? What is the shell I am using in MacOS?

Problem: I need to check if today is Thursday and perform different actions based on the result of this condition. I tried two different approaches: Getting the Day Name: DAYOFWEEK=$(date +"%a") ...

I have configured everything necessary to log in with AD in linux (krb5,sssd, samba and ntp), but when I connect with putty to the server, the default shell that starts me is /bin/sh. I need to ...

In R, We have IN operator to check whether or not the element is present in the specific column. For example: If we have fruits and market dataframe with fruit_name and products as the column name ...

I am curious why can't we switch to a user's home director with either $ cd ~"$USER" or $ cd ~${USER}

$ ls -l /tmp/test/my\ dir/ total 0 I was wondering why the following ways to run the above command fail or succeed? Thanks. $ abc='ls -l "/tmp/test/my dir"' $ $abc ls: cannot access '"/tmp/test/my':...

I have a variable in ksh that can contain no more then 2 comma-separated digits (white spaces allowed). Something like: a="1,2" a="1 ,2" a="1," a="0,0" I want a loop to read through $a exit if ...

I have an old .bat file that I need to run on my QNAP. I need to recursively create folders for each file (based on file name) then move the file to that folder. Here's the old .bat: @echo off for %...

I was trying to inspect a disowned curl process, which was started in an earlier login. I can see that it (PID 17193) is still running: $ ps aux | grep curl 17193 jack 7700 3692 S 1:00 20:48 ...

I have several files named like this: This is a test - AB12-1998.avi (the last code is always 2 letters, 2 numbers, dash, 4 digits) What I'd like to do is rename them like this: AB12-1998 - This is ...

Is it equivalent to have commands print to a file directly, as opposed to writing to a file descriptor? Illustration Writing to file directly: for i in {1..1000}; do >>x echo "$i"; done ...

Is "${blah}" allowed in POSIX sh, or does this require bash derived shells?

I bricked the login of my root user by removing zsh while it was still the default shell. Now as a result will login in fail, since on login will it try to use /bin/zsh(1), which is missing. Only one ...

Is there any terminal shell/emulator out there that supports editing your current command with the mouse? Specifically things like placing the cursor by clicking (useful for long commands) or double ...

I have a Bash script, which looks similar to this: #!/bin/bash echo "Doing some initial work...."; /bin/start/main/server --nodaemon Now if the bash shell running the script receives a SIGTERM ...

I want to write a script that merges contents of several .csv files in one .csv file, i.e appends columns of all other files to the columns of first file. I had tried doing so using a "for" loop but ...

I spend most of my time working in Unix environments and using terminal emulators. I try to use color on the command line, because color makes the output more useful and intuitive. What options exist ...

Could anyone help me with this problem, please? Write a shell script to display all files whose size has increased by more than x blocks in the last y days. X, Y and the current path are positional ...

Today i found that typing this command in bash shell opens vim text editor `echo -n -e '\x76'``echo -n -e '\x69'``echo -n -e '\x6d'` And if you have radare2 already installed then this command will ...

When I login to root via sudo -i sudo changes the working directory of new shell to root's home directory. I can use following commands to keep working directory of parent shell: sudo -s sudo su ......

How to get the char at a given position of a string in shell script?

I work in an environment where I have multiple ssh keys for multiple environments, all of which utilize a bastion host, meaning to ssh to any box in any environment, it is a 2-step hop, first to the ...

My problem is: my bluetooth keyboard won't work with my new android phone (big screen), but it does work with my old android phone (small screen). So I'd like to connect the keyboard to my old phone ...

I've seen couple of similar topics, but they are referring to not quoting variables, which I know could lead to unwanted results. I saw this code and was wondering would if it be possible to inject ...

I am looking to get a time range from a given time. The start time should be 60 mins before the given time and end time should be 60 mins after the given time. Purpose: The given time will be like ...

I'm trying to count the number of lines of output a certain program produces. The problem is, the program takes a long time to run, and I want to display the output to the user. Is there a way to ...

I am running slackopuppy64 linux live version from USB drıve. ıt does not save any of my settıngs or preferences. I want to automate the followıng processes at startup: connect to wıfı (WEP). ...

Per a discussion in Chat, when was command line parsing (using positional parameters) first introduced to the Unix shell? And also, was the naming of $1, $2 etc. in any way borrowed from C (for ...

I have a binary file that is filled with FF values. I filled its start with many \000. Then, I padded its start with 10 \000, in order to get some kind of offset, and then I wrote a shorter string, ...

What is the technique called when you want your variables to disappear after they are run in a subshell? $ (lookForMe=wee && find -type d -name "${lookForMe}_*") $ echo $lookForMe $

How can I run a cron command with existing environmental variables? If I am at a shell prompt I can type echo $ORACLE_HOME and get a path. This is one of my environmental variables that gets set in ...

Using version control systems I get annoyed at the noise when the diff says No newline at end of file. So I was wondering: How to add a newline at the end of a file to get rid of those messages?

I want Firefox window to be opened in a specific size, and location on screen using a shell command, for example: firefox myfile.html size 800x600 location bottom-left Is there such a command?

I have two arrays: arrayA=(1 2 3) arrayB=(a b c) and I want to print out one of them using a command line argument, i.e., without any if else. I tried a few variations on the syntax with no success....

I'm trying to filter the most used commands and print that out in a certain way. So far, I've managed to put the desired "filters": $ history | tr -s ' ' | cut -d ' ' -f3 | sort | uniq -c | sort -n | ...

I'm using CentOS 7. I"m trying to capture the "master PID" of a process in a script variable. This is my script #!/bin/sh set -e PID="$APP_ROOT/shared/pids/puma.pid" echo "before ..." MASTER_PID=`...

How can I list all the printable ASCII characters in the terminal?

At the top of a bash script, I have this: if [[ "$npm_registry_override" != "yes" ]]; then echo "refusing to source npm.sh script because env is not set." exit 0; fi the problem is that when I ...

When looking for the path to an executable or checking what would happen if you enter a command name in a Unix shell, there's a plethora of different utilities (which, type, command, whence, where, ...

I for some reason can't figure this out. I need the following to look like this. I basically don't want to write the same command 20-50 times depending or even more. Thanks! The problem with the ...

I know how to kill a job with kill %(number) but is it possible to kill a job as background job, the question is "kill tail as a background job?"

Given this input: # Lines starting with # stay the same # Empty lines stay the same # only lines with comments should change ls  # show all major directories               # and other things cd     ...

Language

Popular Tags