General :: Bash Function/alias For Package Managers?

Jul 6, 2010

I have packer installed for AUR packages, but I want to be able to use the pacman command for both. I think I will need a function for this -- what I mean is that whenever I use pacman, it will try using packer and if that fails (invalid option) it will use pacman-color. It could also decide which program to use based on the arguments. I can't just use packer (alias pacman='sudo packer') because packer doesn't have some options like -R to remove packages. I want to always use it to install and upgrade packages however, because It can install from the default repositories as well as AUR.

Does someone know how to accomplish this, or could point me in the right direction? I'm new to bash scripting. error (e.g. pacman -V prints packer: Option '-V' is not valid.).

View 1 Replies


ADVERTISEMENT

General :: Using An Alias Inside A Function In Bash?

Jun 8, 2011

I have trouble with using an alias inside aash function. I would like to ssh into multiple machines by executing:ssh machine To achieve this, I put something like the following into my ~/.bashrc:

alias machine='user@machine'
ssh()
{

[code]....

View 1 Replies View Related

Fedora :: Bash Function Alias To Recursively Grep Current Directory?

Feb 14, 2011

This should be a simple thing to accomplish, but I can seem to figure it out. Essentially, I want to have a bash alias or function that will let me recursively grep the current directory. A while back I added this to my .bashrc:

Code:

alias rg="grep -r --exclude=*/.svn/* --exclude=*.swp"

This works fine, (and also ignores any svn and vim swp files), and I can call it like:

Code:

rg foo *

However, 99.999% of the time, I am only interested in searching in the current directory, so the "*" is a bit redundant. Also, I would say 5-10% of the time, I am typing faster than thinking and forget the "*", so grep just sits there trying to read from stdin. It's a pretty minor thing, but ideally I'd like to be able to just type:

Code:

rg foo

I've tried creating a function to handle this:

Code:

function rg(){
grep -r --exclude=*/.svn/* --exclude=*.swp $1 *
}

but it behaves exactly the same as the alias above. escaping the "*" with 's doesn't work, and neither does trying `pwd` (or even a hard-coded path) in its place.

View 2 Replies View Related

General :: Noob Qn Regarding Package Managers?

Feb 28, 2011

I have a noob qn, if I installed a program with yum, will I be able to see the details of the installed program with rpm -qa? My linux has no internet access so I can't test it out.

View 11 Replies View Related

General :: Package Managers Upgrade Packages Like Glibc?

Jul 16, 2011

I've been looking further into Linux from Scratch, and I am particularly interested in the package management side of the system. I understand that this is not covered in the book, but if I were to attempt LFS, package management would be a major convenience. From what I have read, when upgrading packages like glibc, you have to recompile everything to reflect the change.

If that is true, how do package managers like pacman and apt get around this issue? Isn't lacking glibc for even the time it takes to replace the files catastrophic to the system?

View 1 Replies View Related

General :: Set Alias In Bash Scripts

Sep 6, 2010

I tried this to set an alias: alias lsf='ls -f' and it works fine... But when I put it in a bash script it doesnt work. SCRIPT:

cd ~
alias lsf='ls -F'
lsf

I get the following output: line 3: lsf: command not found

View 2 Replies View Related

General :: Compile Programs And Their Dependencies Manually Or Are Package Managers The Only Way?

May 29, 2010

Is there an easier way (without using a package manager) to upgrade programs? For example, I just want to upgrade Amarok. In order to do this, I've had to upgrade every one of it's dependencies because they've all had minor upgrades from the versions I already have installed.

Is there an easier way to compile programs and their dependencies manually or are package managers the only way?

View 1 Replies View Related

General :: Using Shortcuts/alias Inside A Bash Command?

Jan 28, 2010

I know that using alias I can run a whole command with a shortcut. But my requirement is to use parts of a long command and in between I have to pass some user defined values.
E.g. Suppose I have to routinely copy a directory to another remote directory on a remote machine.The remote machine name is quite long as well as the directory path to which I want to copy the files into.So the command to do scp would look like this[URL]Now I want to do some sort of aliasing (say "ecp") so that I just need to pass the source_directory name and the ecp command and do my job

View 3 Replies View Related

Programming :: Using An Alias Or Function Without The Newline?

May 1, 2010

I want to create an alias or function that when used prints something like this on the command line so I can further modify it before pressing enter myself.

Code:
$ FILE=exercise1; cc -o $FILE $FILE.c && ./$FILE; FILE=
The idea is that I'm studying c and want to change the name of the file once instead of

[code]....

View 3 Replies View Related

Ubuntu :: Package Managers All Of It Is Not Responding?

Dec 14, 2010

My problem is whit the package managers all of it is not responding (update,GDebi,synaptic), it bater if any one know application replacing them because i'm always having problem whit them and this picture could help ;

View 5 Replies View Related

Ubuntu :: Package Managers Crash ?

Jul 14, 2011

All my package managers are crashing. I will try to start them up, they will begin loading, and then will crash. The problem began with the Update Manager putting up the red circle error icon that says: "An error has occured, please run Package Manager from the right-click menu or apt-get in a terminal to see what is wrong. The error message was: 'Error: BrokenCount > 0'. This usually means that your installed packages have unmet dependencies."

The recommended fix for this looks to be on this post that I got from LaunchPad: [url]

It says to: "Open the Synaptic package manager. System --> Administration --> Synaptic Package Manager

If anything is broken it will tell you.Choose 'Custom' from the buttons at the bottom then click on 'Broken'

Right click on the offending package and choose to remove it."

Unfortunately, Synaptic won't open.

View 2 Replies View Related

General :: Unset Or Get Rid Of A Bash Function?

Jun 19, 2010

If you set or export an environment variable in bash, you can unset it. If you set an alias in bash, you can unalias it. But there doesn't seem to be an unfunction.

Consider this (trivial) bash function, for example, set in a .bash_aliases file and read at shell initialization.

function foo () { echo "bar" ; }

How can I clear this function definition from my current shell? (Changing the initialization files or restarting the shell doesn't count.)

View 1 Replies View Related

Ubuntu :: Any Simpler Package Managers In Kubuntu?

Jan 10, 2011

I have been using kubuntu 10.04 for a while now and its working great. The main problem is that as far as I know it lacks a simplified package manager like ubuntu software center. Kpackagekit is fine as a synaptic replacement but searching for programs among all sorts of unrelated packages is very tiring. Are there any other options?

View 4 Replies View Related

Debian :: Apt, Aptitude And Other Package Managers Fail To Work

Jun 27, 2011

I had debian squeeze on my personal computer at home, 3 days ago i've upgraded it to the debian testing. last day i've installed virtualbox which i've gotten from virtualbox.org . today non of package managers work. an example of installing sumthin new with apt:

root@fairyland:/home/timmy# apt-get install clamav
Reading package lists... Done
Segmentation faulty tree... 50%
root@fairyland:/home/timmy#

also synaptic can't be started. i've run apt-get clean and removed /var/lib/apt/list i also tried apt-get update but these don't work sum useful info:

root@fairyland:/home/timmy# tail -n 40 /var/log/dpkg.log
2011-06-26 11:58:07 status half-installed virtualbox-ose 3.2.12-dfsg-1
2011-06-26 11:58:07 status config-files virtualbox-ose 3.2.12-dfsg-1

[code]....

just don't tell me i've to refresh its base, shit i hate to do this, i'd never done that about debian, this is one of the reasons i luv debian.

View 3 Replies View Related

Ubuntu Installation :: Can't Download Any Updates And Can't Use Package Managers

Jan 19, 2010

I don't know whats happening. the second i open either the update manager, add or remove programs, or the package manager tehy close instantaneously and when i click the button for updates on the top bar of my computer it shows a picture of a minus sign in a red circle. hwo can i fix this. i have ubuntu 9.04 and im trying to upgrade it and get new programs but it wont let me. ive tried the sudo get updates etc etc

View 1 Replies View Related

General :: Invoke A Function In Bash Shell Script?

Apr 24, 2010

I just wonder the distinction calling the function between $(one_function) and one_function in bash shell script.

When I set the variable PS1 in ~/.bashrc, I can't invoke the function by one_func
ex:

export PS1="
[e[31m] $(one_func) # it works
export PS1="
[e[31m] one_func # it doesn't work

View 3 Replies View Related

General :: Bash Catching The Function Returning Value Into A Variable?

Mar 17, 2010

i am dealing with this problemI have a function

function Une {
...
return $some_variable

[code]...

View 6 Replies View Related

General :: Function For Block Commenting Bash Scripts In Gedit

Apr 9, 2010

I just started writing bash scripts and have a little question about the text editors. I now use gedit which I really like (don't like emacs for some reason), but I do miss some function for inserting/removing comment signs (in this case # for bash scripts) on a whole block of text. For example in Matlab you can simply mark a whole block and comment/uncomment all of it at once. Is this possible in gedit (via some plug-in or something?), or maybe in some other nice editor you can recommend?

View 7 Replies View Related

Programming :: Setting PATH Alias In Bash?

Jul 15, 2010

I am trying to execute executable files in bash without adding ./ I know there must be an alias to add in .bashrc, that must be something like alias PATH=$PATH:. But this seems not to be working.

View 1 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

Programming :: Bash Function Using If / Then And Else

May 2, 2011

I am trying to build a function inside a script.

Code:
#!/bin/sh
#System commands and other configurable.
IPT=/sbin/iptables
IP6T=/sbin/ip6tables
IPST=/usr/sbin/ipset
MODP=/sbin/modprobe
GET=/usr/bin/wget
INT_NET=192.168.1.0/24 .....

I can find lots of tutorials in how to use if, then, else. However, how do I define a variable inside the function?
SEE>>
Code:
for c in $ISO
Also, am I using the 'test' command correctly( -/+ week as valid test)?

View 7 Replies View Related

Fedora :: Bash Function With Arguments

Nov 16, 2010

I wanted to make an alias with arguments (like in cshell) which is in bash done by functions. The function must simply perform a command (nedit), append the arguments from the cli and make it run in the background (adding &).

So here is the function in a naive attempt:

Code:

when using the command

Code:

Code:

How can i use arguments and still start it in background? In cshell it was like:

View 8 Replies View Related

Programming :: Getting $1 From A Bash Script That Uses A Function?

Jan 23, 2011

I made a script that calls a function. However when I run the script I cannot get a value from the first parameter. Here is the function:

Code:
$cat function_library
_file_info()
{
if [ -e "$1" ]
then

[Code]....

View 6 Replies View Related

Software :: Bash Function - Getting Error But No Output

Oct 29, 2010

I have taken into count spacing of functions as a reason for not working. Can you get this function to work on your machine?
quickfind () { find . -maxdepth 2 -iname "*$1*" }

It does not print the retired output but find . -maxdepth 2 -iname "*$1*" does work. What is wrong?
quickfind () { f
ind . -maxdepth 2 -iname "*$1*" ; }

If I run this from the command line I don't get an error but no output? I am not running this inside a script but from the command line. I want to be able to run any function () from the command line. I have more functions that I can't get to work?
tt () { tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> " }

View 1 Replies View Related

Programming :: Bash Function Check For Valid IP?

Apr 16, 2010

I have been working on this way too long now...this *should* be simple. I must be missing something simple at this point.

Code:
function f_is_ip()
{
if [ "`echo "$1" | /bin/egrep "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"`" != "" ] ## Error on this line

[Code]....

When I echo $1 ## prints 192.168.1.22

View 4 Replies View Related

Programming :: Bash Function For Searching Files ?

Jun 15, 2011

I'm making a small script for searching and doing some operations with photos, but I'm kinda stuck on this little function:

Code:

function findallformat {
prefix=""
if [ $1 = -pre ] then

[code]....

That function should find for every file with a certain type; and you can specify a prefix using a "-pre" followed by the prefix that you want to search. The format should be "stackable", so you can use as many types that you want, without repeating the same function on the code.

Example: findallformat -pre IMG_ .JPG .CR2 #That should search files that start with "IMG_" and finishes with .JPG and .CR2. My problem it's that, when I try to use it on the script, it says "bash: syntax error near `token' unexpected `}'"

View 4 Replies View Related

Programming :: Bash: Give A Variable The Value Of A Function?

Aug 8, 2010

I was wondering if possible in bash for a variable to take the value of a function, I mean the function returns a value and a variable will take it. example:

[Code]....

View 3 Replies View Related

Programming :: Finesse Weather Function For Bash?

Feb 4, 2011

I found a weather function for bash from searching google, and started to finesse it. This is what I have so far, any tips to finesse it even more?

Code:
# Based on code by Crouse at www.bashscripts.org
weather() {
declare -a WEATHERARRAY
WEATHERARRAY=('lynx -dump "[URL]?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+${1}&btnG=Search" | grep -A 18 -m 1 "Current:" | sed -e 's/^[ ]*//' | cut -d '|' -f 1-5 ')
echo Weather for the zipcode of $1:$'
' ${WEATHERARRAY[@] } }

View 10 Replies View Related

Fedora :: Bash - Binding A Function To Control-something Key Combo - F11

Aug 20, 2009

I want to set a key binding in bash for "history-search-backward" readline command to a combination of Control+some other key (I'm using 2 as an example), but I'm unable to do so. in fact, I'm unable to alter or add bindings to Control+key combinations.

After several tries my ~/.inputrc now looks like this

But it doesn't work and bind -p | grep "-2" gives nothing. If I try something without the control key:

I can search in the history by prssing the sequence C + - + 2.

bind -p gives control in C form, for example:

I've tried different formats in my inputrc:

But nothing works.

works if I press Escape followed by 2.

Setup:
Fedora 11:
Bash version 4.0.23(1)
GNU Readline 5.2 (according to the man page)

View 2 Replies View Related

General :: Write Script To Use Function And Still Keep Function Active?

Feb 21, 2010

the function terminates if no key is pressed for 10 consecutive seconds. I tried using the -t option as suggested in some forums, but my version of showkey doesn't have the option of changing the timeout. The options I get are:

-h --helpdisplay this help text
-a --asciidisplay the decimal/octal/hex values of the keys
-s --scancodesdisplay only the raw scan-codes
-k --keycodesdisplay only the interpreted keycodes (default).

Is it possible to write a script to use this function and still keep the function active until an interrupt is recieved?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved