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)

1
vote
2answers
60 views

Linux shell that allows you to choose from tab completion

This is an odd question, and I don't have a lot of information to provide but .. I recall seeing a Linux terminal that had a feature which allowed its user to choose between the options listed from a ...
3
votes
2answers
40 views

wait and recycling of PID

I have a concern whereby in a script, I will be calling parallel versions of a function to run in the background and then issuing a wait. a () { sleep $1 } a 10 & PIDs="$PIDs $!" a 50000 & ...
0
votes
2answers
110 views

How to remove a script tag from a text file with sed

I have a number of header.php files that have a malicious script tag contained within them (don't ask). I've written a not-so-elegant shell script to replace these with blank space. I had initially ...
3
votes
1answer
31 views

What is the purpose of the uucico shell on HP-UX, Solaris, and possibly other Unix varieties?

For my work, I review Unix and Linux server configurations for compliance with security guidelines. So I'm not a Unix admin myself, but I work with Unix servers on a regular basis and am fairly ...
0
votes
1answer
18 views

bash-like last command in history using up-down arrow keys in zsh [duplicate]

In bash, we can use the up and down arrow keys to get the last or nth previous command in history. Can we do this in zsh?
2
votes
2answers
55 views

Set awk array on command line?

I know the -v switch can be used to awk on the command line to set the value for a variable. Is there any way to set values for awk associative array elements on the command line? Something like: ...
7
votes
5answers
119 views

What's wrong with this for loop in bash script?

I am trying to print a simple value for $AR1_p1 but the variable $i is not evaluating. for i in 1 2 3 4 do AR1_p1=22 AR1_p2=23 AR1_p3=24 AR1_p3=25 echo $AR1_p$i done It's like concatenating ...
-1
votes
0answers
12 views

List all files in USB device from /Volumes shell script [duplicate]

To clear things up I have setup folder actions on my mac for whenever a USB device is plugged into my mac it will run a shell script. When I list all files in the Directory /Volumes i get $ ls -a . ...
0
votes
1answer
23 views

regarding recursive deleting of a specific file type

I wanted to delete a specific file type say *.bak file from any directory and its subdirectories. I used the following command to find the files. find <path> -name "*.bak" -type f However, ...
0
votes
3answers
41 views

How to put variable in for loops? [duplicate]

for seq in {046725..046899} do #body done Above segment of code runs beautifully keeping preceding zeroes in seq variable but why following code segment doesn't run? Is there any way? I need seq ...
3
votes
3answers
171 views

move middle part of filename to front

I have files named in the style 02.04.11 DJ Kilbot.mp3 (for several dates) and I want to reformat the name in this manner: DJ Kilbot 2011-02-04.mp3. In other words, the current format is MM.DD.YY ...
1
vote
3answers
36 views

What does the option -9 mean for killall?

I saw the command killall -9 but there is not such a option in the man page. So now I'm a bit confused: what does -9 option mean?
0
votes
1answer
29 views

Kill process with timeout

I want to start a programm with timeout, how can I kill the process using SIGINT and SIGKILL? If the programm not terminate within 5 seconds, send SIGINT. If it’s still running after 10 seconds (in ...
-1
votes
1answer
29 views

How is a trace of commands different from shell input lines?

I am unclear about two options when invoking a bash shell process or for set: -v Print shell input lines as they are read. -x Print a trace of simple commands, for commands, case commands, ...
3
votes
3answers
42 views

How to treat numbers starting with zeroes as decimal integer

Input would be file name like following : A-B-000001-C A-B-000002-C ..... ..... A-B-999999-C All file should be sequential. I want to find missing sequential file names. For this I'm separating 6 ...
0
votes
1answer
37 views

Get the external IP address in shell without dig in 2016?

This question: "How can I get my external IP address in bash?" Solves the question with a call to dig: dig +short myip.opendns.com @resolver1.opendns.com; that is the fastest resolution possible, ...
0
votes
2answers
35 views

Use a shell variable with Awk

I have this: if [[ $1 = "-c" ]] && [[ $2 =~ ^[a-z A-Z]+$ ]] then awk -v var="$2" '{print $2}' something.txt fi What I want is with a comand like -c abc to show the lines in something.txt ...
0
votes
1answer
20 views

How to set up a pre-defined variable with multiple directory paths to use with the find command

I am looking to have a script delete files that are older than 90 days in certain directories. As in, there are 8 directories that have different paths to them. I can run the find command on one ...
0
votes
1answer
32 views

Parenthesis on echo shell command

I have this echo command: $ echo "alias notepad++="C:/Program\ Files\ "(x86)"/Notepad++/Notepad++.exe"" >> ~/.bashrc As shown in the picture it does not recognize the parenthesis.
8
votes
4answers
176 views

dirname and basename vs parameter expansion

Is there any objective reason to prefer one form to the other? Performance, reliability, portability? filename=/some/long/path/to/a_file parentdir_v1="${filename%/*}" parentdir_v2="$(dirname ...
10
votes
4answers
813 views

Why doesn't echo called as /bin/sh -c echo foo output anything?

For example, while this works: $ echo foo foo This doesn't: $ /bin/sh -c echo foo Whereas this does: $ /bin/sh -c 'echo foo; echo bar' foo bar Is there an explanation?
2
votes
2answers
53 views

SOLVED: Shell Script cant run man command

I have a script that runs commands & takes a screen shot. I want the man file to display & grab a screen shot of it. My script works for the commands alone but if I add "man " before the ...
0
votes
2answers
43 views

How to delete a line with a given word using SED function

I have a file .txt with inside ID VALUE test value_1 testing value_2 first value_3 second value_4 I'm trying to write a shell script which will delete a line corresponding to a ...
0
votes
1answer
27 views

How to run command after entering postgres

I am trying to execute ls after opening a new Guake tab and logging into postgres. guake -n guake -e 'sudo -i -u postgres && ls' The command successful opens a new tab then prompts me for ...
0
votes
0answers
20 views

How do I execute a command if a drive is not mounted?

I am trying to create a shell script to mount a LUKS volume if it is not already mounted. The LUKS password will be in the shell script. The shell script is being stored in a encrypted folder so it is ...
0
votes
2answers
63 views

How can I use fdisk to create a ntfs partition on /dev/sdx?

I would like to know how to create a ntfs partition on /dev/sdx. I could not figure out if I should use partition type 7 86 or 87. What is the full list of commands to use?
1
vote
1answer
38 views

How can the read/write speed of a partition or drive be measured? [duplicate]

How can I preferable from the terminal measure the read and write speeds of /dev/sdx?
0
votes
1answer
23 views

Update phpmyadmin config.inc.php file in bash

When you download and extract latest phpMyAdmin, it comes with a config.sample.inc.php file. I would like to set a random blowfish_secret value on this line: $cfg['blowfish_secret'] = ''; /* YOU ...
1
vote
0answers
26 views

'Chain' shells' profile and runcom files?

While setting zsh up, I found a post stating that to keep a .zshrc as clean and backwards compatible as possible, one can 'chain' the shells' configuration files. If I recall, it consists more or less ...
14
votes
3answers
503 views

How to convert an emoticon specified by a U+xxxxx code to utf-8?

Emoticons seem to be specified using a format of U+xxxxx wherein each x is a hexadecimal digit. For example, U+1F615 is the official Unicode Consortium code for the "confused face" 😕 As I am ...
1
vote
3answers
60 views

Renaming thousand files with similar names

I'm having a difficulty creating a bash script to rename my files,so i'm asking for help. The files are in the same folder and all look something like this 1xxx_(bunch of characters)=(bunch of ...
0
votes
0answers
22 views

How does GUI works different from the shell CLI?

For example if I want to remove a file I would write rm command in my shell CLI. But when I delete a file using GUI how does the process works ? For shell it would find the filesystem for rm program ...
1
vote
3answers
47 views

Is it safe to disable shell access to all users listed in /etc/passwd?

I have just read about how to disable shell access for users in Ubuntu in this post for security reasons. Is it safe to disable shell access to all users listed in /etc/passwd except the root:x:0:0 ...
2
votes
1answer
36 views

Cancel an option used in aliased command?

Suppose for example, the following implementation of ll: alias ls="ls -F -G" # colourise and display dir,exec,etc. icons alias ll="ls -l -h -o" # long-list, use KB,MB,etc. sizes, no ...
2
votes
3answers
139 views

get environment variable by variable name? [duplicate]

For example, I have a variable: env_name="GOPATH" Now I want to get the environment variable GOPATH as if like this: echo $GOPATH How can I get $GOPATH by $env_name?
0
votes
2answers
62 views

mv: No such file or directory error even though directory most certainly exists

I am attempting to do the very simple task of moving file.gz from /home/username/Downloads/file.gz into /mnt/gentoo/proc/ When I issue mv /home/username/Downloads/file.gz /mnt/gentoo/proc/ it returns ...
0
votes
1answer
24 views

Whatis command (shell builtin vs executable programs)

I know that whatis command is used to output a brief description about an executable program (Command). So both whatis cd whatis type Will print: nothing appropriate (Because from my ...
-2
votes
1answer
24 views

insert patterns into text file after the last line [closed]

I use below codes to insert the lines after specific line into text file w.r.t. the user's variable. echo -n "WHICH STATIONS?" read station echo ${station[${i}]} awk -v input="$station" ' BEGIN { ...
3
votes
2answers
328 views

The type command can't distinguish between an executable command and a shell script

So I was reading the book The Linux Command Line, and it says that commands are of four types: (1) executable programs (2) shell builtins (3) shell functions (shell scripts) (4) ...
1
vote
1answer
38 views

Bash : ambiguous redirect

I am trying to collect dump of java process with jstack and I have tried below command. But its saying ambiguous redirect as I cant redirect to a command. jstack -l `pgrep java` > ...
0
votes
0answers
31 views

ubuntu Crontab not running properly

I have to run crontab in xvfb display mode forever when the system restarts...below is crontab code.... @reboot nohup Xvfb :1 -screen 0 1024x768x24 & export DISPLAY=":1" @reboot /usr/bin/forever ...
-4
votes
1answer
51 views

How to transform row to collumn in csv file?

2015-12-2119:30:00;ManagedElement=1,Equipment=1,Subrack=1 ;pmEs ;0 I need this result 2015-12-2119:30:00;ManagedElement=1,Equipment=1,Subrack=1;pmEs;0 Extra data from comment: 2015-12-21 ...
8
votes
2answers
141 views

Variable assignments affect present running shell

While writing some code I found out that this line: $ TZ="America/Los_Angeles" date; echo "$TZ" Thu Dec 24 14:39:15 PST 2015 Correctly gives the actual time at "Los Angeles" and that the ...
2
votes
2answers
33 views

rename of file extension doesnt work [closed]

I'm using code like the following to create a logfile using the shell's string manipulation tools: I have a file name and, in the case of an error, I need to create a log file with the err. Suppose ...
5
votes
3answers
105 views

How can I wrap variable expansion in quotes?

My bash script looks like this: #!/bin/bash set -x ./test FLAGS=${@:2} And when I run ./script 1 2 3 the command that is executed is ./test FLAGS=2 3. I want FLAGS="2 3". When I change the ...
3
votes
1answer
49 views

ls & dircolors - differentiate between symlink to directory and symlink to regular file

Is it possible to have the colors for symlinks-to-directories be colored differently than other symlinks? I know I can do: Link target to get the symlinks to take the color settings of their ...
-1
votes
2answers
60 views

why can I see the directory without “read” privilege?

now i am user "lawrence.li" ,I can see directory "lijunda" with "read" privilege but now i have no "read" privilege,why can i still see this directory? I am confused that what is the difference ...
5
votes
8answers
400 views

Generate two sequences of numbers separated by “|”

I'm using bash (CentOS 5) and looking to generate this output (I assume I could use seq or echo together maybe?): 1|1, 2|2, 3|3, .... 31|31, 32|32, 33|33, I googled seq examples for over two hours ...
4
votes
2answers
46 views

Redirecting bash loop output to variable specific files

this should probably be obvious to me, but I've been stuck for some time. I'm trying to write a very simple bash loop to take a list of servers, retrieve some specific info from them, and save the ...
0
votes
0answers
89 views

How do you open Wireshark's Legacy (GTK) By Default?

I've recently updated Wireshark on OSX El Capitan from 1.12.0 to 2.0.0. The newer stable release uses the Qt interface instead of the old X11 but the new UI is a lot buggy for me and I want the old ...