Godlike Productions - Discussion Forum
Users Online Now: 1,618 (Who's On?)Visitors Today: 1,210,788
Pageviews Today: 2,125,344Threads Today: 805Posts Today: 16,122
10:54 PM


Rate this Thread

Absolute BS Crap Reasonable Nice Amazing
 

Urgent help on Linux

 
Anonymous Coward
User ID: 1339701
United States
03/10/2013 08:50 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
...


You're redirecting the file to the tr command. You want to do the complete head command first and then pipe the output to tr.
 Quoting: Anonymous Coward 1339701


you mean something like this
head -2 stenton/gen_ed/cars2 | tr "[a-z]" "[A-Z]"
 Quoting: IMAX



Yes, butt as AC35769388 pointed out, you only want the 2nd line instead of the first two.
 Quoting: Anonymous Coward 1339701


ahhh
head -2 stenton/gen_ed/cars2 | tail -1 | tr "[a-z]" "[A-Z]"
 Quoting: IMAX



yep
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 08:51 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
/home/msabbar/sample_dir2
`-- sample_dir
|-- admin
|-- cambridge
| |-- cafeteria
| |-- library
| `-- security
| |-- annex
| |-- building
| `-- parking
|-- faculty
|-- history.exe
|-- markham
| |-- annex
| |-- building1
| `-- parking
`-- stenton
|-- gen_ed
| |-- Holidays
| `-- cars2
|-- lib_arts
| |-- english.txt
| `-- match.doc
`-- phone_directory

11 directories, 12 files

Your current directory is sample_dir. Display cars2 sorted numerically by
the 4th field:
Imagine if there was no country
Stop the Sabre Rattlings and Wars
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 08:53 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
okay so this question:
Your current directory is sample_dir. Display cars2 sorted numerically by
the 4th field:

what command would be more appropriate ?

i did
ls -l stenton/gen_ed/cars2 | sort -nk 4

cat stenton/gen_ed/cars2 | sort -nk 4

ls stenton/gen_ed/cars2 | sort -nk 4
 Quoting: IMAX


please post a couple of lines of the cars2 file so people can see what is in it.
 Quoting: Anonymous Coward 35769388


i can't show files within cars2...all i can show is the tree
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 08:54 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
okay so this question:
Your current directory is sample_dir. Display cars2 sorted numerically by
the 4th field:

what command would be more appropriate ?

i did
ls -l stenton/gen_ed/cars2 | sort -nk 4

cat stenton/gen_ed/cars2 | sort -nk 4

ls stenton/gen_ed/cars2 | sort -nk 4
 Quoting: IMAX


please post a couple of lines of the cars2 file so people can see what is in it.
 Quoting: Anonymous Coward 35769388


i can't show files within cars2...all i can show is the tree
 Quoting: IMAX


isn't cars2 a file? use less on it and see what is in there.
Anonymous Coward
User ID: 1339701
United States
03/10/2013 08:54 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
okay so this question:
Your current directory is sample_dir. Display cars2 sorted numerically by
the 4th field:

what command would be more appropriate ?

i did
ls -l stenton/gen_ed/cars2 | sort -nk 4

cat stenton/gen_ed/cars2 | sort -nk 4

ls stenton/gen_ed/cars2 | sort -nk 4
 Quoting: IMAX


cat stenton/gen_ed/cars2 | sort -nk 4 is most appropriate.

You don;t need to cat the file first. You can just sort it...

sort -nk 4 stenton/gen_ed/cars2
Anonymous Coward
User ID: 1339701
United States
03/10/2013 08:56 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
sorting by fields is tricky though because I think it requires whitespace as a field separator. Not totally sure though because I'm a college dropout.
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 08:57 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
sorting by fields is tricky though because I think it requires whitespace as a field separator. Not totally sure though because I'm a college dropout.
 Quoting: Anonymous Coward 1339701


sort has -t to set the separator.
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 09:03 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
okay so this question:
Your current directory is sample_dir. Display cars2 sorted numerically by
the 4th field:

what command would be more appropriate ?

i did
ls -l stenton/gen_ed/cars2 | sort -nk 4

cat stenton/gen_ed/cars2 | sort -nk 4

ls stenton/gen_ed/cars2 | sort -nk 4
 Quoting: IMAX


cat stenton/gen_ed/cars2 | sort -nk 4 is most appropriate.

You don;t need to cat the file first. You can just sort it...

sort -nk 4 stenton/gen_ed/cars2
 Quoting: Anonymous Coward 1339701


you're right
but I don't get why cat or less or ls wouldn't work if it is asking me to display it?
putin
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:08 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
okay so this question:
Your current directory is sample_dir. Display cars2 sorted numerically by
the 4th field:

what command would be more appropriate ?

i did
ls -l stenton/gen_ed/cars2 | sort -nk 4

cat stenton/gen_ed/cars2 | sort -nk 4

ls stenton/gen_ed/cars2 | sort -nk 4
 Quoting: IMAX


cat stenton/gen_ed/cars2 | sort -nk 4 is most appropriate.

You don;t need to cat the file first. You can just sort it...

sort -nk 4 stenton/gen_ed/cars2
 Quoting: Anonymous Coward 1339701


you're right
but I don't get why cat or less or ls wouldn't work if it is asking me to display it?
putin
 Quoting: IMAX



ls lists the files. cat displays the contents of a file. more or less show the contents of a file with page breaks and some tput formatting. Most commands that operate on the contents of a file do the cat for you. In the old days, you would have to cat a file and pipe the output to another command.
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 09:08 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
you're right
but I don't get why cat or less or ls wouldn't work if it is asking me to display it?
 Quoting: IMAX


what wacky software are you using for this? how do you know when you get the "right answer"? does it go DING!!?

maybe they replaced your shell with some weird shell, and it's not really a shell at all. it just wants you to put in the "correct command" and then it goes DING!!?
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 09:20 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
for this question
11 directories, 12 files

Your current directory is sample_dir. Display only the 1st field (last name)
of each record in phone_directory:

do i want to use the 'cut' command?
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:21 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
for this question
11 directories, 12 files

Your current directory is sample_dir. Display only the 1st field (last name)
of each record in phone_directory:

do i want to use the 'cut' command?
 Quoting: IMAX


cut, awk or sed.
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:21 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
for this question
11 directories, 12 files

Your current directory is sample_dir. Display only the 1st field (last name)
of each record in phone_directory:

do i want to use the 'cut' command?
 Quoting: IMAX


cut, awk or sed.
 Quoting: Anonymous Coward 1339701


or perl, hehe
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 09:21 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
you're right
but I don't get why cat or less or ls wouldn't work if it is asking me to display it?
 Quoting: IMAX


what wacky software are you using for this? how do you know when you get the "right answer"? does it go DING!!?

maybe they replaced your shell with some weird shell, and it's not really a shell at all. it just wants you to put in the "correct command" and then it goes DING!!?
 Quoting: Anonymous Coward 35769388


yes exactly
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 09:21 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
for this question
11 directories, 12 files

Your current directory is sample_dir. Display only the 1st field (last name)
of each record in phone_directory:

do i want to use the 'cut' command?
 Quoting: IMAX


sounds like a plan!
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 09:22 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
you're right
but I don't get why cat or less or ls wouldn't work if it is asking me to display it?
 Quoting: IMAX


what wacky software are you using for this? how do you know when you get the "right answer"? does it go DING!!?

maybe they replaced your shell with some weird shell, and it's not really a shell at all. it just wants you to put in the "correct command" and then it goes DING!!?
 Quoting: Anonymous Coward 35769388


yes exactly
 Quoting: IMAX


then that is probably why you can't cat or ls or less the file, because they think you don't need to do that.
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 09:26 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
for this question
11 directories, 12 files

Your current directory is sample_dir. Display only the 1st field (last name)
of each record in phone_directory:

do i want to use the 'cut' command?
 Quoting: IMAX


cut, awk or sed.
 Quoting: Anonymous Coward 1339701


so i do
cut -f1 stenton/phone_directory
and
cut -f stenton/phone_directory
cut -uf 1 stenton/phone_directory

cut -uf1 stenton/phone_directory

nothing
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:28 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
Here's a good reason to learn Linux. Your own drone with a Linux development kit.

[link to www.ardrone-flyers.com]
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 09:29 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
cut -d : -f 1 stenton/phone_directory

1dunno1
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 09:30 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
cut -uf1 stenton/phone_directory

nothing
 Quoting: IMAX

nothing? come on, doesn't it give you an error message?

look at the phone_directory file with cat, less, more, vi, emacs, nano, or pico, and find out what the fields look like, and what the field separators are. read the cut man page and figure it out
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:31 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
for this question
11 directories, 12 files

Your current directory is sample_dir. Display only the 1st field (last name)
of each record in phone_directory:

do i want to use the 'cut' command?
 Quoting: IMAX


cut, awk or sed.
 Quoting: Anonymous Coward 1339701


so i do
cut -f1 stenton/phone_directory
and
cut -f stenton/phone_directory
cut -uf 1 stenton/phone_directory

cut -uf1 stenton/phone_directory

nothing
 Quoting: IMAX


Your current directory is sample_dir ..
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:35 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
Is phone_directory in the stenton directory?
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 09:35 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
for this question
11 directories, 12 files

Your current directory is sample_dir. Display only the 1st field (last name)
of each record in phone_directory:

do i want to use the 'cut' command?
 Quoting: IMAX


cut, awk or sed.
 Quoting: Anonymous Coward 1339701


so i do
cut -f1 stenton/phone_directory
and
cut -f stenton/phone_directory
cut -uf 1 stenton/phone_directory

cut -uf1 stenton/phone_directory

nothing
 Quoting: IMAX


Your current directory is sample_dir ..
 Quoting: Anonymous Coward 1339701


yeah i know that...and sample_dir/stenton/phone_directory
since i am currently in it, i type in stenton/phone_directroy
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 09:37 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
how about the "file" command, can you use that?

file stenton/phone_directory
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:39 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
cut -f1 phone_directory
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 09:46 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
cut -f1 phone_directory
 Quoting: Anonymous Coward 1339701


no
cuz phone_directory is in stenton
and stenton is in sample_dir
and i am in sample_dir


so more likely cut -f1 stenton/phone_directory
but that was not the answer either
Imagine if there was no country
Stop the Sabre Rattlings and Wars
Anonymous Coward
User ID: 35769388
Australia
03/10/2013 09:50 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
can you cat the phone_directory? use less? can you use find to find it?
Anonymous Coward
User ID: 1339701
United States
03/10/2013 09:52 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
cut -f1 phone_directory
 Quoting: Anonymous Coward 1339701


no
cuz phone_directory is in stenton
and stenton is in sample_dir
and i am in sample_dir


so more likely cut -f1 stenton/phone_directory
but that was not the answer either
 Quoting: IMAX


They might want the delimiter argument to cut ? Hard to tell without being able to see the contents of the file.
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 10:10 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
AAAHHHHHHH


found it

cut -d' ' -f1 stenton/phone_directory
Imagine if there was no country
Stop the Sabre Rattlings and Wars
IMAX  (OP)

User ID: 35675988
Canada
03/10/2013 11:13 PM
Report Abusive Post
Report Copyright Violation
Re: Urgent help on Linux
guys now icant answer this

/home/msabbar/sample_dir2
`-- sample_dir
|-- admin
|-- cambridge
| |-- cafeteria
| |-- library
| `-- security
| |-- annex
| |-- building
| `-- parking
|-- cars3
|-- faculty
|-- history.exe
|-- markham
| |-- annex
| |-- building1
| `-- parking
`-- stenton
|-- gen_ed
| |-- Holidays
| `-- cars2
|-- lib_arts
| |-- english.txt
| `-- match.doc
`-- phone_directory

11 directories, 13 files

Your current directory is sample_dir. Create a compressed archive of the stenton directory and it's contents,
called stenton.tar.gz, and place it in the sample_dir directory. Use a non-verbose tar command with a single
option string, including the option to invoke gzip:
Imagine if there was no country
Stop the Sabre Rattlings and Wars





GLP