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
2answers
10 views

VNC/SSH: How to execute a command after logging in?

I'm looking for a way to create a VNC console user that executes the command screen or bash immediately after logging in so they get their own restricted shell for executing commands etc. Screen/bash ...
0
votes
0answers
42 views

Need to have password coded in script [duplicate]

I have to login many Servers day in day out by supplying passwords manually. Now I want to know or have a script where from I can login to any server without password (I mean to say if the ...
0
votes
1answer
40 views

shell script unable to set environment variable with the grepped value

In the shell script, I want to grep a value from the log file and set as the value of one environment. In the log file, there is one line like this: SOME_PATH=/some/specific/path In my shell ...
1
vote
1answer
44 views

Cut some fields from a text file to another

I have the following command: grep -owf champs.txt t.txt and I want to cut the result of this command from the file t.txt to another file. I know that it can be achieved by a nested command but I ...
61
votes
9answers
17k views

How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)?

How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory: tohru:~ $ ls -l total 8 -rw-r--r-- 1 me ...
4
votes
2answers
2k views

Forward SIGTERM to child in Bash

I have a Bash script, which looks similar to this: #!/bin/bash echo "Doing some initial work...."; /bin/start/main/server --nodaemon Now if the bash shell running the script receives a SIGTERM ...
1
vote
1answer
68 views

Cannot change bash shell in Mac OS X

I'm trying to update bash shell on my Mac OS Mavericks. $ brew install bash $ which -a bash /bin/bash /usr/local/bin/bash $ which bash /bin/bash $ chsh -s /usr/local/bin/bash $ which bash /bin/bash ...
1
vote
2answers
79 views

check if a variable is in list

to check if a word is in a list of words or no I wrote this script: tr -s '[[:blank:]]' '\n' < t.txt | while IFS= read -r word; do if [[ "$word" =~ $(echo ^\($(paste -sd'|' ./champs.txt)\)$) ...
5
votes
4answers
237 views

Change the time zone of a cronjob

I have a cronjob which is executes every day at 9:00 AM of UTC-Time. I'm in GMT+1 so it executes at 10:00 AM local time. When there is the timezone change (to daylight saving time, DST), the cronjob ...
-2
votes
1answer
95 views

Sqlplus: Command not found

I have two virtual machines ubuntu, one is a server when I installed oracle 11g express, and the other is a simple client. My goal is to run an sql query remotely from the client machine. So I ...
21
votes
12answers
8k views

Object-oriented shell for *nix

Preface: I love bash and have no intention of starting any sort of argument or holy-war, and hopefully this is not an extremely naive question. This question is somewhat related to this post on ...
5
votes
2answers
341 views

Object oriented Unix shell with at least LINQ capabilities?

Well, "at least" is rather -- it would be perfect ;-) There is similar question -- Object-oriented shell for *nix . For me similarity with bash is no issue. I would like to have some simple OOP plus ...
37
votes
5answers
52k views

How to monitor CPU/memory usage of a single process?

I would like to monitor one process's memory / cpu usage in real time. Similar to top but targeted at only one process, preferably with a history graph of some sort.
1
vote
1answer
43 views

Given a *nix command, how do I find where the executable is? [duplicate]

There is a command written in bash I found from documentation from people who previously worked in this project. Now I need to locate the command's source and modify it. I tried which my_command ...
1
vote
4answers
52 views

Sed substitution grouping is appending in OSX rather than the expected sub in Linux

I've got three comma separated columns. Last name, First name, social. I'm trying to capitalize all characters in the last name column using sed 's/\([^,]*\)/\U\1/' foo.file In osx this command ...
1
vote
3answers
98 views

Bash long string, no word splitting?

I want to tidy up some script with long commands, so that for example: { somecheck || somecomand "reallyreallyreallyreallyreallyreallylongstring" } &> /dev/null & becomes something like: ...
0
votes
2answers
45 views

How to search recursively in a directory for different files?

I have a x.tar file in directory /a. After untaring x.tar I got the following result: cust/ cust/01/ cust/01/INFENG/ cust/01/INFENG/scr/ cust/01/INFENG/scr/test.scr cust/01/INFENG/SQL/ ...
5
votes
2answers
455 views

How can I make xargs play nice with stdin?

$ seq 1 3 1 2 3 $ seq 1 3 | xargs echo 1 2 3 $ Mentally replace seq 1 3 with any command that lists entries one-per-line on standard out. How can I get more-or-less what you'd expect, i.e. the ...
9
votes
3answers
1k views

Why does “$(( ~33 ))” produce -34?

$ echo $(( 255 )) 255 $ echo $(( 33 )) 33 $ echo $(( ~33 )) -34 $ echo $(( ~255 )) -256 $ and my kernel is: $ uname -a Linux HOSTNAME 3.2.0-40-generic-pae #64-Ubuntu SMP Mon Mar 25 21:44:41 UTC ...
62
votes
15answers
62k views

How can I get distribution name and version number in a simple shell script?

I'm working on a simple bash script that should be able to run on Ubuntu and CentOS distributions (support for Debian and Fedora/RHEL would be a plus) and I need to know the name and version of the ...
2
votes
3answers
78 views

bash: error handling on find -exec

I was using this little script to find malformed images: find -name '*.jpg' -exec identify -format "%f\n" {} \; 2>errors.txt It worked well enough, but now I need to modify it slightly. Instead ...
1
vote
0answers
23 views

What Does the Output of “--help” Mean? [duplicate]

When using the --help option of a terminal program, a lot of output is produced. It usually starts with Usage: and then a bunch of things and brackets and parentheses. My question is, what doe the ...
1
vote
1answer
56 views

Running some parts of a script as an unprivileged user with shell environment

I am creating an instance configuration script that sets up a machine. I am running the script via sudo i.e. sudo run.sh. Most of the steps require root access but some of the script's steps do no ...
2
votes
1answer
48 views

Bash - Command substitution adds single quotes

I have a problem with bash behavior while evaluating grave accents. I want to run find with optional -name: find -name "*.log" works fine, but when i want to get the -name part from nested script ...
0
votes
0answers
43 views

Counting program fails in arithmetic test

having a little trouble with this rather basic script. This script works on Bash in my macbook pro, but not on my Linux Mint desktop, which also uses bash. I can't figure out what's wrong with it, ...
0
votes
1answer
47 views

Print file name,Modified Date and Size with Header

How do I print file size, file name and modified date with header.Till now I have come up with: find . -regex '.*\.csv' -execdir stat --printf '%n,%y,%s' {} \; How to add header and do not print ...
28
votes
2answers
780 views

find(1): how is the star wildcard implemented for it to fail on some filenames?

In a file system where filenames are in UTF-8, I have a file with a faulty name; it is displayed as: D�sinstaller, actual name according to zsh: D$'\351'sinstaller, Latin1 for Désinstaller, itself a ...
2
votes
1answer
36 views

Syntax When Combining dd and pv

I am a linux newbie; so, sorry if this is obvious to you... sudo dd if=/dev/sda bs=64k | pv --size 1.5t | dd of=/dev/sdb Does the block size for dd go on the left side of this after the input as ...
14
votes
8answers
759 views

Suggested setup for an ultra-lightweight text-based programming environment in linux

I am looking for suggestions for a setup for my particular needs. I haven't done much linux since college and want to get back into it as a hobby. I have some not-too-powerful hardware (512 MB ram, ...
16
votes
8answers
35k views

List only regular files (but not directories) in current directory

I can use ls -ld */ to list all the directory entries in the current directory. Is there a similarly easy way to just list all the regular files in the current directory? I know I can use find find . ...
1
vote
1answer
47 views

How to recover a shell script I deleted from a specific folder in Debian 7?

So in a merry mood last night, I deleted an important shell script from my system. I mistook it for something else and figured it wasn't needed. I am trying to recover it. I have tried 'scalpel' and ...
1
vote
0answers
61 views

gdrive -bash: /usr/bin/drive: cannot execute binary file

I am processing hundreds of image files on a weekly basis and gdrive would be perfect for automatically making duplicate copies of the raw images for archive before the originals go through the ...
18
votes
4answers
2k views

How to know the “level” of shells I am in?

If I open a terminal like xterm I will have a shell. Then if I use ssh or zsh I will have another "level" of shell. Is there a way to know how many times I have to Ctrl+D or type exit to exit all of ...
4
votes
2answers
112 views

My /var/log/ is mysteriously filling up GBs in minutes! Any cure before I re-install Debian 7?

Good morning, fellow *nix enthusiasts! I have been using Debian 7 for a while now and after a recent upgrade I noticed I constantly kept running out space on my root partition. I mean to the point ...
1
vote
2answers
30 views

Background processes mix up order of shell script execution

Can someone explain me why the script echo one && echo two & echo three && echo four gives me [1] 3692 three four one two [1]+ Done echo one && ...
1
vote
2answers
30 views

Problem with using expr

I've got two strings str1="( 1 + 2 + 3 + 4 + 5 ) / 3 + 5" and str2="( 1 + 2 + 3 + 4 + 5 ) / 3 + 5 * 2" The command result=` expr $str1` returns a correct value, while result=` expr $str2` ...
0
votes
0answers
11 views

What shell extension recommends packages if command is not found and how to update it? [duplicate]

I know this question might sound a little strange but i really don't know how to describe it better. On my Debian system I have a shell extension for bash that, whenever I enter an unknown command, ...
1
vote
1answer
65 views

Running every command through another

I'm setting up a system in which any external command that does something with real effect must be crypthographically signed before before the system will execute them. The restrictions are in place ...
0
votes
5answers
119 views

Read File word by word

My problem is to read a text file word by word and recovers every word in a variable. I tried to do: while read ligne; do { for ( i=1; i<= length ($ligne); i++); do { var=$(awk '{print $i}' ...
3
votes
3answers
14k views

Pass command line arguments to bash script

I am new to bash script programming. I want to implement a bash script 'deploymLog', which accepts as input one string argument(name). [root@localhost Desktop]# ./deploymLog.sh name here I want to ...
0
votes
0answers
23 views

Is there a way to add a timestamp to the logs for qsub job?

I'm submitting jobs on a cluster via qsub but the error/output logs don't have a timestamp, making debugging more difficult. Is there a way to add timestamps to the logs in the bash script? Appreciate ...
0
votes
3answers
49 views

copy the contents of a variable in a text file

I know this is a stupid question but I want to know how I can put the contents of a variable in a text file. This variable is a string that I want the code with the base64 command.But this command ...
1
vote
3answers
2k views

How to run a Python script in Makefile

I want to write a Makefile to find specific files and run a Python script on each file. The Python script accepts sys.stdin input. find $(W)/$(OVE) -name "*.xml" -print | \ while read x ; do \ cat ...
3
votes
3answers
452 views

Including sub-parameters in help options to execute wisely without getopt or getopts?

I am writing a script which can choose a file and print specific content. For example, san#./script.sh Expected Usage : ./script.sh --file1 --dns (Here it checks for file1, search for dns name and ...
1
vote
4answers
1k views

Tail -f the most recent log file

In a few spots I got this to work ls -rt /path/to/log/file/ | tail -1 | xargs tail -f But I can't figure out why it won't always work (This is quick fix until I get the log rolling fixed here)
1
vote
1answer
44 views

shell script for date checking between two days

There is date in my file, like 30-apr-2015. How can I compare this with the current date and get notified if they are equal?
-1
votes
1answer
41 views

Replace mutiple strings with different values in a file using unix [duplicate]

I have a file in which the data is like below, 01,0000000,xxxxxxx/ 02,xxxxxxxx,yyyyyy/ 03,test1,41203016,,/ 01,0000000,xxxxxxx/ ...
3
votes
2answers
72 views

Why can't I load modules while executing my bash script, but only when sourcing it?

I am using modules to control the packages on my system and I have python/2.7.2 installed as a module. I have simple python executable python_exe.py which I am going to call from a simple 'driving' ...
1
vote
1answer
1k views

Deleting Non-empty Directory with smbclient

How can I remove a non-empty directory with smbclient? I have tried the following: 1) rm Result: NT_STATUS_NO_SUCH_FILE listing [dir_path] 2) recurse;rm Result: No Error but also nothing ...
0
votes
5answers
45 views

I want to design a scipt to send alert for Swap usage more than 85%

cat /proc/meminfo | grep Swap SwapCached: 460248 kB SwapTotal: 8388600 kB SwapFree: 1031900 kB I want to use this information to compare it with a threshold ...