LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-26-2004, 01:12 PM   #121
trade14u
LQ Newbie
 
Registered: Mar 2004
Posts: 14

Rep: Reputation: 0

My favorite trick: Using the shell's { } expansion--

echo h{i,ello}
hi hello

the brackets are expanded with the letter(s) preceding the bracket one at a time. How is this useful? Copying files with long names!

cp thisisaverylongfilename.jar {, .bak}

makes:

cp thisisaverylongfilename.jar thisisaverylongfilename.jarBAK


Try it!
 
Old 03-26-2004, 05:57 PM   #122
oneferna
Member
 
Registered: May 2003
Distribution: Fedora Core 3, Gentoo
Posts: 47

Rep: Reputation: 15
bash tab-ing

In the bash shell you could also type the first few letters of the very long file name and then hit tab and it will fill it in for you, but your way is cool too, trade14u.
 
Old 03-27-2004, 03:14 AM   #123
bluej
LQ Newbie
 
Registered: Mar 2004
Location: japan
Distribution: debian
Posts: 24

Rep: Reputation: 15
in bash, you can use C-r (control + r) to search in the command history.
for example, suppose you did a "less /usr/src/linux-2.6.4/Documentation/usb/usb-serial.txt" a couple of days ago, and you want to read the file again but you cannot remember the path anymore, only that the word 'serial' was in it. what you can do is search in your command history for the word 'serial' by pressing C-r, then typing 'serial'. the matching command line will be displayed as you type each letter. if the result is not yet the command you were looking for, then press C-r again to step back in your history until the right command appears, and press enter.

it's all on the man page, you can jump right there by searching for 'reverse'. there's also a list of other useful bindings, for example moving back/forward one word, deleting back/forward one word. these bindings are also good to memorize because they work in emacs too. (and that's actually how i found them in the first place, i thought i was in an emacs window, haha!)
 
Old 03-29-2004, 04:35 AM   #124
slackmagic
Member
 
Registered: Aug 2003
Distribution: Slackware
Posts: 255

Rep: Reputation: 35
hi there,

this is more likely known to a lot of linux users, but one of the things I always like to set up immediately after I've installed a new distro is change the .bashrc for root

this is how my /root/.bashrc looks like:

Code:
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

export PATH=$PATH:/sbin

export PS1="\\033[0;31m\u\\033[1;31m@\\033[0;31m\h\\033[1;31m:\\033[0;31m\w\\033[1;31m\\$\n: \\033[0;37m"

It's the RED code that I added. It pretty much reminds me ALWAYS whenever I'm logged on as root - you should give that a try :P


simple, but quite useful
(of course you can add many more changes to it)

Last edited by slackmagic; 03-29-2004 at 05:33 AM.
 
Old 04-06-2004, 02:02 AM   #125
jon1591
Member
 
Registered: Nov 2003
Location: NE England
Distribution: Slackware 9.1
Posts: 52

Rep: Reputation: 15
Hi guys, I think this is a cool thread but I would like to know one about using &&. Is there any difference between doing:

Code:
make dep && make bzImage && etc...
or doing

Code:
make dep& make bzImage& etc...
Jon
 
Old 04-06-2004, 03:09 PM   #126
AutOPSY
Member
 
Registered: Mar 2004
Location: US
Distribution: Redhat 9 - Linux 2.6.3
Posts: 836

Rep: Reputation: 31
5) man manpage|col -b>manpage.txt
is usefull to redirect a rather big man page to a text file in easy readable format

This is also usefull for printer perfectly formatted man pages.
 
Old 04-06-2004, 03:13 PM   #127
AutOPSY
Member
 
Registered: Mar 2004
Location: US
Distribution: Redhat 9 - Linux 2.6.3
Posts: 836

Rep: Reputation: 31
Quote:
Originally posted by jon1591
Hi guys, I think this is a cool thread but I would like to know one about using &&. Is there any difference between doing:

Code:
make dep && make bzImage && etc...
or doing

Code:
make dep& make bzImage& etc...
Jon


& - forks a job to the background

&& is a boolean operator I belive. not sure exactly how to explain it but, simply
do && do && do

is 'do' and 'do' and 'do'
I guess thats a pretty hoakie explanation.
 
Old 04-06-2004, 04:11 PM   #128
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
Quote:
Originally posted by AutOPSY
do && do && do

is 'do' and 'do' and 'do'
I guess thats a pretty hoakie explanation.
Close....

do ; do ; do
is 'do' and 'do' and 'do'

do && do && do
is 'do' and if successful then 'do' and if successful then 'do'

If the first 'do' fails, the others will not run. If the first 'do' is successful and the second 'do' fails, the third will not run.
 
Old 04-08-2004, 03:39 AM   #129
jon1591
Member
 
Registered: Nov 2003
Location: NE England
Distribution: Slackware 9.1
Posts: 52

Rep: Reputation: 15
Thanks for your help guys.

Jon
 
Old 04-26-2004, 03:05 PM   #130
jon1591
Member
 
Registered: Nov 2003
Location: NE England
Distribution: Slackware 9.1
Posts: 52

Rep: Reputation: 15
Hi again,
If you would like Num Lock to be switched on at boot-up add this to your rc.local:

Code:
 for tty in /dev/tty[1-6]; do
 /usr/bin/setleds -D +num < $tty
 done
Jon
 
Old 05-13-2004, 10:30 AM   #131
naren
Member
 
Registered: Feb 2004
Posts: 66

Rep: Reputation: 15
I m just subscribing to this thread ...
sorry for the in convenience caused.
 
Old 05-13-2004, 01:42 PM   #132
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
OK here's one someone might find useful. Have you ever wanted ls to print the permissions in numbers instead of "rwxr--r--" or whatever? Make this a shell alias:

Code:
 ls -l | sed -e 's/rwx/7/g' | sed -e 's/r--/4/g' | sed -e 's/r-x/5/g' | sed -e 's/rw-/6/g' | sed -e 's/---/0/g'
It won't work for every file, but it should for most normal files.

edit: this could be written more succinctly as:
Code:
 ls -l | sed -e 's/rwx/7/g' -e 's/r--/4/g' -e 's/r-x/5/g' -e 's/rw-/6/g' -e 's/---/0/g'

Last edited by bulliver; 08-08-2006 at 06:21 PM.
 
Old 06-16-2004, 06:17 PM   #133
rickenbacherus
Member
 
Registered: Mar 2003
Location: colorado springs. colorado
Distribution: Debian-Sid 2.6.24-rt1
Posts: 290

Rep: Reputation: 30
I always thought aliases resided in memory so I prefer to write small scripts and place them in /usr/bin. Example. I have a box named cromag that I frequently ssh into.
touch cromag && echo "ssh user@192.168.1.125" > cromag && chmod +x cromag
sudo mv cromag /usr/bin

To find your current resolution:
xvidtune -show
OR
xrandr|grep \*

To enable/disable energystar features:
xset +/-dpms

If you're a bad typist like me and commonly transpose your last two letters of a command you can use CTRL+T to switch them like so:

apt-gte
CTRL+T
(now your typo gets corrected)
apt-get

Last edited by rickenbacherus; 06-16-2004 at 06:36 PM.
 
Old 06-16-2004, 10:06 PM   #134
Joey.Dale
Member
 
Registered: Jun 2003
Location: Tampa, Fl
Distribution: Gentoo, Slackware
Posts: 828

Rep: Reputation: 39
no &&=if no error do this while ; just starts l a new comand

-Joey

Last edited by Joey.Dale; 06-16-2004 at 10:08 PM.
 
Old 05-02-2005, 12:09 PM   #135
freakyg
Member
 
Registered: Apr 2005
Distribution: LFS 5.0 and 6.1
Posts: 705

Rep: Reputation: 30
I'll add to what retiredsoldier posted............In my ~/.bashrc I like to define all the colors first, then export them so my PS1 is a little easier to create............
Code:
 
# Color Variables for Prompt
GRAD1='\333\262\261\260'
GRAD2='\260\261\262\333'
YLOBRN='\[\033[01;33;43m\]'
WHTBRN='\[\033[01;37;43m\]'
REDBRN='\[\033[01;31;43m\]'
BLUBRN='\[\033[01;34;43m\]'
GRNBRN='\[\033[00;32;43m\]'
REDBLK='\[\033[00;31;40m\]'
PPLBLK='\[\033[01;35;40m\]'
WHTBLK='\[\033[01;37;40m\]'
NONE='\[\033[00m\]'
HBLK='\[\033[00;30;30m\]'
HBLU='\[\033[01;34;34m\]'

BLU='\[\033[01;34m\]'
YEL='\[\033[01;33m\]'
WHT='\[\033[01;37m\]'
PRPL='\[\033[00;35m\]'
RED='\[\033[01;31m\]'
GRN='\[\033[01;32m\]'          
GRAY='\[\033[01;30m\]'
PINK='\[\033[01;35m\]'
NORM='\[\033[01;00;0m\]'
CYAN='\[\033[01;36m\]'


export GRAD1 GRAD2 YLOBRN WHTBRN REDBRN BLUBRN GRNBRN REDBLK PPLBLK WHTBLK NONE HBLK HBLU BLU YEL WHT PRPL RED GRN GRAY PINK NORM CYAN

# what I use for normal users
PS1="$CYAN[\s]$YEL[\t] $GRN\u$YEL@$BLU\h $WHT[\w]\$$NONE $NORM"
try it out............
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wargame Hints? the_p0et Linux - Security 3 10-19-2003 11:04 PM
hints and tips bigjohn LQ Suggestions & Feedback 0 08-04-2003 01:48 PM
Slackware CUPS hints mi6 Slackware 3 06-05-2003 08:56 PM
Hints - process myquestion Programming 2 04-15-2002 07:26 PM
gcad hints ? jamaso Linux - General 0 03-02-2002 08:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration