Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

All Questions

Tagged with
1
vote
3answers
237 views

Why does a file move/copy function only move one file at a time when using the “*” wildcard?

function mv1 { mv -n "$1" "targetdir" -v |wc -l ;} mv1 *.png It does only move the first .png file it finds, not all of them. How can I make the command apply to all files that match the wildcards?
1
vote
1answer
85 views

/bin/sh: /usr/bin/wkhtmltopdf: not found

I installed /bin/sh: wkhtmltopdf /usr/bin/ directory. However when I try to run the program by entering /usr/bin/wkhtmltopdf to shell I receive an error /bin/sh: /usr/bin/wkhtmltopdf: not found. It ...
-1
votes
2answers
36 views

Implement file read option from command line - “anonymous” file [closed]

I have a command line program like so: my_cmd -f <file> which would normally be used like: my_cmd -f some-file.json my question is - is there a way to read an inline file, something like ...
1
vote
0answers
97 views

Browse the internet from the command line

I know there are command-line web browsers like w3m lynx etc. But I am looking for a simpler tool to just print search queries. Somewhat like curl does, but more nicely formatted. Like if I run https:...
-2
votes
1answer
79 views

What is a system tool? [closed]

I frequently come across the term system tool, so I wanted to understand the exact meaning of it in Linux. Which of the following three explanations of a system tool in Linux is correct? Is a system ...
0
votes
1answer
60 views

how to add additional command-line usage scenarios to script?

how can one make this script work with both input usage scenarios below? #1 ./script.sh #2 ./script.sh input.file contents of script.sh for i in *.mp4; do ffmpeg -i "$i" "${i%.*}.mp4 ...
1
vote
1answer
62 views

Linux command that continuously outputs string of text

At some point I used a shell command that continuously sent a very short string of text to the standard output, but at this moment I can't recall it's name. Its name was something very short, like '...
0
votes
1answer
101 views

How can I open terminal and run command automatically?

I'm in the terminal emulator. I want to open another terminal to run a specified command. gnome-terminal -e "zsh -c 'pwd; zsh;'" That runs pwd and zsh consecutively and successfully in another ...
0
votes
2answers
40 views

Concatenate the Content of Files from Various Directories with a Blank Line in Between

I have the file dir1.txt that contains the names of the following directories: 2 3 4 Directory 2 contains files 2_1.txt and 2_2.txt Directory 3 contains files 3_1.txt and 3_2.txt Directory 4 ...
0
votes
2answers
76 views

Run ssh command without quotes

You can execute a command on a remote server using ssh user@host 'the command' but is there a way to execute the command without quotes? (I am on BSD and using OpenSSH)
-1
votes
1answer
49 views

How can I run only a portion of a command line in a user built shell?

I make a shell that takes arguments in a command line with special conditions on what it is able to do. For example, anything that appears after the # character will be considered as a comment and ...
4
votes
1answer
227 views

stdout and stderr redirection to different files

How can I redirect stdout to 2 different files and stderr to another, different file? I want something like <my_cmd> 1> file1 file2 2>file3 I know: <my_cmd> | tee file1 file2 > /...
2
votes
3answers
169 views

Getting out of while loop on console

I ran a command: while true ; do ..... ....... ; done on the Linux console/terminal, and now this while loop is continuously running. I have two questions here: How to get out of this while loop? ...
0
votes
1answer
63 views

How to use the bash shell with Python's in place of /bin/sh

I have commands to execute in the terminal but I want to execute them directly from my python script except that my script it launches the commands on /bin /sh and my terminal on bash: just an ...
0
votes
1answer
44 views

Parsing “mdls” output

The following script takes a user input (path to a mounted macOS volume such as /Volumes/Macintosh\ HD/) #!/bin/bash # Author: Swasti Bhushan Deb # macOS 10.13.3 # kMDItemWhereFroms.sh read -e -p "...
1
vote
1answer
157 views

How to modify these bash functions into one?

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time. ...
1
vote
2answers
100 views

Expanding only certain variables inside a heredoc

This is an extension of the question I asked . Passing directory from command line to shell script I have a script which writes another script using a heredoc. I need to be able to write unexpanded ...
1
vote
3answers
61 views

Sed add newline before last occurrence of brace?

I want to insert a new line before the last occurrence of brace. My text file looks like that "accounts": { "0x0000000000000000000000000000000000000008": { "builtin": { "name": "...
2
votes
2answers
52 views

Use of multiple <<<

I am wondering about the way the redirection <<< works in bash. I understand that it redirects the chain after it to the command before as if the content was in virtual file. Examples $ ...
0
votes
0answers
16 views

How do you escape “-” in a command in the Shell (Zsh)? [duplicate]

I am trying to rename a file named "-a" to "a" using the command line (zsh shell). I have tried the following mv \-a "a" mv '\-a' "a" mv "\-a" "a" but got mv: illegal option -- a usage: mv [-f | -...
1
vote
2answers
37 views

How to use regular expression result into another expression

I have two regular expressions i.e. command1 and command2 where i need to combine both expressions into a single expression using | for that command1 output should be passed to next expression. ...
0
votes
0answers
84 views

Invalid desktop entry file: '/usr/share/applications/lxde-x-terminal-emulator.desktop'

i can't run terminal because of this error. contents of file: [Desktop Entry] Version=1.0 Name=Terminal emulator Name[pt_BR]=Emulador de terminal Name[zh_CN]=终端 Name[zh_TW]=終端機 Comment=...
0
votes
1answer
72 views

How to Copy Millions of Files from Remote Server to Local One [duplicate]

I have this problem, I have an Ubuntu server (SSH enabled on port 4444). Inside this server there's a directory called /folder/a/, this directory literally contains millions of small size text files. ...
2
votes
2answers
80 views

Create a script to check the date, time and string and trigger a mail

Need to create a script where I want to take the last few lines of the log file and check that the last line with Start Date contains the date of today and the time 17:00:xx and is followed by xxxxx ...
1
vote
2answers
119 views

Copy a folder overwriting ONLY smaller files in destination

I have tons of PDFs in multiple sub-folders in /home/user/original that I have compressed using ghostscript pdfwrite in /home/user/compressed. ghostscript has done a great job at compressing about 90% ...
1
vote
0answers
38 views

Command to list all reserved words [duplicate]

Is there a command to list all reserved words? I'm aware of resources such as the GNU reserved word index, but what I'm looking for is a command that gives me this information for my shell on the ...
1
vote
3answers
65 views

Shell: only double quote on test -n/-z? [duplicate]

In case of test -e for example: VAR="<this is a file path: /path/to/file/or/dir" test -e $VAR && do_something || do_anotherthing Question: Should I use "$VAR" here?, here I don't like ...
1
vote
2answers
64 views

How to start a new column after every nth row?

I have a file (comma separated) on a Linux system with 3 columns. I want to start new column after every 4th row. Input: col1,col2,col3 1,disease1,high 1,disease2,low 1,disease3,high col1,col2,...
1
vote
1answer
50 views

program called twice from the command line [closed]

Let's say I have a (Python3) script of my own named myscript; for various reasons, myscript (not myscript.py) is stored in a sub-directory named bin : mydir/ mydir/bin/ mydir/bin/myscript -rwxr-...
-1
votes
1answer
45 views

Bash: weird parse output? [duplicate]

I'm working on a simple script that accepts multiple command line arguemnts in an order: #!/bin/bash function arg_parser () { while [[ $# != 0 ]] ; do case "$1" in --one) varone="$2" ...
0
votes
1answer
64 views

Move all files into subdirectories named after part of file name [duplicate]

I have a directory that contains quite a lot of files with names made up of artirst's name and album e.g.: Now the task is to go through each of the files, create a directory named after artist's ...
1
vote
1answer
46 views

mixed results from the same command (related to ARG_MAX) [duplicate]

I'm asking a question based on this link How to cause "Argument list too long" error? From the thread, I'm seeing the equivalent error, if i'm running this: >/bin/echo `perl -e 'print "...
3
votes
3answers
704 views

Set variable conditionally on command line [duplicate]

I want to set a variable if my condition is true on my Ubuntu system. This proves that my if-statement is correct: $ (if [ 1 == 1 ]; then echo "hi there"; fi); hi there This proves that I can set ...
-1
votes
1answer
156 views

How to properly write and execute a shell script and exit correctly? [duplicate]

I have written a shell script named startup.sh which does a lot of things (basically start a lot of things for me after turning on my local machine) - here is an excerpt: #!/bin/bash gnome-terminal --...
1
vote
1answer
47 views

How to see which files are identical given a list of files in two projects

I have two projects named project1 and project2 with identical file trees as follows. project1/, project2/ . ├── src │ ├── index.html │ ├── main.js │ ├── normalize.js │ ├── routes │ │ ├──...
-1
votes
1answer
451 views

Get command history from remote user on Linux server [closed]

I have a Linuxserver(CentOS) and many users can access this by ssh. I need to get all history commands from users: Date: the time of execution Pwd: executable directory Remote host ip User Command
2
votes
2answers
115 views

Bash: how to properly accept user input?

I couldn't find an example online but I'm sure I've seen shell coders use ${1:--} to accept user input. Here's an example: #!/bin/bash var="${1:--}" echo "$var" Then, run it: $ ./test.sh "this is ...
0
votes
2answers
238 views

How to add multiple directories like the name 1-100 in one command

I need to create multiple directories using one command.  Is it possible? Like directory name starts from 1-100. mkdir 1..100
0
votes
1answer
497 views

How to redirect output to file to STDOUT?

Similar problem as here How to redirect output from file to stdout? However, the solution given there is not universal. My problem: I have a command that produces output to STDOUT. At the same time, ...
-2
votes
4answers
112 views

How do I add the file size output together

158416 757249 574994 144436 520739 210444 398630 1219080 256965 684782 393445 157957 273642 178980 339245 6014031 These are the file sizes in my current directory. I got them using the command: ls -...
1
vote
1answer
38 views

How to produce from the terminal in a single command 2 emacs windows?

I am trying to open 2 separate windows/instances of emacs from the terminal in a single command. I have tried: emacs &; emacs & (error: bash:syntax error near unexpected token ; and emacs &...
0
votes
2answers
120 views

What part of the terminal stack is responsible for the direction of text being output? [closed]

The question is asked here: https://serverfault.com/questions/152310/reverse-bash-console-text-flow https://superuser.com/questions/719317/can-i-reverse-the-stream-direction-of-my-terminal https://...
1
vote
1answer
60 views

why $($var) gives an error?

I am trying to execute the following code in shell but I am not getting the output as expected. The command is as follows: i=1 echo $($i) I am getting an error: Command not found error I think it ...
2
votes
2answers
376 views

id -u $var gives the same output if $var has a value or not

I'm writing a script to configure new debian installs while finding the best solution to confirming that a user exists in the script, the best way I found gives me wierd output. PROBLEM: id -u $var ...
3
votes
2answers
1k views

How to delete or access a file with a backslash \ in its name?

I have some files here that I copied over to this linux box using the python module pysftp: [jm@spartan tf]$ ls -la total 0 drwxrwxrwx. 3 jm jm 69 Aug 14 13:50 . drwxrwxrwt. 9 root root 238 ...
1
vote
1answer
56 views

How do I detect a command is being executed and then execute an additional command after the current command

I want the shell to detect that I had run a specific command and then after running the command, run another command. For Example : When every I run the command : git commit -m " " First finish the ...
3
votes
1answer
41 views

Awk output to read in a section

I'm trying to output a variable & input to a new command: jira.sh --action createIssue --project "BLAH" --type "Incident" --summary "THIS IS A TEST" --components "BLA" --priority "BLAH"| awk '{...
-1
votes
1answer
87 views

bash variable with quotes and percentage [duplicate]

I want to use a time command in a script and put it into a variable (I will have to use it for many commands) so than I can modify just the single variable. Simplified, this is how I tried it: ...
-1
votes
3answers
2k views

Execute command without terminal output [duplicate]

Let me give a bit of background to my question. I am using a terminal RSS reader newsboat which allows for the usage of macros to operate on links. For example, I have a macro running cd ~/videos &...
0
votes
2answers
362 views

How to store output command in variable and use this varible again for next command after pipe

How to store output command in a variable and use this variable again for next command after pipe? lsblk | awk {'print $1'} | grep ^sd | parted $input mklable gpt mkpart primary "1 -1" -s $input is ...