On Fri, Nov 28, 2014 at 1:08 PM, Baskar Selvaraj wrote:
>>> $ echo "/pub/videos/nptel/Computer Science and Engineering/Data
>>> Structures And
>>> Algorithms" | awk '{print $(NF - 1), $NF}' FS='/' OFS='/'
>>
>> It works, but however I could not store the output in a variable
>> because of long
On Fri, Nov 28, 2014 at 1:51 PM, Baskar Selvaraj wrote:
[...]
> Now, I want only the previous directory, leaving out the last directory.
The NF variable in Awk represents the Number of fields that you have
got in your current record line. So when you say `print $(NF - 1),
$NF` you are printing
>
> Ok now.
>
> subject=$(echo $PWD | awk '{print $(NF - 1), $NF}' FS='/' OFS='/')
No idea with awk, sorry for troubling again.
Now, I want only the previous directory, leaving out the last directory.
/pub/videos/nptel/Computer Science and Engineering/Data Structures And
Algorithms
to
Computer
>> $ echo "/pub/videos/nptel/Computer Science and Engineering/Data Structures
>> And
>> Algorithms" | awk '{print $(NF - 1), $NF}' FS='/' OFS='/'
>
> It works, but however I could not store the output in a variable
> because of long file name in the output.
>
> echo $PWD | awk '{print $(NF-1), $
On Fri, Nov 28, 2014 at 12:11 PM, Shakthi Kannan wrote:
> Hi,
> Use awk:
>
> $ echo "/pub/videos/nptel/Computer Science and Engineering/Data Structures
> And
> Algorithms" | awk '{print $(NF - 1), $NF}' FS='/' OFS='/'
It works, but however I could not store the output in a variable
because of
Hi,
--- On Fri, Nov 28, 2014 at 11:58 AM, Baskar Selvaraj
wrote:
| I need to extract the last two directory names using sed. Any
| help/pointers would be appreciated
\--
Use awk:
$ echo "/pub/videos/nptel/Computer Science and Engineering/Data Structures And
Algorithms" | awk '{print $(NF - 1
Dear all,
I need to extract the last two directory names using sed. Any
help/pointers would be appreciated
input:
/pub/videos/nptel/Computer Science and Engineering/Data Structures And
Algorithms
output should be:
Computer Science and Engineering/Data Structures And Algorithms
--
S. Baskar