The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …).

learn more… | top users | synonyms (1)

0
votes
1answer
38 views

Combine curl and base64 into one command?

I'd like to POST the Base64 encoding of a file to a server, combining curl and base64 into one command that I can execute. I've tried the following: curl 'http://localhost:5000/files' -X POST -H ...
0
votes
1answer
34 views

What is the behaviour of & operator [duplicate]

I am trying to chain the commands in linux, I am using ubuntu 14.04 distribution. The aim to create a directory and go into that directory. Generally we do this mkdir foldername cd foldername ...
1
vote
3answers
81 views

How do I get the current line count from xargs?

I want to grab every 5 images in a directory and merge them together into a new file with a unique filename per 5 image group. find *.jpg | xargs -n 5 -i convert {} -append {#}.png This is really ...
0
votes
2answers
31 views

Which file should be sourced in .devishrc to permanently change the hitch-file? [closed]

By default, in DEVISH (at least for me) the hitch file used is mhitch.py... I can change the hitch using the -h option for the shfile command, but I need to permanently set it to something... Any ...
0
votes
2answers
70 views

Bash script that detects if a file is the correct size

I'm trying to make this bash script dispatch and email when it detects that a certain type of file (files ending in ".gz"), which was last modified 24 hours ago, is below a certain size in a ...
2
votes
1answer
28 views

ssh not showing full output of command

I have a list of servers 20+ that I would like to get the shell that they are using. While logged onto a server I can run the following command $ ps -p $$ PID TTY TIME CMD 12022 pts/6 ...
1
vote
2answers
24 views

How to switch to bash on DEVISH?

With the update from BasilOS Quad to Pentus, DEVISH became the primary shell(replacing bash)... I am completely unfamiliar with DEVISH, so I need to be able to switch back to bash... I tried chsh but ...
2
votes
3answers
104 views

Delete several sequential file names, but ignore part of the first

Sometimes, my scripts get trapped in infinite loops. When the loop creates new files, things get messy. I currently have this file name format: Task.4883.store.log where 4883 is a counter. I ...
1
vote
1answer
35 views

Backquotes interpretation

I'd like to know what's the difference between these two commands: echo ` echo `date` ` echo ` echo \`date\` ` I know that \ is used to escape characters, but I cannot understand it in this ...
1
vote
1answer
69 views

change LS_COLORS behaviour

I am trying to modify LS_COLORS behavior. Presently it (say for sh or py), changes color depending on if it is executable or not, as shown here But, I want all my script, executable or not, have ...
2
votes
3answers
80 views

Execute a shell command upon a click event in a web page

Is there a way to execute a bash command when I click on a text in a browser? The web page is on computer A, the browser is on computer B : I want to execute the code on computer B, e.g hsetroot to ...
1
vote
2answers
51 views

/bin/sh - echo >> operator not working as expected

I'm writing a shell script that appends binary contents to a file. I tried using this command: echo -en '\x61\x62\x63..' >> /tmp/myfile but that caused the following output: -en ...
0
votes
1answer
81 views

Unix date format validation script

I wrote this small unix shell script to validate the date format. My script should check whether the string is in YYYYMMDDHHMISS format . If it is not in this format , it should send an error message ...
1
vote
2answers
64 views

How do I test if my variable is not in a set?

I am trying to modify the bash shell script and need some assistance. I have a directory with a bunch of files. What I need is to go through the files in a loop and if the file name not in a specific ...
-2
votes
1answer
44 views

How to get more than 20 lines of output with grep when searching for a string with spaces [closed]

I am currently using grep like this: grep search_string search_file > output_file Here is an example: grep "ich arbeite" deu.txt > out.txt When used in this way, I only get the last 20 ...
1
vote
2answers
84 views

CasperJS and PHP In Cron Job Cannot Open Files, Works Fine When Run Manualy

I recently got a new DigitalOcean LEMP environment with Ubuntu. I tried making an SH script that uses CasperJS to scrape data from an external website to a JSON file, and a PHP script to parse the ...
6
votes
2answers
95 views

Why does the terminal echo keystrokes when commands are running?

I was recently running tail -f on a log file of a server that was running, trying to diagnose a bug, when I accidentally bumped the keyboard and typed some characters. They got mixed in with the ...
1
vote
1answer
50 views

Is there a tool that automatically inserts and updates a script header block for e.g. shell or Python scripts?

I found scripts by a former admin who scripted quite nice things with Bash or Python. All his scripts are well formatted and equipped with a always similar looking "script header" or "code header", I ...
3
votes
4answers
135 views

Provide strings stored in a file as a list of arguments to a command?

I install a list of URLs in a text file named myurls: http://www.examples.com/1 http://www.examples.com/2 http://www.examples.com/3 How shall I pass these URLs to wkhtmltopdf as inputs? The direct ...
0
votes
0answers
6 views

redirect help info to vim [duplicate]

I use this kind of commands to redirect help info to vim, for example: man ls | col -b | vim -R - but for some help info highlighted with color: celery -h there is a mess in it. How to make it ...
2
votes
0answers
51 views

Where EOF character is processed when it sent over telnet connection

Lets suppose I am connecting to telnet server, where bash is running. I am executing comand "cat > /tmp/qqq"; typing some contents of a file and finally sending 0x0a 0x04 which meant EOF. The ...
1
vote
3answers
66 views

Why are file names surrounded wtih “â” sign?

After adding alias rm='rm -i' to my ~/.bashrc file, because when I remove file, shell wasn't asking for confirmation, file names are surrounded with "â" sign like in example below: rm: cannot remove ...
2
votes
3answers
39 views

grep .* returns results from .bash_history and complains about

I'm new to Linux and so far I've been playing around with some utilities, specifically the grep utility. I decided to create a new file (aptly called 'newfile') with the following content: Lady of ...
3
votes
1answer
144 views

Bash substitution with variable defined from a glob pattern

The below example explains the issue. Why is the FILENAME printed correctly when echoed and perceived as a pattern when using substitution? #!/bin/bash FILEPATH_WITH_GLOB="/home/user/file_*" ...
0
votes
1answer
35 views

Bash script to connect to Teletalk internet

I'm running Elementary OS(based on Ubuntu 12.04), and I have to connect to the internet in a peculiar style. I use a Teletalk modem to connect to the internet. Unfortunately, the modem gets recognized ...
1
vote
2answers
31 views

Scanning no: of characters of a file and write it that file itself

I have to scan the no of characters in a file and to write to that file itself with a hardcoded way like 99|EOF|. for eg: if a text file : test.txt is having abcd as text in it. count will be 4. So i ...
-1
votes
2answers
50 views

can i do this or how can i do this awk + sort?

cat file_outunique.out | awk '{ print $1, $2}' | sort $2 -u > ledernier.out I want to output $1 and $2 for the 1st iteration of $2 Do you have any suggestions about this? I've tried to change ...
0
votes
2answers
221 views

Why are there three syntax for setting variables in shell scripts?

root@ubuntu:~# echo ${x=1} 1 root@ubuntu:~# echo ${x:=1} 1 root@ubuntu:~# echo ${x-1} 1 root@ubuntu:~# Why are there three syntax for setting variables in shell scripts? What is the technical ...
3
votes
1answer
86 views

Filename Expansion: Find Utility Pattern Matching vs Bash Shell Pattern Matching

For filename expansion, the 'find' utility's '-name' option seems to function similarly, but not exactly the same as the bash shell's builtin pattern matching. Here are the relevant sections of the ...
4
votes
2answers
112 views

Difference between find ~ and find *

What is the difference between find * and find ~ for searching a file? In terminal when my present working directory on root,then in terminal root@devils-ey3:~# find * -print -quit ~ On same ...
1
vote
3answers
85 views

Is there any way to print value inside variable inside single quote?

Consider I've set variable site and needs to be printed by echo or printf, but If I use single quote to write something and want to use variable then how? Example: $ site=unix.stackexchange.com $ ...
1
vote
2answers
45 views

How to use multiline as group-separator in grep?

In grep you can use --group-separator to write something in between group matches. This comes handy to make it clear what blocks do we have, especially when using -C X option to get context lines. $ ...
1
vote
2answers
52 views

about executing a python program in a shell script which is scheduled on crontab

i have a problem with regards on crontab. I have a script named checker.sh and i want to schedule it that would run every minute: * * * * * sh /home/pi/checker.sh so i have the script here: the ...
0
votes
2answers
45 views

How to find and replace only a particular word (which is at the end of the file) using shell command?

File1: Dms 01.01.2015 feeder1 6kv close at 04:30 Updated Dms 01.01.2015 feeder1 6kv open at 06:20 Updated Dms 04.02.2015 feeder10 6kv close at 17:23 Updated Dms 04.02.2015 feeder12 6kv ...
7
votes
1answer
87 views

Cannot cd into a directory, no visible problem

I've tried searching and couldn't find a similar scenario. I have a directory into which I cannot cd: # cd /var/log # cd apache2 bash: cd: apache2: No such file or directory # ll -d apache2 ...
5
votes
3answers
365 views

Why does this one-liner fail to produce output? [duplicate]

The following produces nothing in bash: while true ; do upower -d ; sleep 1 ; done | grep percentage | uniq I've discovered that it doesn't matter what the last- or even the second to last- program ...
5
votes
2answers
378 views

Read multiple lines from text files in bash

When I am shell scripting, the majority of what I am doing is wrapping the I/O of other modules in python, matlab, etc. To do so, I usually use text files or something of that nature with the ...
2
votes
2answers
118 views

How do you add a bash script to your PATH variable using symlinks?

I run a gaming server called PocketMine. So basically I have a folder in my home directory that has a bash script to run the server: ~/PocketMine/start.sh Everytime I want to run the server I either ...
3
votes
1answer
112 views

what is the use of “export” command

I created a environment variable in one terminal window and tried to echo it in another terminal window. That displayed nothing. $TEST=hello After that I exported it and tried again to echo it in ...
0
votes
1answer
47 views

How to use output from openssl encryption routines in a pipe?

openssl manual claims that openssl enc uses standard output by default. But something is not right with the standard output when decrypting a file. Piping the output to any application such as grep, ...
5
votes
3answers
204 views

How to display commands in a different terminal?

I have a raspberry pi with a screen attached to it. It boots up to a login prompt. I have no keyboard and no mouse attached to it and would like to keep it this way. I proceed to login to it via ssh ...
1
vote
2answers
64 views

Rename file containing spaces and punctuation marks

Someone in our Global Linux 3.0.31-0.9 server has put a file with several spaces, parenthesis, question mark and a colon in its name. And I am at my wit's end to rename or remove it! Sample of the ...
3
votes
3answers
117 views

How to set HOSTNAME in zsh?

In bash, which sets $HOSTNAME for you, I was able to calculate the total length of prompt line simply by using something like: PS1_length=$((${#USER}+${#HOSTNAME}+${#PWDNAME}+12+${#PS1_GIT})) It was ...
0
votes
2answers
52 views

Adding a new directory to PATH vs. a symlink for directory already in PATH

In setting it up so I could execute Sublime Text from bash, I discovered two methods of doing this via different tutorials: Method 1) Create a symlink from /usr/local/bin/subl to Sublime's bin dir: ...
7
votes
4answers
642 views

Why doesn't SIGKILL terminate a stopped program (yes)?

I'm using Ubuntu 14.04 and I'm experiencing this behavior I can't seem to understand: Run the yes command (in the default shell: Bash) Type CtrlZ to stop yes Run jobs. Output: [1]+ Stopped yes ...
-3
votes
1answer
70 views

What command would I issue in order to complete this question?

So I have tried over 10 different attempts and I'm just stumped Here are two inverted-tree diagrams. Issue a command to change the left diagram to the right diagram. Assume that you are in your home ...
1
vote
1answer
64 views

piping commands after a piped xargs

HP-UX ***** B.11.23 U ia64 **** unlimited-user license find . -type d -name *log*|xargs ls -la gives me the directory name(the ones which contain log in the directory name) followed by all files ...
1
vote
4answers
91 views

Unix bash/ksh : Selection of first non space character from file from specific line

I have file file1.txt whose contents are as follows: Date List ----------- Quarter Date Year Date Month Date Now I want to read the non space elements from each row of ...
1
vote
1answer
63 views

Recover deleted commands from history?

If someone were to delete commands from the shells history, is there any way to recover those deleted commands in Linux?
5
votes
8answers
642 views

How do I delete the first n lines and last line of a file using shell commands?

I have a file named Element_query containing the result of a query : SQL> select count (*) from element; [Output of the query which I want to keep in my file] SQL> spool off; I want to ...