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
105 views

Replacing white-space / characters with backslashes

I want to convert a bunch of mkvs to mp4s with the following command: for i in $(ls *mkv); do ffmpeg -i $i -vcodec copy -acodec copy $i.mp4; done; However, the filenames have whitespaces and ...
1
vote
1answer
11 views

Any special permission ssh remote command working on fifo file(aka named pipe)?

I need to redirect some strings to a fifo file with ssh remote command, but always got permission denied, the command I executed is: ssh rundeck@nagios1 sudo su - root -c 'printf ...
0
votes
1answer
7 views

I'm trying to deploy with git to a semi-managed vps, need to write a script to change owners

I'm trying to deploy my sites on my company's semi-managed vps server using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps It ...
1
vote
1answer
23 views

Absolute path from user input without losing symlinks inside

Is it possible to convert in a shell script a user input path (absolute or relative) to the absolute path but without losing the symlinks inside, e.g. /a/b/c is the current user dir and c is a symlink ...
0
votes
3answers
34 views

How can I capture the common characters between two strings

I'm looking to compare two strings and capture the common part e.g. FILE0000010985.LOG FILE0000010999.LOG FILE0000011000.LOG If I compare 1 to 2, I want the output to be ...
0
votes
1answer
18 views

Generate SCP string

Generally when I am copying files from a local instance to a server, I find it difficult to generate the SCP string for the server to copy the files. I need to execute the following three commands ...
-1
votes
0answers
27 views

problem in AWK with Shell scripting [on hold]

Aim : I have 5 .CSV files namely 1. A.CSV 2. B.CSV 3. C.CSV 4. D.CSV 5. E.CSV I just want to copy the header column names from each file and place to another file named Header.csv . Code : ...
0
votes
1answer
18 views

find files with two types of extensions last modified over 30 days ago

I want to find all the files in a directory that have not been modified for at least 30 days and end in .xml or .out. This is my attempt to cobble together a couple of references to build the right ...
0
votes
3answers
30 views

Change Multiple (Including No) File Extensions

If I have a directory of files, where some files have an extension like .html and some files have no extension, how do I change them all to, e.g. .txt?
0
votes
0answers
52 views

How to password protect a file? [on hold]

I have the script called Linux.sh. I want it executable by every one. But in order to edit it should prompt for password.
0
votes
1answer
23 views

Which way is safer to read data from /sys

I am attempting to write a program that will monitor the temperature of various hardware components. The language I chose for it is Java. Now there are two ways I could read the temperatures: a) Do ...
0
votes
5answers
152 views

How to get current working directory? [duplicate]

I want to have a script that takes the current working directory to a variable. The section that needs the directory is like this dir = pwd. It just prints pwd how do I get the current working ...
1
vote
4answers
51 views

Completely buffer command output before piping to another command?

Is there a way to only execute a command after another is done without a temp file? I have one longer running command and another command that formats the output and sends it to a HTTP server using ...
2
votes
2answers
28 views

Why is a variable passed to the su command, but not an array from the same scope?

In the example below, why does $var get passed to the su in the start function, but not the array modules ? #!/bin/bash var=cat modules=( one two three four ) start() { su gleventh -c "for i in ...
0
votes
2answers
48 views

Why would the prompt get overwritten?

p_ash-3.2$ cp some_file1234.html /some/loc/ation/ofthe/some_file1234.html.html_Backu Have been seeing this intermittent issue with the command-line, while typing longer lines as part of any command, ...
1
vote
1answer
30 views

remove lines where a field's value is less than or equal to 3 - sed or awk?

I need to remove every line that has a value of 2 or less in the 8th field (column). My data looks like this: 12-31 Airport 189 379 41 49.70946503 -124.91377258 2 2880 30.8 01-01 ...
0
votes
0answers
23 views

convert from one memory format to another and find the difference between them

Using shell scripting, how can I convert from one memory format to another and find the difference between them? I want to compare current rate and previous memory rate (Where we need to compare ...
0
votes
2answers
17 views

How to search parenthesis by ack

I want to search for a parentheis ( using ack, but neither using ( nor \( worked. The first one ("(") is recognized as a multiple line command. The second one ("\(") is treated as an invalid regular ...
-2
votes
0answers
20 views

print character in specific rows and columns [on hold]

I have one file F1 having data Column 1 will represent character and column 2 represent multipliers (number of time a character suppose to be repeat). file 1 as input: A 2 B 4 C 4 D 6 ...
1
vote
1answer
54 views

how to locate a name-not-specified file in bash? [on hold]

I have a bash like this to easily upload a file to my server: FILE=../"$1"/1.txt scp 1.txt remoteserver #upload the file to a remote server. The $1 is for input directory and I have a lot of ...
15
votes
2answers
747 views

Renaming the current directory from a shell - possible?

Is it possible to rename the current working directory from within a shell (Bash in my particular case)? If I attempt to do this the straightforward way, I end up with an error: ...
1
vote
1answer
31 views

Specify the type of field to modify in a file

I have a list of clients, "code", "name", "location", "etc" and I want to make a function that asks the employee to give the client's code and then the field he/she wants to change. For example, ...
2
votes
3answers
49 views

Calculate date difference between Last modified date of a file and NOW using shell script

I am trying to calculate the time elapsed since the log file was last updated. I guess following commands will be used lastUpdate=$(date -r myLogFile.log) now=$(date) How can I subtract them and ...
3
votes
5answers
161 views

Pick the latest file based upon the sequence number given in the file name

I have a requirement, I have few files in a directory, I need to pick the oldest one for processing. For Exp: I have below files in /tmp directory: Sample_0000237826-001_xyz.dat ...
0
votes
0answers
10 views

sending NEDIT to background on launching

I have this problem - for opening nedit it will open in the foreground. Then either you open it using & ex- prompt> nedit & is there any way where I can open nedit directly in the ...
2
votes
4answers
49 views

space check on unix machines

I am having space issues on 1 of the UNIX servers. I am executing the below command to check the space utilization. But this command is very slow and takes hours of time to give the result. du -sg * ...
0
votes
1answer
22 views

Error with sed on MAC OS X invalid command u

Im french sorry in advance for my bad english... So i have an error on MAC OS X when im using sed sed -i '' '/user_pref("mail.identity.id1.reply_on_top", 1);/ a\ ...
1
vote
1answer
49 views

loop through multiple folders and perform commands then write to file

I have 10 folders that I want to loop through while executing the following command: awk 'FNR > 1' *.csv | sort -sk 1,2 | sort -sk 3,3 > ${f}_appended.dat With a for loop wrapper, like ...
1
vote
1answer
50 views

Shell script runs diffrently based on working directory.

I have a script which runs differently based on current working directory. Basically it processes an .ini file and takes parameters from it and runs mysql backup. Script is running as root user. ...
0
votes
1answer
16 views

Having problem with mysql dbdump when password starts with special character

I am trying to take a db backup with a php file that is running from a cronjob. It was running fine when I tested with sample db. But when I used the actual db there was an error. I am using ...
-1
votes
1answer
43 views

Can you please tell me what is wrong in below script?

script : it is giving below error. please help me. basically i need to get email when memory exceeds some limit. error : ./vamsitest.sh: line 10: [: missing `]'   #! /bin/bash # Total memory ...
0
votes
1answer
19 views

Unable to extract to specific directory

I am trying to extract to file to specific directory but it doesn't produce result Operating system : SunOS Command: zcat /export/home/tceng/Desktop/temp/3.tar.Z | tar -xf - -C ...
2
votes
1answer
30 views

Windowless xterm? (Faking a terminal for a process)

I'm fighting with a rather odd problem with Matlab. The startup script is located in /opt/matlab_2013b/bin and is called matlab. When I run it in terminal, it works fine. But I want to make a ...
0
votes
3answers
56 views

How to use password in shell scripting

I am writing a script which greps for for multiple files from 3 log files. One of the log file is created as superuser and every time it executes it prompts for password. How do I put it the same ...
1
vote
0answers
32 views

delete non important characters from command output

the version command in my Linux machines display the following output version Red.Hat.OS. release..........5.5 APP.Release.............4.2.0.0-02 how to remove the middle "." dot character ...
0
votes
2answers
39 views

What is difference between Power broker utility and sudo command?

I got a little clarity with the following answer on this Source Symark Power Broker is a commercial package. Sudo is an open source tool.
4
votes
2answers
260 views

How to echo `single quote` when using single quote to wrap special characters in shell?

I'm reading shell tutorial today from http://www.tutorialspoint.com/unix/unix-quoting-mechanisms.htm In which it mentions: If a single quote appears within a string to be output, you should not ...
1
vote
1answer
39 views

When did bash quit exporting SHELL?

I upgraded a Debian box from stable to Jessie and I noticed that SHELL is no longer exported, so screen and similar programs start dash for subshells instead of bash. When was this change made and ...
9
votes
4answers
659 views

Spaces next to pipes

I've seen history | grep blah and history |grep blah; and history|grep blah also works, though no one ever seems to use it. Is there any significance in the spaces (e.g. piping to/from different ...
0
votes
2answers
44 views

Gzip file but excluding some directories|files and also append current date

I'm looking for a way to create a .tar.gz file from a directory but I have some doubts. I'm know that the command for create the file is: tar -zcvf /path/to/compressed/file.tar.gz /path/to/compress ...
0
votes
1answer
26 views

explain this shell command with redirection and pipe

I can understand the statements like. bzip2 --version >/tmp/list_right 2>/tmp/list_error bzip2 --version >/tmp/list 2>&1 But I don't understand the statement: bzip2 --version ...
1
vote
2answers
78 views

use “read” command to pass lines as positional parameters to a shell script

The following file runs, but not doing anything, yet it does not error.... while read dates; do ./avg_hrly_all_final.sh ${dates}; done < ./dates_all.csv I have a list of dates in ...
1
vote
1answer
20 views

Multi-platform web based terminal emulator

Is there a web-based terminal emulator compatible with all device like pc browser, smarthphone and tablets (android and iOs)? I tried shellinabox, but with iOS doesn't work correctly (can't activate ...
1
vote
0answers
38 views

Bash cannot see PATH update

I am running Debian on a VM. I login to the GUI and go to Applications > Accessories > Terminal. # echo shell: /bin/bash I modified ENV_SUPATH, ENV_PATH inside of /etc/login.defs. I restarted ...
1
vote
0answers
60 views

Sed regex printing into a file.txt

I'm connected to a MQTT stream, and I filter out the data by entering : mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p}" into the Ubuntu terminal. ...
4
votes
2answers
56 views

How to get the real name of the controlling terminal?

How can one get the real name of the controlling terminal (if there is one, else an error) as a pathname? By "real name", I mean not /dev/tty, which cannot be used by other arbitrary processes to ...
0
votes
1answer
31 views

looping through a file on 2 lines in shell

I have a file which looks like this: >a TCCACTCCACGC >b ACCTCCAG I want to loop through the file in such a way that it takes into account 2 lines at a time i.e >a and its sequence and then ...
2
votes
1answer
44 views

attempting to put dynamic input data in a variable via cat method

I'm attempting to write a bash script that should be able to collect data from ttyS0 and put in a variable. I need to talk with a device on the serial line, that is a module able to receive AT ...
4
votes
2answers
55 views

How can set a row as column in unix [duplicate]

How can I set a row as column in Unix. Example: name : Keshav sub : C++ branch: cse DOB :22/09/1990 company:NONE name : Vijay sub : Java branch: cse DOB :22/09/1985 company:NONE I want output ...
0
votes
2answers
51 views

how to save the contents of a webpage in a file using shell script

how to save the contents of a webpage in a file using shell script. Web page is using URL, username and password to open. curl -O odcview:password ...