Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

1
vote
1answer
12 views

how to split multiline records by awk?

How to split multi line records by awk, i.e below file: ...
0
votes
0answers
4 views

Have to transform some bunch of csv in req format and store it in some other location with same name

I am having some input CSV files INPUT_FILE: A_B_C_NFM001_20150729.csv A_B_C_NFM002_20150729.csv A_B_C_NFM003_20150730.csv I want output file also with the same name as input after performing below ...
0
votes
0answers
6 views

Bspwm and Lemonbar - integrate bash script into the current bar

So I've got lemonbar (formerly bar) with Bspwm up and running. I have the colors the way I want them. I also have a bash script, which when run separately from Bspwm - just "./bash_script | bar -p" ...
0
votes
0answers
17 views

How to normalize irregular data values

From a PHP table I get the values graphically represented. However some of the data recieved is 'damaged' or incorrect thus yielding a non-sensible graphical representation. The hours (y-axis) is ...
0
votes
2answers
35 views

Rename specific level of sub folders

I have list of sub folders inside a parent folder as follow: Parent folder folder1 foldera folder2 folderb folder3 folderc I want to rename the subfolders only in ...
2
votes
1answer
38 views

Running compilation scripts only if the source file is more recent than the compiled programe

all. I'm not sure if this question belongs here or some other site but I figured I would start here and some helpful moderator would kick me over if there is a better location. What I am trying to ...
1
vote
1answer
34 views

How do I get a folder name using a wildcard and check for it's uniqueness

I want to move a series of file into different folder based on their ID, but I want to make sure that the folder I'm moving the file to exists and is unique The folders have a matching ID as the ...
0
votes
1answer
37 views

mv: cannot access file

Good day All, I have a script with permissions - 770 root:root script.sh. The scripts has to zip then moves files with permissions - 644 rex:roger file.csv. With a bash one line - mv file.csv ...
1
vote
1answer
28 views

How can I remove part of folder name

I have list of folder names file1xxx file2xxx file3xxx I want to remove "xxx" from it's name. I tried the following bash for dirname in $(cat ${in}/all.txt); do # all.txt include the name of the ...
-3
votes
0answers
33 views

unix script for this [on hold]

Have two files File1 and File2, each file should have two columns. File1 should have Customer_ID and Customer_name columns with ‘|’ as delimiter. File2 should have Customer_id and Dept_name ...
2
votes
2answers
107 views

!(*.sh) works on the command line but not in a script

When I use the code below in a terminal on Ubuntu, it works fine: rm !(*.sh) -rf But if I place the same line code in a shell script (clean.sh) and run shell script from terminal, it throws error ...
0
votes
2answers
22 views

wget, logging the output and the response

I calling an url using wget. This url gives me a response, its a Message id. I want to write the logs to a log file, with the message id as well. Also the log should be appended each time. I trying to ...
0
votes
1answer
19 views

Faster way to enter in command mode with vi mode in the shell

I want to use the vi mode in bash but I find the ESC key a little bit too far, as for vim. The ideal can be to keep a key pressed, like ALT or the caps lock, to stay in command mode and be in insert ...
2
votes
5answers
493 views

How to add a password to a BASH script

I want to create a script to run the following BASH command: mysqldump -u [username] -p [db_name] > [path to backup file] Which results in a backup file. When running this in BASH, it prompts ...
0
votes
4answers
93 views

Fast way to add/append to large a file [on hold]

I have a bash script that reads a rather large file, line by line, and for each line does some processing and writes the results to another file. Currently I am using echo to append to the end of the ...
0
votes
3answers
44 views

How do I create a directory for every file in a parent directory

I have parent folder and inside this folder I have 4 files ParentFolder File1.txt File2.txt File3.txt File4.txt I wanted to create subfolders inside the parent folder and ...
1
vote
2answers
41 views

Compare Dates by awk

I have the below file: 1,2,3,4,5,2015-10-13,7,8,2037-01-15 1,2,3,4,5,2015-09-05,7,8,2040-01-15 1,2,3,4,5,2015-09-15,7,8,2016-06-15 1,2,3,4,5,2015-10-13,7,8,2015-07-08 ...
0
votes
1answer
26 views

How to concatenate tables from different directories with only one header [on hold]

I have several directories ("amazon", "niger",...), in which I have several subdirectories ("gfdl", "hadgem",...), in which I also have several sub-directories ("rcp8p5", "rcp4p5",...). In this last ...
0
votes
1answer
37 views

Redirect console output in sed in background process don't give back hand

I'm using sed to add the date at the beginning of every lines given by a command (which use vlc and never stops...). I found this way on another stackexchange post and that works as expected. command ...
0
votes
1answer
24 views

Problem with loading settings from .bashrc

I have got strange problem with terminal settings. I am Debian 3.16.7 user. I saw .bashrc file using ls -a but I couldn't open it (no file comunicate), so I restored it from /etc/skel/.bashrc. Now ...
1
vote
2answers
38 views

How to forcibly update a file if left unchanged after 55 minutes? [on hold]

I need a log file to be updated if it has been left unchanged during 55 minutes. For example, say it is now 19:00 and IOstatDisk2.log hasn't changed since 18:00: solaris1a:/var/tmp ROOT # ls -ltr ...
11
votes
2answers
280 views

Resource usage using pipe and here string

We can get the same result using the following two in bash, echo 'foo' | cat and cat <<< 'foo' My question is what are the difference between these two as far as the resources used are ...
0
votes
2answers
52 views

How to use cp command in bash script to copy files with spaces ans $ characters in it? [duplicate]

I am trying to copy some files with spaces and $, @ symbols in their file names in a bash script but the script fails to copy the files stating it cannot find the file. I can see that it is treating ...
0
votes
1answer
26 views

Folder organization

I have several folders ("amazon", "niger", "rhine",...). Inside each of them I have several subfolders ("gfdl", "hadgem", "ipsl",...). Each subfolders is composed by 5 subfolders (e.g. in "amazon", ...
-2
votes
1answer
51 views

Bash Code Injection Vulnerability On Linux

Found a new bug in Linux System, a bash code injection vulnerability. The solution to this is the update the bash package. yum update bash My Question is "do I need to reboot the system"? ...
3
votes
2answers
82 views

Using bash variables in perl command in bash script

I am trying to generate a hashed password as in /etc/shadow file, using bash script. The user is prompted for the password which is saved in a variable PSWD. I have extracted the Hash and the salt ...
1
vote
0answers
28 views

Recording shell output for interactive commands

While looking into a shell redirection problem, I found a couple of answers that pointed me to the script command. As I understand it, script just records in- and output of the terminal, and allows me ...
1
vote
3answers
38 views

Set, backup and restore colors in the terminal

I use this program to display all color available in the terminal. That waht I get: This program doesn't show me colors below 100. Why? Is there a way to display them. Is the are way to change ...
0
votes
1answer
37 views

error ./c.sh: line 24: [: too many arguments in shell program

I am trying to make a shell script to print the amount of time user was logged into the system but I encountered a too many arguments error. I tried many methods from the internet but none worked. ...
1
vote
1answer
64 views

Issue with ':' character in Bash script over SSH

I am currently writing a script that will perform backups on a set of databases, comress them, encrypt them, transfer them to a separate storage machine, and verify that the file made it successfully. ...
1
vote
2answers
60 views

What Bash Statement does

Can you explain to me what the below statement does. grep `date +%Y-%m-%d --date='1 day ago'` /path/to/file/FILE_PREFIX_\`date +%Y%m%d --date='1 day ago'`.dsv | grep -v 'ERROR' | cut -d "|" -f 2 | ...
3
votes
3answers
144 views

If statement string comparison

I'm reading a csv file with 14 values per line. I want to convert the HEX value from 10th [f10] value to a DEC value. In order to do this if the 7th [f7] value must hold EnHr or EnSt or SpJb or Chem ...
1
vote
4answers
55 views

One column into two

I have a file that is one column, and I need to split it into two. Have tried column command and doesn't seem to work: 123-zyx 234-yxw 345-xwv 456-wvu 567-vut 678-uts
3
votes
2answers
71 views

Why does man page completion fail after su?

I have a default Debian 8.1 installation. I do su man apt<TAB> but get nothing. I do see the manual when I write man apt-get in both modes: as user mas and as root. However, tab ...
0
votes
1answer
31 views

Reload network interfaces without rebooting

I'm doing a BASH script for Arch Linux in a Raspberry Pi 2. The thing is that in some point I'd like to reload the network interfaces without reboot and have my new named network interfaces (en0 and ...
1
vote
2answers
42 views

Best way to make variables local in a source'd bash script?

I have a bash script that generates a report on the progress of some long-running jobs on the machine. Basically, this parent script loops through a list of child scripts (calling them all with ...
2
votes
5answers
70 views

bash expanding to same value instead of line by line value in sed command

I have a file containing numbers in it say numbers.txt as follows. 9374541632553 51243747879841 32030098896914 84654557358238 11000656847765 I want to convert it to the following format. ...
1
vote
4answers
70 views

How to number a string in each line of a file

Given file.txt that looks like this: line_ some text line_ some text line_ some text How can I number the lines like this with Bash: line_1 some text line_2 some text line_3 some text Here is my ...
1
vote
2answers
14 views

How to pass an argument from a bash script to 'x-terminal-emulator -e bash -c'?

Let's say I've got this script : x-terminal-emulator -e bash -c 'echo hello > ~/text' I call it foo.sh and make it executable. If I execute this script I'll have a text file in my home folder ...
1
vote
2answers
59 views

What's the most efficient way to log crontab shell script errors with error occurred time?

A common way to log crontab task errors looks like below: 1 */8 * * * sh /pseudo_path/test.sh 2>> my_err_log It's a concise command, but it can't record the error occurred time, and the path ...
0
votes
2answers
39 views

Variable expansion inside parenthesis and quotes

In the script below, I can't seem to make $var1 expand in the second statement. I've tried $var1, ${var1}, echo $var1 and '$var1'. It is inside a few sets of quotes and parenthesis which I guess is ...
3
votes
1answer
22 views

Bash script with conf file with unknown number of sets of variables

I am writing a bash script that has a configuration file. The configuration file will have sets of mode and mtu values. There can be zero or as many sets as the user defines. The bash script will ...
1
vote
2answers
45 views

Grep and ignoring leading whitespace

I've been working on a bash script to search for names of defines, and then grab the hex values for them and put them in the list. Once I have the list of names I'll attempt to search for "#define ...
0
votes
1answer
31 views

Sending special characters and new lines via KANNEL

Howto send message to kannel with lines and special character. Example if I have file message.txt which have following text line1 with few special characters like @ " / : line 2 spaces words etc line ...
0
votes
0answers
32 views

Drawing a histogram from a bash command output

I have the following output from a miRNA Predictor: Read Sequence:hsa-miR-576-3p MIMAT0004796 (22 nt) Read Sequence:gi|182396|gb|M74088.1|HUMFAPAPC Human APC gene mRNA, complete cds (8972 nt) ...
1
vote
1answer
19 views

Arrange program windows out of bash script?

I'm writing a shell script to automatically launch my work environment. It would be pretty nice to arrange the program windows automatically (for example vim opens at the left on desktop, and browser ...
1
vote
3answers
35 views

bc scale: How to avoid rounding? (Calculate small binomial probability)

Following code calculates the Binomial Probability of a success event k out of n trials: n=144 prob=$(echo "0.0139" | bc) echo -e "Enter no.:" read passedno k=$passedno nCk2() { num=1 ...
0
votes
0answers
31 views

How to scan for wireless networks fast

I have written a script which scans for wifi networks with iw dev wlan0 scan and put the SSIDs in a file. Is there a similar tool wich works a bit faster?
0
votes
1answer
30 views

How to copy files to the timestamp generated directory?

Hello I am trying to copy all files from Documents directory to the backup directory that has a timestamp. So I have created a directory called bk$( the time stamp of the directory) and I am trying to ...
1
vote
0answers
28 views

Calculate Out data Kb/s for specific PID

I have this command cat /proc/8221/net/netstat | grep 'IpExt: ' | tail -n 1 | awk '{ print $9 }' This shows me out bytes in that moment right? If yes, how can i show total kb/s in just one command ...