Turns out I don't have bc in my Ubuntu distro and I can't install it. how to subtract two variables (BASH variables) from awk and set the result as another variable, e.g: finalvalue=`awk '{print $first - $second}'`
I have two text files on Linux. One contains a list of valid IDs. E.g: abcd efgh ijkl etc.
The other contains a list of invalid IDs. But, some of these also appear on the list of valid IDs, in this example "efgh": mnop qrst efgh etc.
How can I easily construct a text file that contains all the lines from the invalid list that do not appear in the valid list? That is, I want to end up with a text file that has: mnop qrst etc. I'd like either some Linux commandline magic of some clever Vim trickery.
I just need to perform a simple operation of subtracting two numbers - that aren't whole numbers, i.e 200.56 - 67.24attempting to use expr i merely get "expr: non-numeric argument"
mkvmerge -o <filename without extension>_TV.mkv -S <filename> && mkvextract tracks <filename> 3:<filename without extension>.*** && perl /home/brian/Desktop/ass2srt.pl <filename without extension>.*** && rm <filename without extension>.***
Doing these commands for multiple command line file inputs is the goal. So I can just type ./script.sh *.mkv in my terminal.This is what I have so far, but it doesn't work whatsoever.
I'm have been tasked with created a base Ubuntu image that can be used for cloning to multiple machines. As this is a network environment, each hostname will obviously need to be unique. Rather than manually changing the hostname each time a new, cloned machine is rolled out, I was wondering if there is a way to use a variable in the hostname (i.e., use a variable to truncate the the last 6 digits of the MAC address to the end of the static hostname--or any other unique variable for that matter--so it would look like hostname00E6D4).
I have a list of names (testnames.txt) and I have a set of log files (testlogdata.log). I'm trying to search the column in my log file for each of the names in my testnames.txt file, and output the result to individual files, name1.txt, name2.txt, name3.txt, etc the names in the column of my log file can appear in different formats , ie the name "Tom Smith" can appear as "tom_smith", "tom-smith", "ACME/tom.smith", "ACME/thomas.smith". etc. To allow for the variations, I have my names in the testnames.txt as expressions, ie, for tom smith, I use the expression "to.*smith", etc.I'm running the following command:
for i in $(cat testnames.txt); do awk '{if ($9~/$i/) print $0}' testlogdata.log > $ioutput.log; done
I want the command to read a value for i, insert it into the if ($9~/inserted value for i/, and dump each line from testlogdata.log into a file named <value-for-i>output.log.
I am trying to use bash 'printf' to format an environment variable.Doing this I get on the screen just the format I need (underscores mean blank spaces):prompt> printf "%10s" "1.23"________1.23Unfortunately, when this is assigned to a variable, the format disappears:prompt> X=`printf "%10s" "1.23"`prompt> echo $X1.23Does anyone know what can be done in this case to get a proper format?Why does not 'printf' respect the left blank spaces when assigning values to a variable?
I have what I hope is a fairly simple question to answer. In my ~/.bashrc file I can create this alias:
Code: alias uChmodDP='chmod -R $1 $2' #specify permissions. and the variables work fine. But I cannot seem to get any love from this alias:
Code: alias umnt='umount /dev/$1' I realize the likely problem is the variable following hot on the heels of a specific directory, but is there anyway to specify a variable in an alias like this? For some reason I cannot umount usb pen drives by right clicking, and have to always resort to the terminal to do so, which for me is no real biggie, but if I could create this alias it would be an even better no biggie to umount using the terminal.
Actually, the inability to right click to umount usb devices seems to be a Thunar issue since I run xubuntu. Using Nautilus I am able to right click and eject/safely remove devices. Using Thunar however, right click unmount always pukes back an error that the device must have been mounted on the command line or some such BS. But like I said it is no real biggie to use terminal, but an alias would be even nicer. I prefer using Thunar and Xubu most of the time b/c my laptop is quite underpowered.
I know many people have asked about environment variables before, but I am having a hard time dealing with these paths while ensuring I don't mess around with the original settings. How would you go about executing these commands in Ubuntu in terms of environment variables?
put /home/stanley/Downloads/ns-allinone-2.34/bin:/home/stanley/Downloads ns-allinone-2.34/tcl8.4.18/unix:/home/stanley/Downloads/ns-allinone-2.34/tk8.4.18/unixinto your PATH environment; so that you'll be able to run itm/tclsh wish/xgraph.
IMPORTANT NOTICES:
(1) You MUST put /home/stanley/Downloads/ns-allinone-2.34/otcl-1.13, /home/stanley/Downloads/ns-allinone-2.34/lib, into your LD_LIBRARY_PATH environment variable.
In terminal, I use the command " export XXX="xxx" " to create a new environment variable, and then " env | grep XXX " to check if it is existed. But when I run the terminal again, the variable I created is disappeared. I've found it just can't save the variables I created..
I can't seem to find how to export a variable to all processes I run under my user? I have an application that needs this variable, and currently I have to manually export this variable (typing "export VAR=... in terminal) every time before I run the application.
Which profile file I have to put the export expression into? I want all processes to inherit this variable, not just the shell/terminal. I.e. a true environment variable...
With my .conkyrc. Whenever I output the values of any of the mixer variables, eg. mixer, mixerbar, mixerl, mixerlbar, mixerr, mixerrbar - the correct value is initially displayed but it only persists for one iteration of conky. As soon as conky refreshes (2 secs. in my case), the value goes to zero (0). I'd have to restart conky in order to get another reading until conky loops/refreshes again.
I'm sure that it's not normal behavior because nothing else in conky seems to work this way. Has anyone come across this? I couldn't find a mention of it anywhere.
I've created a new environment variable and updated another one (PATH). I just want to save this changes once after reboot and forever. This is because I want to run a program (tecplot) just typing 'tec360' in the command line. If I create those new variable ( TEC_360_2008=/usr/tec360_2008 ) and update the PATH variable ( export PATH=$PATH:$TEC_360_2008/bin ) then bash detect the command 'tec360' and it runs my program. The problem is that this changes are not saved after rebooting.
According to the manual, I have to update the .bash_profile in my home directory but I don't have this file in this directory (neither in other directory). I only have .bash_history, .bash_logout and .bashrc in the home directory. I have updated .bashrc (typing . ./.bashrc) but it is not working.
When I execute something with sudo, the environment that it executes in doesn't have all the environment variables from /etc/profile{,.d/} defined. I googled around and found that there is a way to get the environment variables from the calling environment to be carried over to sudo's own environment, but that's not exactly what I want. I just want sudo to read the /etc/profile and /etc/profile.d/ before executing commands.
"Once upon a time", I think heard of a way to use variables in the url field in firefox(or maybe it was ubuntu in general?).Anyways, if one would type, for instance, "google pokemon," the url would be changed to
I'm having a strange problem. I'm using Ubuntu server 10.04 LTS and I want to setup a system with 2 network interfaces: eth0 and eth1. However eth1 does not come up at boot I have a screenshot of my /etc/network/interfaces file I don't see what is wrong. eth0 gets it's adress from DHCP eth1 gets a static adress. When i try to restart networking it quits with this message "don't seem to be have all the variables for eth1 inet" Can anyone point out what I'm doing wrong? if i do 'sudo ifconfig eth1 192.168.3.1 netmask 255.255.255.0 up' eth1 comes up
Does anyone know what file I have to modify to set the environment variables for FSCK? I can't run FSCK on my file system because it runs out of memory after about 10 minutes. This variable sounds like it will solve all of my problems but I can't find the file to modify to set the variable or what parameters it takes (number? yes/no?, etc).I'm trying to recover has a lot of information on it that I would really like to get back.
I want to be able to grab some text from a directory listing in a bash script, and then apply that text to future commands in the same script. For instance, say I do "ls -lais /media/Movies" and get:
2147560409 712544 -rwxr-x--- 1 root users 729645056 1999-03-07 11:45 Young Guns (1987).avi 2147560410 712400 -rwxr-x--- 1 root users 729497600 2002-01-09 01:11 Young Guns II (1990).avi
Then say I want to grab the year from this output and then use that information as part of the command to modify the file timestamp, such as:
2147560409 712544 -rwxr-x--- 1 root users 729645056 1987-01-01 12:00 Young Guns (1987).avi 2147560410 712400 -rwxr-x--- 1 root users 729497600 1990-01-01 12:00 Young Guns II (1990).avi
Anyway, that's just one example, but I often find myself needing to do this type of thing, and I'm sure its possible, just not really done enough scripting recently to know how to do it.
I always have to google about setting environment path variables when I install new software. My basic problem is that I dont know whether these variables need to be set globally or not. I have read a number of mails/tutorials which say that Environment variables should be set by simply doing an export ..eg EDITOR=nano export EDITOR
additionally I have read that it should be written into /etc/bash.bashrc
But are these really global variables or local? I want the variables to be set even after I have logged out.
I'm trying to write a bash script, and for some reason Bash doesn't seem to like any of my variables _except_ the one used in a loop.What's going on? The same problem with MYS occurs regardless of its name, whether it is declared or referenced before, after, or inside the loop, and whether it is a string, integer, or floating-point number. Also, as far as I can tell, everything related to Bash is up to date.
I have installed ubuntu10.04 LTS in VirtualBox in my home computer(i forgot to tell you i am very new to linux-though i am studying a lot, but....-maybe because of my age "45" i am going slow. LOL. I hope i dont have a heart attack before i finish what i am trying to do in the server). Back to my issue: What i want is to have in the server some enviromental variables running not only for the root user but for all the users,when the server is open and not having to type the following commands every single time i open the terminal. Here are the commands:
(where java, maven, tomcat are symbolic links for java jdk, maven and apache-tomcat 5.5.31). Please (LOL) save me from the heart attack, give me the chance to enjoy the holidays with my family!
I'm trying to install the latest version of tracker - 0.8.15. When I run ./configure, I come up with an error like this:
Code: checking for getline... yes checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GLIB2... configure: error: Package requirements (glib-2.0 >= 2.24.0) were not met: No package 'glib-2.0' found
[Code]...
Surely the libglib2.0-0 package is some kind of replacement for glib-2.0? My understanding from the man page is that PKG_CONFIG_PATH is some way of linking to and checking requested packages... is this right? Can I change it to point at the libglib package instead?
I'm trying to use system to call echo and pass variables to it. That was a success. The problem is the variables inside the while-loop i wrote cannot be manipulated. what I'm doing wrong here? here's the code:
The website creates a RPG character through a traditional Wizard. It calls itself with a hidden variable being the page number and tests which page and returns the page data with the page incremented.
Each page should be treated as a seperate page and so would be unique. I am echoing the contents of POST to the top of the page and so I can see variables being returned. When I get data from an Ajax query from page three it saves the data (23 post fields of no more than 25 characters for each field). Page four does the same but with less fields - but it is NOT returning the data - only four fields being those that were originally posted.
I cut/paste the function from section three to section four and changed the displayed text and the names of variables to test so there are no code errors, since page three works and is saved to a database.
So the only option is that there is a PHP or Apache2 issue when POST variables are returned? I am completely out of ideas as to why this would even be an issue or how it could possibly appear.
Is the number of variables an issue? This page is less than the previous page.... And the form is POSTed...
PS: I am getting NOTICE errors from PHP being the POSTed variables that are not displayed/returned... I used:
error_reporting (E_ALL ^ E_NOTICE);
to stop these form being reported but do I need to test each one? PPS: Using If Isset($_POST['xxx']) does NOT allow that variable through...
PS: I have the default Ubuntu 10.04 Apache2 with all the ubuntu 10.04 updates...