Bash is the shell used in Ubuntu's command-line interface.

learn more… | top users | synonyms (1)

1
vote
1answer
22 views

How to use shell variables after doing sudo su

I am writing a script to fix a missing 'F' letter in a mail log file. The mail log file is continuously updating. I am getting a file name, after that I am doing 'sudo su' to get superuser access. ...
0
votes
0answers
19 views

Using sed to remove all lines containing special characters , numbers, and spaces

So I'm fairly new to using shell--bash specifically--and I'm in the process of writing a script which will translate files containing DNA sequences into a more useful format. Unfortunately, many of ...
0
votes
3answers
37 views

Add particular strings to an array sed/awk/grep

I have this ciscoFlashCopyStatus OBJECT-TYPE SYNTAX INTEGER { copyOperationPending(0), copyInProgress(1), ...
1
vote
1answer
18 views

core file size with ulimit

My question is probably not related to Ubuntu in particular, but since my desktop running this OS, I came to this forum. I am trying to change the core file size using ulimit -c command as follows: ...
1
vote
1answer
21 views

Storing some strings in a array

I have this sCSISmart1 TRAP-TYPE ENTERPRISE cyclone VARIABLES {cycHostAdapterNumber, cycHostAdapterID, cycManagerID} DESCRIPTION ...
2
votes
1answer
22 views

Passing Variable into awk gsub

I have this command Here vovar=OBJECTS prvar="$(awk '/'"$vovar"'/,/}/ {gsub("$vovar"," "); gsub("}",": %s,"); gsub("{"," ");gsub(",",": %s,");print}' temp1)" Contents of temp1 ...
0
votes
0answers
10 views

How can I tackle a pager formatting trouble with (certain) man outputs?

I ran into something that made me suddenly 25 years younger today. (Wish this could happen more often.) That long ago it was troff that occasionally did this; now see: $ man man -> normal output to ...
0
votes
0answers
13 views

Ubuntu 14.04 desktop goes to sleep when issued “poweroff” command while lid closed?

My ubuntu version is 14.04 LTS. I used the following command to shutdown the system after a certain process was completed (This process takes a long time to complete, so I needed a way to ...
0
votes
0answers
12 views

Getting Rid of Autojump

I just removed autojump and I still get this line whenever I access my command terminal: bash: /usr/share/autojump/autojump.sh: No such file or directory I used sudo rm -rf autojump as my primary ...
0
votes
2answers
45 views

create scatter plot

file (1. arg) will create (scatter plot) for n. column (x-axis, 2. arg) and m. column (y-axis, 3. arg) function is called myfun sourcefile 1 3 for scatter plot of 1. and 3. column from file ...
4
votes
3answers
257 views

How can I pipe the output of a bash or shell command to the clip board? [duplicate]

In order to minimize mouse usage (accessibility and health reasons), how can I pipe the standard out to the OS clip board? That is, I'd like to do something like: $ drush uli | ...
0
votes
2answers
20 views

appends n-th line from the file x at the end of the file y

I have been asked to write a command that appends the n-th line (MYN) from a file (x)to another file (y). Here's what I've done so far: MYN=4 hey=$(awk 'NR==$MYN' x) echo "$hey" >> y But why ...
2
votes
2answers
110 views

How do I write a Bash script for this scenario?

I have these files in the directory home/acs. TBBN027162G_38d8-2f08-0c40 TBBN027605G_38d8-2f08-1518 TBBN027941G_38d8-2f08-0d1c TBBN027923G_38d8-2f08-35e4 I want to read TBBN027162G as service_id ...
2
votes
2answers
173 views

How to cancel next job in order after rsync

If two jobs are entered into bash command line separated by semicolon: $ job 1; job 2; How do I cancel the second one? If I press CTRL+c, the first one will be canceled and 'job 2' would start, I ...
6
votes
5answers
262 views

How do I delete everything after second occurrence of quotes using the command line?

I have this store in a variable sCellEventTrap-03-28 TRAP-TYPE -- CAC Code: 00 ENTERPRISE compaq VARIABLES { scellNameDateTime, scellSWComponent, ...
0
votes
2answers
35 views

How to make a script delete a directory after checking for its existence?

How might one make a bash script which when run will check for the existence of a file/folder and if the file/folder is there remove it?
1
vote
2answers
56 views

How to change niceness of process by name

Java process is killing my computer (Intel i3, 8GB RAM). It takes over whole CPU and system starts to hang. I was trying to change niceness of java processes but i have to control it for all time and ...
1
vote
2answers
31 views

Make echo ignore spaces?

I have a file called temp1 sCellEventTrap-03-27 TRAP-TYPE -- CAC Code: 01 ENTERPRISE compaq VARIABLES { scellNameDateTime, scellSWComponent, ...
0
votes
0answers
12 views

OpenVPN --up called scrip does not work properly

I use such command to run my OpenVPN connection (part of script): gw=`netstat -rn|grep UG|awk '{print $2}'` openvpn --config ./openvpn.ovpn --up "./up $gw" >/dev/null 2>/dev/null& So I ...
3
votes
2answers
54 views

How to execute a custom script when Internet reconnects?

My Internet gets disconnected every now and then. I'd like to run a Bash script every time the Internet reconnects. The script is quite simple: #!/bin/bash mplayer /home/user/sound.mp3 It's placed ...
6
votes
1answer
79 views

How can I send commands to specific terminal windows?

I'd like to write a script for opening multiple programs (servers) simultanously in separate terminals - doesn't matter which one - and assign different commands to different terminals with commands ...
0
votes
2answers
40 views

Ubuntu can't find my bash-script at /usr/bin/

On my first Xubuntu I successfully copied my script trans.sh to /usr/bin, made executable and after that I can run it in any position of terminal, but my second Xubuntu can't find my script in ...
1
vote
0answers
19 views

Passing Strings to /bin/login

I'm in the process of creating a login wrapper for /bin/login so that when you boot Linux you get a TUI Login instead of the bland login on the tty console. This will be just a bash script for this ...
1
vote
1answer
43 views

Ubuntu shutdown script

I am using Ubuntu 14.04 and looking for updating an script to allow passwordless powering off my machine after executing set of commands. To do so, I have configured sudo shutdown now and it does the ...
0
votes
1answer
31 views

Add or remove locked Unity launcher items from terminal? [duplicate]

I've been building a very thorough script to handle the process of fresh-installing Ubuntu and setting it up just the way I like (as well as adapting it for use at where I work). It's a bash script I ...
2
votes
2answers
79 views

Does bash (or any shell, for that matter) have an 'overwrite' mode?

I'm running similar commands on (e.g.) a set of files. As an example, let's say I'm doing something like this (this isn't what I'm doing, it's just an example): > cat path/to/dir/file01.txt ...
-3
votes
2answers
26 views

get two files together [duplicate]

how could I get two files together like this file1.txt: ROW 1 3 5 654 56 5 56 65 6 54 4 3345 35 53 3 32 2 1 ROW2 6 65 456 67 687 78 89 657 435 34 534 5 435 5 2 file4.txt: ...
3
votes
4answers
215 views

Bash create custom string

how could in bash a pattern like ROW1 n1 n2 n3 n4 up to 300 be done with some command in bash or also just perl...the delimiter would need to be \t as above
1
vote
0answers
17 views

Problem running backup script at shutdown Ubuntu 14.04.2

I want to run a script at shutdown, and a far as I can tell I've followed the proper procedures. The script (close) is supposed to launch another script (gdrive) in a terminal which prompts me to sync ...
2
votes
3answers
182 views

Dealing with bash breaking commands of a certain length

Consider you want to run this command in bash: echo -n "Command of a specific length will break at the second run attempt." Here's the output for a 24x80 TTY: ubuntu@ubuntu:~$ echo -n "Command of ...
2
votes
3answers
49 views

moving the file from one folder to another folder

I have got 2 folder in the same directory ie directory exp folders name data ,log. I wold like to write the bash script so that when I click on move .sh file then content of data folder should ...
2
votes
1answer
45 views

Print characters behind the digits

function/script, that for argument in format (alphas and digits) afa5hgt3tt, errerew9ax66w, prints characters behind the digits many times as value of digit, e.g. hgthgthgthgthgttttttt ...
2
votes
1answer
39 views

Print “hello” if number of files in a directory is bigger than the number in first line of a file

Write command line that prints hello if number of files in current directory is bigger than the number specified in first line of file check. This works fine but i want a one command line. Any ...
1
vote
1answer
41 views

How to restore bash executable after accidentally delete it?

I accidentally doing something wrong, want I meant to do is: ln -svf /bin/bash /bin/sh But, I miss typing it and become: ln -svf /bin/sh /bin/bash So, bash is now a symlink that point to sh ...
0
votes
4answers
61 views

matrix operation in bash

the point is that I woul need to transpose a large file - 1600 times 80k but the entries are not tab delimited but just U and K so it looks like UUUUTTTUTUTUUUTUTUT TTUTUTUTUUTUTUTUTUT is there a ...
2
votes
1answer
33 views

create sum, avg and min of file

I have this homework question: create function agg, first argument is filename, second will be sum, avg or min. script will compute sum, average or minimum (dependig on 2. argument) from the ...
12
votes
7answers
482 views

Renaming files to add a suffix

I need a command to rename all files in the current working directory, in a way that the new filename will be the same as the old, but including a suffix corresponding to the number of lines of the ...
0
votes
0answers
31 views

Adding a file to startup list using terminal

I have created a short bash script that I want to run on startup. Adding it to the startup list through the GUI is simple enough, but I need to do it through the command-line, as I plan to access the ...
2
votes
2answers
21 views

Executing wmctrl from bash

After playing a little from the terminal with wmctrl, now comes the next step. Execute wmctrl from a bash script. I do achieve to execute wmctrl in a bash when it is completely alone. Example: ...
0
votes
4answers
46 views

Adding a number to a already present variable sed/grep/awk

I have this in file.txt FORM: lookupfile Version: 1 LookupFile:"$i" How can I find this in the file and add a variable b to the $i. So example INPUT FORM: ...
0
votes
1answer
23 views

If condition fail skip to end of file

for (( v=0; v<t ; v++ )) do awk '/TRAP-TYPE/{i++}i' $fname >tron if [ "$?" -eq 0 ] then echo "MIB file found" else t=$t-1 fi some other commands echo "MIB not ...
2
votes
2answers
94 views
+50

How to stop command number incrementation on duplicate command?

Problem Thanks to this question, I succeed to forbid my bash to stock the same command more than one time if I write many times the same command. However, there is still a detail that I cannot ...
3
votes
2answers
303 views

Tee doesn't get whole output from the pipe

I have a script executing commands like: export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH;./some_app -i $INDEX | tee $LOG echo "Number of errors: $(grep "ERROR" $LOG | wc -l)" The problem is probably in ...
0
votes
2answers
27 views

How to create a zip file from contents of a folder with certain name pattern?

is it possible to create a tar.gz file from contents of a folder but only put the files with certain name pattern in the archive and ignore the rest? for example just put the files which their names ...
1
vote
2answers
101 views

Looping tr command to remove '\r' in multiple files in a directory

I have about 260 files in a directory. How can I input these files one by one into some thing like this file is an array name file=input stream of multiple files x=0 LOOP tr -d '\r' file2 rm ...
2
votes
1answer
30 views

Is it possible to cancel or clear a notification created by a bash script using notify-send?

So I wrote a little script that makes sure a certain user plugs in a laptop when he logs on (it disables if he doesn't). The script uses notify-send to tell him to plug it in. If he plugs it in, the ...
0
votes
0answers
12 views

Psycopg2 can't commit to a local database [on hold]

I've got a postgresql database on my local machine. I'm trying to write a python script, for use on many machines, that will query system information and then store it to a database, called ...
-1
votes
2answers
64 views

Help with script

#!/bin/bash a=`netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | grep -v '1 ' | grep -v '2 ' | grep -v '3 ' | grep -v '1.1.1.1' | grep -v '1.2.2.2' | grep -v '127.0.0.1' | ...
5
votes
5answers
279 views

Compare 2 numerals and copy only similar part sed/grep/awk

Supposing I have a array called a. There are 2 entries in a array a[1] and a[2].So each element contains a numeral value. Both these values have a similar starting numbers however they have different ...
1
vote
2answers
44 views

How to disown a chromium or chrome app on double click

I wrote a bash script to open an app (by double click) in my chromium. The code works but after opening the app when i close terminal the app also closes. I have searched through web and found out ...