Quote:
Originally Posted by
somu_june
I tried with awk command
head -10 /home/o55555/test11.txt | awk -F '/' '{print $0\%/*","$NF}' .
But I got below error Syntax Error The source line is 1.
The error context is
{print >>> $0\ <<< %/*","$NF}
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.
and the file has the data like I mentioned in my early post
/dev/cm/test1.txt
/qa/tm/hmkr/cc/test2.txt
Can we get above result using awk command
You can get the above result for this exact input. But, to get a reliable solution we need more details about what the what forms of pathnames can exist in your input file, what shell you're using, and whether or not your environment supports a super root file system.
If the contents of your input file only contains absolute pathnames, never contains the pathname "/", and either your environment doesn't support a super root or your input file will never contain the pathname of a file in your root directory; then the solution Scott proposed will work and can be translated into awk code if you really need something much less efficient.
If your input contains any relative pathnames that don't contain a / character, we need a completely different approach.
If your environment includes a super root (where //
node refers to the root of the system named
node on your local network), there is another set of issues that need to be considered before we can propose an approach that will work reliably.
So, instead of giving us a two line example of what the input might look like, please give us an explicit description of the allowed input file format.