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
1answer
37 views

xterm not loading xresources properly

There are similar questions out there, however, I was not able to figure out the flaws in my .xinitrc file which causes .Xresources not to load. The respective .xinitrc #!/bin/sh [[ -f ~/.Xresources ...
1
vote
2answers
43 views

Syntax Error near Unexpected Token in a bash function definition [closed]

Forgive me; I'm pretty new to bash files and the like. Here is a copy of my .bashrc: alias k='kate 2>/dev/null 1>&2 & disown' function kk {kate 2>/dev/null 1>&2 & disown}...
1
vote
1answer
39 views

create listening port on IPV6 WITHOUT netcat

I wish to be able to listen to a port (eventually creating a bind shell) on an IPV6 address. I have tried using the netcat installed on the linux (debian) machine I am trying to bind. sadly it seems ...
0
votes
1answer
24 views

Copy folders has specific part of name and it is content

I have a long list of folder as follow: 001_bat_3513 002_mon_3213 003_bat_3515 004_btt_3540 005_bat_4513 055_bpt_8523 056_bot_3513 058_bat_1513 . . From this list: How can I copy the folders ( and ...
3
votes
5answers
361 views

When I redirect the output of ls to a file, the filename is included in that file. How can I avoid this?

Observe: $ ls $ ls > list $ cat list list This appears to indicate that when ls is executed that the redirection into file list has already begun and the list file is already created. A fine ...
0
votes
0answers
30 views

How To Create Soft Links To An Entire Directory Structure Which Has Sub-Directories, Files Etc! [duplicate]

I'd like to: Create a soft link for a directory or file. But have a scenario where I need to create soft links, to a directory which has multiple sub-directories, files etc. I wanted to loop across ...
1
vote
0answers
31 views

Save return value from a function in one of its own parameters

Function: Func1() { str1=$2 $1=$str1 } Call function: local var1 Func1 var1 "Helle World" echo $var1 I know this will work but I guess it's not very "pretty": Func1() { str1=$2 eval ...
4
votes
2answers
78 views

How to use a special character as a normal one?

Many questions like 'How to type the double-quote char (")?' are being asked, and we don't want to clutter our community with the same answer (Type it as \" if not enclosed in 's, " if enclosed in 's.)...
0
votes
2answers
33 views

How to delete files in directory

I have to delete one particular file in each directory. Can you help me with any shell script to do? Example: MKRUW, DKRUW, TKRUW In each of these directories I need to enter MKRUW/default/file and ...
3
votes
1answer
232 views

How to count occurances of phrase in grep, ignoring case?

I need to search for a name nicolas bomber with grep. Name can also be NiCoLaS BomBer. I need to run a .sh file which display the number of occurrences of that name. The command I made is this one: ...
1
vote
1answer
26 views

How to set which shell does Midnight Commander use?

As far as I know, Midnight Commander should be able to run different shells within it (the line second to the bottom). My question is, where/how can I configure which shell does mc use? Thanks!
2
votes
3answers
109 views

Writing an unlimited number of defined values into a file [closed]

I can use /dev/zero or /dev/urandom to write values into a file. Is there also a way to write an unlimited amount (just restricted by a command line switch maybe) of defined numbers (e.g. 1, 2, etc.) ...
0
votes
1answer
48 views

Script for automatic gateway switching

I have two network connections. If one goes down other should come up automatically how i can do it with a shell script in Ubuntu 12.04
0
votes
1answer
27 views

What is Alternative of initlog (present in RHEL5) but deprecated in RHEL6?

I am using initlog tool in a cron file to write the output of ntpq -p command in syslog.. But initlog command has been deprecated in RHEL6. Now, I want know the alternative of initlog command in ...
0
votes
0answers
20 views

Set variables into script before or after SCP [duplicate]

I have two scripts out and disk_check.sh. The main script is the out which exports multiple variables but I need two variables set in disk_check.sh which are: VOL and VM_VOLUME. So my out script ...
2
votes
2answers
237 views

Dropping a process into the background

If I have started a process, and it spends more time than I anticipated, and I regret not having said rm foo & rather than rm foo, can I do something to drop it into the background?
6
votes
1answer
103 views

Cannot exec /bin/false: no such file or directory

I'm trying to open GNU Screen with the following command on my Mac OS: host:~ user$ screen The screen terminal opens but quickly dies with the error message: Cannot exec /bin/false: no such ...
0
votes
0answers
25 views

alias defined in modulefile does not work in launched shell [duplicate]

I am trying to get aliases working on my company's number crunching machine, which uses the bash shell on CentOS 7. For software management, we use GNU modules. Some case set-ups for certain ...
0
votes
0answers
42 views

Removing directories: Shell vs. File Manager

I've noticed that some graphical file manages such as Thunar allow you to remove any directory as long as you are the owner of this directory -- even if this directory contains a sub directory which ...
0
votes
3answers
205 views

Check for process and kill if running

I am trying to find if a process is running or not, and if it is runing then I want to call a script or print something. I tried with the below few ways, but it gives me syntax error or command not ...
1
vote
1answer
37 views

copy a file to a destination with different names

I want to copy a text file to a directory with multiple names with curly braces: cp /path/to/file/a.txt /path/to/file/{b,c,d}.txt But it gives me the error: target '/path/to/directory/d.txt' is not ...
2
votes
1answer
85 views

Move all files into subdirectories named after beginning of file name

I have a directory that contains quite a lot of files with names made up of 8 random letters, numbers, _ and -, e.g.: 0dckGYH5.jpg 32Pz5-WQ.png 32_17pxH.png Hsf4BQW9.jpg xh-fa3Nu.gif zYtBEaKA.png ... ...
0
votes
1answer
48 views

`source …/settings.csh` not working from `sh ./test.sh`

I want to source Xilinx ise setiin64.csh file with the source command. I have source /home/xilinx/ise_14.5/14.5/ISE_DS/settings64.csh in another file, test.sh. So I want to run only test.sh file ...
1
vote
1answer
48 views

is it possbile to add comma in this SQL?

I have a statement like this UPDATE `test`.`scores` SET id=1 name='kobe' score=99 WHERE id=1 name='kobe' score=100 UPDATE `test`.`scores` SET id=2 name='tmac' score=70 ...
4
votes
1answer
471 views

which bash is executing?

I think I have configured bash as shell, but why is this happening? My shell is bash: # ls -al `which sh` lrwxrwxrwx 1 root root 4 Jul 12 03:25 /bin/sh -> bash Error executing a script with ...
1
vote
2answers
95 views

what's the simplest way to increment the numbers in this string 01:02:99 in unix?

What is the simplest way to increment the numbers in this string 01:02:99? Expected output: 01:03:00 I'm hoping for a sed response, but I don't think it would be simple.
2
votes
2answers
30 views

finding a folder names based on list contained in .txt file

I have a .txt file containing 150 different ID number on each line like so: 12345 15876 19643 12586 Located in the same directory as the .txt file, I have 300 folders and I want to copy only the ...
2
votes
2answers
50 views

Bash function comments before or inside the function [closed]

Does the Bash language have a standard that dictates whether comments about the function should precede the function or be placed inside of it. I have seen scripts written both ways. # Comment ...
1
vote
2answers
26 views

Mail one liner to check if null before sending [duplicate]

I'm trying to modify a script which emails a user group the contents of a directory. The modification I'm looking for is to check the script below to see if it has valid output before sending. The ...
0
votes
1answer
36 views

Why does my terminal say I'm running -bash (with a leading dash) and not bash?

I have recently started learning UNIX for a week or so and I've played around with the bash_profile and bashrc files to add in some basic preferences. But today, I couldn't execute several terminal ...
3
votes
2answers
101 views

How can I start several processes with a single command?

I use pianobar player. But before launching it I need to run tor and polipo. Both are continuous (are running until interrupted). Basically what I'm looking for is a single command which would spawn ...
1
vote
2answers
96 views

Escalate permissions through a background shell script

I would like to write to a Device File (of a printer) located at /dev/usb/lp0. The file is owned by lp user and group. This file is created whenever I connect my printer device to the system. I ...
4
votes
3answers
105 views

How to print same lines multiple times with variables changed using Sed/Awk/ anything?

a. Have set of lines as given below. cr_v8_sel0 : cross cp_v8_en, cp_sel0 { ignore_bins ig_v8_sel0 = binsof(cp_v8_en) && binsof(cp_sel0) intersect {[0:3],[5:$]}; } b. I wanted to print ...
3
votes
0answers
114 views

How can I run 'ls' with options from a C program? [migrated]

I want to execute the command ls -a using execv() on a Linux machine as follows: char *const ptr={"/bin/sh","-c","ls","-a" ,NULL}; execv("/bin/sh",ptr); However, this command does not list hidden ...
0
votes
3answers
58 views

Delete last line of gz file

I need to delete the last line of gz file without uncompressing. The file has 500 lines. How can I do that? I have tried: gzip -dc "$files" | tail -500 | gzip -c > "$files".tmp But It doesn´...
3
votes
2answers
76 views

How to Run a command on all subfolders

If you have a series of sub folders (like from a to z) and want to run a command on each one of them (like dsmmigrate * & ) how do you do that? The manual approach would be, cd a dsmmigrate * &...
0
votes
0answers
55 views

What are the minimum required environment variables? [migrated]

I am writing a shell. With the execvpe system call, I can run a program and control its environment. What are the minimum values I need to pass through here? Alternatively, I understand that child ...
1
vote
0answers
23 views

convert windows path to unix path inside wine application command line

I'm running a windows application in wine, which executes configurable commands to run external applications (e.g. an diff editor to show differences between two source files). So these commands are ...
2
votes
2answers
68 views

bash:Syntax near unexpected error '(' [closed]

I am following a tutorial in computational microbiology: William Lindstrom, Garrett M. Morris, Christoph Weber, and Ruth Huey (2008-01-29). Using AutoDock 4 for Virtual Screening. Scripps Research ...
4
votes
2answers
131 views

Replacing only specific variables with envsubst

I'm trying to perform environment variable replacement through envsubst, but I want to only replace specific variables. From the docs I should be able to tell envsubst to only replace certain ...
4
votes
4answers
425 views

How to obtain grep exit status into a variable

I started learning Bash a couple of days ago. I'm trying to obtain an exit status of grep expression into a variable like this: check=grep -ci 'text' file.sh and the output that I got is No ...
1
vote
1answer
40 views

how to change contents of one column in a file?

I have a file that looks something like that: 1 mm10_rmsk exon 67108753 67108881 239.000000 + . gene_id "RLTR17B_Mm"; transcript_id "RLTR17B_Mm"; 1 mm10_rmsk exon 134217652 ...
2
votes
1answer
35 views

How to extract IP and URL from a log file

I have a long and generic squid log file. My boss is asking me to extract IP's alongside with accessed URLs. So far I can process IP's, but I need those IP's listed with the URLs accessed. Something ...
1
vote
2answers
42 views

Compute Sum Of Date

A third party script we use pulls information based on the number of minutes a certain job runs for. I need to enter this input in the script. E.g Here is an example export etool_start=`date +"...
0
votes
1answer
37 views

how to properly pass _set_ of parameters with spaces into shell function

My problem is not simple passing parameters with spaces (I know how to achieve that), consider more complicated case: function build() { make CC="$1" CFLAGS="$2" $* # $* is not correct here! } ...
2
votes
4answers
268 views

New line in variable

I want to create a config file with a .sh file. I can't figure out how i insert new lines. The code i already have: domainconf='<VirtualHost *:80>\n ServerName '$fulldomain'\n DocumentRoot '$...
1
vote
0answers
26 views

Should I quote variable when passing to command? [duplicate]

I always do this when passing variable to command mkdir -p "$dir_to_make" are those quotes needed? I tried to google but didn't find much. I always write them, just interested if they are necessary....
3
votes
1answer
214 views

How do I access a folder which I can't sudo cd into?

I'm trying to change my directory to /boot/efi, but running sudo cd /boot/efi does nothing. I'm on fedora 23. Is there a more powerful command for this?
1
vote
2answers
98 views

Merging contents of multiple .csv files into single .csv file

I want to write a script that merges contents of several .csv files in one .csv file, i.e appends columns of all other files to the columns of first file. I had tried doing so using a "for" loop but ...
3
votes
1answer
371 views

Delete all files with executable permission in a directory

I am in need of deleting all executable files from a directory. My directory contains some configuration files and executable files, and I need to delete all executable files that I don't want. For ...