You are not logged in.

#1 2008-06-03 18:31:05

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

How copy just line in text file with cat? (SOLVED)

Hi.

How i make to copy just only line in text file with cat?

For example:

[:0.0]
file=/home/Arch/./.wallpaper.png
mode=0
bgcolor=# 0 0 0

I want copy just "/home/Arch/./.wallpaper.png" part.

Actually i want create a shortcut for last wallpaper set from Nitroget, then i put this in SLim background.

Recently i use hsetroot for wallpaper (~/.wallpaper.png) and i create a shortcut in /usr/share/slim/theme/MYTHEME whith ln -s ~/.wallpaper.png /usr/share/slim/theme/MYTHEME/background.png.

I want make a same with Nitrogen.

I now this looks like crazy, but... tongue

Sorry my English.

Last edited by kramerxiita (2008-06-04 16:50:48)

Offline

#2 2008-06-03 18:33:36

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,899
Website

Re: How copy just line in text file with cat? (SOLVED)

Have you tried restore option

http://wiki.archlinux.org/index.php/Nitrogen


Mr Green

Offline

#3 2008-06-03 18:37:22

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

Yes, don't work for create shortcut for image.

Offline

#4 2008-06-03 18:41:00

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

Just adding something. My idea is when a change wallpaper, SLim backgroung change too.

When a use hsetroot this happen.

Thanks

Offline

#5 2008-06-03 18:47:31

kishd
Member
Registered: 2006-06-14
Posts: 401

Re: How copy just line in text file with cat? (SOLVED)

"sed -n 2p file.txt". Where 2 is the line number that you want from file.txt.

Last edited by kishd (2008-06-03 19:43:03)


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#6 2008-06-03 18:49:16

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: How copy just line in text file with cat? (SOLVED)

How can you make SliM change the background ? You link the theme background to another file ?


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#7 2008-06-03 19:11:06

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

moljac024 wrote:

How can you make SliM change the background ? You link the theme background to another file ?

Yes. In theme directory i put background.png shortcut for my wallpaper. So, when a change wallpaper, slim background change too.

Example:

ln -s mywallpaper.png /usr/share/slim/themes/default/background.png

So, Slim background always is my wallpaper.

Offline

#8 2008-06-03 19:16:40

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

kishd wrote:

Don't really know too much about linux commands. Perhaps using cat -n which places line numbers in each line and pipe the result to grep eg. cat -n file.txt | grep 2 | to sed etc to get rid of the line number.

try this and don't work. sad

Thanks anyway.

Offline

#9 2008-06-03 19:20:00

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: How copy just line in text file with cat? (SOLVED)

kramerxiita wrote:
moljac024 wrote:

How can you make SliM change the background ? You link the theme background to another file ?

Yes. In theme directory i put background.png shortcut for my wallpaper. So, when a change wallpaper, slim background change too.

Example:

ln -s mywallpaper.png /usr/share/slim/themes/default/background.png

So, Slim background always is my wallpaper.

So the wallpaper has to be a *.png ?


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#10 2008-06-03 19:27:43

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

moljac024 wrote:
kramerxiita wrote:
moljac024 wrote:

How can you make SliM change the background ? You link the theme background to another file ?

Yes. In theme directory i put background.png shortcut for my wallpaper. So, when a change wallpaper, slim background change too.

Example:

ln -s mywallpaper.png /usr/share/slim/themes/default/background.png

So, Slim background always is my wallpaper.

So the wallpaper has to be a *.png ?

No, jpg is possible. But when you create a symbolic link, remember put the extension too. If change png to jpg, change a symbolic link extension.

But, remember if slim theme directory have background.png and background.jpg, Slim always choice .png. So, put only one this.

Offline

#11 2008-06-03 23:18:10

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: How copy just line in text file with cat? (SOLVED)

cat file | awk -F= '$1 ~ /^file$/ {print $2}'

here's a oneliner to make the link:

F=$( cat test | awk -F= '$1 ~ /^file$/ {print $2}' ) ln -s $( basename $F ) $F

Last edited by klixon (2008-06-03 23:52:03)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#12 2008-06-04 01:54:12

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

klixon wrote:
cat file | awk -F= '$1 ~ /^file$/ {print $2}'

here's a oneliner to make the link:

F=$( cat test | awk -F= '$1 ~ /^file$/ {print $2}' ) ln -s $( basename $F ) $F

First thanks a lot for reply.

But, i don't understand. When a put a patch for files...

It could give me an example?

Thanks

Offline

#13 2008-06-04 05:27:10

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: How copy just line in text file with cat? (SOLVED)

just replace "file" with the actual filename, or replace "cat file" with the program that gives the output.
I saved the few lines you give in a file called "file" to test if it works. Cat just prints it, the awk-statement does the actual work.
It splits the lines into field using "=" as field seperator (-F= ) and checks if the first field is "file" ($1 ~ /^file$/), if so it prints the second field...

Last edited by klixon (2008-06-04 05:29:55)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#14 2008-06-04 13:27:49

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

So, command will be like this?

F=$( cat ~/.config/nitrogen/bg-saved.cfg | awk -F= '$1 ~ /^file$/ {print $2}' ) ln -s $( basename $F ) shortcut.png

A try this and don't work.

Offline

#15 2008-06-04 14:09:01

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: How copy just line in text file with cat? (SOLVED)

Stupid me for reading wrong roll

ln -s $( awk -F= '$1 ~ /^file$/ {print $2}' ~/.config/nitrogen/bg-saved.cfg ) /usr/share/slim/theme/MYTHEME/background.png

Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#16 2008-06-04 15:25:09

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

\o/

This work perfect.

Thanks very very much, klixon.

smile

Offline

#17 2008-06-04 15:59:43

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: How copy just line in text file with cat? (SOLVED)

My pleasure. Glad it worked.

Can you mark the thread [solved]?


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#18 2008-06-04 16:50:26

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

Make this.

Just another question.

This command don't accept large names.

Example:

Work: myimage.png

Don't work: my image.png

There a fix for this?

Offline

#19 2008-06-04 21:29:56

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

The problem is with ln -s command, does not recognize space like terminal. For example:

In terminal: My\ Image.png
With avk command: My image.png

But i don't know as fix this, and make avk insert space or \ and shortcut work with name and spaces.

Offline

#20 2008-06-04 22:19:34

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: How copy just line in text file with cat? (SOLVED)

I understand the problem, but i'm too tired to think of something just now hmm
Lemme sleep on in and hopefully i'll be able to cook something up tomorrow


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#21 2008-06-04 22:31:47

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: How copy just line in text file with cat? (SOLVED)

kramerxiita wrote:

The problem is with ln -s command, does not recognize space like terminal. For example:

In terminal: My\ Image.png
With avk command: My image.png

But i don't know as fix this, and make avk insert space or \ and shortcut work with name and spaces.

I think enclosing the command expansion in quotes would work.
You can spell it My\ Image.png or "My Image.png"

Offline

#22 2008-06-04 23:01:04

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

carlocci wrote:
kramerxiita wrote:

The problem is with ln -s command, does not recognize space like terminal. For example:

In terminal: My\ Image.png
With avk command: My image.png

But i don't know as fix this, and make avk insert space or \ and shortcut work with name and spaces.

I think enclosing the command expansion in quotes would work.
You can spell it My\ Image.png or "My Image.png"

And how make this?

Offline

#23 2008-06-05 16:15:49

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

Maybe klixon know how make.

Sorry for up this topic, but a still try this work.

Offline

#24 2008-06-05 19:53:28

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: How copy just line in text file with cat? (SOLVED)

target=$( awk -F= '$1 ~ /^file$/ {print $2}' ~/.config/nitrogen/bg-saved.cfg ); ln -s "${target}" /usr/share/slim/theme/MYTHEME/background.png

This seems to work...


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#25 2008-06-05 20:37:25

kramerxiita
Member
Registered: 2008-02-14
Posts: 89

Re: How copy just line in text file with cat? (SOLVED)

Perfect now.

Thank you very very much, klixon.

Sorry for boring you. tongue

Offline

Board footer

Powered by FluxBB