Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why does 'kate mytextfile' work, but 'mytextfile | kate' doesn't?
A pipe connects the output of one command to the input of the next.
"mytextfile" does not produce any output---it actually does nothing. to prove this, just type it in at a prompt.
The first example works because the kate command is set up to handle what are called "command-line arguments"
If you like to experiment, try entering:
"cat mytextfile | <somecommand>" This reads the content of mytextfile and gives it to <somecommand>
A common usage would be "cat mytextfile | grep hello"
This prints any line from the file that contains the word "hello"
Pipes are often used with a type of program called a filter. Grep, sed, tr & awk are common filters. They are placed after a pipe, taking the standard input from the pipe and printing the result to the standard output.
Another type of program like kate, or kghostview expect a filename argument. Some of these will accept the "-" dash character argument as a signal to take the input from standard input.
For example, try:
man -t bash | kghostview -
Then read page 5 to learn about pipes!
Or suppose that you want a text file output:
man bash | cat >bash.txt
A program such as "enscript" will be setup to write a file instead of sending the output to stdout.
With enscript and others you can use the output filename of "/dev/stdout" to generate a stdout stream.
examples:
man bash | enscript -o /dev/stdout >bash.ps
man bash | enscript -o /dev/stdout | kghostview -
A handy command to learn is "xargs". This command will take the standard output of a pipe and use them as arguments to another command.
Just minutes ago, I used pipes to take the contents of the unziped .k3b file to get the filelist of files I backed up to cdrom.
unzip name.k3b.
The resultant maindata.xml contains the filenames that were backed up. So I can delete them like this:
sed -e '/^<url>/!d'-e 's/<url>\(.*\)<\/url>/\1/' -e 's/\&/\\&/' maindata.xml | tr '\n' '\000' | xargs -0 rm -v
The sed commands extract just the filenames from the xml file and escape an "evil" character in the filenames. The tr command replaces newlines with nulls. The -0 option to xargs tells it to use nulls instead of returns. This helps with filenames that contains spaces. These filenames are used as arguments to the "rm" command and are deleted.
Hi does anyone know how to merge three two photos into one by chance. If anyone can help mea dn give me suggestions i would greatyl appreciate it thanks a ton.
ImageMagick is a package of several programs. One of them will combine photos.
I think the program you want is called mogrify.
Quote:
NAME
mogridy (sic) - resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Mogrify overwrites
the original image file, whereas, convert(1) writes to a different image file.
...
For more information about this command, point your browser to file:///usr/share/doc/packages/ImageMagick/index.html.
Run `mogrify -help' to get a summary of the mogrify command options.
cs-cam > The reason that doesn't work is obvious but I can't think of a decent way of explaining them so here's a link...
Yup, thanks... It is indeed obvious to me too, now that I've been using Linux a month longer (and having taken this long to check this thread).
That's good, though... If such originally-confusing stuff seems so simple now, it means there's hope for all of us as we confront the truly hard stuff. (Er, if anybody understands what I just said, explain it to me, okay?)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.