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)

13
votes
1answer
201 views

Update bash history on others terminals on exit of one

I know this question has a similar interpretation, as its asked here keep updating (and duplicated here). But what I'm trying to achieve is a bit different. I don't like the idea of my prompt ...
0
votes
1answer
47 views

Issue a command in each directory

I have 3 directories: dir1 contains two subdirs. In every subdir there is a slackbuild. I want to build all slackbuilds, staying in the parent directory. I have tried (cd *;sh *ld) But it only ...
0
votes
2answers
59 views

How do you search ! in man sed?

You cannot search ! directly because it puts process behind. For instance, you cannot search ! in sed man. How can you search ! in man?
2
votes
1answer
77 views

Convert IP Address to Coordinates using database

I have a file which contains IP and I wanted to compare it to Coordinates using a local database (instead of API). I tried following a process and break down to pieces and created scripts referring ...
0
votes
1answer
48 views

Practical usage of “shift” shell builtin command?

I checked the /usr/bin/ssh-copy-id(part of openssh-client package at least under Debian) shell-script and it contains following if-statement: if [ "-i" = "$1" ]; then shift # check if we have 2 ...
2
votes
2answers
66 views

ssh command with quotes

I have an odd error that I have been unable to find anything on this. I wanted to change the user comment with the following command. $ sudo usermod -c "New Comment" user This will work while ...
5
votes
6answers
594 views

How do I check if a variable exists in bash?

I need to check a variable's existence in an if statement. Something to the effect of: if [ -v $somevar ] then echo "Variable somevar exists!" else echo "Variable somevar does not exist!" ...
1
vote
1answer
50 views

Move files from multiple directories to another system

Let's suppose I have a folders in the source system: AB1, AB2, AB3. And I have the same folder names AB1, AB2, AB3 in the destination system. I want to move AB1 files to AB1 and AB2 files AB2 and ...
1
vote
2answers
59 views

How do i search for certain sections of a file and then extract only relevant information within that section?

So I have a text file that is a server report and has about 1000 lines of information in it. I'm trying to write a script that can search the report for only certain pieces of information I'm looking ...
2
votes
4answers
221 views

locate alias with find

On small systems where there is no locate installed, How would an alias look like that gets the same result as locate? I can imagine find can produce the same output so an alias could look like ...
-3
votes
2answers
45 views

Transform text records using only a “for” loop

I have an input file that is text, consisting of lines that look like: 352|C|PAID|7036|VOICE|01-FEB-12 I need to split each line into fields at the | (vertical bar) characters and output each field ...
4
votes
2answers
47 views

How can I disable bash traces?

For any command that I execute in the terminal a comment like + command appears. For example for ls it shows + ls --color=auto.
3
votes
5answers
130 views

How to add column in the beginning of file using perl?

I want a Perl one-liner that checks whether the first fields of an input file is the file's name and, if it isn't, adds the file name as the first column on every line. Example written in shell : ...
0
votes
2answers
34 views

Does kali distro not use /etc/environments file?

I appended a path to /etc/environments file and now it is like so: mindaugas@Kali:~$ cat /etc/environment | tr ":" "\n" PATH="/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /sbin" I ...
1
vote
2answers
52 views

Unable to store ascii value in a variable

I am trying to convert hex to decimal to ascii and store it in a variable. I am using the following code. HEX=30 DEC=`printf "%d\n" 0x${HEX}` echo "$DEC" ASC=`printf \\$(printf '%03o' $DEC)` echo ...
-6
votes
1answer
46 views

Copying and relative Home

Your current directory is oxford. Make a copy of the file named outline.doc and place it into the sample_dir directory, using relative pathnames. I've attempted everything. sample_dir1 `-- ...
0
votes
1answer
41 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
82 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
72 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
29 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
26 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
106 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
74 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
81 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
55 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
88 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
94 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
97 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
51 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
136 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
53 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
69 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
149 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
38 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
32 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
226 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
95 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
113 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
86 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
46 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
55 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
47 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 ...