The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks.

learn more… | top users | synonyms (1)

1
vote
3answers
693 views

Get default ubuntu motd in fish shell

I would like to have Ubuntu's MOTD in the fish shell. Ubuntu's default is as follows: That is essentially what I would like to see when open up my terminal (terminator, which loads fishfish) As ...
5
votes
2answers
443 views

modify path globally

Is there a standard for $PATH and the order of things that are supposed to be in there? out of the box Arch Linux doesn't have /usr/local/bin in the $PATH. I want to add it but I'm not sure if there's ...
1
vote
3answers
180 views

Finding lists of files with specific permissions

I looked into the find command and came up with find . -maxdepth 1 -perm 521 > test.txt to output the permissions to a text file, but is it possible to do it just using, for example, simple ...
1
vote
1answer
569 views

Outputting last modification date to another file?

I'm trying to read the number of lines in a file, and the last modification date of that file (e.g. if it was last modified Jan 18, 2013, it should output 2013-01-18), then append the data to the ...
7
votes
2answers
176 views

Difference between [[ $variable ]] and [[ -n $variable ]]?

In bash, are [[ $variable ]] and [[ -n $variable ]] completely equivalent? It appears to be the case judging by the output below, but I see both forms of usage prevalent in shell scripts. $ z="abra" ...
3
votes
4answers
367 views

mkdir -p for files

mkdir -p will create a directory; it will also make parent directories as needed. Does a similar command exist for files, that will create a file and parent directories as needed?
24
votes
4answers
1k views

Is there a one-liner that allows me to create a directory and move into it at the same time?

I find myself repeating a lot of: mkdir longtitleproject cd longtitleproject Is there a way of doing it in one line without repeating the directory name? I'm on bash here.
3
votes
1answer
491 views

Why does sendmail work differently in different shells?

The following code works when I directly run it in bash shell: SUBJECT="SUBJECT-"`date`; MAIL_FROM="abc@site.com"; MAIL_TO="abc@site.com"; MAIL_CC="abc@site.com"; MAIL_FILE="/path/of/html/body.html"; ...
1
vote
1answer
603 views

Installing a gedit plugin on Fedora

I have been trying to install a gedit plugin called RunC to compile C programs using the text editor. Although the instructions tell me to use ubuntu 9 or 10 for this, I'm currently running Fedora ...
3
votes
4answers
1k views

How to pipe the stdout to a file if the current command is already being piped through gzip

So I have this command I need to run then disown: innobackupex-1.5.1 --user=root --password=**** --stream=tar ./ | gzip - > /data/myfile.tar.gz How do I pipe any output to a file? adding ...
5
votes
2answers
1k views

bourne shell if [ -e $directory/file.$suffix ]

I've been looking inclusive I even checked the if manual for bash and tried in cli mode. #!/bin/sh CONFIG_DIR="/var/opt/SUNWldm/" read option if [ $option -eq 9 ]; then ret=1 elif [ -e ...
7
votes
3answers
255 views

OpenSSH - map aliases in ~/.ssh/config to IP addresses in command line

Is it possible to query ~/.ssh/config in the command line? Let's say I would like to retrieve what IP address does the particular alias point to in a separate program, is it possible?
4
votes
3answers
3k views

How to get subshell's PID in Korn Shell (equivalent of $BASHPID)

In bash you have this handy variable: $BASHPID wich always returns the currently running subshell's PID. How can I get a subshell's PID in ksh? For example see the code below: #!/usr/bin/ksh93 echo ...
1
vote
2answers
554 views

Parsing string by awk and get only elements without pipes or semi colons

I would like get this string line AUGUSTYN|Stanisław|3589238 without | and : I tried something like that: cat baza|grep "AUGUSTYN" -n|awk -F '|' '{print $1,$2,$3,$4}'` (baza is my file with ...
3
votes
1answer
147 views

No output from inotifywait | awk

I'm attempting to use part of a one-liner found here: Script to monitor folder for new files? When I try the following procedure I get no output whatsoever and I cannot figure out why. In terminal ...
8
votes
2answers
6k views

How can I handle raw binary data in a bash pipe?

I have a bash function that takes a file as a parameter, verifies the file exists, then writes anything coming off stdin to the file. The naive solution works fine for text, but I am having problems ...
1
vote
1answer
84 views

Unsure about the behaviour of my script when writing to log file

I have a very simple ksh script and at certain points I want to write to a log file. I use the following commands in two places... print "Directory listing 1:\n" > ${LogFile} ll >> ...
3
votes
1answer
1k views

What are special prompt symbols for busybox's sh support?

I want to setup a time prompt on PS1. But, there is no document about what are symbols the busybox support. Is there any one know? Here are all which I knew. PS1='\u@\h: \w \$'
3
votes
2answers
209 views

Setting a shell variable in a null coalescing fashion

I'm really fond of "null coalescing", where you can set a variable to the first "non-null" value in a list of things. Many languages support this, for example: C#: String myStr = string1 ?? string2 ...
3
votes
2answers
211 views

$BASHPID And $$ differ in some cases

I'm reading "BASH pocket guide of Oreilly". It said: The process ID of the current Bash process. In some cases, this can differ from $$. Above explanation , explained $BASHPID variable. ...
3
votes
3answers
461 views

Find functions, commands, and builtins [duplicate]

Possible Duplicate: Executing user defined function in a find -exec call Suppose I have the following bash code: !#/bin/bash function print_echo (){ echo "This is print_echo Function" ...
2
votes
1answer
220 views

Exit status ($?) of 148 upon Ctrl+Z

I just customized my .bashrc to include the exit status of the last command, so I get fancy prompts like ☑ larsmans@host:~$ and I no longer have to re-run commands to see their exit status because ...
7
votes
1answer
269 views

What is the significance of the dot in bash commands and how is it different from an asterisk?

I'm trying to understand the significance of the dot in bash and how it differs from an asterisk. Can someone please elaborate? For example, what's the difference between cp -ar /foo/. /foo2/ and cp ...
4
votes
3answers
131 views

Can any shell do argument-level interactive search?

Sometimes I need to reuse certain long arguments like paths. If I use history search (CTRL+R), I may find some command that contains the path, but I still need to delete anything else in the old ...
4
votes
2answers
2k views

Executing a shell script from remote server on local machine

Imagine a shell script on the remote server as #!/bin/bash rm /test.x How can I (if possible) to execute this script from my local machine to delete /test.x file on my local machine. Obviously, the ...
1
vote
1answer
113 views

What is the “~/” directory?

I'm trying to locate where some files are stored and I can easily browse to them via ssh by going to "cd ~/foldername", however, I have no idea what directory "~/" actually is. When I browse around ...
0
votes
1answer
119 views

How to delete number of lines from file repetitively

I've read How do I delete the first n lines of an ascii file using shell commands?, it is helpful. However I've a file something as below (please consider 2 columns as 2 different files): 1 4 1 4 1 4 ...
1
vote
2answers
4k views

Copy file from Windows shared folder to Unix

I am totally new to Unix. I am writting a script which will copy files from a Windows shared folder to Unix. In Windows, when I type \\Servername.com\testfolder in Run command I am able to see ...
2
votes
2answers
424 views

Changing tmux .bash_profile behavior

I have a script in my .bash_profile that prompts for X sessions to boot. When I launch tmux, I get this prompt that I had only intended for the TTY login. Is there something I can put in ...
5
votes
1answer
137 views

Can I add to my groups in the current (shell) process? [duplicate]

If I add myself to a group, it applies only to newly launched processes. Actually it's more restricted than that; it seems to apply only to new logins. I'm not sure what the exact mechanism is, but ...
1
vote
2answers
866 views

Can the UNIX command tree display only directories matching a pattern?

I'm trying to figure out if there is a way to get the UNIX command tree to display only directories that match a specific pattern. % tree -d tstdir -P '*qm*' -L 1 tstdir |-- d1 |-- d2 |-- qm1 |-- ...
3
votes
1answer
409 views

Need to improve urlencode function

I need a way to URL encode strings with a shell script on a OpenWRT device running old version of busybox. Right now I ended up with the following code: urlencode() { echo "$@" | awk -v ORS="" '{ ...
2
votes
1answer
199 views

Can I transfer running process from dead ssh [duplicate]

Possible Duplicate: How can I disown a running process and associate it to a new screen shell? I have started (as expected) a long copy process from ssh shell (putty) which died due to ...
2
votes
2answers
82 views

How to supress the display of previous job details?

When I run a process in the background the process ID gets displayed in the command prompt. For example: $ gvim 1 & [3] 9584 Now when I run another process the state of the previous one also ...
3
votes
4answers
4k views

programmatically creating a remote directory using ssh

Using a shell script, how can I create a directory remotely from serverA -> serverB using ssh? Can I pass the create directory command with the ssh command? How? I'm basically looking to create a ...
1
vote
3answers
483 views

What's the difference between these ways of accessing the shell?

From what I know it seems that there are many ways to access the shell on Linux. So far the methods I know are: To use a program such as Terminal or Konsole To use the shortcuts CTRL + ALT + F1-6 To ...
2
votes
2answers
114 views

What does this syntax mean “${i%.avi}.mp4” [duplicate]

Possible Duplicate: How do ${0##*/} and ${0%/*} work? I have encountered this type of syntax somewhere on the web : for i in *.avi do ffmpeg -i "$i" "${i%.avi}.mp4" done how does ...
1
vote
2answers
512 views

How to correctly concatenate strings in shells script?

I have a bash shell which I need to modify, and I have to set a variable in a script and then call another script. My variable, EXTRA_JAVA_OPTIONS must be -javaagent:myagent.jar="-d 0 -i 1000 -l log2 ...
2
votes
2answers
345 views

Get total size of jpeg images per directory in each directory containing jpegs

I'm trying to get a per-directory total size of all the .jpg/.jpeg images in each directory that contains such images. And showing the full directory path. I'm no bash expert but I've managed to ...
1
vote
3answers
164 views

Rerunning the same command with a different parameter

I know that I can run the following command ls Some{File,Folder} And it is equivalent to running this: ls SomeFile SomeFolder (I also use it a lot for things like mv place_{a,b}) However, I was ...
6
votes
2answers
4k views

/dev/tcp listen instead of nc listen

With a netcat listener like: nc -l <port> < ~/.bashrc I can grab my .bashrc on a new machine (doesn't have nc or LDAP) with: cat < /dev/tcp/<ip>/<port> > ~/.bashrc My ...
16
votes
3answers
5k views

bulk rename (or correctly display) files with special characters

I have a bunch of directories and subdirectories that contain files with special characters, like this file: robbie@phil:~$ ls test�sktest.txt test?sktest.txt Find reveals an escape sequence: ...
3
votes
2answers
285 views

Use variables in find command

mount |awk '{print $3}' --> list of mount points find "list of mount points" -name "aaa" -print How can I redirect the result from previous line into find command as searching directory? I would ...
0
votes
2answers
806 views

variables in find command and more shell problem [duplicate]

Possible Duplicate: Recursive rename files and directories I wrote the following script: #!/bin/bash SAVEIFS=$IFS alias export='export' IFS=$(echo -en "\n\b") find $1 -name "*" ...
1
vote
2answers
574 views

What is wrong with this call to sed -i?

I have this line find . -type f \( ! -name '*.plist' \) -and \( ! -name '*.mp4' \) -and \( ! -name '.DS*' \) -print0 | xargs -0 sed -i 's/AAA/BBB/g' my intention is from the current directory ...
15
votes
1answer
473 views

How does “man” restore the screen when I quit the program?

If I open a man page of a program like cat or ls, it prints (may not be the appropriate word) the contents of the man page and when I press q, it shows the screen just like before invoking the man ...
3
votes
1answer
155 views

How to scroll large datafile while keeping header

Suppose I have some large datafile, which overflow the screen in both vertical and horizontal direction. How can I browse this file, while the header-lines stay on the screen? For the moment, I am ...
3
votes
2answers
1k views

Creating a variable with sed in ksh

I'm using Ksh88 on a Solaris 10 machine. If I do the following: foo="one two three" for i in $foo; do echo $i; done The script executes as expected: $ ./script.ksh one two three However if ...
2
votes
3answers
1k views

Manipulate file name piped from find command

I'm relatively new to Bash and am trying to do something that on the surface seemed pretty straightforward - run find over a directory hierarchy to get all of the *.wma files, pipe that output to a ...
3
votes
2answers
1k views

Check whether files in a file list exist in a certain directory

The runtime arguments are as follows: $1 is the path to the file containing the list of files $2 is the path to the directory containing the files What I want to do is check that each file listed in ...