6
votes
2answers
177 views

How many commands can be queued up with control operators?

I have been reading up on control operators, and I was wondering if there was a limit to how many commands you could line up with control operators, such as ||, && and ;. In addition, is ...
1
vote
2answers
89 views

Pass a command to ROOT from a shell script and having it stay open

I am writing a bash script to perform some analysis using the program ROOT. I want to run some initial command to load the result of the analysis, then continue using ROOT interactively. The analysis ...
2
votes
2answers
32 views

Select a range of files after sorting them

One thing I notice slower for me if I switch from using a GUI file manager to CLI is: In a GUI file manager, I can quickly select a subset of files under a dir by, first sorting them according to ...
0
votes
1answer
32 views

Must pass urls in quotes

I'm trying pass a URL to mpv for it to play it as a network stream. This can be done in bash with the following syntax: $ mpv http://myvideosite.com However, zsh wants to evaluate the URL as ...
6
votes
2answers
295 views

How to find out which program can open a given file?

Let's say I have a file thesis.pdf or picture.jpg Is there a command which returns a program to open this file with? I am aware of the command file, but it just returns the correct type of the file ...
4
votes
3answers
109 views

Write text messages between Unix and Windows

Is it possible to send text messages between two users of the same LAN, but the first running Windows with cmd and the second running Linux/Unix? I am not looking for an instant messaging service. I ...
0
votes
0answers
14 views

command type “hashed”? [duplicate]

type displays information about a command's type. How would it be interpreted if used as a command name? What command "types" are there? In the following example, what does "hashed" mean? Is it ...
1
vote
3answers
88 views

Problem when splitting command with backslash in unix prompt

I often use the space-backslash combination ( ) to split a command and its parameters into various lines and make it more readable: /home/user> ls -ltra \ > file1.txt \ > file2.txt ...
3
votes
4answers
83 views

Generate random numbers in specific range

After googling a bit I couldn't find a simple way to generate with a shell command a random number included in a specific range, between a minimum and a maximum. I read about /dev/random, ...
5
votes
3answers
144 views

Combining brace expansion and output redirection

Often, I use parameter expansion on the command-line, such as cp a.{ext1,ext2} which is expands to cp a.ext1 a.ext2 However, in many cases I do not use cp, but another tool, let's call it cat, ...
1
vote
1answer
59 views

How to find list of available shells by command-line?

How to list available shells for use by command-line?
6
votes
1answer
74 views

Filetype and dereference when listing directory with LS command

I'm trying to combine arguments to the ls command to list a directory content. What I'm basically trying to achieve is listing the directory dereferencing all links, but showing explicitly that the ...
1
vote
5answers
101 views

How to copy a file from a remote network to the local desktop

So I used SSH to remotely login to another computer on a network. I have many files that I would like to copy over to my local desktop. I am trying to follow this How-to : However, I think one ...
9
votes
2answers
391 views

disable CTRL-D window close in terminator (terminal emulator)

I am often logged in through multiple SSH sessions. To logout from my sessions, I press CTRL+d, until I am back on my local machine. However, sometimes I press once too many, and my terminal exits. ...
7
votes
6answers
807 views

How to read first and last line from cat output?

I have text file. Task - get first and last line from file after $ cat file | grep -E "1|2|3|4" | commandtoprint $ cat file 1 2 3 4 5 Need this without cat output (only 1 and 5). ~$ cat file | ...
2
votes
2answers
108 views

“cat” command: how to automatically escape everything that might be a violation?

If you copy the contents of httpd.conf and then paste it into a cat command.. such as this one.. #!/bin/bash cat > /test << EOF pasted here.. EOF you run into this error: -bash: ...
8
votes
3answers
325 views

Local, timestamped logging of all ssh commands?

How can I keep a local, timestamped record of all remote commands I use in ssh (command-line openssh client started through bash)? Requirements: Essential: 100% client-side without relying on ...
1
vote
3answers
60 views

How to remove all FIFO files with a shell command

I can't find a shell command to remove all the FIFO files inside a directory. In fact, for the removal of directories, the rm command offers the options -d, --dir, but for FIFOs it offers no option. ...
0
votes
1answer
463 views

Proper escaping of double quotations for curl post data?

I'm trying to test out a server, by sending it JSON data and reading the response. I need to POST data like {"item":"value with spaces"} but when I use curl I find that it sends the backslashes as ...
1
vote
1answer
39 views

Is there a command which creates a temporary file containing the arguments passed to it?

I can paste the contents of a file into a command using cat and backticks: ls `cat filenames` Is there a way to do the reverse - to turn a string into a (temporary) filename? gcc -o cpuburn `uncat ...
0
votes
1answer
45 views

Set alias which doesn't send specified text? [closed]

EDIT I set a alias task in ~/.bashrc. The following: alias join="clear; screen -ls; screen -rx [<ID_OF_THE_RUNNING_SCREEN> quit]" If i the task join is executed, the following has to ...
3
votes
1answer
64 views

What is 'ls quote'?

Today I happened to press ' after ls So the command is ls' After I issued this command: [edit]Seems the image can't display properly > ls' quote> ls' zsh: command not found: ls\nls > ...
15
votes
3answers
2k views

Why isn't there any shell command to create files?

Attention please: I am not asking how to make a file from the command line! I have been using touch for making files for years without paying attention that its main purpose is something else. If ...
16
votes
6answers
2k views

Why do I have to cd out of a deleted directory?

On my server I have a directory structure looking something like this: /myproject/code I normally have an ssh connection to the server and 'stand' in that directory: root@machine:/myproject/code# ...
6
votes
3answers
492 views

What is the difference between the use of ; and executing a script

I'm using bash as my main shell, but it's an open question and responses for shells others than bash are very welcome. If I'm typing interactively #original line #wget http://something.com ...
8
votes
3answers
310 views

How to execute a command repeatedly with different arguments?

I'm on Ubuntu. I copied some arguments (separated by newline) and I can use xsel to print them out like this $ xsel arg1 arg2 arg3 arg4 ... Now, I want to use each of these arguments for another ...
1
vote
1answer
75 views

Command works with tilde at the end. How?

I'm on Ubuntu. I have a script called myscripts in /usr/bin/myscripts This script simply changes the current directory to ~/Work/MyScripts Normally, I simply open a terminal and type ~/Desktop$ . ...
1
vote
1answer
325 views

Exit of “> ” mode in Unix shell

In sh (not Bash), how would we abort execution of command when the prompt is in > mode? For example, when entering a string with quotes only at the beginning, it makes the prompt look like >, ...
1
vote
7answers
206 views

what are some uses of .(single period) & ..(double period) in the shell command line

The single period . means current working directory The double period .. means parent of the current working directory I can only think of . being used in relative pathname etc cd ./bin/usr How are ...
2
votes
1answer
226 views

When should you use subshells vs `xargs`?

Many simple commands using xargs could be rewritten as commands using subshells. For instance, here is something I was using earlier today, to concatenate the ten largest binaries in /usr/bin, written ...
2
votes
1answer
286 views

Copy files based on date/time from subset of directories

I'm teaching a class where (~80) students are submitting assignments that I can access via webdav, organized by student in directories named by their unique identifier. The students are split into ...
9
votes
2answers
340 views

How can I redirect `time` output and command output to the same pipe?

Suppose I have a binary called foo. If I want to redirect the output of foo to some other process bar, I could write ./foo | bar. On the other hand, if I wanted to time foo, and redirect the output ...
4
votes
2answers
222 views

Dump process's stdin and stdout

I have two processes, let's say Parent and Child. Parent launches the Child and communicates with it through child's stdin and stdout. Parent <-> Child These processes use text protocol and I ...
3
votes
7answers
463 views

Batch renaming of files [duplicate]

I have a directory full of images: DSCN4749.JPG DSCN4750.JPG DSCN4892.JPG ... And I would like a one-liner to rename them to (say). dscn4749.jpg dscn4750.jpg dscn4892.jpg ... How do I do this? ...
2
votes
4answers
188 views

Incrementing a variable each time the system boots up

The idea is to initialize a variable and set it to 0. Then create a script that executes on boot and increments that variable by 1 each time the system boots up again. Sounds simple enough right?
6
votes
5answers
833 views

How does one find out how many bits a file has in one command?

I know I can use ls -lat to find out how many bytes has a file and then multiply by 8 to find out how many bits. But is this possible in only one command line?
0
votes
1answer
151 views

How to escape spaces while using command's output in command line [duplicate]

I want to perform the following command in command line : $ md5sum $(find . -type f) But this would cause problems when it encounter files with spaces in filenames : md5sum: Kaufmann: No such ...
2
votes
3answers
163 views

Preserving color output with cut

Using bash interactively I am trying to use cut to prevent the lines from going longer than my terminal width. But when using a command with colorized output all the color gets removed by cut. For ...
0
votes
3answers
459 views

How to compact a chmod UNIX command

Is there anyway to compact the follow UNIX command: chmod 755 scriptA.ksh | chmod 755 scriptB.ksh | chmod 755 scriptC.ksh | chmod 755 scriptD.ksh The above command makes every KornShell (ksh) ...
0
votes
0answers
20 views

Multiply 2 array index variables shell programming [duplicate]

How do i multiply 2 array index variables given the following foo=(1 2) bar=(0.1 0.2) foobar=$((foo[1]*price[1])) # this is wrong echo "$foobar" Current output : 0 Correct/Expected output : 0.4
0
votes
2answers
85 views

zsh: What does the command “time + number” do in zsh

When I type time + number in zsh: # atupal at local in /tmp/atupal/setup/bin [10:01:49] $ time 1 /tmp/atupal/setup/bin/lib/python2.7 # atupal at local in /tmp/atupal/setup/bin/lib/python2.7 ...
3
votes
3answers
405 views

How to move the first x files

I have this huge folder with thousands of unordered files. Is it feasible to move the first 5000s to a subfolder via the mv command? For now I move files with mv *some_pattern* ./subfolder1/ ...
1
vote
2answers
89 views

Removing “[crap-like-this]” from strings using bash parameter expansion?

If I have the following $STRING aaa.bbb.ccc.[ddd].eee.fff.[ggg].hhh is there any way, using bash parameter expansion, to echo the following aaa.bbb..ccc.eee.fff..hhh That is, remove all ...
7
votes
2answers
138 views

what is `env <command>` doing?

What is the command env ls -al doing? I had a Linux test and there was question: "How to run command directly, but not its alias?" I knew that there exists solution like prefixing command with some ...
3
votes
4answers
193 views

How do you find what keys the “erase” and “line-kill” characters are in Ubuntu?

I'm new to Unix and have bought today a copy of "The Unix Programming Environment". I'm trying out the stuff from the book. But some of them are not working as expected like : To kill a line and ...
3
votes
1answer
94 views

Getting size of directories and exclude some folders

I have an directory structure like this: application1 application1_edit application2 application2_edit Is there any way to get the total size for every folder (including sub-directories) and ...
1
vote
2answers
99 views

Using globbing/wildcards when Opening Files from Terminal

I have a folder A. Inside the folder, there are some files a,b,c,d and there is a subfolder, B, containing files e,f,g. Suppose I want to open files a,b,c,d: then I just type xdg-open *. However, ...
0
votes
2answers
98 views

Using Pipeline to Direct Files to Program that Opens Them

I have a Music folder, in which I have some music tracks, which aren't organized too well. Thus, if I want to find a particular track, I usually type: ls Music | grep <keyword>, where ...
2
votes
1answer
46 views

Piping fragments of a document through various commands

I want to send, maybe using escape sequences such as $$$, fragments of an article through various commands, possibly with modifiers. The stdin would be replaced by the corresponding stdout. (Deleting ...
0
votes
1answer
112 views

How to pass wildcards in command line [closed]

So this works: foo -a -b -c "path/file.ext" And this too if I want to pass all files from directory: foo -a -b -c path/* But if I add the quotes foo -a -b -c "path/*" It doesn't work anymore: ...